Package org.apache.vysper.xmpp.stanza

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


        }
    }

    public Stanza getNextRecordedResponseForResource(String resource) {
        for (Iterator<Stanza> it = recordedResponses.iterator(); it.hasNext();) {
            Stanza recordedResponse = it.next();
            if (recordedResponse.getTo() != null && recordedResponse.getTo().isResourceSet()) {
                if (recordedResponse.getTo().getResource().equals(resource)) {
                    it.remove();
                    return recordedResponse;
                }
            }
        }
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());
View Full Code Here

    }
   
    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());
View Full Code Here

        if (!(o instanceof StanzaWriteInfo)) {
            throw new IllegalArgumentException("StanzaWriterProtocolEncoder only handles StanzaWriteInfo objects");
        }
        StanzaWriteInfo stanzaWriteInfo = (StanzaWriteInfo) o;

        Stanza element = stanzaWriteInfo.getStanza();
        Renderer renderer = new Renderer(element);

        IoBuffer byteBuffer = IoBuffer.allocate(16).setAutoExpand(true);
        if (stanzaWriteInfo.isWriteProlog()) byteBuffer.putString(StanzaWriter.XML_PROLOG, getSessionEncoder());
        if (stanzaWriteInfo.isWriteOpeningElement()) byteBuffer.putString(renderer.getOpeningElement(), getSessionEncoder());
View Full Code Here

     * @param nodeJID the node from which the message comes from
     * @param subscriptionID the subscription ID
     * @param subscriber the receiver of the notification
     */
    public void visit(String nodeName, String subscriptionID, Entity subscriber) {
        Stanza event = createMessageEventStanza(nodeName, subscriber, "en", item); // TODO extract the hardcoded "en"

        try {
            stanzaRelay.relay(subscriber, event, dfs);
        } catch (DeliveryException e1) {
            if(logger.isTraceEnabled()) logger.trace("Couldn't deliver message to " + subscriber.getFullQualifiedName(), e1);
View Full Code Here

                    "<mechanism>PLAIN</mechanism>" +
                    "<mechanism>ANONYMOUS</mechanism>" +
                  "</mechanisms>" +
                "</features>");

        Stanza stanza = parser.getNextStanza();


        List<SASLMechanism> mechanismList = new ArrayList<SASLMechanism>();
        mechanismList.add(new External());
        mechanismList.add(new Plain());
        mechanismList.add(new Anonymous());
        // add others
        assertEquals("stanzas are identical", stanza.toString(), new ServerResponses().getFeaturesForAuthentication(mechanismList).toString());
    }
View Full Code Here

    public void testProcessUnknownStanza() {

        sessionContext.setSessionState(SessionState.AUTHENTICATED);

        Stanza stanza = new StanzaBuilder("ProtocolWorkerProcessTestCase", "testNSURI").build();
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanza, sessionStateHolder);

        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        XMLElementVerifier verifier = recordedResponse.getVerifier();
        assertTrue("error", verifier.nameEquals("error"));
        assertTrue("unsupported stanza type", verifier.subElementPresent(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE.value()));
    }
View Full Code Here

        sessionContext.setSessionState(SessionState.AUTHENTICATED);

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("ProtocolWorkerProcessTestCase");
        namespaceHandlerDictionary.register(stanzaHandler);

        Stanza stanza = new StanzaBuilder("ProtocolWorkerProcessTestCase", "testNSURI").build();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanza, sessionStateHolder);

        stanzaHandler.assertHandlerCalled();
        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertNull("no emmitter, no response", recordedResponse);
    }
View Full Code Here

        sessionContext.setSessionState(SessionState.AUTHENTICATED);

        CallTestStanzaHandlerResponse stanzaHandler = new CallTestStanzaHandlerResponse("ProtocolWorkerProcessTestCase");
        namespaceHandlerDictionary.register(stanzaHandler);

        Stanza stanza = new StanzaBuilder("ProtocolWorkerProcessTestCase", "testNSURI").build();
        Stanza responseStanza = new StanzaBuilder("response").build();

        stanzaHandler.setResponseStanza(responseStanza);

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanza, sessionStateHolder);

        stanzaHandler.assertHandlerCalled();
        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertEquals("response handled", responseStanza, recordedResponse);

        stanzaHandler.setResponseStanza(null);
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanza, sessionStateHolder);
        assertNull("handler emmitted null as response", stanzaHandler.getResponseStanza());
View Full Code Here

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("ProtocolWorkerProcessTestCase");
        namespaceHandlerDictionary.register(stanzaHandler);
        stanzaHandler.setProtocolException(new ProtocolException("forced error"));

        Stanza stanza = new StanzaBuilder("ProtocolWorkerProcessTestCase", "testNSURI").build();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanza, sessionStateHolder);

        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertEquals("bad format", "error", recordedResponse.getName());
        assertTrue("closed", sessionContext.isClosed());
    }
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.