Package org.apache.vysper.xmpp.stanza

Examples of org.apache.vysper.xmpp.stanza.Stanza


        TestSessionContext sessionContext = TestSessionContext.createSessionContext(toEntity);
        String resource = resourceRegistry.bindSession(sessionContext);
        boolean noResourceRemains = resourceRegistry.unbindResource(resource);
        assertTrue(noResourceRemains);

        Stanza stanza = StanzaBuilder.createMessageStanza(fromEntity, toEntity, "en", "Hello").build();

        try {
            stanzaRelay.relay(toEntity, stanza, new IgnoreFailureStrategy());
            Stanza recordedStanza = sessionContext.getNextRecordedResponse(1000);
            assertNull("stanza not delivered to unbound", recordedStanza);
        } catch (DeliveryException e) {
            throw e;
        }
    }
View Full Code Here


        TestSessionContext sessionContextToEntity_1_prio3 = createSessionForTo(toEntity, 3); // NON-NEGATIVE
        TestSessionContext sessionContextToEntity_2_prio0 = createSessionForTo(toEntity, 0); // NON-NEGATIVE
        TestSessionContext sessionContextToEntity_3_prio3 = createSessionForTo(toEntity, 3); // NON-NEGATIVE
        TestSessionContext sessionContextToEntity_4_prioMinus = createSessionForTo(toEntity, -1); // not receiving, negative

        Stanza stanza = StanzaBuilder.createMessageStanza(fromEntity, toEntity, "en", "Hello").build();

        try {
            stanzaRelay.relay(toEntity, stanza, new IgnoreFailureStrategy());
            Stanza recordedStanza_1 = sessionContextToEntity_1_prio3.getNextRecordedResponse(100);
            assertNotNull("stanza 1 delivered", recordedStanza_1);
            Stanza recordedStanza_2 = sessionContextToEntity_2_prio0.getNextRecordedResponse(100);
            assertNotNull("stanza 2 delivered", recordedStanza_2);
            Stanza recordedStanza_3 = sessionContextToEntity_3_prio3.getNextRecordedResponse(100);
            assertNotNull("stanza 3 delivered", recordedStanza_3);
            Stanza recordedStanza_4 = sessionContextToEntity_4_prioMinus.getNextRecordedResponse(100);
            assertNull("stanza 4 delivered", recordedStanza_4);
        } catch (DeliveryException e) {
            throw e;
        }
View Full Code Here

        TestSessionContext sessionContextToEntity_1_prio3 = createSessionForTo(toEntity, 3); // HIGHEST PRIO
        TestSessionContext sessionContextToEntity_2_prio0 = createSessionForTo(toEntity, 1); // not receiving
        TestSessionContext sessionContextToEntity_3_prio3 = createSessionForTo(toEntity, 3); // HIGHEST PRIO
        TestSessionContext sessionContextToEntity_4_prioMinus = createSessionForTo(toEntity, -1); // not receiving

        Stanza stanza = StanzaBuilder.createMessageStanza(fromEntity, toEntity, "en", "Hello").build();

        try {
            stanzaRelay.relay(toEntity, stanza, new IgnoreFailureStrategy());
            Stanza recordedStanza_1 = sessionContextToEntity_1_prio3.getNextRecordedResponse(100);
            assertNotNull("stanza 1 delivered", recordedStanza_1);
            Stanza recordedStanza_2 = sessionContextToEntity_2_prio0.getNextRecordedResponse(100);
            assertNull("stanza 2 not delivered", recordedStanza_2);
            Stanza recordedStanza_3 = sessionContextToEntity_3_prio3.getNextRecordedResponse(100);
            assertNotNull("stanza 3 delivered", recordedStanza_3);
            Stanza recordedStanza_4 = sessionContextToEntity_4_prioMinus.getNextRecordedResponse(100);
            assertNull("stanza 4 not delivered", recordedStanza_4);
        } catch (DeliveryException e) {
            throw e;
        }
View Full Code Here

public class PlainTestCase extends TestCase {
    protected SessionStateHolder stateHolder;

    public void testPlainEmpty() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
    }
View Full Code Here

        assertResponse(response, "malformed-request");
    }

    public void testPlainNonBASE64() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText("aEflkejidkj==")
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
    }
View Full Code Here

        builder.addAttribute("to", SERVER_JID);
        builder.addAttribute("from", CLIENT_JID);
        builder.startInnerElement("ping", NamespaceURIs.URN_XMPP_PING);
        builder.endInnerElement();
       
        Stanza request = builder.build();
        IQStanza requestIq = new IQStanza(request);

        ServerErrorResponses serverErrorResponses = ServerErrorResponses.getInstance();
       
        Stanza errorReply = serverErrorResponses.getStanzaError(StanzaErrorCondition.SERVICE_UNAVAILABLE,
                requestIq, StanzaErrorType.CANCEL, "Test", "en", null);
        assertEquals("error", errorReply.getAttributeValue("type"));
        assertEquals(SERVER_JID, errorReply.getAttributeValue("from"));
        assertEquals(CLIENT_JID, errorReply.getAttributeValue("to"));
       
        List<XMLElement> children = errorReply.getInnerElements();
       
        XMLElement pingElm = children.get(0);
        assertEquals("ping", pingElm.getName());
        assertEquals(NamespaceURIs.URN_XMPP_PING, pingElm.getNamespaceURI());
       
View Full Code Here

        assertResponse(response, "malformed-request");
    }

    public void testPlainNonExistingUser() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(encode("dieter", "schluppkoweit"))
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "not-authorized");
    }
View Full Code Here

        assertResponse(response, "not-authorized");
    }

    public void testPlainNotExistingUser() throws XMLSemanticError {

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(encode("dieter", "schluppkoweit"))
                .build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "not-authorized");
    }
View Full Code Here

    public void testPlainNoUserPasswordCombination() throws XMLSemanticError {

        String innerText = new String(Base64.encodeBase64("continuous".getBytes()));

        Stanza stanza = new StanzaBuilder("plain", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
                .addText(innerText).build();

        Stanza response = startMechanism(stanza);
        assertResponse(response, "malformed-request");
    }
View Full Code Here

    }

    private Stanza startMechanism(Stanza finalStanza) {
        Plain plain = new Plain();
        stateHolder = new SessionStateHolder();
        Stanza response = plain.started(new TestSessionContext(stateHolder), stateHolder, finalStanza);
        return response;
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.stanza.Stanza

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.