Package org.javalite.test

Examples of org.javalite.test.XPathHelper


        a.add(Tag.create("content", "orm"));
        LazyList<Article> articles = Article.where("title = ?", "ActiveJDBC polymorphic associations")
                .include(Tag.class, Comment.class);

        String xml = articles.toXml(true, true);
        XPathHelper h = new XPathHelper(xml);
        a(h.count("/articles/article")).shouldEqual(1);
        a(h.count("/articles/article/comments/comment")).shouldEqual(1);
        a(h.count("/articles/article/tags/tag")).shouldEqual(1);
        the(h.selectText("/articles/article[1]/comments/comment[1]/content")).shouldBeEqual(
                "this is just a test comment text");
        the(h.selectText("/articles/article[1]/tags/tag[1]/content")).shouldBeEqual("orm");
    }
View Full Code Here


        checkXmlStructure(u.toXml(true, true));
        checkXmlStructure(u.toXml(false, true));
    }

    private void checkXmlStructure(String xml){
        XPathHelper h = new XPathHelper(xml);
        the(h.selectText("//first_name")).shouldBeEqual("Marilyn");
        the(h.selectText("//last_name")).shouldBeEqual("Monroe");
        the(h.count("//address")).shouldBeEqual(4);
        the(h.selectText("//address[1]/address1")).shouldBeEqual("123 Pine St.");
        the(h.selectText("//address[2]/address1")).shouldBeEqual("456 Brook St.");
        the(h.selectText("//address[3]/address1")).shouldBeEqual("23 Grove St.");
        the(h.selectText("//address[4]/address1")).shouldBeEqual("123 Pine & Needles");
    }
View Full Code Here

TOP

Related Classes of org.javalite.test.XPathHelper

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.