Package org.apache.vysper.xml.fragment

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


        field.addOption(new Option("1.", "uno"));
        field.addOption(new Option("2.", "due"));
        form.addField(field);

        XMLElement formElement = new DataFormEncoder().getXML(form);
        XMLElementVerifier formElementVerifier = formElement.getVerifier();
        formElementVerifier.nameEquals("x");
        formElementVerifier.attributeEquals("type", "form");
        formElementVerifier.subElementsPresentExact(3);
        formElementVerifier.subElementPresent("title");
        formElementVerifier.subElementPresent("instructions");
        formElementVerifier.subElementPresent("field");

        XMLElement fieldElement = formElement.getSingleInnerElementsNamed("field");
        XMLElementVerifier fieldElementVerifier = fieldElement.getVerifier();
        fieldElementVerifier.subElementsPresentExact(3);
        formElementVerifier.subElementPresent("value");
        formElementVerifier.subElementPresent("option");

    }
View Full Code Here


    }

    protected boolean checkPresence(Stanza stanza, PresenceStanzaType presenceType, Entity from, String show) {
        if (stanza == null)
            return false;
        XMLElementVerifier xmlElementVerifier = stanza.getVerifier();
        if (from == null) {
            if (stanza.getFrom() != null)
                return false;
        } else {
            if (!stanza.getFrom().equals(from))
                return false;
        }
        if (!xmlElementVerifier.nameEquals("presence"))
            return false;
        if (presenceType == null && xmlElementVerifier.attributePresent("type"))
            return false;
        if (presenceType != null && !xmlElementVerifier.attributeEquals("type", presenceType.value()))
            return false;
        try {
            if (show != null && !xmlElementVerifier.subElementPresent("show")
                    && !stanza.getSingleInnerElementsNamed("show").getSingleInnerText().getText().equals(show)) {
                return false;
            }
        } catch (XMLSemanticError xmlSemanticError) {
            return false;
View Full Code Here

        Stanza stanza = stanzaBuilder.build();
        ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(stanza, senderSessionContext
                .getServerRuntimeContext(), true, senderSessionContext, null);

        Stanza receivedStanza = receiverUser.getNextStanza();
        XMLElementVerifier timestampVerifier = receivedStanza.getFirstInnerElement().getVerifier();

        assertTrue("stanza relayed to", receivedStanza.getVerifier().toAttributeEquals(
                receiverUser.getEntity().getFullQualifiedName()));
        assertTrue("stanza relayed inner", timestampVerifier.attributeEquals("value", timestamp));
        assertNotNull("from added", receivedStanza.getFrom());
        assertNotNull("from is full JID", receivedStanza.getFrom().equals(senderUser.getEntityFQ()));
        assertEquals("stanza relayed to correct receiver", receiverUser.getEntity(), receivedStanza.getTo());

    }
View Full Code Here

                runtimeContext, new SessionStateHolder()));

        assertTrue(resultStanza.getVerifier().onlySubelementEquals("query",
                NamespaceURIs.XEP0030_SERVICE_DISCOVERY_INFO));
        XMLElement queryElement = resultStanza.getFirstInnerElement();
        XMLElementVerifier queryVerifier = queryElement.getVerifier();
        assertTrue(queryVerifier.subElementsPresentExact(4));
        List<XMLElement> innerElements = queryElement.getInnerElements();
        XMLElement xmlElement = innerElements.get(innerElements.size() - 1);
        XMLElementVerifier xmlElementVerifier = xmlElement.getVerifier();
        assertTrue(xmlElementVerifier.nameEquals("x"));
    }
View Full Code Here

        TestIQHandler iqHandler = new TestIQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanzaBuilder.build(), sessionContext
                .getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("error", verifier.nameEquals("error"));
    }
View Full Code Here

        IQHandler iqHandler = new IQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext
                .getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("error", verifier.nameEquals("error")); // response is _not_ IQ stanza
    }
View Full Code Here

    private void assertIQError(Stanza stanza) {
        TestIQHandler iqHandler = new TestIQHandler();
        ResponseStanzaContainer responseStanzaContainer = iqHandler.execute(stanza, sessionContext
                .getServerRuntimeContext(), true, sessionContext, null);
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier verifier = responseStanza.getVerifier();
        assertTrue("iq", verifier.nameEquals("iq"));
        assertTrue("error type", verifier.attributeEquals("type", IQStanzaType.ERROR.value()));
        assertTrue("iq-error", verifier.subElementPresent("error"));
    }
View Full Code Here

        assertTrue("iq-id", verifier.attributeEquals("id", "1"));
        assertTrue("iq-type-get", verifier.attributeEquals("type", "get"));

        // response is "result"
        Stanza responseStanza = responseStanzaContainer.getResponseStanza();
        XMLElementVerifier responseVerifier = responseStanza.getVerifier();
        assertTrue("iq", responseVerifier.nameEquals("iq"));
        assertTrue("iq-id", responseVerifier.attributeEquals("id", "1"));
        assertTrue("iq-type-result", responseVerifier.attributeEquals("type", "result"));
    }
View Full Code Here

        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"));
        assertTrue("unsupported stanza type", verifier.subElementPresent(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE
                .value()));
    }
View Full Code Here

        } catch (Exception e) {
            // not called, OK
        }
        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertEquals("open stream", "stream", recordedResponse.getName());
        XMLElementVerifier xmlElementVerifier = recordedResponse.getVerifier();
        assertTrue("error embedded", xmlElementVerifier.subElementPresent("error"));
        XMLElement error = (XMLElement) recordedResponse.getInnerFragments().get(0);
        assertEquals("bad format", "error", error.getName());
        assertTrue("closed", sessionContext.isClosed());
    }
View Full Code Here

TOP

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

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.