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

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


        return (XppDom)getTopLevelNodes().get(0);
    }

    @Override
    protected Object createNode(final String name) {
        final XppDom newNode = new XppDom(encodeNode(name));
        final XppDom top = top();
        if (top != null) {
            top().addChild(newNode);
        }
        return newNode;
    }
View Full Code Here


        document.appendChild(root);
        Element a = document.createElement("a");
        root.appendChild(a);
        writer = new DomWriter(a, document, new XmlFriendlyNameCoder());
       
        final XppDom xppRoot = new XppDom("root");
        XppDom xppA = new XppDom("a");
        xppRoot.addChild(xppA);
        XppDom xppB = new XppDom("b");
        xppA.addChild(xppB);
        xppB.setAttribute("attr", "foo");
       
        assertDocumentProducedIs(xppA, xppB);
        XppDomWriter xppDomWriter = new XppDomWriter();
        new HierarchicalStreamCopier().copy(createDocumentReaderFor(document.getDocumentElement()), xppDomWriter);
        assertTrue(equals(xppRoot, xppDomWriter.getConfiguration()));
View Full Code Here

        document.appendChild(root);
        Element a = document.createElement("a");
        root.appendChild(a);
        writer = new DomWriter(a);
       
        final XppDom xppRoot = new XppDom("root");
        XppDom xppA = new XppDom("a");
        xppRoot.addChild(xppA);
        XppDom xppB = new XppDom("b");
        xppA.addChild(xppB);
        xppB.setAttribute("attr", "foo");
       
        assertDocumentProducedIs(xppA, xppB);
        XppDomWriter xppDomWriter = new XppDomWriter();
        new HierarchicalStreamCopier().copy(createDocumentReaderFor(document.getDocumentElement()), xppDomWriter);
        assertTrue(equals(xppRoot, xppDomWriter.getConfiguration()));
View Full Code Here

     *
     * @throws Exception unexpected
     */
    public void testEqualsEmptyDocuments() throws Exception {
        final String xml = "<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 values.
     *
     * @throws Exception unexpected
     */
    public void testSortsElementsWithDifferentValue() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom>value1</dom>");
        XppDom dom2 = XppFactory.buildDom("<dom>value2</dom>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom::text()", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom::text()", xpath.get());
    }
View Full Code Here

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

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

     * Tests comparison of attributes in different order.
     *
     * @throws Exception unexpected
     */
    public void testEqualsAttributesInDifferentOrder() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom a='1' b='2'/>");
        XppDom dom2 = XppFactory.buildDom("<dom b='2' a='1'/>");
        assertEquals(comparator, dom1, dom2);
        assertNull(xpath.get());
    }
View Full Code Here

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

     * Tests comparison of different attributes.
     *
     * @throws Exception unexpected
     */
    public void testSortsDifferentAttributes() throws Exception {
        XppDom dom1 = XppFactory.buildDom("<dom a='1'/>");
        XppDom dom2 = XppFactory.buildDom("<dom b='1'/>");
        assertEquals(-1, comparator.compare(dom1, dom2));
        assertEquals("/dom[@a?]", xpath.get());
        assertEquals(1, comparator.compare(dom2, dom1));
        assertEquals("/dom[@b?]", xpath.get());
    }
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.