Package org.apache.vysper.xmpp.addressing

Examples of org.apache.vysper.xmpp.addressing.EntityImpl


        // fully qualified, e.g. from="client@vysper.org/resourceId"
       
        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'lea'
        sessionContext.setInitiatingEntity(new EntityImpl("lea", server.getDomain(), null));

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("iq", "testNSURI");
        namespaceHandlerDictionary.register(stanzaHandler);

        String firstBoundResource = sessionContext.bindResource();
        String secondBoundResource = sessionContext.bindResource();

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
       
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertUnknownSenderError(recordedResponse); // not allowed, bare id without resource and two resources bound
        sessionContext.reset();
       
        // unbind second resource, leaving only one
        boolean noResourceRemains = sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(secondBoundResource);
        assertFalse(noResourceRemains);

        // bare id allowed, only one resource is bound
        stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
        stanzaHandler.assertHandlerCalled();
        sessionContext.reset();

        // second resource is now invalid and cannot be used anymore in a full qualified entity
        stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), secondBoundResource).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
        recordedResponse = sessionContext.getNextRecordedResponse();
        assertUnknownSenderError(recordedResponse);
       
View Full Code Here


        client = EntityImpl.parse("tester@vysper.org");
       
        sessionContext = TestSessionContext.createWithStanzaReceiverRelayAuthenticated();
        sessionContext.setInitiatingEntity(client);
       
        boundClient = new EntityImpl(client, sessionContext.bindResource());
        server = sessionContext.getServerJID();
       
        handler = new XmppPingIQHandler();
    }
View Full Code Here

    public void testAsyncGet() throws ExecutionException, InterruptedException {
        AsyncIQGetHandler asyncIQGetHandler = new AsyncIQGetHandler();
       
        assertNull("future is create on execute", asyncIQGetHandler.getWaitingRunnableFuture());

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(new EntityImpl("test", "vysper.org", null), null, IQStanzaType.GET, "id1");
        stanzaBuilder.startInnerElement("query").endInnerElement();
        Stanza iqStanza = stanzaBuilder.build();

        ResponseStanzaContainer container = asyncIQGetHandler.execute(iqStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, sessionStateHolder);
        assertTrue(container == null || container.hasNoResponse());
View Full Code Here

        super.setUp();

        protocolWorker = new ProtocolWorker();
        sessionStateHolder = new SessionStateHolder();
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        DefaultServerRuntimeContext context = new DefaultServerRuntimeContext(new EntityImpl(null, "test", null), receiverRelay);
        receiverRelay.setServerRuntimeContext(context);
        sessionContext = new TestSessionContext(context, sessionStateHolder);
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();

        protocolWorker = new ProtocolWorker();
        sessionStateHolder = new SessionStateHolder();
        Entity serverEnitity = new EntityImpl(null, "vysper-server.org", null);
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(serverEnitity, receiverRelay);
        receiverRelay.setServerRuntimeContext(serverRuntimeContext);
        serverRuntimeContext.addDictionary(new BaseStreamStanzaDictionary());
        sessionStateHolder = new SessionStateHolder();
View Full Code Here

        super.setUp();
       
        collection = new CollectionNode();
        serviceConfig = new PubSubServiceConfiguration(collection);

        owner = new EntityImpl("owner","vysper.org", null);
        Entity jid = new EntityImpl(null, "pubsub.vysper.org", null);
        serviceConfig.setServerJID(jid);
    }
View Full Code Here

    protected LeafNode node;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        Entity nodeJID = new EntityImpl(null, "pubsub.vysper.org", null);
        PubSubServiceConfiguration serviceConfig = new PubSubServiceConfiguration(new CollectionNode());
        serviceConfig.setServerJID(nodeJID);
        Entity creatorJID = new EntityImpl("creator", "vysper.org", null);
       
        node = new LeafNode(serviceConfig, "node", "Some test node", creatorJID);
    }
View Full Code Here

    }
   

    public void testPublishForbidden() throws Exception {
        DefaultPublishStanzaGenerator sg = new DefaultPublishStanzaGenerator();
        Entity yodaNotSubscribed = new EntityImpl("yoda","vysper.org","dagobah"); // yoda@vysper.org/dagobah

        ResponseStanzaContainer result = sendStanza(sg.getStanza(yodaNotSubscribed, pubsubService, "id123", "news"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
View Full Code Here

        assertEquals(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS, errorContent.get(0).getNamespaceURI());
    }

    protected Entity createUser(String jid) throws BindException {
        String boundResourceId = sessionContext.bindResource();
        Entity usr = new EntityImpl(clientBare, boundResourceId);
        return usr;
    }
View Full Code Here

        if (newTo != null) {
            stanzaBuilder.addAttribute("to", newTo.getFullQualifiedName());
        }
        Entity newFrom = original.getTo();
        if (newFrom != null) {
            if (fromIsServerOnly) newFrom = new EntityImpl(null, newFrom.getDomain(), null);
            stanzaBuilder.addAttribute("from", newFrom.getFullQualifiedName());
        }
        stanzaBuilder.addAttribute("type", type);
        if (original.getID() != null) stanzaBuilder.addAttribute("id", original.getID());
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.addressing.EntityImpl

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.