Package org.apache.vysper.xmpp.protocol

Examples of org.apache.vysper.xmpp.protocol.ResponseStanzaContainer


   
    public void testSomeAffiliations() {
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
       
        Stanza stanza = sg.getStanza(client, pubsubService, "4711", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);
       
        assertTrue(result.hasResponse());
       
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());
        XMLElement sub = response.getFirstInnerElement().getFirstInnerElement();
        assertEquals("affiliations", sub.getName());
        assertEquals(3, sub.getInnerElements().size());
       
View Full Code Here


        // make sure it is subscribed
        assertTrue(node.isSubscribed(client));

        // unsubscribe via XMPP
        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);

        // check subscription and response stanza
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());
        assertFalse(node.isSubscribed(client));
    }
View Full Code Here

        // subscribe two times
        node.subscribe("subid1", client);
        node.subscribe("subid2", client);

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertTrue(node.isSubscribed(client));
        assertEquals(2, node.countSubscriptions(client));

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

    public void testUnsubscribeNoSuchSubscriber() {
        DefaultUnsubscribeStanzaGenerator sg = new DefaultUnsubscribeStanzaGenerator();

        assertFalse(node.isSubscribed(client));
        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertFalse(node.isSubscribed(client));
        assertEquals(0, node.countSubscriptions(client));

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

        String yoda = "this@somesubscriber.is/yoda";
        sg.overrideSubscriberJID(yoda);

        node.subscribe("subid1", EntityImpl.parse(yoda));

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertFalse(node.isSubscribed(client));
        assertEquals(0, node.countSubscriptions(client));

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

    public void testUnsubscribeNoSuchNode() {
        DefaultUnsubscribeStanzaGenerator sg = new DefaultUnsubscribeStanzaGenerator();
        Entity pubsubWrongNode = new EntityImpl(null, "pubsub.vysper.org", null);

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubWrongNode, "id123", "doesnotexsist"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertFalse(node.isSubscribed(client));

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

        // subscribe two times
        node.subscribe("subid1", client);
        node.subscribe("subid2", client);

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertTrue(node.isSubscribed(client));
        assertEquals(2, node.countSubscriptions(client)); // still 2 subscriptions

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

    public void testUnsubscribeJIDMalformed() {
        DefaultUnsubscribeStanzaGenerator sg = new DefaultUnsubscribeStanzaGenerator();
        sg.overrideSubscriberJID("@@");

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
        assertFalse(node.isSubscribed(client));

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
View Full Code Here

       
        assertNull(receiverUser.getNextStanza()); // nothing there yet
        assertNull(senderUser.getNextStanza()); // nothing there yet

        Stanza stanza = stanzaBuilder.build();
        ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(stanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);

        Stanza receivedStanza = receiverUser.getNextStanza();
        XMLElementVerifier timestampVerifier = receivedStanza.getFirstInnerElement().getVerifier();
       
        assertTrue("stanza relayed to", receivedStanza.getVerifier().toAttributeEquals(receiverUser.getEntity().getFullQualifiedName()));
View Full Code Here

        StanzaReceiverQueue receiverQueue = new StanzaReceiverQueue();
        stanzaRelay.add(sender, senderQueue);
        stanzaRelay.add(receiver, receiverQueue);

        Stanza successfulMessageStanza = StanzaBuilder.createMessageStanza(sender, receiver, "en", "info").build();
        ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(successfulMessageStanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
        assertEquals(successfulMessageStanza, receiverQueue.getNext());

        Stanza failureMessageStanza = StanzaBuilder.createMessageStanza(sender, noReceiver, "en", "info").build();
        responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
        assertNull(receiverQueue.getNext());
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.protocol.ResponseStanzaContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.