This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 21b37d8 CAMEL-16905: remove obsolete code from MockEndpoint (#6024) 21b37d8 is described below commit 21b37d8093af233d7ccbef0a01be61db52fe5c13 Author: klease <38634989+kle...@users.noreply.github.com> AuthorDate: Fri Sep 3 17:07:27 2021 +0200 CAMEL-16905: remove obsolete code from MockEndpoint (#6024) * 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 --- .../apache/camel/component/mock/MockEndpoint.java | 10 +----- .../camel/component/mock/MockEndpointTest.java | 36 ---------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java index f0eba38..62c4910 100644 --- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java +++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java @@ -802,15 +802,7 @@ public class MockEndpoint extends DefaultEndpoint implements BrowsableEndpoint, 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); diff --git a/core/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java index a3834f8..17b84ff 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java @@ -29,9 +29,7 @@ import org.apache.camel.ContextTestSupport; 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; @@ -283,28 +281,6 @@ public class MockEndpointTest extends ContextTestSupport { } @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"); mock.expectsAscending().body(); @@ -1076,18 +1052,6 @@ public class MockEndpointTest extends ContextTestSupport { } @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();