Package com.thoughtworks.xstream.io.xml.xppdom

Examples of com.thoughtworks.xstream.io.xml.xppdom.XppDom


     * Tests comparison of different number of attributes.
     *
     * @throws Exception unexpected
     */
    public void testSortsAccordingNumberOfAttributes() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom/>");
        XppDom dom2 = XppFactory.buildDom("<dom a='1'/>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom::count(@*)", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom::count(@*)", xpath.get());
    }
View Full Code Here


     *
     * @throws Exception unexpected
     */
    public void testEqualsDocumentsWithChildren() throws Exception {
        final String xml = "<dom><a/></dom>";
        XppDom dom1 = XppFactory.buildDom(xml);
        XppDom dom2 = XppFactory.buildDom(xml);
        assertEquals(comparator, dom1, dom2);
        assertNull(xpath.get());
    }
View Full Code Here

     * Tests comparison of different number of children.
     *
     * @throws Exception unexpected
     */
    public void testSortsAccordingNumberOfChildren() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom/>");
        XppDom dom2 = XppFactory.buildDom("<dom><a/></dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom::count(*)", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom::count(*)", xpath.get());
    }
View Full Code Here

     * Tests comparison of different elements.
     *
     * @throws Exception unexpected
     */
    public void testSortsElementsByName() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom><a/></dom>");
        XppDom dom2 = XppFactory.buildDom("<dom><b/></dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom/a[0]?", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom/b[0]?", xpath.get());
    }
View Full Code Here

     * Tests comparison of different nth elements.
     *
     * @throws Exception unexpected
     */
    public void testSortsElementsByNthName() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom><a/><b/><c/><a/></dom>");
        XppDom dom2 = XppFactory.buildDom("<dom><a/><b/><c/><b/></dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom/a[1]?", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom/b[1]?", xpath.get());
    }
View Full Code Here

     * Tests comparison sorts attributes before elements.
     *
     * @throws Exception unexpected
     */
    public void testSortsAttributesBeforeElements() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom x='a'><a/></dom>");
        XppDom dom2 = XppFactory.buildDom("<dom x='b'><b/></dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom[@x]", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom[@x]", xpath.get());
    }
View Full Code Here

     * Tests comparison will reset XPath after recursion.
     *
     * @throws Exception unexpected
     */
    public void testWillResetXPathAfterRecursion() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom><a><b>foo</b></a><c x='1'/></dom>");
        XppDom dom2 = XppFactory.buildDom("<dom><a><b>foo</b></a><c x='2'/></dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom/c[0][@x]", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom/c[0][@x]", xpath.get());
    }
View Full Code Here

                "  </small>" +
                "  <small-two>" +
                "  </small-two>" +
                "</big>";

        XppDom document = Xpp3DomBuilder.build(new StringReader(xml));

        XppDom small = document.getChild("small");

        HierarchicalStreamReader xmlReader = new XppDomReader(small);

        assertEquals("small", xmlReader.getNodeName());
View Full Code Here

            assertTrue(equals(expected[i], xpp3.getConfiguration()));
        }
    }

    public void testProducesDomElements() {
        final XppDom root = new XppDom("hello");
        root.setValue("world");
        assertDocumentProducedIs(root);
    }
View Full Code Here

        root.setValue("world");
        assertDocumentProducedIs(root);
    }

    public void testSupportsNestedElements() {
        final XppDom a = new XppDom("a");

        XppDom b = new XppDom("b");
        b.setValue("one");
        a.addChild(b);

        b = new XppDom("b");
        b.setValue("two");
        a.addChild(b);

        final XppDom c = new XppDom("c");
        a.addChild(c);
        final XppDom d = new XppDom("d");
        d.setValue("three");
        c.addChild(d);

        assertDocumentProducedIs(a);
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.io.xml.xppdom.XppDom

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.