Package org.apache.vysper.xml.fragment

Examples of org.apache.vysper.xml.fragment.XMLElement


        }
    }

    private void emitStanza() {
        isBodyPayloadDecoded = true;
        XMLElement element = builder.build();
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("BOSH decoding request: {}", new Renderer(element).getComplete());
        }
        boshHandler.process(request, (Stanza) element);
        builder = null;
View Full Code Here


        // now, let user 2 exit room
        Stanza errorStanza = sendMessage(OCCUPANT1_JID, ROOM1_JID,
                GROUPCHAT, body);

        XMLElement expectedBody = new XMLElementBuilder("body").addText(body).build();
        assertMessageErrorStanza(errorStanza, ROOM1_JID, OCCUPANT1_JID, "modify",
                expectedErrorName,expectedBody);

        // no message should be relayed
        assertNull(occupant1Queue.getNext());
View Full Code Here

        assertNotNull(stanza);
        assertEquals(expectedFrom, stanza.getFrom());
        assertEquals(expectedTo, stanza.getTo());
        assertEquals(expectedType, stanza.getAttributeValue("type"));
       
        XMLElement xElm = stanza.getFirstInnerElement();
        assertEquals(NamespaceURIs.XEP0045_MUC_USER, xElm.getNamespaceURI());
       
        Iterator<XMLElement> innerElements = xElm.getInnerElements().iterator();
        for(Item item : expectedItems) {
            XMLElement itemElm = innerElements.next();
           
            assertEquals("item", itemElm.getName());
            assertEquals(item.getJid().getFullQualifiedName(), itemElm.getAttributeValue("jid"));
            assertEquals(item.getNick(), itemElm.getAttributeValue("nick"));
            assertEquals(item.getAffiliation().toString(), itemElm.getAttributeValue("affiliation"));
            assertEquals(item.getRole().toString(), itemElm.getAttributeValue("role"));
        }
       
        if(expectedStatuses != null) {
            for(StatusCode status : expectedStatuses) {
                XMLElement statusElm = innerElements.next();
   
                assertEquals("status", statusElm.getName());
                assertEquals(status.code(), Integer.parseInt(statusElm.getAttributeValue("code")));
   
            }
        }
    }
View Full Code Here

                    List<Attribute> stanzaAttributes = fillAttributesFromXML(elementEvent);
                    List<XMLFragment> xmlInnerFragments = new ArrayList<XMLFragment>();
                    fillDeep(elementEvent.element.rawname, xmlInnerFragments); // (return value can be savely ignored)

                    // create element with all collected data
                    XMLElement xmlInnerElement = new XMLElement(namespaceURI, innerName, null, stanzaAttributes, xmlInnerFragments);
                    xmlFragments.add(xmlInnerElement);
                } else {
                    return name.equals(elementEvent.element.rawname); // succeed if exact end element found and all is balanced
                }
            } else if (event.type == XMLEvent.CDATA) {
View Full Code Here

        room.addOccupant(OCCUPANT2_JID, "Nick 2");

        // send message to occupant 1 with type groupchat
        Stanza errorStanza = sendMessage(OCCUPANT1_JID, new EntityImpl(ROOM1_JID, "Nick 2"), MessageStanzaType.GROUPCHAT, BODY);

        XMLElement expectedBody = new XMLElementBuilder("body").addText(BODY).build();
        assertMessageErrorStanza(errorStanza, ROOM1_JID, OCCUPANT1_JID, "modify",
                "bad-request", expectedBody);

        // no message should be relayed
        assertNull(occupant1Queue.getNext());
View Full Code Here

        assertPresenceErrorStanza(response, ROOM2_JID, OCCUPANT1_JID, "auth", "not-authorized");
    }

    private void assertPresenceErrorStanza(Stanza response, Entity from, Entity to,
            String type, String errorName) {
        XMLElement xElement = new XMLElementBuilder("x", NamespaceURIs.XEP0045_MUC).build();
        assertErrorStanza(response, "presence", from, to, type, errorName, xElement);
    }
View Full Code Here

        // 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
View Full Code Here

    }

    private static List<XMLFragment> createFragments(String reason) {
        List<XMLFragment> fragments = new ArrayList<XMLFragment>();
        if(reason != null) {
            XMLElement reasonElm = new XMLElement(NamespaceURIs.XEP0045_MUC, "reason", null, null, new XMLFragment[]{new XMLText(reason)});
            fragments.add(reasonElm);
        }
        return fragments;
    }
View Full Code Here

        }
    }
   
    public String getReason() {
        try {
            XMLElement reasonElm = getSingleInnerElementsNamed("reason");
            if(reasonElm != null && reasonElm.getInnerText() != null) {
                return reasonElm.getInnerText().getText();
            } else {
                return null;
            }
        } catch (XMLSemanticError e) {
            throw new IllegalArgumentException("Invalid stanza", e);
View Full Code Here

        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

TOP

Related Classes of org.apache.vysper.xml.fragment.XMLElement

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.