Package org.apache.flex.forks.batik.test

Examples of org.apache.flex.forks.batik.test.Test


                if(child.getNodeType() == Node.ELEMENT_NODE){
                    Element childElement = (Element)child;
                    String tagName = childElement.getTagName().intern();
                    // System.out.println("Processing child : " + tagName);
                    if(tagName == XTS_TEST_TAG){
                        Test t = buildTest(childElement);
                        testSuite.addTest(t);
                    }
                    else if(tagName == XTS_TEST_GROUP_TAG){
                        Test t = buildTestSuite(childElement, testSuite);
                        testSuite.addTest(t);
                    }
                }
            }
        }
View Full Code Here


        return testSuite;
    }

    protected static Test buildTest(Element element) throws TestException {
        try{
            Test t = (Test)XMLReflect.buildObject(element);

            String id
                = element.getAttribute(XTS_ID_ATTRIBUTE);
            t.setId(id);
            return t;
        }catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
View Full Code Here

* @version $Id: MainTest.java,v 1.14 2005/03/27 08:58:37 cam Exp $
*/
public class MainTest extends DefaultTestSuite {
   
    public MainTest(){
        Test t = new MainConfigTest("-d samples") {
                public TestReport validate(SVGConverter c){
                    File dst = c.getDst();
                    if(dst!= null && dst.equals(new File("samples"))){
                        return reportSuccess();
                    } else {
                        return reportError("-d", "samples", "" + dst);
                    }
                }
               
            };
       
        addTest(t);
        t.setId("MainConfigTest.output");
       
        t = new MainConfigTest("samples/anne.svg") {
                String ERROR_UNEXPECTED_SOURCES = "MainConfigTest.error.unexpected.sources";
               
                public TestReport validate(SVGConverter c){
                    Vector sources = c.getSources();
                    if(sources.size() == 1){
                        String src = (String)sources.elementAt(0);
                        if ("samples/anne.svg".equals(src)){
                            return reportSuccess();
                        }
                    }
                   
                    return reportError(ERROR_UNEXPECTED_SOURCES);
                }
               
            };
   
        addTest(t);
        t.setId("MainConfigTest.source");
   
        t = new MainConfigTest("-m image/jpeg") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.JPEG)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.JPEG.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.jpegA");

        t = new MainConfigTest("-m image/jpg") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.JPEG)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.JPEG.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.jpegB");

        t = new MainConfigTest("-m image/jpe") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.JPEG)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.JPEG.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.jpegC");

        t = new MainConfigTest("-m image/png") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.PNG)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.PNG.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.png");

        t = new MainConfigTest("-m application/pdf") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.PDF)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.PDF.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.pdf");

        t = new MainConfigTest("-m image/tiff") {
                public TestReport validate(SVGConverter c){
                    DestinationType type = c.getDestinationType();
                    if(type.equals(DestinationType.TIFF)){
                        return reportSuccess();
                    } else {
                        return reportError("-m", DestinationType.TIFF.toString(), "" + type);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.mimeType.tiff");

        t = new MainConfigTest("-w 467.69") {
                public TestReport validate(SVGConverter c){
                    float width = c.getWidth();
                    if(width == 467.69f){
                        return reportSuccess();
                    } else {
                        return reportError("-w", "" + 467.69, "" + width);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.width");

        t = new MainConfigTest("-h 345.67") {
                public TestReport validate(SVGConverter c){
                    float height = c.getHeight();
                    if(height == 345.67f){
                        return reportSuccess();
                    } else {
                        return reportError("-h", "" + 345.67, "" + height);
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.height");

        t = new MainConfigTest("-maxw 467.69") {
                public TestReport validate(SVGConverter c){
                    float maxWidth = c.getMaxWidth();
                    if(maxWidth == 467.69f){
                        return reportSuccess();
                    } else {
                        return reportError("-maxw", "" + 467.69, "" + maxWidth);
                    }
                }
           
            };
        addTest(t);
        t.setId("MainConfigTest.maxWidth");

        t = new MainConfigTest("-maxh 345.67") {
                public TestReport validate(SVGConverter c){
                    float maxHeight = c.getMaxHeight();
                    if(maxHeight == 345.67f){
                        return reportSuccess();
                    } else {
                        return reportError("-maxh", "" + 345.67, "" + maxHeight);
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.maxHeight");

        t = new MainConfigTest("-a 5,10,20,30") {
                public TestReport validate(SVGConverter c){
                    Rectangle2D aoi = c.getArea();
                    Rectangle2D.Float eAoi = new Rectangle2D.Float(5,10,20,30);
                    if(eAoi.equals(aoi)){
                        return reportSuccess();
                    } else {
                        return reportError("-a", toString(eAoi), toString(aoi));
                    }
                }

                public String toString(Rectangle2D r){
                    if (r == null){
                        return "null";
                    } else {
                        return r.getX() + "," + r.getY() + "," + r.getWidth() + "," + r.getHeight();
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.aoi");

   
        t = new MainConfigTest("-bg 128.200.100.50") {
                public TestReport validate(SVGConverter c){
                    Color bg = c.getBackgroundColor();
                    Color eBg = new Color(200,100,50,128); // Alpha is last
                    if(eBg.equals(bg)){
                        return reportSuccess();
                    } else {
                        return reportError("-bg", toString(eBg), toString(bg));
                    }
                }

                public String toString(Color c){
                    if (c==null){
                        return "null";
                    } else {
                        return c.getAlpha() + "." + c.getRed() + "." + c.getGreen() + "." + c.getBlue();
                    }
                }
           
            };
   
        addTest(t);
        t.setId("MainConfigTest.backgroundColor");

        t = new MainConfigTest("-cssMedia projection"){
                public TestReport validate(SVGConverter c){
                    String cssMedia = c.getMediaType();
                    String eCssMedia = "projection";
                    if(eCssMedia.equals(cssMedia)){
                        return reportSuccess();
                    } else {
                        return reportError("-cssMedia", eCssMedia, cssMedia);
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.cssMedia");


        t = new MainConfigTest("-font-family Arial, Comic Sans MS"){
                public TestReport validate(SVGConverter c){
                    String fontFamily = c.getDefaultFontFamily();
                    String eFontFamily = "Arial, Comic Sans MS";
                    if(eFontFamily.equals(fontFamily)){
                        return reportSuccess();
                    } else {
                        return reportError("-font-family", eFontFamily, fontFamily);
                    }
                }

                String[] makeArgsArray(String args) {
                    return new String[] {"-font-family",
                                        "Arial, Comic Sans MS"};
                }
            };

        addTest(t);
        t.setId("MainConfigTest.fontFamily");




        t = new MainConfigTest("-cssAlternate myAlternateStylesheet"){
                public TestReport validate(SVGConverter c){
                    String alternate = c.getAlternateStylesheet();
                    String eAlternate = "myAlternateStylesheet";
                    if(eAlternate.equals(alternate)){
                        return reportSuccess();
                    } else {
                        return reportError("-cssAlternate", eAlternate, alternate);
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.cssAlternate");

        t = new MainConfigTest("-validate"){
                public TestReport validate(SVGConverter c){
                    if(c.getValidate()){
                        return reportSuccess();
                    } else {
                        return reportError("-validate", "true", "false");
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.validate");

        t = new MainConfigTest("-onload"){
                public TestReport validate(SVGConverter c){
                    if(c.getExecuteOnload()){
                        return reportSuccess();
                    } else {
                        return reportError("-onload", "true", "false");
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.onload");

        t = new MainConfigTest("-scripts text/jpython"){
                public TestReport validate(SVGConverter c){
                    if("text/jpython".equals(c.getAllowedScriptTypes())){
                        return reportSuccess();
                    } else {
                        return reportError("-scripts", "text/jpython", ">>" + c.getAllowedScriptTypes() + "<<");
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.scripts");

        t = new MainConfigTest("-anyScriptOrigin"){
                public TestReport validate(SVGConverter c){
                    if(!c.getConstrainScriptOrigin()){
                        return reportSuccess();
                    } else {
                        return reportError("-anyScriptOrigin", "true", "false");
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.anyScriptOrigin");

        t = new MainConfigTest("-scriptSecurityOff"){
                public TestReport validate(SVGConverter c){
                    if(c.getSecurityOff()){
                        return reportSuccess();
                    } else {
                        return reportError("-scriptSecurityOff", "true", "false");
                    }
                }
            };

        addTest(t);
        t.setId("MainConfigTest.scriptSecurityOff");

        t = new MainConfigTest("-lang fr"){
                public TestReport validate(SVGConverter c){
                    if("fr".equals(c.getLanguage())){
                        return reportSuccess();
                    } else {
                        return reportError("-lang", "fr", c.getLanguage());
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.lang");

        t = new MainConfigTest("-cssUser myStylesheet.css"){
                public TestReport validate(SVGConverter c){
                    if("myStylesheet.css".equals(c.getUserStylesheet())){
                        return reportSuccess();
                    } else {
                        return reportError("-cssUser", "myStylesheet.css", c.getUserStylesheet());
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.cssUser");

        t = new MainConfigTest("-dpi 5.08"){
                public TestReport validate(SVGConverter c){
                    if(c.getPixelUnitToMillimeter() == 5f){
                        return reportSuccess();
                    } else {
                        return reportError("-dpi", "5f", "" + c.getPixelUnitToMillimeter());
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.dpi");

        t = new MainConfigTest("-q .5"){
                public TestReport validate(SVGConverter c){
                    if(c.getQuality() == .5f){
                        return reportSuccess();
                    } else {
                        return reportError("-q", ".5f", "" + c.getQuality());
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.quality");

        t = new MainConfigTest("-indexed 8"){
                public TestReport validate(SVGConverter c){
                    if(c.getIndexed() == 8){
                        return reportSuccess();
                    } else {
                        return reportError("-indexed", "8",
                                           "" + c.getIndexed());
                    }
                }
            };
        addTest(t);
        t.setId("MainConfigTest.indexed");

        t = new MainConfigErrorTest("-d", "hello.svg -d");
        addTest(t);
        t.setId("MainConfigErrorTest.output");

        t = new MainConfigErrorTest("-m", "hello.svg -m");
        addTest(t);
        t.setId("MainConfigErrorTest.mimeType");

        t = new MainConfigErrorTest("-w", "hello.svg -w");
        addTest(t);
        t.setId("MainConfigErrorTest.width");

        t = new MainConfigErrorTest("-h", "hello.svg -h");
        addTest(t);
        t.setId("MainConfigErrorTest.height");

        t = new MainConfigErrorTest("-maxw", "hello.svg -maxw");
        addTest(t);
        t.setId("MainConfigErrorTest.maxWidth");

        t = new MainConfigErrorTest("-maxh", "hello.svg -maxh");
        addTest(t);
        t.setId("MainConfigErrorTest.maxHeight");

        t = new MainConfigErrorTest("-a", "hello.svg -a");
        addTest(t);
        t.setId("MainConfigErrorTest.area");

        t = new MainConfigErrorTest("-bg", "hello.svg -bg");
        addTest(t);
        t.setId("MainConfigErrorTest.backgroundColor");

        t = new MainConfigErrorTest("-cssMedia", "hello.svg -cssMedia");
        addTest(t);
        t.setId("MainConfigErrorTest.mediaType");

        t = new MainConfigErrorTest("-font-family", "hello.svg -font-family");
        addTest(t);
        t.setId("MainConfigErrorTest.font-family");

        t = new MainConfigErrorTest("-cssAlternate", "hello.svg -cssAlternate");
        addTest(t);
        t.setId("MainConfigErrorTest.cssAlternate");

        t = new MainConfigErrorTest("-lang", "hello.svg -lang");
        addTest(t);
        t.setId("MainConfigErrorTest.lang");

        t = new MainConfigErrorTest("-cssUser", "hello.svg -cssUser");
        addTest(t);
        t.setId("MainConfigErrorTest.cssUser");

        t = new MainConfigErrorTest("-dpi", "hello.svg -dpi");
        addTest(t);
        t.setId("MainConfigErrorTest.dpi");

        t = new MainConfigErrorTest("-q", "hello.svg -q");
        addTest(t);
        t.setId("MainConfigErrorTest.quality");

        t = new MainConfigErrorTest("-scripts", "hello.svg -scripts");
        addTest(t);
        t.setId("MainConfigErrorTest.allowedScriptTypes");

        t = new MainIllegalArgTest("-m", "-m images/jpeq");
        addTest(t);
        t.setId("MainIllegalArgTest.mediaType");

        t = new MainIllegalArgTest("-w", "-w abd");
        addTest(t);
        t.setId("MainIllegalArgTest.width");

        t = new MainIllegalArgTest("-h", "-h abaa");
        addTest(t);
        t.setId("MainIllegalArgTest.height");

        t = new MainIllegalArgTest("-maxw", "-maxw abd");
        addTest(t);
        t.setId("MainIllegalArgTest.maxWidth");

        t = new MainIllegalArgTest("-maxh", "-maxh abaa");
        addTest(t);
        t.setId("MainIllegalArgTest.maxHeight");

        t = new MainIllegalArgTest("a", "-a aaaaaa");
        addTest(t);
        t.setId("MainIllegalArgTest.aoi");

        t = new MainIllegalArgTest("bg", "-bg a.b.c.d");
        addTest(t);
        t.setId("MainIllegalArgTest.bg");

        t = new MainIllegalArgTest("dpi", "-dpi invalidDPI");
        addTest(t);
        t.setId("MainIllegalArgTest.dpi");

        t = new MainIllegalArgTest("q", "-q illegalQuality");
        addTest(t);
        t.setId("MainIllegalArgTest.q");

    }
View Full Code Here

        int n = testSuites != null ? testSuites.length : 0;
        for(int i=0; i<n; i++){
            String suiteHref =
                testSuites[i].getAttribute(XTRun_HREF_ATTRIBUTE);

            Test test = XMLTestSuiteLoader.loadTestSuite(suiteHref, testSuite);
            if(test != null){
                testSuite.addTest(test);
            }
        }
View Full Code Here

    protected TestReport run(Element testRunElement, String[] ids)
        throws TestException{
        //
        // First, build entire suite of tests
        //
        Test testRun
            = buildTestRunTestSuite(testRunElement);

        //
        // Filter testSuite if necessary
        //
        Test filteredTestRun = testRun;
        if(ids != null && ids.length > 0){
            IdBasedTestFilter filter = new IdBasedTestFilter(ids);
            filteredTestRun = filter.filter(testRun);
            String unusedIds = filter.traceUnusedIds();
            if(unusedIds != null){
View Full Code Here

            Painter painter = null;
            URL refURL = new URL("http",
                                 "dummyHost",
                                 "dummyFile.svg");

            Test t
                = new SVGAccuracyTest(painter, refURL);
           
            setConfig(t,
                      false,
                      SVGAccuracyTest.ERROR_CANNOT_GENERATE_SVG);
View Full Code Here

        public TestReport runImpl() throws Exception {
            Painter painter = this;
            URL refURL = new URL("http",
                                 "dummyHost",
                                 "dummyFile.svg");
            Test t = new SVGAccuracyTest(painter, refURL);
           
            setConfig(t,
                      false,
                      SVGAccuracyTest.ERROR_CANNOT_GENERATE_SVG);
View Full Code Here

        }
    }

    static class NullReferenceURL extends ValidPainterTest {
        public TestReport runImpl() throws Exception {
            Test t = new SVGAccuracyTest(this, null);

            setConfig(t,
                      false,
                      SVGAccuracyTest.ERROR_CANNOT_OPEN_REFERENCE_SVG_FILE);
View Full Code Here

        }
    }

    static class InexistantReferenceURL extends ValidPainterTest {
        public TestReport runImpl() throws Exception {
            Test t = new SVGAccuracyTest(this,
                                         new URL("http",
                                                 "dummyHost",
                                                 "dummyFile.svg"));

            setConfig(t,
View Full Code Here

        public TestReport runImpl() throws Exception {
            File tmpFile = File.createTempFile("EmptySVGReference",
                                               null);
            tmpFile.deleteOnExit();

            Test t = new SVGAccuracyTest(this,
                                         tmpFile.toURL());

            setConfig(t,
                      false,
                      SVGAccuracyTest.ERROR_GENERATED_SVG_INACCURATE);
View Full Code Here

TOP

Related Classes of org.apache.flex.forks.batik.test.Test

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.