Search in sources :

Example 1 with SchemaValidationException

use of org.apache.camel.processor.validation.SchemaValidationException in project camel by apache.

the class ValidatingProcessorTest method testInvalidMessage.

public void testInvalidMessage() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:invalid");
    mock.expectedMessageCount(1);
    String xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "<user xmlns=\"http://foo.com/bar\">" + "  <username>someone</username>" + "</user>";
    try {
        template.sendBody("direct:start", xml);
        fail("Should have thrown a RuntimeCamelException");
    } catch (RuntimeCamelException e) {
        assertTrue(e.getCause() instanceof SchemaValidationException);
    // expected
    }
    assertMockEndpointsSatisfied();
}
Also used : SchemaValidationException(org.apache.camel.processor.validation.SchemaValidationException) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Example 2 with SchemaValidationException

use of org.apache.camel.processor.validation.SchemaValidationException in project camel by apache.

the class ValidatingProcessorTest method testNonWellFormedXml.

public void testNonWellFormedXml() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:invalid");
    mock.expectedMessageCount(1);
    String xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "user xmlns=\"http://foo.com/bar\">" + "  <id>1</id>" + "  <username>davsclaus</username>";
    try {
        template.sendBody("direct:start", xml);
        fail("Should have thrown a RuntimeCamelException");
    } catch (RuntimeCamelException e) {
        assertTrue(e.getCause() instanceof SchemaValidationException);
    // expected
    }
    assertMockEndpointsSatisfied();
}
Also used : SchemaValidationException(org.apache.camel.processor.validation.SchemaValidationException) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Example 3 with SchemaValidationException

use of org.apache.camel.processor.validation.SchemaValidationException in project camel by apache.

the class ValidatingProcessorNotUseSharedSchemaTest method testInvalidMessage.

public void testInvalidMessage() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:invalid");
    mock.expectedMessageCount(1);
    String xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "<user xmlns=\"http://foo.com/bar\">" + "  <username>someone</username>" + "</user>";
    try {
        template.sendBody("direct:start", xml);
        fail("Should have thrown a RuntimeCamelException");
    } catch (RuntimeCamelException e) {
        assertTrue(e.getCause() instanceof SchemaValidationException);
    // expected
    }
    assertMockEndpointsSatisfied();
}
Also used : SchemaValidationException(org.apache.camel.processor.validation.SchemaValidationException) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Aggregations

RuntimeCamelException (org.apache.camel.RuntimeCamelException)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3 SchemaValidationException (org.apache.camel.processor.validation.SchemaValidationException)3