Examples of Stanza


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

        assertEquals("nick", occupant.getName());
    }
   
    public void testEnterWithoutNick() throws Exception {
        // try entering without a nick
        Stanza response = enterRoom(OCCUPANT1_JID, ROOM1_JID);

        assertPresenceErrorStanza(response, ROOM1_JID, OCCUPANT1_JID, "modify", "jid-malformed");
    }
View Full Code Here

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

    public void testEnterWithoutPassword() throws Exception {
        Room room = conference.createRoom(ROOM2_JID, "Room 1", RoomType.PasswordProtected);
        room.setPassword("secret");

        // try entering without a password
        Stanza response = enterRoom(OCCUPANT1_JID, ROOM2_JID_WITH_NICK);
       
        assertPresenceErrorStanza(response, ROOM2_JID, OCCUPANT1_JID, "auth", "not-authorized");
    }
View Full Code Here

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

       
        // now, let user 1 enter room
        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK);

        // verify stanzas to existing occupants on the new user
        Stanza user1JoinedStanza = occupant2Queue.getNext();
        // should be from room + nick name
        assertEquals(ROOM1_JID.getFullQualifiedName() + "/nick", user1JoinedStanza.getFrom().getFullQualifiedName());
        // should be to the existing user
        assertEquals(OCCUPANT2_JID, user1JoinedStanza.getTo());
       
        XMLElement xElement = user1JoinedStanza.getSingleInnerElementsNamed("x");
        assertEquals(NamespaceURIs.XEP0045_MUC_USER, xElement.getNamespaceURI());
       
        // since this room is non-anonymous, x must contain an item element with the users full JID
        XMLElement itemElement = xElement.getSingleInnerElementsNamed("item");
        assertEquals(OCCUPANT1_JID.getFullQualifiedName(), itemElement.getAttributeValue("jid"));
        assertEquals("none", itemElement.getAttributeValue("affiliation"));
        assertEquals("participant", itemElement.getAttributeValue("role"));


        // verify stanzas to the new user on all existing users, including himself with status=110 element
        // own presence must be sent last
        // assert the stanza from the already existing user
        Stanza stanza = occupant1Queue.getNext();
        assertNotNull(stanza);
        assertEquals(ROOM1_JID.getFullQualifiedName() + "/Some nick", stanza.getFrom().getFullQualifiedName());
        assertEquals(OCCUPANT1_JID, stanza.getTo());

        // assert stanza from the joining user, must have extra status=110 element       
        stanza = occupant1Queue.getNext();
        assertNotNull(stanza);
        assertEquals(ROOM1_JID_WITH_NICK, stanza.getFrom());
        assertEquals(OCCUPANT1_JID, stanza.getTo());
        List<XMLElement> statusElements = stanza.getFirstInnerElement().getInnerElementsNamed("status");
        assertEquals(2, statusElements.size());
        assertEquals("100", statusElements.get(0).getAttributeValue("code"));
        assertEquals("110", statusElements.get(1).getAttributeValue("code"));
       
    }
View Full Code Here

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

        // send message to room
        sendDisco(request.build());

        assertNull(occupant1Queue.getNext());
        Stanza stanza = occupant2Queue.getNext();
        assertNotNull(stanza);
        assertEquals(OCCUPANT1_JID, stanza.getFrom());
        assertEquals(OCCUPANT2_JID, stanza.getTo());
        assertEquals("get", stanza.getAttributeValue("type"));
        assertEquals("123", stanza.getAttributeValue("id"));
        XMLElement query = stanza.getFirstInnerElement();
        assertNotNull(query);
        assertEquals(getNamespace(), query.getNamespaceURI());
    }
View Full Code Here

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

            throw new RuntimeException("no termination cause given");
        }

    if (terminationCause == SessionTerminationCause.CLIENT_BYEBYE ||
            terminationCause == SessionTerminationCause.CONNECTION_ABORT) {
            Stanza unavailableStanza = StanzaBuilder.createUnavailablePresenceStanza(null, terminationCause);
            StanzaHandler handler = serverRuntimeContext.getHandler(unavailableStanza);
            try {
                handler.execute(unavailableStanza, serverRuntimeContext, true, this, sessionStateHolder);
            } catch (ProtocolException e) {
                logger.error("Failed to send unavailable stanza on connection close", e);
View Full Code Here

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

        assertFalse(item.hasSubject());
    }

    public void testCreateStanza() throws Exception {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(FROM, ROOM_JID, MessageStanzaType.GROUPCHAT, null, BODY);
        Stanza inStanza = builder.build();
        DiscussionMessage item = new DiscussionMessage(inStanza, FROM_OCCUPANT, TIMESTAMP);
       
        Entity to = TestUtil.parseUnchecked("user2@vysper.org/res");
        Occupant toOccupant = new Occupant(to, "nick 2", Affiliation.None, Role.Visitor);
        MessageStanza outStanza = (MessageStanza) MessageStanza.getWrapper(item.createStanza(toOccupant, true));
View Full Code Here

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

               
                // now add all messages, as long as the predicated are fulfilled
                // first, do this in reverse order so that older messages are filtered out
                for(int i = itemsWithSubject.size() - 1; i > -1; i--) {
                    DiscussionMessage item = itemsWithSubject.get(i);
                    Stanza stanza = item.createStanza(receiver, includeJid);
                    counter++;
   
                    if(secondsLimit != -1 && secondsLimit > item.getTimestamp().getTimeInMillis()) {
                        // too old, break
                        break;
View Full Code Here

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

        IQHandler infoIQHandler = createDiscoIQHandler();

        StanzaBuilder request = buildRequest();
       
        ResponseStanzaContainer resultStanzaContainer = infoIQHandler.execute(request.build(), serverRuntimeContext, false, new TestSessionContext(serverRuntimeContext, new SessionStateHolder()), null);
        Stanza resultStanza = resultStanzaContainer.getResponseStanza();

        assertEquals("Disco request must not return error", "result", resultStanza.getAttributeValue("type"));
        XMLElement queryElement = resultStanza.getFirstInnerElement();
       
        assertResponse(queryElement);
    }
View Full Code Here

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

                new Occupant(OCCUPANT2_JID, "nick2", Affiliation.None, Role.Participant));
       
        // now, let user 1 enter room
        enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK, null, new History(2, null, null, null), false);

        Stanza stanza = occupant1Queue.getNext();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("presence", stanza.getName());
       
        stanza = occupant1Queue.getNext();
        // here we get the message history
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        MessageStanza msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body2", msgStanza.getBody(null));

        stanza = occupant1Queue.getNext();
        // first stanza should be room presence
        assertNotNull(stanza);
        assertEquals("message", stanza.getName());
        msgStanza = (MessageStanza) MessageStanza.getWrapper(stanza);
        assertEquals("Body3", msgStanza.getBody(null));
       
        // we only requested two messages
        assertNull(occupant1Queue.getNext());
View Full Code Here

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

    }
   
    private Stanza exitRoom(Entity occupantJid, Entity roomJid, String status) throws ProtocolException {
        StanzaBuilder stanzaBuilder = StanzaBuilder.createPresenceStanza(occupantJid, roomJid, null, PresenceStanzaType.UNAVAILABLE, null, status);

        Stanza presenceStanza = stanzaBuilder.build();
        ResponseStanzaContainer container = handler.execute(presenceStanza, sessionContext.getServerRuntimeContext(), true, sessionContext, null);
        if(container != null) {
            return container.getResponseStanza();
        } else {
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.