Package org.apache.sis.test

Examples of org.apache.sis.test.XMLComparator


     *
     * @throws Exception Should never happen.
     */
    @Test
    public void testIgnore() throws Exception {
        final XMLComparator cmp = new XMLComparator(
            "<body>\n" +
            "  <form id=\"MyForm\">\n" +
            "    <table cellpading=\"1\">\n" +
            "      <tr><td>foo</td></tr>\n" +
            "    </table>\n" +
            "  </form>\n" +
            "</body>",
            "<body>\n" +
            "  <form id=\"MyForm\">\n" +
            "    <table cellpading=\"2\">\n" +
            "      <tr><td>foo</td></tr>\n" +
            "    </table>\n" +
            "  </form>\n" +
            "</body>");

        ensureFail("Should fail because the \"cellpading\" attribute value is different.", cmp);

        // Following comparison should not fail anymore.
        cmp.ignoredAttributes.add("cellpading");
        cmp.compare();

        cmp.ignoredAttributes.clear();
        cmp.ignoredAttributes.add("bgcolor");
        ensureFail("The \"cellpading\" attribute should not be ignored anymore.", cmp);

        // Ignore the table node, which contains the faulty attribute.
        cmp.ignoredNodes.add("table");
        cmp.compare();

        // Ignore the form node and all its children.
        cmp.ignoredNodes.clear();
        cmp.ignoredNodes.add("form");
        cmp.compare();
    }
View Full Code Here


     *
     * @throws Exception Shall never happen.
     */
    @Test
    public void testIgnore() throws Exception {
        final XMLComparator cmp = new XMLComparator(
            "<body>\n" +
            "  <form id=\"MyForm\">\n" +
            "    <table cellpading=\"1\">\n" +
            "      <tr><td>foo</td></tr>\n" +
            "    </table>\n" +
            "  </form>\n" +
            "</body>",

            "<body>\n" +
            "  <form id=\"MyForm\">\n" +
            "    <table cellpading=\"2\">\n" +
            "      <tr><td>foo</td></tr>\n" +
            "    </table>\n" +
            "  </form>\n" +
            "</body>");

        assertFail("Shall fail because the \"cellpading\" attribute value is different.", cmp);

        // Following comparison should not fail anymore.
        cmp.ignoredAttributes.add("cellpading");
        cmp.compare();

        cmp.ignoredAttributes.clear();
        cmp.ignoredAttributes.add("bgcolor");
        assertFail("The \"cellpading\" attribute should not be ignored anymore.", cmp);

        // Ignore the table node, which contains the faulty attribute.
        cmp.ignoredNodes.add("table");
        cmp.compare();

        // Ignore the form node and all its children.
        cmp.ignoredNodes.clear();
        cmp.ignoredNodes.add("form");
        cmp.compare();
    }
View Full Code Here

     *
     * @throws Exception Shall never happen.
     */
    @Test
    public void testNamespaceAware() throws Exception {
        XMLComparator cmp = new XMLComparator(
            "<ns1:body xmlns:ns1=\"http://myns1\" xmlns:ns2=\"http://myns2\">\n" +
            "  <ns1:table ns2:cellpading=\"1\"/>\n" +
            "</ns1:body>",

            "<ns4:body xmlns:ns4=\"http://myns1\" xmlns:ns3=\"http://myns2\">\n" +
            "  <ns4:table ns3:cellpading=\"1\"/>\n" +
            "</ns4:body>");

        // Following comparison should not fail anymore.
        cmp.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
        cmp.compare();
        /*
         * Opposite case: same prefix, but different URL.
         * The XML comparison is expected to fail.
         */
        cmp = new XMLComparator(
            "<ns1:body xmlns:ns1=\"http://myns1\" xmlns:ns2=\"http://myns2\">\n" +
            "  <ns1:table ns2:cellpading=\"1\"/>\n" +
            "</ns1:body>",

            "<ns1:body xmlns:ns1=\"http://myns1\" xmlns:ns2=\"http://myns3\">\n" +
View Full Code Here

TOP

Related Classes of org.apache.sis.test.XMLComparator

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.