Package org.switchyard.validate

Examples of org.switchyard.validate.Validator


        }
    }

    @Test(expected=SwitchYardException.class)
    public void test_invalid_schemafile() throws IOException, SAXException {
        Validator validator = getValidator("sw-config-invalid-schemafile.xml");
        ValidationResult result = validator.validate(new DefaultMessage().setContent("<order type='A' />"));
    }
View Full Code Here


        ValidationResult result = validator.validate(new DefaultMessage().setContent("<order type='A' />"));
    }

    @Test
    public void test_valid_xml() throws IOException, SAXException {
        Validator validator = getValidator("sw-config-xmlv-01.xml");
        String source = "<person name='foo' age='50' />";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        source = "<person2 firstName='タロウ' lastName='ヤマダ' age='50' />";
        result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

        Assert.assertNull(result.getDetail());
    }

    @Test
    public void test_invalid_xml() throws IOException, SAXException {
        Validator validator = getValidator("sw-config-xmlv-01.xml");
        String source = "<person name='foo'/>";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        Assert.assertFalse(result.isValid());
        LOGGER.info(result.getDetail());
        Assert.assertTrue(result.getDetail().startsWith("1 validation error(s)"));
    }
View Full Code Here

        Assert.assertTrue(result.getDetail().startsWith("1 validation error(s)"));
    }

    @Test
    public void test_namespaceaware_valid_xml() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-namespace.xml");
        String source = "<import:person.2 xmlns:import=\"switchyard-validate-test:import:1.0\" firstName='foo' lastName='bar' name='foo bar' age='50' />";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

        Assert.assertNull(result.getDetail());
    }

    @Test
    public void test_namespaceaware_catalog_valid_xml() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-namespace-catalog.xml");
        String source = "<import:person.2 xmlns:import=\"switchyard-validate-test:import:1.0\" firstName='foo' lastName='bar' name='foo bar' age='50' />";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

        Assert.assertNull(result.getDetail());
    }

    @Test
    public void test_dtd_valid_xml() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-dtd.xml");
        String source = "<!DOCTYPE person SYSTEM \"src/test/resources/org/switchyard/validate/internal/xml/person.dtd\"> <person name='foo' age='50' />";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

        Assert.assertNull(result.getDetail());
    }

    @Test
    public void test_dtd_valid_xml_two() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-dtd-two.xml");
        String source = "<!DOCTYPE nn:memo SYSTEM \"src/test/resources/org/switchyard/validate/internal/xml/memo.dtd\">"
                + "<nn:memo xmlns:nn=\"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<nn:to>Garfield</nn:to>"
                + "<nn:from>Odie</nn:from>"
                + "<nn:body>I love lasagna!</nn:body>"
                + "</nn:memo>";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

     * Tests included DTD.
     * @throws Exception exception
     */
    @Test
    public void test_dtd_valid_xml_three() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-dtd-two.xml");
        String source = "<!DOCTYPE nn:memo ["
                + "<!ELEMENT nn:memo (nn:to,nn:from,nn:body)>"
                + "<!ATTLIST nn:memo xmlns:nn CDATA #FIXED \"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<!ELEMENT nn:to (#PCDATA)>"
                + "<!ELEMENT nn:from (#PCDATA)>"
                + "<!ELEMENT nn:heading (#PCDATA)>"
                + "<!ELEMENT nn:body (#PCDATA)>"
                + "]>"
                + "<nn:memo xmlns:nn=\"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<nn:to>Garfield</nn:to>"
                + "<nn:from>Odie</nn:from>"
                + "<nn:body>I love lasagna!</nn:body>"
                + "</nn:memo>";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (!result.isValid()) {
            Assert.fail(result.getDetail());
        }
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

     * Negative test, tests invalid DTD.
     * @throws Exception exception
     */
    @Test
    public void test_dtd_valid_xml_four() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-dtd-two.xml");
        String source = "<!DOCTYPE nn:memo ["
                + "<!ELEMENT nn:memo (to,from,body)>"
                + "<!ATTLIST nn:memo xmlns:nn CDATA #FIXED \"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<!ELEMENT nn:to (#PCDATA)>"
                + "<!ELEMENT nn:from (#PCDATA)>"
                + "<!ELEMENT nn:body (#PCDATA)>"
                + "]>"
                + "<nn:memo xmlns:nn=\"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<nn:to>Garfield</nn:to>"
                + "<nn:from>Odie</nn:from>"
                + "<nn:body>I love lasagna!</nn:body>"
                + "</nn:memo>";
        ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        if (result.isValid()) {
            Assert.fail(result.getDetail());
        }
    }
View Full Code Here

     * Negative test, tests invalid schema name.
     * @throws Exception exception
     */
    @Test
    public void test_dtd_valid_xml_five() throws Exception {
        Validator validator = getValidator("sw-config-xmlv-dtd-two.xml");
        String source = "<!DOCTYPE nn:memo SYSTEM \"failmemo.dtd\">"
                + "<nn:memo xmlns:nn=\"urn:switchyard-quickstart:dtd-example:0.1.0\">"
                + "<nn:to>Garfield</nn:to>"
                + "<nn:from>Odie</nn:from>"
                + "<nn:body>I love lasagna!</nn:body>"
                + "</nn:memo>";

        boolean flag = false;
        try {
            ValidationResult result = validator.validate(new DefaultMessage().setContent(source));
        } catch (Exception fnfe) {
            flag = true;
        }
        if (!flag) {
            Assert.fail("Somehow found DTD that we should not have.");
View Full Code Here

TOP

Related Classes of org.switchyard.validate.Validator

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.