Examples of TestReport


Examples of org.apache.batik.test.TestReport

     * Compares the input exception with the expected exception
     * If they match, then the test passes. Otherwise, the test fails
     */
    protected TestReport handleException(Exception e) {
        if (!isMatch(e.getClass(), expectedExceptionClass)) {
            TestReport report = reportError(ERROR_UNEXPECTED_EXCEPTION);
            report.addDescriptionEntry(ENTRY_KEY_UNEXPECTED_EXCEPTION,
                                       e.getClass().getName());
            report.addDescriptionEntry(ENTRY_KEY_EXPECTED_EXCEPTION,
                                       expectedExceptionClass);
            return report;
        } else {
            if (!ERROR_CODE_NO_CHECK.equals(expectedErrorCode)
                && e instanceof BridgeException) {
                if ( !expectedErrorCode.equals(((BridgeException)e).getCode()) ) {
                    TestReport report = reportError(ERROR_UNEXPECTED_ERROR_CODE);
                    report.addDescriptionEntry(ENTRY_KEY_UNEXPECTED_ERROR_CODE,
                                               ((BridgeException)e).getCode());
                    report.addDescriptionEntry(ENTRY_KEY_EXPECTED_ERROR_CODE,
                                               expectedErrorCode);
                    return report;
                }
            }
            return reportSuccess();
View Full Code Here

Examples of org.apache.batik.test.TestReport

                = new SamplesRenderingTest();

            t.setId(svgURL);

            if(!t.refImgURL.toString().endsWith(expectedRefImgURL)){
                TestReport r = reportError(ERROR_UNEXPECTED_REFERENCE_IMAGE_URL);
                r.addDescriptionEntry(ENTRY_KEY_EXPECTED_VALUE, expectedRefImgURL);
                r.addDescriptionEntry(ENTRY_KEY_FOUND_VALUE, "" + t.refImgURL);
                return r;
            }

            if(!t.variationURL.toString().endsWith(expectedVariationURL)){
                TestReport r = reportError(ERROR_UNEXPECTED_VARIATION_URL);
                r.addDescriptionEntry(ENTRY_KEY_EXPECTED_VALUE, expectedVariationURL);
                r.addDescriptionEntry(ENTRY_KEY_FOUND_VALUE, "" + t.variationURL);
                return r;
            }

            if(!t.saveVariation.toURL().toString().endsWith(expectedCandidateURL)){
                TestReport r = reportError(ERROR_UNEXPECTED_CANDIDATE_URL);
                r.addDescriptionEntry(ENTRY_KEY_EXPECTED_VALUE, expectedCandidateURL);
                r.addDescriptionEntry(ENTRY_KEY_FOUND_VALUE, "" + t.saveVariation.toURL().toString());
                return r;
            }

            return reportSuccess();
        }
View Full Code Here

Examples of org.apache.batik.test.TestReport

        // Compare the two output: they should be identical
        if (swA.toString().equals(swB.toString())) {
            return reportSuccess();
        } else {
            TestReport report = reportError(ERROR_DIFFERENT_SVG_OUTPUT);
            report.addDescriptionEntry(ENTRY_KEY_NO_ARG_OUTPUT,
                                       swA.toString());
            report.addDescriptionEntry(ENTRY_KEY_SVG_ARG_OUTPUT,
                                       swB.toString());
            return report;
        }
    }
View Full Code Here

Examples of org.apache.batik.test.TestReport

        cdata = (CDATASection)text.getFirstChild();
        if (cdata.getData().equals(unescapedContent)) {
            return reportSuccess();
        }

        TestReport report = reportError("Unexpected CDATA read-back");
        report.addDescriptionEntry("expected cdata", unescapedContent);
        report.addDescriptionEntry("actual cdata", cdata.getData());
        return report;
    }
View Full Code Here

Examples of org.apache.batik.test.TestReport

        }
    }

    public TestReport runImpl() throws Exception {
        Handler h = new Handler();
        TestReport report = null;

        // cdata-sections == false
        Document doc = newSVGDoc();
        DOMConfiguration conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("cdata-sections", Boolean.FALSE);
        Element e = doc.getDocumentElement();
        e.appendChild(doc.createTextNode("abc"));
        e.appendChild(doc.createCDATASection("def"));
        e.appendChild(doc.createTextNode("ghi"));
        ((AbstractDocument) doc).normalizeDocument();
        if (!(e.getFirstChild().getNodeType() == Node.TEXT_NODE
                && e.getFirstChild().getNodeValue().equals("abcdefghi")
                && e.getFirstChild() == e.getLastChild())) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "cdata-sections == false");
        }

        // comments == false
        doc = newSVGDoc();
        conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("comments", Boolean.FALSE);
        e = doc.getDocumentElement();
        e.appendChild(doc.createTextNode("abc"));
        e.appendChild(doc.createComment("def"));
        e.appendChild(doc.createTextNode("ghi"));
        ((AbstractDocument) doc).normalizeDocument();
        if (!(e.getFirstChild().getNodeType() == Node.TEXT_NODE
                && e.getFirstChild().getNodeValue().equals("abcghi")
                && e.getFirstChild() == e.getLastChild())) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "comments == false");
        }

        // element-content-whitespace == false
        doc = newSVGDoc();
        conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("element-content-whitespace", Boolean.FALSE);
        e = doc.getDocumentElement();
        e.appendChild(doc.createTextNode("    "));
        e.appendChild(doc.createElementNS(SVG_NAMESPACE_URI, "g"));
        e.appendChild(doc.createTextNode("    "));
        ((AbstractDocument) doc).normalizeDocument();
        if (!(e.getFirstChild().getNodeType() == Node.ELEMENT_NODE
                && e.getFirstChild().getNodeName().equals("g")
                && e.getFirstChild() == e.getLastChild())) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "element-content-whitespace == false");
        }

        // split-cdata-sections == true
        doc = newSVGDoc();
        conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("split-cdata-sections", Boolean.TRUE);
        conf.setParameter("error-handler", h);
        e = doc.getDocumentElement();
        e.appendChild(doc.createCDATASection("before ]]> after"));
        ((AbstractDocument) doc).normalizeDocument();
        if (!(e.getFirstChild().getNodeType() == Node.CDATA_SECTION_NODE
                && e.getFirstChild().getNodeValue().equals("before ]]")
                && e.getFirstChild().getNextSibling().getNodeType() == Node.CDATA_SECTION_NODE
                && e.getFirstChild().getNextSibling().getNodeValue().equals("> after")
                && e.getFirstChild().getNextSibling() == e.getLastChild()
                && h.get("cdata-sections-splitted") == 1)) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "split-cdata-sections == true");
        }

        // well-formed
        doc = newSVGDoc();
        ((AbstractDocument) doc).setStrictErrorChecking(false);
        conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("error-handler", h);
        e = doc.getDocumentElement();
        e.appendChild(doc.createComment("before -- after"));
        e.appendChild(doc.createComment("ends in a dash -"));
        e.setAttribute("*", "blah");
        e.appendChild(doc.createProcessingInstruction("abc", "def?>"));
        ((AbstractDocument) doc).normalizeDocument();
        if (!(h.get("wf-invalid-character-in-node-name") == 1
                && h.get("wf-invalid-character") == 3)) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "well-formed == true");
        }

        // namespaces
        doc = newDoc();
        e = doc.createElementNS(null, "root");
        doc.appendChild(e);
        Element e2 = doc.createElementNS(null, "parent");
        e.appendChild(e2);
        e2.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:ns", "http://www.example.org/ns1");
        e2.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:bar", "http://www.example.org/ns2");
        Element e3 = doc.createElementNS("http://www.example.org/ns1", "ns:child1");
        e2.appendChild(e3);
        e3.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:ns", "http://www.example.org/ns2");
        e3 = doc.createElementNS("http://www.example.org/ns2", "ns:child2");
        e2.appendChild(e3);
        ((AbstractDocument) doc).normalizeDocument();
        Attr a = e3.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "ns");
        if (!(a != null
                    && a.getNodeName().equals("xmlns:ns")
                    && a.getNodeValue().equals("http://www.example.org/ns2"))) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "namespaces == true, test 1");
        }

        doc = newDoc();
        e = doc.createElementNS(null, "root");
        doc.appendChild(e);
        e2 = doc.createElementNS("http://www.example.org/ns1", "ns:child1");
        e.appendChild(e2);
        e2.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:ns", "http://www.example.org/ns1");
        e3 = doc.createElementNS("http://www.example.org/ns1", "ns:child2");
        e2.appendChild(e3);
        e2 = (Element) ((AbstractDocument) doc).renameNode(e2, "http://www.example.org/ns2", "ns:child1");
        ((AbstractDocument) doc).normalizeDocument();
        a = e2.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "ns");
        Attr a2 = e3.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "ns");
        if (!(a != null
                    && a.getNodeName().equals("xmlns:ns")
                    && a.getNodeValue().equals("http://www.example.org/ns2")
                    && a2 != null
                    && a2.getNodeName().equals("xmlns:ns")
                    && a2.getNodeValue().equals("http://www.example.org/ns1"))) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "namespaces == true, test 2");
        }

        doc = newDoc();
        e = doc.createElementNS(null, "root");
        doc.appendChild(e);
        e2 = doc.createElementNS("http://www.example.org/ns1", "child1");
        e.appendChild(e2);
        e2.setAttributeNS("http://www.example.org/ns2", "blah", "hi");
        ((AbstractDocument) doc).normalizeDocument();
        a = e2.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "xmlns");
        a2 = e2.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "NS1");
        if (!(a != null
                    && a.getNodeValue().equals("http://www.example.org/ns1")
                    && a2 != null
                    && a2.getNodeValue().equals("http://www.example.org/ns2"))) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "namespaces == true, test 3");
        }

        // namespace-declarations == false
        doc = newDoc();
        e = doc.createElementNS(null, "ex:root");
        e.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:ex", "http://www.example.org/ns1");
        conf = ((AbstractDocument) doc).getDomConfig();
        conf.setParameter("namespace-declarations", Boolean.FALSE);
        doc.appendChild(e);
        ((AbstractDocument) doc).normalizeDocument();
        if (!(e.getAttributeNodeNS(XMLNS_NAMESPACE_URI, "ex") == null)) {
            if (report == null) {
                report = reportError("Document.normalizeDocument test failed");
            }
            report.addDescriptionEntry("DOMConfiguration parameter", "namespace-declarations == false");
        }

        if (report == null) {
            return reportSuccess();
        }
View Full Code Here

Examples of org.apache.batik.test.TestReport

        // try { Thread.sleep(5000); } catch (InterruptedException ie) { }
        return false;
    }

    public TestReport runImpl() throws Exception {
        TestReport ret = doSomething();
        if ((ret != null) && !ret.hasPassed())
            return ret;

        checkAllObjects();

        DefaultTestReport report = new DefaultTestReport(this);
View Full Code Here

Examples of org.apache.batik.test.TestReport

        = "MainConfigTest.entry.key.actual.value";

    public TestReport reportError(String option,
                                  String expectedValue,
                                  String actualValue){
        TestReport report = reportError(ERROR_UNEXPECTED_OPTION_VALUE);
        report.addDescriptionEntry(ENTRY_KEY_OPTION, option);
        report.addDescriptionEntry(ENTRY_KEY_EXPECTED_VALUE, expectedValue);
        report.addDescriptionEntry(ENTRY_KEY_ACTUAL_VALUE, actualValue);
        return report;
    }
View Full Code Here

Examples of org.apache.batik.test.TestReport

            = extractTestReportProcessor(testRunElement);

        //
        // Run the test
        //
        TestReport report = runTest(testRun);

        //
        // Process the report
        //
        if(processors != null){
View Full Code Here

Examples of org.apache.batik.test.TestReport

            // Now run the test.
            //
            XMLTestSuiteRunner runner
                = new XMLTestSuiteRunner();

            TestReport runReport
                = runner.run(doc, args);

            //
            // Analyse TestReport
            //
View Full Code Here

Examples of org.apache.batik.test.TestReport

        boolean accurate = false;

        try{
            accurate = compare(streamA, streamB);
        }catch(IOException e){
            TestReport report = reportException(ERROR_WHILE_COMPARING_FILES, e);
            report.addDescriptionEntry(ENTRY_KEY_FIRST_IMAGE,
                                       urlA.toString());
            report.addDescriptionEntry(ENTRY_KEY_SECOND_IMAGE,
                                       urlB.toString());
            return report;
        }

        if(accurate){
            return reportSuccess();
        }

        // We are in error (images are different: produce an image
        // with the two images side by side as well as a diff image)
        BufferedImage imageA = getImage(urlA);
        if(imageA == null){
            TestReport report = reportError(ERROR_COULD_NOT_LOAD_IMAGE);
            report.addDescriptionEntry(ENTRY_KEY_IMAGE_URL,
                                       urlA.toString());
            return report;
        }

        BufferedImage imageB = getImage(urlB);
        if(imageB == null){
            TestReport report = reportError(ERROR_COULD_NOT_LOAD_IMAGE);
            report.addDescriptionEntry(ENTRY_KEY_IMAGE_URL,
                                       urlB.toString());
            return report;
        }

        BufferedImage diff = buildDiffImage(imageA, imageB);
        BufferedImage cmp  = buildCompareImage(imageA, imageB);

        File tmpDiff = imageToFile(diff, IMAGE_TYPE_DIFFERENCE);
        File tmpCmp  = imageToFile(cmp,  IMAGE_TYPE_COMPARISON);

        TestReport report = reportError(ERROR_DIFFERENCES);
        report.addDescriptionEntry(ENTRY_KEY_COMPARISON, tmpCmp);
        report.addDescriptionEntry(ENTRY_KEY_DIFFERENCE, tmpDiff);

        return report;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.