Search in sources :

Example 1 with ThreadedDummyConnection

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());
    }
}
Also used : ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection) DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) PubSub(org.jivesoftware.smackx.pubsub.packet.PubSub) XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) DiscoverInfoBuilder(org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder) Identity(org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity) StanzaError(org.jivesoftware.smack.packet.StanzaError) Test(org.junit.jupiter.api.Test)

Example 2 with ThreadedDummyConnection

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());
}
Also used : ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection) PubSub(org.jivesoftware.smackx.pubsub.packet.PubSub) Test(org.junit.jupiter.api.Test)

Example 3 with ThreadedDummyConnection

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();
}
Also used : ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ThreadedDummyConnection

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);
}
Also used : ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection) Test(org.junit.jupiter.api.Test)

Example 5 with ThreadedDummyConnection

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);
}
Also used : ThreadedDummyConnection(org.jivesoftware.smack.ThreadedDummyConnection) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.jupiter.api.Test)

Aggregations

ThreadedDummyConnection (org.jivesoftware.smack.ThreadedDummyConnection)15 Test (org.junit.jupiter.api.Test)10 IQ (org.jivesoftware.smack.packet.IQ)5 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)4 PubSub (org.jivesoftware.smackx.pubsub.packet.PubSub)4 Identity (org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity)3 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)2 DiscoverInfoBuilder (org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder)2 Test (org.junit.Test)2 StanzaError (org.jivesoftware.smack.packet.StanzaError)1 XMPPError (org.jivesoftware.smack.packet.XMPPError)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1