Skip to content

Commit

Permalink
CAMEL-16905: remove obsolete code from MockEndpoint (#6024)
Browse files Browse the repository at this point in the history
* CAMEL-16905: remove obsolete code from MockEndpoint which evalutes expression values. Adapt unit test accordingly.

* Remove unit tests related to removed code which evaluated Expressions in MockEndpoint
  • Loading branch information
klease committed Sep 3, 2021
1 parent 50cccd0 commit 21b37d8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 45 deletions.
Expand Up @@ -802,15 +802,7 @@ private Object extractActualValue(Exchange exchange, Object actualValue, Object
return null;
}

if (actualValue instanceof Expression) {
Class<?> clazz = Object.class;
if (expectedValue != null) {
clazz = expectedValue.getClass();
}
actualValue = ((Expression) actualValue).evaluate(exchange, clazz);
} else if (actualValue instanceof Predicate) {
actualValue = ((Predicate) actualValue).matches(exchange);
} else if (expectedValue != null) {
if (expectedValue != null) {
String from = actualValue.getClass().getName();
String to = expectedValue.getClass().getName();
actualValue = getCamelContext().getTypeConverter().convertTo(expectedValue.getClass(), exchange, actualValue);
Expand Down
Expand Up @@ -29,9 +29,7 @@
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.language.xpath.XPathBuilder;
import org.apache.camel.spi.Registry;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -282,28 +280,6 @@ public void testExpectationOfHeaderWithNumber() throws InterruptedException {
resultEndpoint.assertIsSatisfied();
}

@Test
public void testExpressionExpectationOfHeader() throws InterruptedException {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.reset();

resultEndpoint.expectedHeaderReceived("number", 123);
template.sendBodyAndHeader("direct:a", "<foo><id>123</id></foo>", "number",
XPathBuilder.xpath("/foo/id", Integer.class));
resultEndpoint.assertIsSatisfied();
}

@Test
public void testExpressionExpectationOfProperty() throws InterruptedException {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.reset();

resultEndpoint.expectedPropertyReceived("number", 123);
template.sendBodyAndProperty("direct:a", "<foo><id>123</id></foo>", "number",
XPathBuilder.xpath("/foo/id", Integer.class));
resultEndpoint.assertIsSatisfied();
}

@Test
public void testAscending() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
Expand Down Expand Up @@ -1075,18 +1051,6 @@ public void testExpectedBodyTypeCoerce() throws Exception {
assertMockEndpointsSatisfied();
}

@Test
public void testExpectedBodyExpression() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived(987);

// start with 0 (zero) to have it converted to the number and match 987
// and since its an expression it would be evaluated first as well
template.sendBody("direct:a", ExpressionBuilder.constantExpression("0987"));

assertMockEndpointsSatisfied();
}

@Test
public void testResetDefaultProcessor() throws Exception {
final AtomicInteger counter = new AtomicInteger();
Expand Down

0 comments on commit 21b37d8

Please sign in to comment.