use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class ConfigureFormTest method getConfigFormWithInsufficientPrivileges.
@Test
public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException {
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result").ofType(IQ.Type.result).from(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
DiscoverInfo discoverInfo = info.build();
con.addIQReply(discoverInfo);
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
errorIq.setType(IQ.Type.error);
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
StanzaError error = StanzaError.getBuilder(Condition.forbidden).build();
errorIq.setError(error);
con.addIQReply(errorIq);
try {
node.getNodeConfiguration();
fail();
} catch (XMPPErrorException e) {
assertEquals(StanzaError.Type.AUTH, e.getStanzaError().getType());
}
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PubSubManagerTest method deleteNodeTest.
@Test
public void deleteNodeTest() throws InterruptedException, SmackException, IOException, XMPPException {
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, DUMMY_PUBSUB_SERVICE);
mgr.deleteNode("foo@bar.org");
PubSub pubSubDeleteRequest = con.getSentPacket();
assertEquals("http://jabber.org/protocol/pubsub#owner", pubSubDeleteRequest.getChildElementNamespace());
assertEquals("pubsub", pubSubDeleteRequest.getChildElementName());
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class ItemValidationTest method setUp.
@BeforeEach
public void setUp() throws Exception {
// Uncomment this to enable debug output
// SmackConfiguration.DEBUG = true;
connection = new ThreadedDummyConnection();
connection.connect();
connection.login();
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PingTest method checkPingToServerSuccess.
@Test
public void checkPingToServerSuccess() throws Exception {
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSuccess = pinger.pingMyServer();
assertTrue(pingSuccess);
}
use of org.jivesoftware.smack.ThreadedDummyConnection in project Smack by igniterealtime.
the class PingTest method checkSuccessfulDiscoRequest.
@Test
public void checkSuccessfulDiscoRequest() throws Exception {
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
// @formatter:off
String reply = "<iq type='result' id='qrzSp-16' to='test@myserver.com'>" + "<query xmlns='http://jabber.org/protocol/disco#info'><identity category='client' type='pc' name='Pidgin'/>" + "<feature var='urn:xmpp:ping'/>" + "</query></iq>";
// @formatter:on
IQ discoReply = PacketParserUtils.parseStanza(reply);
con.addIQReply(discoReply);
PingManager pinger = PingManager.getInstanceFor(con);
boolean pingSupported = pinger.isPingSupported(DUMMY_AT_EXAMPLE_ORG);
assertTrue(pingSupported);
}
Aggregations