Package org.apache.vysper.xmpp.protocol

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


        assertEquals(PubSubAffiliation.NONE, n1.getAffiliation(client3));

        DefaultModifyAffiliationsStanzaGenerator sg = new DefaultModifyAffiliationsStanzaGenerator(n1.getName(), client, PubSubAffiliation.NONE);

        Stanza stanza = sg.getStanza(client, pubsubService, "4711", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);

        assertTrue(result.hasResponse());

        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());

        assertEquals("4711", response.getAttributeValue("id")); // IDs must match

        XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
View Full Code Here


    }

    public void testSubscribe() throws Exception {
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());
        assertTrue(node.isSubscribed(client));

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

    public void testSubscribeNoFrom() throws Exception {
        DefaultSubscribeStanzaGenerator sg = (DefaultSubscribeStanzaGenerator)getDefaultStanzaGenerator();
        sg.overrideSubscriberJID(client.getFullQualifiedName());
       
        Stanza stanza = sg.getStanza(null, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());
        assertTrue(node.isSubscribed(client));

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

    public void testSubscribeNonMatchingJIDs() {
        DefaultSubscribeStanzaGenerator sg = new DefaultSubscribeStanzaGenerator();
        sg.overrideSubscriberJID("someone@quite.dif/ferent");

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", testNode), 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

    public void testSubscribeJIDMalformed() {
        DefaultSubscribeStanzaGenerator sg = new DefaultSubscribeStanzaGenerator();
        sg.overrideSubscriberJID("@@");

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubService, "id123", testNode), 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

    public void testSubscribeNoSuchNode() throws Exception {
        DefaultSubscribeStanzaGenerator sg = new DefaultSubscribeStanzaGenerator();
        Entity pubsubWrongNode = EntityImpl.parse("pubsub.vysper.org");

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubWrongNode, "id123", "doesnotexist"), 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

        // make sure we have 4 subscribers
        assertEquals(4, node.countSubscriptions());
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.RESULT.value(),response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
       
        LeafNode n = root.find(testNode);
View Full Code Here

        assertNotNull(root.find(testNode));
        Entity clientNotAuthorized = new EntityImpl("darthvader", "deathstar.tld", null);
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(clientNotAuthorized, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
       
        XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
View Full Code Here

        String testNode = "test";
        assertNull(root.find(testNode));
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());

        assertEquals("id123", response.getAttributeValue("id")); // IDs must match
       
        XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
View Full Code Here

    public void testNoAffiliations() {
        Entity client2 = new EntityImpl("yoda", "starwars.com", null);
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client2, pubsubService, "id123", 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(0, sub.getInnerElements().size()); // there should be no affiliations
    }
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.