Package org.apache.vysper.xmpp.addressing

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


    protected AbstractStanzaGenerator getDefaultStanzaGenerator() {
        return new DefaultRetrieveAffiliationsStanzaGenerator("Node1");
    }

    public void testRetrieveAffiliationsNoAuth() {
        Entity client2 = new EntityImpl("yoda", "starwars.com", null);

        AbstractStanzaGenerator sg = new DefaultRetrieveAffiliationsStanzaGenerator("Node1");
        Stanza stanza = sg.getStanza(client2, pubsubService, "id123", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);
View Full Code Here


        assertEquals("stanza relayed to correct receiver", receiverUser.getEntity(), receivedStanza.getTo());

    }

    public void testStanzaReceiverUnavailable() throws EntityFormatException, DeliveryException {
        Entity sender = EntityImpl.parse("from@example.com/resID");
        Entity receiver = EntityImpl.parse("to_exist@example.com");
        Entity noReceiver = EntityImpl.parse("to_unavail@example.com");

        StanzaReceiverRelay stanzaRelay = (StanzaReceiverRelay) senderSessionContext.getServerRuntimeContext().getStanzaRelay();
        StanzaReceiverQueue senderQueue = new StanzaReceiverQueue();
        StanzaReceiverQueue receiverQueue = new StanzaReceiverQueue();
        stanzaRelay.add(sender, senderQueue);
View Full Code Here

        assertTrue("closed", sessionContext.isClosed());
    }

    public void testDetectWrongFromAddress() throws XMLSemanticError {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'mark'
        sessionContext.setInitiatingEntity(new EntityImpl("mark", server.getDomain(), null));

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

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        // we set a different from user name 'ernest'!
        stanzaBuilder.addAttribute("from", new EntityImpl("ernest", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query").addNamespaceAttribute("jabber:iq:roster").endInnerElement();
       
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);

        try {
View Full Code Here

        assertUnknownSenderError(recordedResponse);
    }

    public void testAllowProperFromResourceId() throws XMLSemanticError, BindException {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'charlotte'
        sessionContext.setInitiatingEntity(new EntityImpl("charlotte", server.getDomain(), null));

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

        String onlyBoundResource = sessionContext.bindResource();

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("charlotte", server.getDomain(), onlyBoundResource).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
       
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);

        stanzaHandler.assertHandlerCalled();
View Full Code Here

        stanzaHandler.assertHandlerCalled();
    }

    public void testDetectWrongFromResourceId() throws XMLSemanticError, BindException {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'charlotte'
        sessionContext.setInitiatingEntity(new EntityImpl("charlotte", server.getDomain(), null));

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

        String onlyBoundResource = sessionContext.bindResource();
        String arbitraryUnboundResource = "unboundResourceID";
       
        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
       
        stanzaBuilder.addAttribute("from", new EntityImpl("charlotte", server.getDomain(), arbitraryUnboundResource).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
       
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);

        try {
View Full Code Here

    public void testAllowBareFromEntityOnlyOnSingleBoundResource() throws XMLSemanticError, BindException {
        // from="client@vysper.org" is only allowed when a single resource is bound
        // if there is more than one resource bound in the same session, from must come
        // 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

    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

       
        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

       
        node = new LeafNode(serviceConfig, "node", "Some test node", creatorJID);
    }

    public void testSubscribe() throws Exception {
        Entity me = EntityImpl.parse("me@vysper.org");
        assertFalse(node.isSubscribed(me));
        node.subscribe("id1", me);
        assertTrue(node.isSubscribed(me));
        assertTrue(node.isSubscribed("id1"));
    }
View Full Code Here

TOP

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

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.