Package org.apache.vysper.xmpp.stanza

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


        handler.execute(stanzaBuilder.build(), sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        assertEquals(ResourceState.AVAILABLE_INTERESTED, getResourceState());
    }

    private StanzaBuilder createRosterGet() {
        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl(client, boundResourceId), null, IQStanzaType.GET, "id1");
        stanzaBuilder.startInnerElement("query", NamespaceURIs.JABBER_IQ_ROSTER).endInnerElement();
        return stanzaBuilder;
    }
View Full Code Here


    private static final String SERVER_JID = "vysper.org";
    private static final String CLIENT_JID = "test@vysper.org/test";
   
    public void testStanzaError() throws ParsingException {
        StanzaBuilder builder = new StanzaBuilder("iq");
        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,
View Full Code Here

* @author The Apache MINA Project (dev@mina.apache.org)
*/
public class StanzaBuilderFactory extends XMLElementBuilderFactory {

  public AbstractXMLElementBuilder<StanzaBuilder, Stanza> createBuilder(String elementName, String namespaceURI, String namespacePrefix, List<Attribute> attributes, List<XMLFragment> innerFragments) {
    return new StanzaBuilder(elementName, namespaceURI, namespacePrefix, attributes, innerFragments);
  }
View Full Code Here

     * @param lang the language of the stanza text-content.
     * @param item the payload as XMLElement
     * @return the prepared Stanza object.
     */
    private Stanza createMessageEventStanza(String nodeName, Entity to, String lang, XMLElement item) {
        StanzaBuilder stanzaBuilder = new StanzaBuilder("message", NamespaceURIs.XEP0060_PUBSUB_EVENT);
        stanzaBuilder.addAttribute("from", serverJID.getFullQualifiedName());
        stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
        stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", lang);
        stanzaBuilder.startInnerElement("event");
        stanzaBuilder.startInnerElement("items");
        stanzaBuilder.addAttribute("node", nodeName);
        stanzaBuilder.addPreparedElement(item);
        stanzaBuilder.endInnerElement(); // items
        stanzaBuilder.endInnerElement(); // event
        return stanzaBuilder.build();
    }
View Full Code Here

    @Override
    protected Stanza executeIQLogic(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        incomingStanza = stanza;

        StanzaBuilder responseBuilder = new StanzaBuilder("iq", NamespaceURIs.JABBER_CLIENT, stanza.getNamespacePrefix());
        if (stanza.getID() != null) responseBuilder.addAttribute("id", stanza.getID());

        responseBuilder.addAttribute("type", IQStanzaType.RESULT.value());

         return responseBuilder.build();
    }
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"));
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();
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);
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());
View Full Code Here

        sessionContext.setSessionState(SessionState.INITIATED);

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

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

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

        try {
            stanzaHandler.assertHandlerCalled();
View Full Code Here

TOP

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

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.