use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PingTest method getAuthentiactedDummyConnection.
private static ThreadedDummyConnection getAuthentiactedDummyConnection() throws SmackException, IOException, XMPPException, InterruptedException {
ThreadedDummyConnection connection = new ThreadedDummyConnection();
connection.connect();
connection.login();
return connection;
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class ConfigureFormTest method getConfigFormWithTimeout.
@Test(expected = SmackException.class)
public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException {
ThreadedDummyConnection con = new ThreadedDummyConnection();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo();
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
Node node = mgr.getNode("princely_musings");
SmackConfiguration.setDefaultReplyTimeout(100);
con.setTimeout();
node.getNodeConfiguration();
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class ConfigureFormTest method getConfigFormWithInsufficientPriviliges.
@Test
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException, InterruptedException {
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo();
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden);
errorIq.setError(error);
con.addIQReply(errorIq);
try {
node.getNodeConfiguration();
} catch (XMPPErrorException e) {
Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
}
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PingTest method checkFailedPingToEntityError.
/**
* Server returns an exception for entity.
* @throws Exception
*/
@Test
public void checkFailedPingToEntityError() throws Exception {
ThreadedDummyConnection threadedCon = getAuthentiactedDummyConnection();
//@formatter:off
String reply = "<iq type='error' id='qrzSp-16' to='test@myserver.com'>" + "<ping xmlns='urn:xmpp:ping'/>" + "<error type='cancel'>" + "<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "</error>" + "</iq>";
//@formatter:on
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
threadedCon.addIQReply(serviceUnavailable);
PingManager pinger = PingManager.getInstanceFor(threadedCon);
boolean pingSuccess = pinger.ping(DUMMY_AT_EXAMPLE_ORG);
assertFalse(pingSuccess);
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PingTest method checkPingToServerError.
/**
* Server returns an exception.
* @throws Exception
*/
@Test
public void checkPingToServerError() throws Exception {
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
//@formatter:off
String reply = "<iq type='error' id='qrzSp-16' to='test@myserver.com' from='" + con.getXMPPServiceDomain() + "'>" + "<ping xmlns='urn:xmpp:ping'/>" + "<error type='cancel'>" + "<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "</error>" + "</iq>";
//@formatter:on
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
con.addIQReply(serviceUnavailable);
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSuccess = pinger.pingMyServer();
assertTrue(pingSuccess);
}
Aggregations