mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-13 14:31:08 +01:00
Introduce SmackException
SmackException (and it's subclasses) is for all errors/exceptions not defined by any XMPP specification. XMPPException is now an abstract class for all errors defined by the XMPP specifications. Methods that involve an IQ exchange now either return the result, which is obtained by IQ response, or they throw an XMPPErrorException if an IQ error was the result of the IQ set/get. If there was no response from the server within the default packet timeout, a NoResponseException will be thrown. XMPP SASL errors are now also reported accordingly. SMACK-426
This commit is contained in:
parent
4b6f09f962
commit
4b56446e40
109 changed files with 2040 additions and 1599 deletions
|
|
@ -19,8 +19,10 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||
|
|
@ -55,9 +57,10 @@ public class InBandBytestreamManagerTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
@ -97,9 +100,11 @@ public class InBandBytestreamManagerTest {
|
|||
* Invoking {@link InBandBytestreamManager#establishSession(String)} should
|
||||
* throw an exception if the given target does not support in-band
|
||||
* bytestream.
|
||||
* @throws SmackException
|
||||
* @throws XMPPException
|
||||
*/
|
||||
@Test
|
||||
public void shouldFailIfTargetDoesNotSupportIBB() {
|
||||
public void shouldFailIfTargetDoesNotSupportIBB() throws SmackException, XMPPException {
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
||||
try {
|
||||
|
|
@ -113,7 +118,7 @@ public class InBandBytestreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (XMPPErrorException e) {
|
||||
assertEquals(XMPPError.Condition.feature_not_implemented.toString(),
|
||||
e.getXMPPError().getCondition());
|
||||
}
|
||||
|
|
@ -147,7 +152,7 @@ public class InBandBytestreamManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void shouldUseConfiguredStanzaType() {
|
||||
public void shouldUseConfiguredStanzaType() throws SmackException {
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
byteStreamManager.setStanza(StanzaType.MESSAGE);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
|
@ -73,9 +74,10 @@ public class InBandBytestreamSessionMessageTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
|
@ -74,9 +75,10 @@ public class InBandBytestreamSessionTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
|
@ -71,9 +73,10 @@ public class Socks5ByteStreamManagerTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
@ -133,9 +136,10 @@ public class Socks5ByteStreamManagerTest {
|
|||
/**
|
||||
* Invoking {@link Socks5BytestreamManager#establishSession(String)} should throw an exception
|
||||
* if the given target does not support SOCKS5 Bytestream.
|
||||
* @throws XMPPException
|
||||
*/
|
||||
@Test
|
||||
public void shouldFailIfTargetDoesNotSupportSocks5() {
|
||||
public void shouldFailIfTargetDoesNotSupportSocks5() throws XMPPException {
|
||||
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
|
||||
|
||||
try {
|
||||
|
|
@ -148,7 +152,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
assertTrue(e.getMessage().contains("doesn't support SOCKS5 Bytestream"));
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
|
@ -201,7 +205,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
protocol.verifyAll();
|
||||
assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
|
||||
}
|
||||
|
|
@ -264,7 +268,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
protocol.verifyAll();
|
||||
assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
|
||||
}
|
||||
|
|
@ -328,7 +332,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
protocol.verifyAll();
|
||||
assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
|
||||
}
|
||||
|
|
@ -351,7 +355,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
/*
|
||||
* #verifyAll() tests if the number of requests and responses corresponds and should
|
||||
* fail if the invalid proxy is queried again
|
||||
|
|
@ -446,7 +450,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (XMPPErrorException e) {
|
||||
protocol.verifyAll();
|
||||
assertEquals(xmppError, e.getXMPPError());
|
||||
}
|
||||
|
|
@ -528,7 +532,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
protocol.verifyAll();
|
||||
assertTrue(e.getMessage().contains("Remote user responded with unknown host"));
|
||||
}
|
||||
|
|
@ -1024,7 +1028,6 @@ public class Socks5ByteStreamManagerTest {
|
|||
DiscoverInfo proxyInfo1 = Socks5PacketUtils.createDiscoverInfo("proxy2.xmpp-server",
|
||||
initiatorJID);
|
||||
Identity identity1 = new Identity("proxy", "proxy2.xmpp-server", "bytestreams");
|
||||
identity1.setType("bytestreams");
|
||||
proxyInfo1.addIdentity(identity1);
|
||||
|
||||
// return the SOCKS5 bytestream proxy identity if proxy is queried
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ import java.io.OutputStream;
|
|||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
|
@ -60,9 +62,10 @@ public class Socks5ByteStreamRequestTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
@ -99,7 +102,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains("Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +146,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains("Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +193,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
"Could not establish socket with any provided host"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
|
|
@ -65,9 +67,10 @@ public class Socks5ClientForInitiatorTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws XMPPException {
|
||||
public void setup() throws XMPPException, SmackException {
|
||||
|
||||
// build protocol verifier
|
||||
protocol = new Protocol();
|
||||
|
|
@ -106,7 +109,7 @@ public class Socks5ClientForInitiatorTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
assertTrue(e.getMessage().contains("target is not connected to SOCKS5 proxy"));
|
||||
protocol.verifyAll(); // assert no XMPP messages were sent
|
||||
}
|
||||
|
|
@ -228,8 +231,8 @@ public class Socks5ClientForInitiatorTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
assertTrue(e.getMessage().contains("activating SOCKS5 Bytestream failed"));
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(XMPPError.Condition.internal_server_error.equals(e.getXMPPError().getCondition()));
|
||||
protocol.verifyAll();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.io.DataOutputStream;
|
|||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Client;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Utils;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
|
|
@ -81,9 +81,9 @@ public class Socks5ClientTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
"establishing connection to SOCKS5 proxy failed"));
|
||||
"SOCKS5 negotiation failed"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
|
|
@ -138,9 +138,9 @@ public class Socks5ClientTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
"establishing connection to SOCKS5 proxy failed"));
|
||||
"Unsupported SOCKS5 address type"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
|
|
@ -201,9 +201,9 @@ public class Socks5ClientTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
catch (SmackException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
"establishing connection to SOCKS5 proxy failed"));
|
||||
"SOCKS5 negotiation failed"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.net.UnknownHostException;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Utils;
|
||||
|
||||
/**
|
||||
|
|
@ -227,17 +227,17 @@ public class Socks5TestProxy {
|
|||
* Negotiates a SOCKS5 connection and stores it on success.
|
||||
*
|
||||
* @param socket connection to the client
|
||||
* @throws XMPPException if client requests a connection in an unsupported way
|
||||
* @throws SmackException if client requests a connection in an unsupported way
|
||||
* @throws IOException if a network error occurred
|
||||
*/
|
||||
private void establishConnection(Socket socket) throws XMPPException, IOException {
|
||||
private void establishConnection(Socket socket) throws IOException, SmackException {
|
||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||
|
||||
// first byte is version should be 5
|
||||
int b = in.read();
|
||||
if (b != 5) {
|
||||
throw new XMPPException("Only SOCKS5 supported");
|
||||
throw new SmackException("Only SOCKS5 supported");
|
||||
}
|
||||
|
||||
// second byte number of authentication methods supported
|
||||
|
|
@ -263,7 +263,7 @@ public class Socks5TestProxy {
|
|||
authMethodSelectionResponse[1] = (byte) 0xFF; // no acceptable methods
|
||||
out.write(authMethodSelectionResponse);
|
||||
out.flush();
|
||||
throw new XMPPException("Authentication method not supported");
|
||||
throw new SmackException("Authentication method not supported");
|
||||
}
|
||||
|
||||
authMethodSelectionResponse[1] = (byte) 0x00; // no-authentication method
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@ package org.jivesoftware.smackx.ping;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
|
@ -70,15 +73,18 @@ public class PingTest extends InitExtensions {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkSendingPing() throws Exception {
|
||||
public void checkSendingPing() throws InterruptedException {
|
||||
dummyCon = new DummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(dummyCon);
|
||||
pinger.ping("test@myserver.com");
|
||||
try {
|
||||
pinger.ping("test@myserver.com");
|
||||
}
|
||||
catch (SmackException e) {
|
||||
// Ignore the fact the server won't answer for this unit test.
|
||||
}
|
||||
|
||||
Packet sentPacket = dummyCon.getSentPacket();
|
||||
|
||||
assertTrue(sentPacket instanceof Ping);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -95,17 +101,20 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
/**
|
||||
* DummyConnection will not reply so it will timeout.
|
||||
* @throws Exception
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Test
|
||||
public void checkFailedPingOnTimeout() throws Exception {
|
||||
public void checkFailedPingOnTimeout() throws SmackException {
|
||||
dummyCon = new DummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(dummyCon);
|
||||
|
||||
boolean pingSuccess = pinger.ping("test@myserver.com");
|
||||
|
||||
assertFalse(pingSuccess);
|
||||
|
||||
try {
|
||||
pinger.ping("test@myserver.com");
|
||||
}
|
||||
catch (NoResponseException e) {
|
||||
return;
|
||||
}
|
||||
fail();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -171,13 +180,18 @@ public class PingTest extends InitExtensions {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkPingToServerTimeout() throws Exception {
|
||||
public void checkPingToServerTimeout() throws SmackException {
|
||||
DummyConnection con = new DummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
||||
boolean pingSuccess = pinger.pingMyServer();
|
||||
|
||||
assertFalse(pingSuccess);
|
||||
try {
|
||||
pinger.pingMyServer();
|
||||
}
|
||||
catch (NoResponseException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ package org.jivesoftware.smackx.pubsub;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.ThreadedDummyConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.packet.XMPPError.Condition;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
|
@ -45,7 +47,7 @@ public class ConfigureFormTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getConfigFormWithInsufficientPriviliges() throws XMPPException
|
||||
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException
|
||||
{
|
||||
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
|
@ -65,14 +67,14 @@ public class ConfigureFormTest
|
|||
{
|
||||
node.getNodeConfiguration();
|
||||
}
|
||||
catch (XMPPException e)
|
||||
catch (XMPPErrorException e)
|
||||
{
|
||||
Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
|
||||
}
|
||||
}
|
||||
|
||||
@Test (expected=XMPPException.class)
|
||||
public void getConfigFormWithTimeout() throws XMPPException
|
||||
@Test (expected=SmackException.class)
|
||||
public void getConfigFormWithTimeout() throws XMPPException, SmackException
|
||||
{
|
||||
ThreadedDummyConnection con = new ThreadedDummyConnection();
|
||||
PubSubManager mgr = new PubSubManager(con);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import static org.mockito.Matchers.*;
|
|||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
|
@ -57,10 +58,11 @@ public class ConnectionUtils {
|
|||
* @param initiatorJID the user associated to the XMPP connection
|
||||
* @param xmppServer the XMPP server associated to the XMPP connection
|
||||
* @return a mocked XMPP connection
|
||||
* @throws XMPPException
|
||||
* @throws SmackException
|
||||
* @throws XMPPErrorException
|
||||
*/
|
||||
public static XMPPConnection createMockedConnection(final Protocol protocol,
|
||||
String initiatorJID, String xmppServer) throws XMPPException {
|
||||
String initiatorJID, String xmppServer) throws SmackException, XMPPErrorException {
|
||||
|
||||
// mock XMPP connection
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
|
|
@ -105,7 +107,7 @@ public class ConnectionUtils {
|
|||
Packet packet = protocol.getResponses().poll();
|
||||
if (packet == null) return packet;
|
||||
XMPPError xmppError = packet.getError();
|
||||
if (xmppError != null) throw new XMPPException(xmppError);
|
||||
if (xmppError != null) throw new XMPPErrorException(xmppError);
|
||||
return packet;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue