Package org.milyn.validation

Examples of org.milyn.validation.ValidationResult


*/
public class OrderTest extends TestCase {

    public void test_01() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));
        ValidationResult result = new ValidationResult();

        try {
            smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message-01.xml")), result);

            assertEquals(4, result.getNumFailures());

            List<OnFailResult> errors = result.getErrors();
            List<OnFailResult> warnings = result.getWarnings();

            assertEquals(3, errors.size());
            assertEquals(1, warnings.size());

            assertEquals("Invalid customer number '123123' at 'order/header/customer/@number'.  Customer number must match pattern '[A-Z]-[0-9]{5}'.", errors.get(0).getMessage());
View Full Code Here


        }
    }

    public void test_02() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));
        ValidationResult result = new ValidationResult();

        try {
            smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message-02.xml")), result);
            fail("Expected SmooksException");
        } catch(SmooksException e) {
            assertEquals("The maximum number of allowed validation failures (5) has been exceeded.", e.getCause().getMessage());
            assertEquals(6, result.getNumFailures());
        } finally {
            smooks.close();
        }
    }
View Full Code Here

        }
    }

    public void test_03() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-config.xml"));
        ValidationResult result = new ValidationResult();

        try {
            smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message-03.xml")), result);
            fail("Expected SmooksException");
        } catch(SmooksException e) {
            assertEquals("A FATAL validation failure has occured [order/order-items/order-item/fail] RegexRuleEvalResult, matched=false, providerName=product, ruleName=failProduct, text=true, pattern=false", e.getCause().getMessage());
            assertEquals(5, result.getNumFailures());
            assertEquals("[order/order-items/order-item/fail] RegexRuleEvalResult, matched=false, providerName=product, ruleName=failProduct, text=true, pattern=false", result.getFatal().toString());
        } finally {
            smooks.close();
        }
    }
View Full Code Here

* @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
public class ValidationExampleTest extends TestCase {

    public void test() throws IOException, SAXException {
        ValidationResult results = Main.runSmooks(Main.readInputMessage());
        List<OnFailResult> errors = results.getErrors();
        List<OnFailResult> warnings = results.getWarnings();

        assertEquals(3, errors.size());
        assertEquals(1, warnings.size());

        assertEquals("Invalid customer number 'user1' at 'Order/header/username'.  Customer number must begin with an uppercase character, followed by 5 digits.", errors.get(0).getMessage());
View Full Code Here

        System.out.println("\n\n==============Message In==============");
        System.out.println(new String(messageIn));
        System.out.println("======================================");

        final ValidationResult results = Main.runSmooks(messageIn);

        System.out.println("\n==============Validation Result=======");
        System.out.println("Errors:");
        for (OnFailResult result : results.getErrors()) {
          RuleEvalResult rule = result.getFailRuleResult();
            System.out.println("\t" + rule.getRuleName() + ": " + result.getMessage());
            System.out.println("\tSwedish:");
            System.out.println("\t" + result.getMessage(new Locale("sv", "SE")));
        }

        System.out.println("Warnings:");
        for (OnFailResult result : results.getWarnings()) {
            System.out.println("\t" + result.getMessage());
            System.out.println("\tSwedish:");
            System.out.println("\t" + result.getMessage(new Locale("sv", "SE")));
        }
View Full Code Here

        final Smooks smooks = new Smooks("smooks-config.xml");

        try {
            // Create an exec context - no profiles....
            final ExecutionContext executionContext = smooks.createExecutionContext();
            final ValidationResult validationResult = new ValidationResult();

            // Configure the execution context to generate a report...
            executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html"));

            // Filter the input message...
View Full Code Here

TOP

Related Classes of org.milyn.validation.ValidationResult

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.