Package org.geotools.validation.dto

Examples of org.geotools.validation.dto.TestSuiteDTO


        if ((obj == null) || !(obj instanceof TestSuiteDTO)) {
            return false;
        }

        boolean r = true;
        TestSuiteDTO ts = (TestSuiteDTO) obj;

        if (name != null) {
            r = r && (name.equals(ts.getName()));
        }

        if (description != null) {
            r = r && (description.equals(ts.getDescription()));
        }

        if (tests == null) {
            if (ts.getTests() != null) {
                return false;
            }
        } else {
            if (ts.getTests() != null) {
                r = r && tests.equals(ts.getTests());
            } else {
                return false;
            }
        }
View Full Code Here


     * @see java.lang.Object#clone()
     * @param plugIns Map of PlugInDTO objects
     * @return TestSuiteDTO
     */
    public TestSuiteDTO toDTO(Map plugIns) {
        TestSuiteDTO ts = new TestSuiteDTO();
        ts.setName(name);
        ts.setDescription(description);

        Map myTests = new HashMap();

        Iterator i = this.tests.keySet().iterator();

        while (i.hasNext()) {
            TestConfig t = (TestConfig) this.tests.get(i.next());
            myTests.put(t.getName(), t.toDTO(plugIns));
        }

        ts.setTests(myTests);

        return ts;
    }
View Full Code Here

            System.err.println("TestSuite file cannot be read");
            System.err.println(testSuite.toString());
            System.exit(1);
        }

        TestSuiteDTO dto = null;

        try {
            dto = XMLReader.readTestSuite(testSuite.getName(), new FileReader(testSuite), plugIns);
        } catch (FileNotFoundException e) {
            System.err.println("TestSuite file was not found.");
            System.err.println(testSuite.toString());
            e.printStackTrace();
            System.exit(1);
        } catch (ValidationException e) {
            System.err.println("TestSuite load had errors.");
            System.err.println(testSuite.toString());
            e.printStackTrace();
            System.exit(1);
        }

        ts.put(dto.getName(), dto);
    }
View Full Code Here

        Set plugInNames = new HashSet();
        Iterator i = testSuites.keySet().iterator();

        // go through each test suite
        while (i.hasNext()) {
            TestSuiteDTO dto = (TestSuiteDTO) testSuites.get(i.next());
            Iterator j = dto.getTests().keySet().iterator();
            // go through each test plugIn
            while (j.hasNext()) {
                TestDTO tdto = (TestDTO) dto.getTests().get(j.next());
                plugInNames.add(tdto.getPlugIn().getName());
            }
        }

        i = plugIns.values().iterator();
        Map errors = new HashMap();

        // go through each plugIn and add it to errors
        while (i.hasNext())
            errors.put(i.next(), Boolean.FALSE);

        // step 2 configure plug-ins with defaults
        Map defaultPlugIns = new HashMap(plugInNames.size());
        i = plugInNames.iterator();

        // go through each plugIn
        while (i.hasNext()) {
            String plugInName = (String) i.next();
            PlugInDTO dto = (PlugInDTO) plugIns.get(plugInName);
            Class plugInClass = null;

            try {
                plugInClass = Class.forName(dto.getClassName());
            } catch (ClassNotFoundException e) {
                // Error, using default.
                errors.put(dto, e);
                e.printStackTrace();
            }

            if (plugInClass == null) {
                plugInClass = Validation.class;
            }

            Map plugInArgs = dto.getArgs();

            if (plugInArgs == null) {
                plugInArgs = new HashMap();
            }

            try {
                PlugIn plugIn = new org.geotools.validation.PlugIn(plugInName, plugInClass, dto
                        .getDescription(), plugInArgs);
                defaultPlugIns.put(plugInName, plugIn);
            } catch (ValidationException e) {
                e.printStackTrace();
                errors.put(dto, e);

                // error should log here
                continue;
            }

            errors.put(dto, Boolean.TRUE); // store the plugIn
        }

        // step 3 configure plug-ins with tests + add to processor
        i = testSuites.keySet().iterator();

        // for each TEST SUITE
        while (i.hasNext()) {
            TestSuiteDTO tdto = (TestSuiteDTO) testSuites.get(i.next());
            Iterator j = tdto.getTests().keySet().iterator();

            // for each TEST in the test suite
            while (j.hasNext()) {
                TestDTO dto = (TestDTO) tdto.getTests().get(j.next());

                // deal with test
                Map testArgs = dto.getArgs();

                if (testArgs == null) {
View Full Code Here

        // go through each test suite
        // and gather up all the required plugInNames
        //
        while (i.hasNext()) {
            String testSuite = (String) i.next();
            TestSuiteDTO dto = (TestSuiteDTO) testSuiteDTOs.get(testSuite);
            Iterator j = dto.getTests().keySet().iterator();

            // go through each test plugIn
            //
            while (j.hasNext()) {
                TestDTO tdto = (TestDTO) dto.getTests().get(j.next());
                plugInNames.add(tdto.getPlugIn().getName());
            }
        }

        return plugInNames;
View Full Code Here

        // step 3
        // set up tests and add to processor
        //
        for (Iterator i = testSuiteDTOs.keySet().iterator(); i.hasNext();) {
            TestSuiteDTO tdto = (TestSuiteDTO) testSuiteDTOs.get(i.next());
            Iterator j = tdto.getTests().keySet().iterator();

            // for each TEST in the test suite
            while (j.hasNext()) {
                TestDTO dto = (TestDTO) tdto.getTests().get(j.next());

                // deal with test
                Map testArgs = dto.getArgs();

                if (testArgs == null) {
View Full Code Here

            m.put(dto.getName(), dto);

            fr = new FileReader(
                    "C:/Java/workspace/geoserver/conf/validation/RoadTestSuite.xml");

            TestSuiteDTO testsuite = XMLReader.readTestSuite("test", fr, m);
            assertTrue("TestSuite Name read",
                "RoadTestSuite".equals(testsuite.getName()));

            // multi line so cannot effectively test

            /*assertTrue("TestSuite Description read",("This test suite checks each road name to see \n"+
               "that they are of appropriate length and checks to \n"+
               "see if they are on the list of possible road names.\n"+
               "It also checks to see if any roads are contained in\n"+
               "a specified box.").equals(testsuite.getDescription()));*/
            TestDTO test = (TestDTO) testsuite.getTests().get("NameLookup");

            assertNotNull("NameLookup does not exist as a test",test);

            // multi line so cannot effectively test
            // assertTrue("Test Description read","Checks to see if the road name is in the list of possible names.".equals(test.getDescription()));
View Full Code Here

     *
     * @throws ValidationException DOCUMENT ME!
     */
    public static TestSuiteDTO readTestSuite(String name, Reader inputSource, Map plugIns)
        throws ValidationException {
        TestSuiteDTO dto = new TestSuiteDTO();
        try {
            Element elem = null;
            try {
                elem = ReaderUtils.loadConfig(inputSource);
            } catch (ParserConfigurationException e) {
                throw new ValidationException( "Problem parsing "+name+":"+e.getMessage(),
                    e);
            } catch (SAXException e) {
                throw new ValidationException( "XML problem with  "+name+":"+e.getMessage(),e);
            }

            try {
                dto.setName(ReaderUtils.getChildText(elem, "name", true));
            } catch (SAXException e) {
                throw new ValidationException("Error loading test suite name", e);
            }

            try {
                dto.setDescription(ReaderUtils.getChildText(elem,
                        "description", true));
            } catch (SAXException e) {
                throw new ValidationException("Error loading test suite description",
                    e);
            }

            Map l = new HashMap();
            dto.setTests(l);

            NodeList nl = elem.getElementsByTagName("test");

            if ((nl == null) || (nl.getLength() == 0)) {
                throw new ValidationException(
                    "The test suite loader has detected an error: no tests provided.");
            } else {
                for (int i = 0; i < nl.getLength(); i++) {
                    try {
                        TestDTO t = loadTestDTO((Element) nl.item(i), plugIns);
                        l.put(t.getName(), t);
                    } catch (ValidationException e) {
                        throw new ValidationException(
                            "An error occured loading a test in "
                            + dto.getName() + " test suite.", e);
                    }
                    catch (Throwable t) {
                        throw new ValidationException(
                            "Could not load test suite "
                            + dto.getName() + ":"+ t.getMessage(), t);
                    }                   
                }
            }
        } catch (IOException e) {
            throw new ValidationException("An error occured loading the "
                + dto.getName() + "test suite", e);
        }

        return dto;
    }
View Full Code Here

        for (int i = 0; i < fileList.length; i++) {
            try {
                if (fileList[i].canWrite() && fileList[i].isFile()) {
                    FileReader fr = new FileReader(fileList[i]);
                    try {
                        TestSuiteDTO dto = XMLReader.readTestSuite( fileList[i].getName(), fr, plugInDTOs);
                        r.put(dto.getName(), dto);                       
                    }
                    finally {                   
                        fr.close();
                    }
                }
View Full Code Here

        if ((obj == null) || !(obj instanceof TestSuiteDTO)) {
            return false;
        }

        boolean r = true;
        TestSuiteDTO ts = (TestSuiteDTO) obj;

        if (name != null) {
            r = r && (name.equals(ts.getName()));
        }

        if (description != null) {
            r = r && (description.equals(ts.getDescription()));
        }

        if (tests == null) {
            if (ts.getTests() != null) {
                return false;
            }
        } else {
            if (ts.getTests() != null) {
                r = r && tests.equals(ts.getTests());
            } else {
                return false;
            }
        }
View Full Code Here

TOP

Related Classes of org.geotools.validation.dto.TestSuiteDTO

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.