Michael Dzuba created CAMEL-12565:
-------------------------------------
Summary: inputTypeWithValidate doesn't work as expected
Key: CAMEL-12565
URL: https://issues.apache.org/jira/browse/CAMEL-12565
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.21.1
Environment: Tested on camel 2.21.1, Java 8, Win
Reporter: Michael Dzuba
{code:java}
package org.mike.tests;
import org.apache.camel.ValidationException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
public class ValidatorTests extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
validator()
.type(String.class)
.withExpression(bodyAs(String.class).isEqualToIgnoreCase("valid"));
onException(ValidationException.class)
.handled(true)
.log("Invalid predicate: ${exception.message}")
.to("mock:invalid");
from("direct:in")
//.validate(bodyAs(String.class).isEqualToIgnoreCase("valid"))
.inputTypeWithValidate(String.class)
.to("mock:out");
}
};
}
@Test
public void testValid() throws InterruptedException {
getMockEndpoint("mock:out").expectedMessageCount(1);
getMockEndpoint("mock:invalid").expectedMessageCount(0);
template.sendBody("direct:in", "valid");
assertMockEndpointsSatisfied();
}
@Test
public void testInvalid() throws InterruptedException {
getMockEndpoint("mock:out").expectedMessageCount(0);
getMockEndpoint("mock:invalid").expectedMessageCount(1);
template.sendBody("direct:in", "wrong");
assertMockEndpointsSatisfied();
}
}
{code}
Expected result: both tests pass
Actual result: 'testValid' - passed, 'testInvalid' - failed
If uncomment line 25 & comment 26
{code:java}
.validate(bodyAs(String.class).isEqualToIgnoreCase("valid"))
//.inputTypeWithValidate(String.class)
{code}
tests will OK
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)