You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/04/17 09:41:17 UTC
[camel] branch mock created (now 354e5b4)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git.
at 354e5b4 CAMEL-13421: Remove BeanInvocation from camel-bean
This branch includes the following new commits:
new c1ad871 Move mock component out of camel-core. Work in progress.
new 31b7d36 Move mock component out of camel-core. Work in progress.
new b75878e Move mock component out of camel-core. Work in progress.
new adea00e Move mock component out of camel-core. Work in progress.
new 60f931b Move mock component out of camel-core. Work in progress.
new fcc5c4e Move mock component out of camel-core. Work in progress.
new 1f05f83 Move mock component out of camel-core. Work in progress.
new 0507896 Move mock component out of camel-core. Work in progress.
new 717f2c1 Move mock component out of camel-core. Work in progress.
new 3082c33 CAMEL-13421: Remove BeanInvocation from camel-bean
new 2aa18b3 CAMEL-13421: Remove BeanInvocation from camel-bean
new 7203092 CAMEL-13422: Remove camel-rmi component
new ad83c3f CAMEL-13422: Remove camel-rmi component
new f5719b6 CAMEL-13422: Remove camel-rmi component
new 2b34c48 CAMEL-13421: Remove BeanInvocation from camel-bean
new a7ec565 CAMEL-13421: Remove BeanInvocation from camel-bean
new 8ed3386 CAMEL-13422: Remove camel-rmi component
new 7525485 Move mock component out of camel-core. Work in progress.
new 69b9453 Move mock component out of camel-core. Work in progress.
new e24fc7a Move mock component out of camel-core. Work in progress.
new 4194f10 Move mock component out of camel-core. Work in progress.
new 9379d72 CAMEL-13421: Remove BeanInvocation from camel-bean
new 28bb7dc Move mock component out of camel-core. Work in progress.
new f4f0c76 Move mock component out of camel-core. Work in progress.
new bba5a61 Move mock component out of camel-core. Work in progress.
new 5ae3555 Move mock component out of camel-core. Work in progress.
new 1fac239 Move mock component out of camel-core. Work in progress.
new 636e29b Move mock component out of camel-core. Work in progress.
new c2d7cfc Move mock component out of camel-core. Work in progress.
new da69799 Move mock component out of camel-core. Work in progress.
new f559083 Move mock component out of camel-core. Work in progress.
new c6384a9 Move mock component out of camel-core. Work in progress.
new 73fb23f Move mock component out of camel-core. Work in progress.
new b85831c Move mock component out of camel-core. Work in progress.
new 632afc4 Move mock component out of camel-core. Work in progress.
new 98f9c20 Move mock component out of camel-core. Work in progress.
new 7943709 Move mock component out of camel-core. Work in progress.
new 354e5b4 CAMEL-13421: Remove BeanInvocation from camel-bean
The 38 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[camel] 35/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 632afc40e4cd1e81f901a88184773e9e718c1ddf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 10:21:39 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../java/org/apache/camel/component/mock/MockExpressionClause.java | 3 +++
.../org/apache/camel/component/mock/MockExpressionClauseSupport.java | 3 +++
.../main/java/org/apache/camel/component/mock/MockValueBuilder.java | 3 +++
.../src/main/java/org/apache/camel/builder/ExpressionBuilder.java | 2 ++
.../src/main/java/org/apache/camel/builder/PredicateBuilder.java | 2 ++
5 files changed, 13 insertions(+)
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
index fa4b202..29254d3 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
@@ -32,6 +32,9 @@ import org.apache.camel.support.ExpressionToPredicateAdapter;
/**
* Represents an expression clause within the DSL which when the expression is
* complete the clause continues to another part of the DSL
+ * <p/>
+ * This implementation is a derived copy of the <tt>org.apache.camel.builder.ExpressionClause</tt> from camel-core,
+ * that are specialized for being used with the mock component and separated from camel-core.
*/
public class MockExpressionClause<T> implements Expression, Predicate {
private MockExpressionClauseSupport<T> delegate;
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
index b518bab..007455d 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
@@ -23,6 +23,9 @@ import org.apache.camel.support.builder.ExpressionBuilder;
/**
* A support class for building expression clauses.
+ * <p/>
+ * This implementation is a derived copy of the <tt>org.apache.camel.builder.ExpressionClauseSupport</tt> from camel-core,
+ * that are specialized for being used with the mock component and separated from camel-core.
*/
public class MockExpressionClauseSupport<T> {
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
index 7253658..551c524 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -31,6 +31,9 @@ import org.apache.camel.support.builder.PredicateBuilder;
/**
* A builder of expressions or predicates based on values.
+ * <p/>
+ * This implementation is a derived copy of the <tt>org.apache.camel.builder.ValueBuilder</tt> from camel-core,
+ * that are specialized for being used with the mock component and separated from camel-core.
*/
public class MockValueBuilder implements Expression, Predicate {
private Expression expression;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index f8eb0cd..446c4ac 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -24,6 +24,8 @@ import org.apache.camel.util.StringHelper;
*/
public final class ExpressionBuilder extends org.apache.camel.support.builder.ExpressionBuilder {
+ // this class is included in camel-core to be backwards compatible by extending from camel-support
+
/**
* Utility classes should not have a public constructor.
*/
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
index 0b6dd01..43b62bd 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
@@ -21,6 +21,8 @@ package org.apache.camel.builder;
*/
public final class PredicateBuilder extends org.apache.camel.support.builder.PredicateBuilder {
+ // this class is included in camel-core to be backwards compatible by extending from camel-support
+
/**
* Utility classes should not have a public constructor.
*/
[camel] 07/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1f05f8389b8e0f94386bf50bff3b05f2cf16ed23
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 17:08:09 2019 +0200
Move mock component out of camel-core. Work in progress.
---
MIGRATION.md | 1 +
.../org/apache/camel/builder/NotifyBuilder.java | 222 +--------------------
.../apache/camel/builder/NotifyBuilderTest.java | 155 --------------
3 files changed, 5 insertions(+), 373 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 578ee48..f60ae99 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -42,6 +42,7 @@ We have also modularized many of the core components and moved them out of `came
- camel-file
- camel-language
- camel-log
+- camel-mock
- camel-properties
- camel-ref
- camel-rest
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
index 6ebe1a8..1a6153c 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
@@ -31,7 +31,6 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spi.CamelEvent;
@@ -799,204 +798,6 @@ public class NotifyBuilder {
}
/**
- * Sets a condition when the provided mock is satisfied based on {@link Exchange}
- * being sent to it when they are <b>done</b>.
- * <p/>
- * The idea is that you can use Mock for setting fine grained expectations
- * and then use that together with this builder. The mock provided does <b>NOT</b>
- * have to already exist in the route. You can just create a new pseudo mock
- * and this builder will send the done {@link Exchange} to it. So its like
- * adding the mock to the end of your route(s).
- *
- * @param mock the mock
- * @return the builder
- */
- public NotifyBuilder whenDoneSatisfied(final MockEndpoint mock) {
- return doWhenSatisfied(mock, false);
- }
-
- /**
- * Sets a condition when the provided mock is satisfied based on {@link Exchange}
- * being sent to it when they are <b>received</b>.
- * <p/>
- * The idea is that you can use Mock for setting fine grained expectations
- * and then use that together with this builder. The mock provided does <b>NOT</b>
- * have to already exist in the route. You can just create a new pseudo mock
- * and this builder will send the done {@link Exchange} to it. So its like
- * adding the mock to the end of your route(s).
- *
- * @param mock the mock
- * @return the builder
- */
- public NotifyBuilder whenReceivedSatisfied(final MockEndpoint mock) {
- return doWhenSatisfied(mock, true);
- }
-
- private NotifyBuilder doWhenSatisfied(final MockEndpoint mock, final boolean received) {
- stack.add(new EventPredicateSupport() {
- private Producer producer;
-
- @Override
- public boolean onExchangeCreated(Exchange exchange) {
- if (received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- @Override
- public boolean onExchangeFailed(Exchange exchange) {
- if (!received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- @Override
- public boolean onExchangeCompleted(Exchange exchange) {
- if (!received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- private void sendToMock(Exchange exchange) {
- // send the exchange when its completed to the mock
- try {
- if (producer == null) {
- producer = mock.createProducer();
- }
- producer.process(exchange);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- public boolean matches() {
- try {
- return mock.await(0, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- @Override
- public void reset() {
- mock.reset();
- }
-
- @Override
- public String toString() {
- if (received) {
- return "whenReceivedSatisfied(" + mock + ")";
- } else {
- return "whenDoneSatisfied(" + mock + ")";
- }
- }
- });
- return this;
- }
-
- /**
- * Sets a condition when the provided mock is <b>not</b> satisfied based on {@link Exchange}
- * being sent to it when they are <b>received</b>.
- * <p/>
- * The idea is that you can use Mock for setting fine grained expectations
- * and then use that together with this builder. The mock provided does <b>NOT</b>
- * have to already exist in the route. You can just create a new pseudo mock
- * and this builder will send the done {@link Exchange} to it. So its like
- * adding the mock to the end of your route(s).
- *
- * @param mock the mock
- * @return the builder
- */
- public NotifyBuilder whenReceivedNotSatisfied(final MockEndpoint mock) {
- return doWhenNotSatisfied(mock, true);
- }
-
- /**
- * Sets a condition when the provided mock is <b>not</b> satisfied based on {@link Exchange}
- * being sent to it when they are <b>done</b>.
- * <p/>
- * The idea is that you can use Mock for setting fine grained expectations
- * and then use that together with this builder. The mock provided does <b>NOT</b>
- * have to already exist in the route. You can just create a new pseudo mock
- * and this builder will send the done {@link Exchange} to it. So its like
- * adding the mock to the end of your route(s).
- *
- * @param mock the mock
- * @return the builder
- */
- public NotifyBuilder whenDoneNotSatisfied(final MockEndpoint mock) {
- return doWhenNotSatisfied(mock, false);
- }
-
- private NotifyBuilder doWhenNotSatisfied(final MockEndpoint mock, final boolean received) {
- stack.add(new EventPredicateSupport() {
- private Producer producer;
-
- @Override
- public boolean onExchangeCreated(Exchange exchange) {
- if (received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- @Override
- public boolean onExchangeFailed(Exchange exchange) {
- if (!received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- @Override
- public boolean onExchangeCompleted(Exchange exchange) {
- if (!received) {
- sendToMock(exchange);
- }
- return true;
- }
-
- private void sendToMock(Exchange exchange) {
- // send the exchange when its completed to the mock
- try {
- if (producer == null) {
- producer = mock.createProducer();
- }
- producer.process(exchange);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- public boolean matches() {
- try {
- return !mock.await(0, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- @Override
- public void reset() {
- mock.reset();
- }
-
- @Override
- public String toString() {
- if (received) {
- return "whenReceivedNotSatisfied(" + mock + ")";
- } else {
- return "whenDoneNotSatisfied(" + mock + ")";
- }
- }
- });
- return this;
- }
-
- /**
* Sets a condition that the bodies is expected to be <b>received</b> in the order as well.
* <p/>
* This condition will discard any additional messages. If you need a more strict condition
@@ -1227,34 +1028,19 @@ public class NotifyBuilder {
* This operation will wait until the match is <tt>true</tt> or otherwise a timeout occur
* which means <tt>false</tt> will be returned.
* <p/>
- * The timeout value is by default 10 seconds. But it will use the highest <i>maximum result wait time</i>
- * from the configured mocks, if such a value has been configured.
- * <p/>
- * This method is convenient to use in unit tests to have it adhere and wait
- * as long as the mock endpoints.
+ * The timeout value is by default 10 seconds.
*
* @return <tt>true</tt> if matching, <tt>false</tt> otherwise due to timeout
+ * @deprecated use {@link #matches(long, TimeUnit)} instead
*/
+ @Deprecated
public boolean matchesMockWaitTime() {
if (!created) {
throw new IllegalStateException("NotifyBuilder has not been created. Invoke the create() method before matching.");
}
- long timeout = 0;
- for (Endpoint endpoint : context.getEndpoints()) {
- if (endpoint instanceof MockEndpoint) {
- long waitTime = ((MockEndpoint) endpoint).getResultWaitTime();
- if (waitTime > 0) {
- timeout = Math.max(timeout, waitTime);
- }
- }
- }
// use 10 sec as default
- if (timeout == 0) {
- timeout = 10000;
- }
-
- return matches(timeout, TimeUnit.MILLISECONDS);
+ return matches(10000, TimeUnit.MILLISECONDS);
}
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
index 87c080d..b3fefe3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.builder;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
public class NotifyBuilderTest extends ContextTestSupport {
@@ -747,160 +746,6 @@ public class NotifyBuilderTest extends ContextTestSupport {
}
@Test
- public void testWhenReceivedSatisfied() throws Exception {
- // lets use a mock to set the expressions as it got many great assertions for that
- // notice we use mock:assert which does NOT exist in the route, its just a pseudo name
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .from("direct:foo").whenDoneSatisfied(mock)
- .create();
-
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Hello World");
- assertEquals(false, notify.matches());
-
- // the notify is based on direct:foo so sending to bar should not trigger match
- template.sendBody("direct:bar", "Hi World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Hi World");
- assertEquals(true, notify.matches());
- }
-
- @Test
- public void testWhenReceivedNotSatisfied() throws Exception {
- // lets use a mock to set the expressions as it got many great assertions for that
- // notice we use mock:assert which does NOT exist in the route, its just a pseudo name
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedMessageCount(2);
- mock.message(1).body().contains("Camel");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .from("direct:foo").whenReceivedNotSatisfied(mock)
- .create();
-
- // is always false to start with
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Bye World");
- assertEquals(true, notify.matches());
-
- template.sendBody("direct:foo", "Hello Camel");
- assertEquals(false, notify.matches());
- }
-
- @Test
- public void testWhenNotSatisfiedUsingSatisfied() throws Exception {
- // lets use a mock to set the expressions as it got many great assertions for that
- // notice we use mock:assert which does NOT exist in the route, its just a pseudo name
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedMessageCount(2);
- mock.message(1).body().contains("Camel");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .from("direct:foo").whenReceivedSatisfied(mock)
- .create();
-
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Hello Camel");
- assertEquals(true, notify.matches());
- }
-
- @Test
- public void testComplexOrCamel() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedBodiesReceivedInAnyOrder("Hello World", "Bye World", "Hi World");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .from("direct:foo").whenReceivedSatisfied(mock)
- .and().from("direct:bar").whenExactlyDone(5).whenAnyReceivedMatches(body().contains("Camel"))
- .create();
-
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Bye World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Hello World");
- assertEquals(false, notify.matches());
-
- // the notify is based on direct:foo so sending to bar should not trigger match
- template.sendBody("direct:bar", "Hi World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:foo", "Hi World");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:bar", "Hi Camel");
- assertEquals(false, notify.matches());
-
- template.sendBody("direct:bar", "A");
- template.sendBody("direct:bar", "B");
- template.sendBody("direct:bar", "C");
- assertEquals(true, notify.matches());
- }
-
- @Test
- public void testWhenDoneSatisfied() throws Exception {
- // lets use a mock to set the expressions as it got many great assertions for that
- // notice we use mock:assert which does NOT exist in the route, its just a pseudo name
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedBodiesReceived("Bye World", "Bye Camel");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .whenDoneSatisfied(mock)
- .create();
-
- // is always false to start with
- assertEquals(false, notify.matches());
-
- template.requestBody("direct:cake", "World");
- assertEquals(false, notify.matches());
-
- template.requestBody("direct:cake", "Camel");
- assertEquals(true, notify.matches());
-
- template.requestBody("direct:cake", "Damn");
- // will still be true as the mock has been completed
- assertEquals(true, notify.matches());
- }
-
- @Test
- public void testWhenDoneNotSatisfied() throws Exception {
- // lets use a mock to set the expressions as it got many great assertions for that
- // notice we use mock:assert which does NOT exist in the route, its just a pseudo name
- MockEndpoint mock = getMockEndpoint("mock:assert");
- mock.expectedBodiesReceived("Bye World", "Bye Camel");
-
- NotifyBuilder notify = new NotifyBuilder(context)
- .whenDoneNotSatisfied(mock)
- .create();
-
- // is always false to start with
- assertEquals(false, notify.matches());
-
- template.requestBody("direct:cake", "World");
- assertEquals(true, notify.matches());
-
- template.requestBody("direct:cake", "Camel");
- assertEquals(false, notify.matches());
-
- template.requestBody("direct:cake", "Damn");
- // will still be false as the mock has been completed
- assertEquals(false, notify.matches());
- }
-
- @Test
public void testReset() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context)
.whenExactlyDone(1)
[camel] 19/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 69b94538860f4bcd8643344fbe73866c4d0a388d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 11:47:50 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../apache/camel/builder/ExpressionBuilder.java | 813 --------------------
.../org/apache/camel/builder/ValueBuilder.java | 1 +
.../language/simple/SimpleExpressionBuilder.java | 851 +++++++++++++++++++++
.../simple/ast/SimpleFunctionExpression.java | 71 +-
4 files changed, 888 insertions(+), 848 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index 5901824..18ca79a 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -18,21 +18,13 @@ package org.apache.camel.builder;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.camel.CamelContext;
@@ -42,29 +34,21 @@ import org.apache.camel.Expression;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.Message;
import org.apache.camel.NoSuchLanguageException;
-import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.RuntimeExchangeException;
import org.apache.camel.model.language.MethodCallExpression;
-import org.apache.camel.spi.ExchangeFormatter;
import org.apache.camel.spi.Language;
import org.apache.camel.spi.PropertiesComponent;
import org.apache.camel.spi.RouteContext;
import org.apache.camel.spi.UnitOfWork;
-import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.GroupIterator;
import org.apache.camel.support.GroupTokenIterator;
import org.apache.camel.support.LanguageSupport;
-import org.apache.camel.support.MessageHelper;
-import org.apache.camel.support.processor.DefaultExchangeFormatter;
-import org.apache.camel.util.FileUtil;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.OgnlHelper;
import org.apache.camel.util.Scanner;
-import org.apache.camel.util.SkipIterator;
import org.apache.camel.util.StringHelper;
/**
@@ -75,8 +59,6 @@ public final class ExpressionBuilder {
// TODO: Make this possible to have a base class in camel-support, and then extend it here, so we can have both
// and maybe deprecate this and refer to the builder in camel-support
- private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])([^+-]+)");
-
/**
* Utility classes should not have a public constructor.
*/
@@ -247,22 +229,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the exchanges inbound message header invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the header in a simple OGNL syntax
- */
- public static Expression headersOgnlExpression(final String ognl) {
- return new KeyedOgnlExpressionAdapter(ognl, "headerOgnl(" + ognl + ")",
- new KeyedOgnlExpressionAdapter.KeyedEntityRetrievalStrategy() {
- public Object getKeyedEntity(Exchange exchange, String key) {
- String text = simpleExpression(key).evaluate(exchange, String.class);
- return exchange.getIn().getHeader(text);
- }
- });
- }
-
- /**
* Returns an expression for the inbound message headers
*
* @return an expression object which will return the inbound headers
@@ -406,36 +372,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the exchanges exception invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the body in a simple OGNL syntax
- */
- public static Expression exchangeExceptionOgnlExpression(final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object exception = exchange.getException();
- if (exception == null) {
- exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
- }
-
- if (exception == null) {
- return null;
- }
-
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- return new MethodCallExpression(exception, ognl).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "exchangeExceptionOgnl(" + ognl + ")";
- }
- };
- }
-
- /**
* Returns an expression for the type converter
*
* @return an expression object which will return the type converter
@@ -529,7 +465,6 @@ public final class ExpressionBuilder {
/**
* Returns an expression for an exception message set on the exchange
*
- * @see <tt>Exchange.getException().getMessage()</tt>
* @return an expression object which will return the exception message set on the exchange
*/
public static Expression exchangeExceptionMessageExpression() {
@@ -600,22 +535,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns an expression for the property value of exchange with the given name invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the property in a simple OGNL syntax
- */
- public static Expression propertyOgnlExpression(final String ognl) {
- return new KeyedOgnlExpressionAdapter(ognl, "propertyOgnl(" + ognl + ")",
- new KeyedOgnlExpressionAdapter.KeyedEntityRetrievalStrategy() {
- public Object getKeyedEntity(Exchange exchange, String key) {
- String text = simpleExpression(key).evaluate(exchange, String.class);
- return exchange.getProperty(text);
- }
- });
- }
-
- /**
* Returns an expression for the exchange properties of exchange
*
* @return an expression object which will return the exchange properties
@@ -805,69 +724,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns an expression for a type value
- *
- * @param name the type name
- * @return an expression object which will return the type value
- */
- public static Expression typeExpression(final String name) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // it may refer to a class type
- String text = simpleExpression(name).evaluate(exchange, String.class);
- Class<?> type = exchange.getContext().getClassResolver().resolveClass(text);
- if (type != null) {
- return type;
- }
-
- int pos = text.lastIndexOf(".");
- if (pos > 0) {
- String before = text.substring(0, pos);
- String after = text.substring(pos + 1);
- type = exchange.getContext().getClassResolver().resolveClass(before);
- if (type != null) {
- return ObjectHelper.lookupConstantFieldValue(type, after);
- }
- }
-
- throw CamelExecutionException.wrapCamelExecutionException(exchange, new ClassNotFoundException("Cannot find type " + text));
- }
-
- @Override
- public String toString() {
- return "type:" + name;
- }
- };
- }
-
- /**
- * Returns an expression that caches the evaluation of another expression
- * and returns the cached value, to avoid re-evaluating the expression.
- *
- * @param expression the target expression to cache
- * @return the cached value
- */
- public static Expression cacheExpression(final Expression expression) {
- return new ExpressionAdapter() {
- private final AtomicReference<Object> cache = new AtomicReference<>();
-
- public Object evaluate(Exchange exchange) {
- Object answer = cache.get();
- if (answer == null) {
- answer = expression.evaluate(exchange, Object.class);
- cache.set(answer);
- }
- return answer;
- }
-
- @Override
- public String toString() {
- return expression.toString();
- }
- };
- }
-
- /**
* Returns the expression for the exchanges inbound message body
*/
public static Expression bodyExpression() {
@@ -958,31 +814,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the exchanges inbound message body invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the body in a simple OGNL syntax
- */
- public static Expression bodyOgnlExpression(final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object body = exchange.getIn().getBody();
- if (body == null) {
- return null;
- }
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- return new MethodCallExpression(body, ognl).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "bodyOgnl(" + ognl + ")";
- }
- };
- }
-
- /**
* Returns the expression for invoking a method (support OGNL syntax) on the given expression
*
* @param exp the expression to evaluate and invoke the method on its result
@@ -1008,52 +839,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the exchanges camelContext invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the context in a simple OGNL syntax
- */
- public static Expression camelContextOgnlExpression(final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- CamelContext context = exchange.getContext();
- if (context == null) {
- return null;
- }
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- return new MethodCallExpression(context, ognl).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "camelContextOgnl(" + ognl + ")";
- }
- };
- }
-
- /**
- * Returns the expression for the exchange invoking methods defined
- * in a simple OGNL notation
- *
- * @param ognl methods to invoke on the exchange in a simple OGNL syntax
- */
- public static Expression exchangeOgnlExpression(final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- return new MethodCallExpression(exchange, ognl).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "exchangeOgnl(" + ognl + ")";
- }
- };
- }
-
- /**
* Returns the expression for the exchanges inbound message body converted
* to the given type
*/
@@ -1095,103 +880,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type and invoking methods on the converted body defined in a simple OGNL notation
- */
- public static Expression bodyOgnlExpression(final String name, final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(name).evaluate(exchange, String.class);
- Class<?> type;
- try {
- type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
- } catch (ClassNotFoundException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- Object body = exchange.getIn().getBody(type);
- if (body != null) {
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- MethodCallExpression call = new MethodCallExpression(exchange, ognl);
- // set the instance to use
- call.setInstance(body);
- return call.evaluate(exchange);
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "bodyOgnlAs[" + name + "](" + ognl + ")";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type
- */
- public static Expression mandatoryBodyExpression(final String name) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(name).evaluate(exchange, String.class);
- Class<?> type;
- try {
- type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
- } catch (ClassNotFoundException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- try {
- return exchange.getIn().getMandatoryBody(type);
- } catch (InvalidPayloadException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- }
-
- @Override
- public String toString() {
- return "mandatoryBodyAs[" + name + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type and invoking methods on the converted body defined in a simple OGNL notation
- */
- public static Expression mandatoryBodyOgnlExpression(final String name, final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(name).evaluate(exchange, String.class);
- Class<?> type;
- try {
- type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
- } catch (ClassNotFoundException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- Object body;
- try {
- body = exchange.getIn().getMandatoryBody(type);
- } catch (InvalidPayloadException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- MethodCallExpression call = new MethodCallExpression(exchange, ognl);
- // set the instance to use
- call.setInstance(body);
- return call.evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "mandatoryBodyAs[" + name + "](" + ognl + ")";
- }
- };
- }
-
- /**
* Returns the expression for the current thread name
*/
public static Expression threadNameExpression() {
@@ -1224,22 +912,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for the {@code null} value
- */
- public static Expression nullExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return null;
- }
-
- @Override
- public String toString() {
- return "null";
- }
- };
- }
-
- /**
* Returns the expression for the exchanges inbound message body converted
* to the given type.
* <p/>
@@ -1665,22 +1337,6 @@ public final class ExpressionBuilder {
};
}
- public static Expression skipIteratorExpression(final Expression expression, final int skip) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // evaluate expression as iterator
- Iterator<?> it = expression.evaluate(exchange, Iterator.class);
- ObjectHelper.notNull(it, "expression: " + expression + " evaluated on " + exchange + " must return an java.util.Iterator");
- return new SkipIterator(it, skip);
- }
-
- @Override
- public String toString() {
- return "skip " + expression + " " + skip + " times";
- }
- };
- }
-
/**
* Returns a sort expression which will sort the expression with the given comparator.
* <p/>
@@ -1883,90 +1539,6 @@ public final class ExpressionBuilder {
};
}
- public static Expression dateExpression(final String command) {
- return dateExpression(command, null, null);
- }
-
- public static Expression dateExpression(final String command, final String pattern) {
- return dateExpression(command, null, pattern);
- }
-
- public static Expression dateExpression(final String commandWithOffsets, final String timezone, final String pattern) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // Capture optional time offsets
- String command = commandWithOffsets.split("[+-]", 2)[0].trim();
- List<Long> offsets = new ArrayList<>();
- Matcher offsetMatcher = OFFSET_PATTERN.matcher(commandWithOffsets);
- while (offsetMatcher.find()) {
- try {
- long value = exchange.getContext().getTypeConverter().mandatoryConvertTo(long.class, exchange, offsetMatcher.group(2).trim());
- offsets.add(offsetMatcher.group(1).equals("+") ? value : -value);
- } catch (NoTypeConversionAvailableException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- }
-
- Date date;
- if ("now".equals(command)) {
- date = new Date();
- } else if (command.startsWith("header.") || command.startsWith("in.header.")) {
- String key = command.substring(command.lastIndexOf('.') + 1);
- date = exchange.getIn().getHeader(key, Date.class);
- if (date == null) {
- throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
- }
- } else if (command.startsWith("out.header.")) {
- String key = command.substring(command.lastIndexOf('.') + 1);
- date = exchange.getOut().getHeader(key, Date.class);
- if (date == null) {
- throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
- }
- } else if (command.startsWith("exchangeProperty.")) {
- String key = command.substring(command.lastIndexOf('.') + 1);
- date = exchange.getProperty(key, Date.class);
- if (date == null) {
- throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
- }
- } else if ("file".equals(command)) {
- Long num = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
- if (num != null && num > 0) {
- date = new Date(num);
- } else {
- date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
- if (date == null) {
- throw new IllegalArgumentException("Cannot find " + Exchange.FILE_LAST_MODIFIED + " header at command: " + command);
- }
- }
- } else {
- throw new IllegalArgumentException("Command not supported for dateExpression: " + command);
- }
-
- // Apply offsets
- long dateAsLong = date.getTime();
- for (long offset : offsets) {
- dateAsLong += offset;
- }
- date = new Date(dateAsLong);
-
- if (pattern != null && !pattern.isEmpty()) {
- SimpleDateFormat df = new SimpleDateFormat(pattern);
- if (timezone != null && !timezone.isEmpty()) {
- df.setTimeZone(TimeZone.getTimeZone(timezone));
- }
- return df.format(date);
- } else {
- return date;
- }
- }
-
- @Override
- public String toString() {
- return "date(" + commandWithOffsets + ":" + pattern + ":" + timezone + ")";
- }
- };
- }
-
public static Expression simpleExpression(final String expression) {
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
@@ -2007,199 +1579,6 @@ public final class ExpressionBuilder {
};
}
- public static Expression fileNameExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- }
-
- @Override
- public String toString() {
- return "file:name";
- }
- };
- }
-
- public static Expression fileOnlyNameExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String answer = exchange.getIn().getHeader(Exchange.FILE_NAME_ONLY, String.class);
- if (answer == null) {
- answer = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- answer = FileUtil.stripPath(answer);
- }
- return answer;
- }
-
- @Override
- public String toString() {
- return "file:onlyname";
- }
- };
- }
-
- public static Expression fileNameNoExtensionExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- return FileUtil.stripExt(name);
- }
-
- @Override
- public String toString() {
- return "file:name.noext";
- }
- };
- }
-
- public static Expression fileNameNoExtensionSingleExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- return FileUtil.stripExt(name, true);
- }
-
- @Override
- public String toString() {
- return "file:name.noext.single";
- }
- };
- }
-
- public static Expression fileOnlyNameNoExtensionExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = fileOnlyNameExpression().evaluate(exchange, String.class);
- return FileUtil.stripExt(name);
- }
-
- @Override
- public String toString() {
- return "file:onlyname.noext";
- }
- };
- }
-
- public static Expression fileOnlyNameNoExtensionSingleExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = fileOnlyNameExpression().evaluate(exchange, String.class);
- return FileUtil.stripExt(name, true);
- }
-
- @Override
- public String toString() {
- return "file:onlyname.noext.single";
- }
- };
- }
-
- public static Expression fileExtensionExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- return FileUtil.onlyExt(name);
- }
-
- @Override
- public String toString() {
- return "file:ext";
- }
- };
- }
-
- public static Expression fileExtensionSingleExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
- return FileUtil.onlyExt(name, true);
- }
-
- @Override
- public String toString() {
- return "file:ext.single";
- }
- };
- }
-
- public static Expression fileParentExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader("CamelFileParent", String.class);
- }
-
- @Override
- public String toString() {
- return "file:parent";
- }
- };
- }
-
- public static Expression filePathExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader("CamelFilePath", String.class);
- }
-
- @Override
- public String toString() {
- return "file:path";
- }
- };
- }
-
- public static Expression fileAbsolutePathExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader("CamelFileAbsolutePath", String.class);
- }
-
- @Override
- public String toString() {
- return "file:absolute.path";
- }
- };
- }
-
- public static Expression fileAbsoluteExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader("CamelFileAbsolute", Boolean.class);
- }
-
- @Override
- public String toString() {
- return "file:absolute";
- }
- };
- }
-
- public static Expression fileSizeExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader(Exchange.FILE_LENGTH, Long.class);
- }
-
- @Override
- public String toString() {
- return "file:length";
- }
- };
- }
-
- public static Expression fileLastModifiedExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
- }
-
- @Override
- public String toString() {
- return "file:modified";
- }
- };
- }
-
/**
* Returns Simple expression or fallback to Constant expression if expression str is not Simple expression.
*/
@@ -2249,196 +1628,4 @@ public final class ExpressionBuilder {
};
}
- /**
- * Returns a random number between 0 and max (exclusive)
- */
- public static Expression randomExpression(final int max) {
- return randomExpression(0, max);
- }
-
- /**
- * Returns a random number between min and max (exclusive)
- */
- public static Expression randomExpression(final int min, final int max) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Random random = new Random();
- int randomNum = random.nextInt(max - min) + min;
- return randomNum;
- }
-
- @Override
- public String toString() {
- return "random(" + min + "," + max + ")";
- }
- };
- }
-
- /**
- * Returns a random number between min and max (exclusive)
- */
- public static Expression randomExpression(final String min, final String max) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- int num1 = simpleExpression(min).evaluate(exchange, Integer.class);
- int num2 = simpleExpression(max).evaluate(exchange, Integer.class);
- Random random = new Random();
- int randomNum = random.nextInt(num2 - num1) + num1;
- return randomNum;
- }
-
- @Override
- public String toString() {
- return "random(" + min + "," + max + ")";
- }
- };
- }
-
- /**
- * Returns an iterator to skip (iterate) the given expression
- */
- public static Expression skipExpression(final String expression, final int number) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // use simple language
- Expression exp = exchange.getContext().resolveLanguage("simple").createExpression(expression);
- return ExpressionBuilder.skipIteratorExpression(exp, number).evaluate(exchange, Object.class);
- }
-
- @Override
- public String toString() {
- return "skip(" + expression + "," + number + ")";
- }
- };
- }
-
- /**
- * Returns an iterator to collate (iterate) the given expression
- */
- public static Expression collateExpression(final String expression, final int group) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // use simple language
- Expression exp = exchange.getContext().resolveLanguage("simple").createExpression(expression);
- return ExpressionBuilder.groupIteratorExpression(exp, null, "" + group, false).evaluate(exchange, Object.class);
- }
-
- @Override
- public String toString() {
- return "collate(" + expression + "," + group + ")";
- }
- };
- }
-
- /**
- * Returns the message history (including exchange details or not)
- */
- public static Expression messageHistoryExpression(final boolean detailed) {
- return new ExpressionAdapter() {
-
- private ExchangeFormatter formatter;
-
- public Object evaluate(Exchange exchange) {
- ExchangeFormatter ef = null;
- if (detailed) {
- // use the exchange formatter to log exchange details
- ef = getOrCreateExchangeFormatter(exchange.getContext());
- }
- return MessageHelper.dumpMessageHistoryStacktrace(exchange, ef, false);
- }
-
- private ExchangeFormatter getOrCreateExchangeFormatter(CamelContext camelContext) {
- if (formatter == null) {
- Set<ExchangeFormatter> formatters = camelContext.getRegistry().findByType(ExchangeFormatter.class);
- if (formatters != null && formatters.size() == 1) {
- formatter = formatters.iterator().next();
- } else {
- // setup exchange formatter to be used for message history dump
- DefaultExchangeFormatter def = new DefaultExchangeFormatter();
- def.setShowExchangeId(true);
- def.setMultiline(true);
- def.setShowHeaders(true);
- def.setStyle(DefaultExchangeFormatter.OutputStyle.Fixed);
- try {
- Integer maxChars = CamelContextHelper.parseInteger(camelContext, camelContext.getGlobalOption(Exchange.LOG_DEBUG_BODY_MAX_CHARS));
- if (maxChars != null) {
- def.setMaxChars(maxChars);
- }
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- formatter = def;
- }
- }
- return formatter;
- }
-
- @Override
- public String toString() {
- return "messageHistory(" + detailed + ")";
- }
- };
- }
-
- /**
- * Expression adapter for OGNL expression from Message Header or Exchange property
- */
- private static class KeyedOgnlExpressionAdapter extends ExpressionAdapter {
- private final String ognl;
- private final String toStringValue;
- private final KeyedEntityRetrievalStrategy keyedEntityRetrievalStrategy;
-
- KeyedOgnlExpressionAdapter(String ognl, String toStringValue,
- KeyedEntityRetrievalStrategy keyedEntityRetrievalStrategy) {
- this.ognl = ognl;
- this.toStringValue = toStringValue;
- this.keyedEntityRetrievalStrategy = keyedEntityRetrievalStrategy;
- }
-
- public Object evaluate(Exchange exchange) {
- // try with full name first
- Object property = keyedEntityRetrievalStrategy.getKeyedEntity(exchange, ognl);
- if (property != null) {
- return property;
- }
-
-
- // Split ognl except when this is not a Map, Array
- // and we would like to keep the dots within the key name
- List<String> methods = OgnlHelper.splitOgnl(ognl);
-
- String key = methods.get(0);
- String keySuffix = "";
- // if ognl starts with a key inside brackets (eg: [foo.bar])
- // remove starting and ending brackets from key
- if (key.startsWith("[") && key.endsWith("]")) {
- key = StringHelper.removeLeadingAndEndingQuotes(key.substring(1, key.length() - 1));
- keySuffix = StringHelper.after(methods.get(0), key);
- }
- // remove any OGNL operators so we got the pure key name
- key = OgnlHelper.removeOperators(key);
-
-
- property = keyedEntityRetrievalStrategy.getKeyedEntity(exchange, key);
- if (property == null) {
- return null;
- }
- // the remainder is the rest of the ognl without the key
- String remainder = StringHelper.after(ognl, key + keySuffix);
- return new MethodCallExpression(property, remainder).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return toStringValue;
- }
-
- /**
- * Strategy to retrieve the value based on the key
- */
- public interface KeyedEntityRetrievalStrategy {
- Object getKeyedEntity(Exchange exchange, String key);
- }
- }
-
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index a37d742..c8ac6cb 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -343,6 +343,7 @@ public class ValueBuilder implements Expression, Predicate {
* @return the current builder
*/
public ValueBuilder method(String methodName) {
+ // TODO: find alternative
Expression newExp = ExpressionBuilder.ognlExpression(expression, methodName);
return onNewValueBuilder(newExp);
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
new file mode 100644
index 0000000..8189149
--- /dev/null
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
@@ -0,0 +1,851 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.simple;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.model.language.MethodCallExpression;
+import org.apache.camel.spi.ExchangeFormatter;
+import org.apache.camel.support.CamelContextHelper;
+import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.MessageHelper;
+import org.apache.camel.support.processor.DefaultExchangeFormatter;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.OgnlHelper;
+import org.apache.camel.util.SkipIterator;
+import org.apache.camel.util.StringHelper;
+
+/**
+ * Expression builder used by the simple language.
+ */
+public class SimpleExpressionBuilder {
+
+ private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])([^+-]+)");
+
+ /**
+ * Returns the expression for the exchanges inbound message header invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the header in a simple OGNL syntax
+ */
+ public static Expression headersOgnlExpression(final String ognl) {
+ return new KeyedOgnlExpressionAdapter(ognl, "headerOgnl(" + ognl + ")",
+ new KeyedOgnlExpressionAdapter.KeyedEntityRetrievalStrategy() {
+ public Object getKeyedEntity(Exchange exchange, String key) {
+ String text = ExpressionBuilder.simpleExpression(key).evaluate(exchange, String.class);
+ return exchange.getIn().getHeader(text);
+ }
+ });
+ }
+
+ /**
+ * Returns the message history (including exchange details or not)
+ */
+ public static Expression messageHistoryExpression(final boolean detailed) {
+ return new ExpressionAdapter() {
+
+ private ExchangeFormatter formatter;
+
+ public Object evaluate(Exchange exchange) {
+ ExchangeFormatter ef = null;
+ if (detailed) {
+ // use the exchange formatter to log exchange details
+ ef = getOrCreateExchangeFormatter(exchange.getContext());
+ }
+ return MessageHelper.dumpMessageHistoryStacktrace(exchange, ef, false);
+ }
+
+ private ExchangeFormatter getOrCreateExchangeFormatter(CamelContext camelContext) {
+ if (formatter == null) {
+ Set<ExchangeFormatter> formatters = camelContext.getRegistry().findByType(ExchangeFormatter.class);
+ if (formatters != null && formatters.size() == 1) {
+ formatter = formatters.iterator().next();
+ } else {
+ // setup exchange formatter to be used for message history dump
+ DefaultExchangeFormatter def = new DefaultExchangeFormatter();
+ def.setShowExchangeId(true);
+ def.setMultiline(true);
+ def.setShowHeaders(true);
+ def.setStyle(DefaultExchangeFormatter.OutputStyle.Fixed);
+ try {
+ Integer maxChars = CamelContextHelper.parseInteger(camelContext, camelContext.getGlobalOption(Exchange.LOG_DEBUG_BODY_MAX_CHARS));
+ if (maxChars != null) {
+ def.setMaxChars(maxChars);
+ }
+ } catch (Exception e) {
+ throw RuntimeCamelException.wrapRuntimeCamelException(e);
+ }
+ formatter = def;
+ }
+ }
+ return formatter;
+ }
+
+ @Override
+ public String toString() {
+ return "messageHistory(" + detailed + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns an iterator to collate (iterate) the given expression
+ */
+ public static Expression collateExpression(final String expression, final int group) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // use simple language
+ Expression exp = exchange.getContext().resolveLanguage("simple").createExpression(expression);
+ return ExpressionBuilder.groupIteratorExpression(exp, null, "" + group, false).evaluate(exchange, Object.class);
+ }
+
+ @Override
+ public String toString() {
+ return "collate(" + expression + "," + group + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns an iterator to skip (iterate) the given expression
+ */
+ public static Expression skipExpression(final String expression, final int number) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // use simple language
+ Expression exp = exchange.getContext().resolveLanguage("simple").createExpression(expression);
+ return skipIteratorExpression(exp, number).evaluate(exchange, Object.class);
+ }
+
+ @Override
+ public String toString() {
+ return "skip(" + expression + "," + number + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns a random number between min and max (exclusive)
+ */
+ public static Expression randomExpression(final String min, final String max) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ int num1 = ExpressionBuilder.simpleExpression(min).evaluate(exchange, Integer.class);
+ int num2 = ExpressionBuilder.simpleExpression(max).evaluate(exchange, Integer.class);
+ Random random = new Random();
+ int randomNum = random.nextInt(num2 - num1) + num1;
+ return randomNum;
+ }
+
+ @Override
+ public String toString() {
+ return "random(" + min + "," + max + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns a random number between 0 and max (exclusive)
+ */
+ public static Expression randomExpression(final int max) {
+ return randomExpression(0, max);
+ }
+
+ /**
+ * Returns a random number between min and max (exclusive)
+ */
+ public static Expression randomExpression(final int min, final int max) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ Random random = new Random();
+ int randomNum = random.nextInt(max - min) + min;
+ return randomNum;
+ }
+
+ @Override
+ public String toString() {
+ return "random(" + min + "," + max + ")";
+ }
+ };
+ }
+
+ public static Expression fileNameExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:name";
+ }
+ };
+ }
+
+ public static Expression fileOnlyNameExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String answer = exchange.getIn().getHeader(Exchange.FILE_NAME_ONLY, String.class);
+ if (answer == null) {
+ answer = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ answer = FileUtil.stripPath(answer);
+ }
+ return answer;
+ }
+
+ @Override
+ public String toString() {
+ return "file:onlyname";
+ }
+ };
+ }
+
+ public static Expression fileNameNoExtensionExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ return FileUtil.stripExt(name);
+ }
+
+ @Override
+ public String toString() {
+ return "file:name.noext";
+ }
+ };
+ }
+
+ public static Expression fileNameNoExtensionSingleExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ return FileUtil.stripExt(name, true);
+ }
+
+ @Override
+ public String toString() {
+ return "file:name.noext.single";
+ }
+ };
+ }
+
+ public static Expression fileOnlyNameNoExtensionExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = fileOnlyNameExpression().evaluate(exchange, String.class);
+ return FileUtil.stripExt(name);
+ }
+
+ @Override
+ public String toString() {
+ return "file:onlyname.noext";
+ }
+ };
+ }
+
+ public static Expression fileOnlyNameNoExtensionSingleExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = fileOnlyNameExpression().evaluate(exchange, String.class);
+ return FileUtil.stripExt(name, true);
+ }
+
+ @Override
+ public String toString() {
+ return "file:onlyname.noext.single";
+ }
+ };
+ }
+
+ public static Expression fileExtensionExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ return FileUtil.onlyExt(name);
+ }
+
+ @Override
+ public String toString() {
+ return "file:ext";
+ }
+ };
+ }
+
+ public static Expression fileExtensionSingleExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String name = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
+ return FileUtil.onlyExt(name, true);
+ }
+
+ @Override
+ public String toString() {
+ return "file:ext.single";
+ }
+ };
+ }
+
+ public static Expression fileParentExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader("CamelFileParent", String.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:parent";
+ }
+ };
+ }
+
+ public static Expression filePathExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader("CamelFilePath", String.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:path";
+ }
+ };
+ }
+
+ public static Expression fileAbsolutePathExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader("CamelFileAbsolutePath", String.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:absolute.path";
+ }
+ };
+ }
+
+ public static Expression fileAbsoluteExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader("CamelFileAbsolute", Boolean.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:absolute";
+ }
+ };
+ }
+
+ public static Expression fileSizeExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader(Exchange.FILE_LENGTH, Long.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:length";
+ }
+ };
+ }
+
+ public static Expression fileLastModifiedExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
+ }
+
+ @Override
+ public String toString() {
+ return "file:modified";
+ }
+ };
+ }
+
+ public static Expression dateExpression(final String command) {
+ return dateExpression(command, null, null);
+ }
+
+ public static Expression dateExpression(final String command, final String pattern) {
+ return dateExpression(command, null, pattern);
+ }
+
+ public static Expression dateExpression(final String commandWithOffsets, final String timezone, final String pattern) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // Capture optional time offsets
+ String command = commandWithOffsets.split("[+-]", 2)[0].trim();
+ List<Long> offsets = new ArrayList<>();
+ Matcher offsetMatcher = OFFSET_PATTERN.matcher(commandWithOffsets);
+ while (offsetMatcher.find()) {
+ try {
+ long value = exchange.getContext().getTypeConverter().mandatoryConvertTo(long.class, exchange, offsetMatcher.group(2).trim());
+ offsets.add(offsetMatcher.group(1).equals("+") ? value : -value);
+ } catch (NoTypeConversionAvailableException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ }
+
+ Date date;
+ if ("now".equals(command)) {
+ date = new Date();
+ } else if (command.startsWith("header.") || command.startsWith("in.header.")) {
+ String key = command.substring(command.lastIndexOf('.') + 1);
+ date = exchange.getIn().getHeader(key, Date.class);
+ if (date == null) {
+ throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
+ }
+ } else if (command.startsWith("out.header.")) {
+ String key = command.substring(command.lastIndexOf('.') + 1);
+ date = exchange.getOut().getHeader(key, Date.class);
+ if (date == null) {
+ throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
+ }
+ } else if (command.startsWith("exchangeProperty.")) {
+ String key = command.substring(command.lastIndexOf('.') + 1);
+ date = exchange.getProperty(key, Date.class);
+ if (date == null) {
+ throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
+ }
+ } else if ("file".equals(command)) {
+ Long num = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
+ if (num != null && num > 0) {
+ date = new Date(num);
+ } else {
+ date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
+ if (date == null) {
+ throw new IllegalArgumentException("Cannot find " + Exchange.FILE_LAST_MODIFIED + " header at command: " + command);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Command not supported for dateExpression: " + command);
+ }
+
+ // Apply offsets
+ long dateAsLong = date.getTime();
+ for (long offset : offsets) {
+ dateAsLong += offset;
+ }
+ date = new Date(dateAsLong);
+
+ if (pattern != null && !pattern.isEmpty()) {
+ SimpleDateFormat df = new SimpleDateFormat(pattern);
+ if (timezone != null && !timezone.isEmpty()) {
+ df.setTimeZone(TimeZone.getTimeZone(timezone));
+ }
+ return df.format(date);
+ } else {
+ return date;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "date(" + commandWithOffsets + ":" + pattern + ":" + timezone + ")";
+ }
+ };
+ }
+
+ public static Expression skipIteratorExpression(final Expression expression, final int skip) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // evaluate expression as iterator
+ Iterator<?> it = expression.evaluate(exchange, Iterator.class);
+ ObjectHelper.notNull(it, "expression: " + expression + " evaluated on " + exchange + " must return an java.util.Iterator");
+ return new SkipIterator(it, skip);
+ }
+
+ @Override
+ public String toString() {
+ return "skip " + expression + " " + skip + " times";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the {@code null} value
+ */
+ public static Expression nullExpression() {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "null";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchanges inbound message body converted
+ * to the given type and invoking methods on the converted body defined in a simple OGNL notation
+ */
+ public static Expression mandatoryBodyOgnlExpression(final String name, final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String text = ExpressionBuilder.simpleExpression(name).evaluate(exchange, String.class);
+ Class<?> type;
+ try {
+ type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
+ } catch (ClassNotFoundException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ Object body;
+ try {
+ body = exchange.getIn().getMandatoryBody(type);
+ } catch (InvalidPayloadException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ MethodCallExpression call = new MethodCallExpression(exchange, ognl);
+ // set the instance to use
+ call.setInstance(body);
+ return call.evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "mandatoryBodyAs[" + name + "](" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchanges inbound message body converted
+ * to the given type
+ */
+ public static Expression mandatoryBodyExpression(final String name) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String text = ExpressionBuilder.simpleExpression(name).evaluate(exchange, String.class);
+ Class<?> type;
+ try {
+ type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
+ } catch (ClassNotFoundException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ try {
+ return exchange.getIn().getMandatoryBody(type);
+ } catch (InvalidPayloadException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "mandatoryBodyAs[" + name + "]";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchanges inbound message body converted
+ * to the given type and invoking methods on the converted body defined in a simple OGNL notation
+ */
+ public static Expression bodyOgnlExpression(final String name, final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ String text = ExpressionBuilder.simpleExpression(name).evaluate(exchange, String.class);
+ Class<?> type;
+ try {
+ type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
+ } catch (ClassNotFoundException e) {
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
+ }
+ Object body = exchange.getIn().getBody(type);
+ if (body != null) {
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ MethodCallExpression call = new MethodCallExpression(exchange, ognl);
+ // set the instance to use
+ call.setInstance(body);
+ return call.evaluate(exchange);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "bodyOgnlAs[" + name + "](" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchange invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the exchange in a simple OGNL syntax
+ */
+ public static Expression exchangeOgnlExpression(final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ return new MethodCallExpression(exchange, ognl).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "exchangeOgnl(" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchanges camelContext invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the context in a simple OGNL syntax
+ */
+ public static Expression camelContextOgnlExpression(final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ CamelContext context = exchange.getContext();
+ if (context == null) {
+ return null;
+ }
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ return new MethodCallExpression(context, ognl).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "camelContextOgnl(" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns the expression for the exchanges inbound message body invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the body in a simple OGNL syntax
+ */
+ public static Expression bodyOgnlExpression(final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ Object body = exchange.getIn().getBody();
+ if (body == null) {
+ return null;
+ }
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ return new MethodCallExpression(body, ognl).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "bodyOgnl(" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Returns an expression that caches the evaluation of another expression
+ * and returns the cached value, to avoid re-evaluating the expression.
+ *
+ * @param expression the target expression to cache
+ * @return the cached value
+ */
+ public static Expression cacheExpression(final Expression expression) {
+ return new ExpressionAdapter() {
+ private final AtomicReference<Object> cache = new AtomicReference<>();
+
+ public Object evaluate(Exchange exchange) {
+ Object answer = cache.get();
+ if (answer == null) {
+ answer = expression.evaluate(exchange, Object.class);
+ cache.set(answer);
+ }
+ return answer;
+ }
+
+ @Override
+ public String toString() {
+ return expression.toString();
+ }
+ };
+ }
+
+ /**
+ * Returns an expression for a type value
+ *
+ * @param name the type name
+ * @return an expression object which will return the type value
+ */
+ public static Expression typeExpression(final String name) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ // it may refer to a class type
+ String text = ExpressionBuilder.simpleExpression(name).evaluate(exchange, String.class);
+ Class<?> type = exchange.getContext().getClassResolver().resolveClass(text);
+ if (type != null) {
+ return type;
+ }
+
+ int pos = text.lastIndexOf(".");
+ if (pos > 0) {
+ String before = text.substring(0, pos);
+ String after = text.substring(pos + 1);
+ type = exchange.getContext().getClassResolver().resolveClass(before);
+ if (type != null) {
+ return ObjectHelper.lookupConstantFieldValue(type, after);
+ }
+ }
+
+ throw CamelExecutionException.wrapCamelExecutionException(exchange, new ClassNotFoundException("Cannot find type " + text));
+ }
+
+ @Override
+ public String toString() {
+ return "type:" + name;
+ }
+ };
+ }
+
+ /**
+ * Returns an expression for the property value of exchange with the given name invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the property in a simple OGNL syntax
+ */
+ public static Expression propertyOgnlExpression(final String ognl) {
+ return new KeyedOgnlExpressionAdapter(ognl, "propertyOgnl(" + ognl + ")",
+ new KeyedOgnlExpressionAdapter.KeyedEntityRetrievalStrategy() {
+ public Object getKeyedEntity(Exchange exchange, String key) {
+ String text = ExpressionBuilder.simpleExpression(key).evaluate(exchange, String.class);
+ return exchange.getProperty(text);
+ }
+ });
+ }
+
+ /**
+ * Returns the expression for the exchanges exception invoking methods defined
+ * in a simple OGNL notation
+ *
+ * @param ognl methods to invoke on the body in a simple OGNL syntax
+ */
+ public static Expression exchangeExceptionOgnlExpression(final String ognl) {
+ return new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ Object exception = exchange.getException();
+ if (exception == null) {
+ exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
+ }
+
+ if (exception == null) {
+ return null;
+ }
+
+ // ognl is able to evaluate method name if it contains nested functions
+ // so we should not eager evaluate ognl as a string
+ return new MethodCallExpression(exception, ognl).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return "exchangeExceptionOgnl(" + ognl + ")";
+ }
+ };
+ }
+
+ /**
+ * Expression adapter for OGNL expression from Message Header or Exchange property
+ */
+ public static class KeyedOgnlExpressionAdapter extends ExpressionAdapter {
+ private final String ognl;
+ private final String toStringValue;
+ private final KeyedEntityRetrievalStrategy keyedEntityRetrievalStrategy;
+
+ KeyedOgnlExpressionAdapter(String ognl, String toStringValue,
+ KeyedEntityRetrievalStrategy keyedEntityRetrievalStrategy) {
+ this.ognl = ognl;
+ this.toStringValue = toStringValue;
+ this.keyedEntityRetrievalStrategy = keyedEntityRetrievalStrategy;
+ }
+
+ public Object evaluate(Exchange exchange) {
+ // try with full name first
+ Object property = keyedEntityRetrievalStrategy.getKeyedEntity(exchange, ognl);
+ if (property != null) {
+ return property;
+ }
+
+
+ // Split ognl except when this is not a Map, Array
+ // and we would like to keep the dots within the key name
+ List<String> methods = OgnlHelper.splitOgnl(ognl);
+
+ String key = methods.get(0);
+ String keySuffix = "";
+ // if ognl starts with a key inside brackets (eg: [foo.bar])
+ // remove starting and ending brackets from key
+ if (key.startsWith("[") && key.endsWith("]")) {
+ key = StringHelper.removeLeadingAndEndingQuotes(key.substring(1, key.length() - 1));
+ keySuffix = StringHelper.after(methods.get(0), key);
+ }
+ // remove any OGNL operators so we got the pure key name
+ key = OgnlHelper.removeOperators(key);
+
+
+ property = keyedEntityRetrievalStrategy.getKeyedEntity(exchange, key);
+ if (property == null) {
+ return null;
+ }
+ // the remainder is the rest of the ognl without the key
+ String remainder = StringHelper.after(ognl, key + keySuffix);
+ return new MethodCallExpression(property, remainder).evaluate(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return toStringValue;
+ }
+
+ /**
+ * Strategy to retrieve the value based on the key
+ */
+ public interface KeyedEntityRetrievalStrategy {
+ Object getKeyedEntity(Exchange exchange, String key);
+ }
+ }
+}
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index 01b58c0..4337273 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.apache.camel.Expression;
import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.language.simple.SimpleExpressionBuilder;
import org.apache.camel.language.simple.types.SimpleParserException;
import org.apache.camel.language.simple.types.SimpleToken;
import org.apache.camel.util.ObjectHelper;
@@ -102,7 +103,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${camelContext.OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.camelContextOgnlExpression(remainder);
+ return SimpleExpressionBuilder.camelContextOgnlExpression(remainder);
}
// Exception OGNL
@@ -112,7 +113,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${exception.OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.exchangeExceptionOgnlExpression(remainder);
+ return SimpleExpressionBuilder.exchangeExceptionOgnlExpression(remainder);
}
// exchange property
@@ -135,7 +136,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (OgnlHelper.isValidOgnlExpression(remainder)) {
// ognl based property
- return ExpressionBuilder.propertyOgnlExpression(remainder);
+ return SimpleExpressionBuilder.propertyOgnlExpression(remainder);
} else {
// regular property
return ExpressionBuilder.exchangePropertyExpression(remainder);
@@ -159,7 +160,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${exchange.OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.exchangeOgnlExpression(remainder);
+ return SimpleExpressionBuilder.exchangeOgnlExpression(remainder);
}
// file: prefix
@@ -176,9 +177,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (remainder != null) {
String[] parts = remainder.split(":", 2);
if (parts.length == 1) {
- return ExpressionBuilder.dateExpression(parts[0]);
+ return SimpleExpressionBuilder.dateExpression(parts[0]);
} else if (parts.length == 2) {
- return ExpressionBuilder.dateExpression(parts[0], parts[1]);
+ return SimpleExpressionBuilder.dateExpression(parts[0], parts[1]);
}
}
@@ -189,7 +190,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (parts.length < 3) {
throw new SimpleParserException("Valid syntax: ${date-with-timezone:command:timezone:pattern} was: " + function, token.getIndex());
}
- return ExpressionBuilder.dateExpression(parts[0], parts[1], parts[2]);
+ return SimpleExpressionBuilder.dateExpression(parts[0], parts[1], parts[2]);
}
// bean: prefix
@@ -241,9 +242,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
// const: prefix
remainder = ifStartsWithReturnRemainder("type:", function);
if (remainder != null) {
- Expression exp = ExpressionBuilder.typeExpression(remainder);
+ Expression exp = SimpleExpressionBuilder.typeExpression(remainder);
// we want to cache this expression so we wont re-evaluate it as the type/constant wont change
- return ExpressionBuilder.cacheExpression(exp);
+ return SimpleExpressionBuilder.cacheExpression(exp);
}
// miscellaneous functions
@@ -274,7 +275,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${bodyAs(type).OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.bodyOgnlExpression(type, remainder);
+ return SimpleExpressionBuilder.bodyOgnlExpression(type, remainder);
} else {
return ExpressionBuilder.bodyExpression(type);
}
@@ -294,9 +295,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${mandatoryBodyAs(type).OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.mandatoryBodyOgnlExpression(type, remainder);
+ return SimpleExpressionBuilder.mandatoryBodyOgnlExpression(type, remainder);
} else {
- return ExpressionBuilder.mandatoryBodyExpression(type);
+ return SimpleExpressionBuilder.mandatoryBodyExpression(type);
}
}
@@ -312,7 +313,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (invalid) {
throw new SimpleParserException("Valid syntax: ${body.OGNL} was: " + function, token.getIndex());
}
- return ExpressionBuilder.bodyOgnlExpression(remainder);
+ return SimpleExpressionBuilder.bodyOgnlExpression(remainder);
}
// headerAs
@@ -370,7 +371,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (OgnlHelper.isValidOgnlExpression(key)) {
// ognl based header
- return ExpressionBuilder.headersOgnlExpression(key);
+ return SimpleExpressionBuilder.headersOgnlExpression(key);
} else {
// regular header
return ExpressionBuilder.headerExpression(key);
@@ -415,7 +416,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
} else if (ObjectHelper.equal(expression, "stepId")) {
return ExpressionBuilder.stepIdExpression();
} else if (ObjectHelper.equal(expression, "null")) {
- return ExpressionBuilder.nullExpression();
+ return SimpleExpressionBuilder.nullExpression();
}
return null;
@@ -423,33 +424,33 @@ public class SimpleFunctionExpression extends LiteralExpression {
private Expression createSimpleFileExpression(String remainder, boolean strict) {
if (ObjectHelper.equal(remainder, "name")) {
- return ExpressionBuilder.fileNameExpression();
+ return SimpleExpressionBuilder.fileNameExpression();
} else if (ObjectHelper.equal(remainder, "name.noext")) {
- return ExpressionBuilder.fileNameNoExtensionExpression();
+ return SimpleExpressionBuilder.fileNameNoExtensionExpression();
} else if (ObjectHelper.equal(remainder, "name.noext.single")) {
- return ExpressionBuilder.fileNameNoExtensionSingleExpression();
+ return SimpleExpressionBuilder.fileNameNoExtensionSingleExpression();
} else if (ObjectHelper.equal(remainder, "name.ext") || ObjectHelper.equal(remainder, "ext")) {
- return ExpressionBuilder.fileExtensionExpression();
+ return SimpleExpressionBuilder.fileExtensionExpression();
} else if (ObjectHelper.equal(remainder, "name.ext.single")) {
- return ExpressionBuilder.fileExtensionSingleExpression();
+ return SimpleExpressionBuilder.fileExtensionSingleExpression();
} else if (ObjectHelper.equal(remainder, "onlyname")) {
- return ExpressionBuilder.fileOnlyNameExpression();
+ return SimpleExpressionBuilder.fileOnlyNameExpression();
} else if (ObjectHelper.equal(remainder, "onlyname.noext")) {
- return ExpressionBuilder.fileOnlyNameNoExtensionExpression();
+ return SimpleExpressionBuilder.fileOnlyNameNoExtensionExpression();
} else if (ObjectHelper.equal(remainder, "onlyname.noext.single")) {
- return ExpressionBuilder.fileOnlyNameNoExtensionSingleExpression();
+ return SimpleExpressionBuilder.fileOnlyNameNoExtensionSingleExpression();
} else if (ObjectHelper.equal(remainder, "parent")) {
- return ExpressionBuilder.fileParentExpression();
+ return SimpleExpressionBuilder.fileParentExpression();
} else if (ObjectHelper.equal(remainder, "path")) {
- return ExpressionBuilder.filePathExpression();
+ return SimpleExpressionBuilder.filePathExpression();
} else if (ObjectHelper.equal(remainder, "absolute")) {
- return ExpressionBuilder.fileAbsoluteExpression();
+ return SimpleExpressionBuilder.fileAbsoluteExpression();
} else if (ObjectHelper.equal(remainder, "absolute.path")) {
- return ExpressionBuilder.fileAbsolutePathExpression();
+ return SimpleExpressionBuilder.fileAbsolutePathExpression();
} else if (ObjectHelper.equal(remainder, "length") || ObjectHelper.equal(remainder, "size")) {
- return ExpressionBuilder.fileSizeExpression();
+ return SimpleExpressionBuilder.fileSizeExpression();
} else if (ObjectHelper.equal(remainder, "modified")) {
- return ExpressionBuilder.fileLastModifiedExpression();
+ return SimpleExpressionBuilder.fileLastModifiedExpression();
}
if (strict) {
throw new SimpleParserException("Unknown file language syntax: " + remainder, token.getIndex());
@@ -472,9 +473,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
if (tokens.length > 2) {
throw new SimpleParserException("Valid syntax: ${random(min,max)} or ${random(max)} was: " + function, token.getIndex());
}
- return ExpressionBuilder.randomExpression(tokens[0].trim(), tokens[1].trim());
+ return SimpleExpressionBuilder.randomExpression(tokens[0].trim(), tokens[1].trim());
} else {
- return ExpressionBuilder.randomExpression("0", values.trim());
+ return SimpleExpressionBuilder.randomExpression("0", values.trim());
}
}
@@ -487,7 +488,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
}
String exp = "${body}";
int num = Integer.parseInt(values.trim());
- return ExpressionBuilder.skipExpression(exp, num);
+ return SimpleExpressionBuilder.skipExpression(exp, num);
}
// collate function
@@ -499,7 +500,7 @@ public class SimpleFunctionExpression extends LiteralExpression {
}
String exp = "${body}";
int num = Integer.parseInt(values.trim());
- return ExpressionBuilder.collateExpression(exp, num);
+ return SimpleExpressionBuilder.collateExpression(exp, num);
}
// messageHistory function
@@ -512,9 +513,9 @@ public class SimpleFunctionExpression extends LiteralExpression {
} else {
detailed = Boolean.valueOf(values);
}
- return ExpressionBuilder.messageHistoryExpression(detailed);
+ return SimpleExpressionBuilder.messageHistoryExpression(detailed);
} else if (ObjectHelper.equal(function, "messageHistory")) {
- return ExpressionBuilder.messageHistoryExpression(true);
+ return SimpleExpressionBuilder.messageHistoryExpression(true);
}
return null;
}
[camel] 01/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c1ad871422c4409ece961d3319a0491a4924bd2c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 09:44:55 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../main/java/org/apache/camel/builder/ExpressionClause.java | 2 +-
.../org/apache/camel/builder/ExpressionClauseSupport.java | 2 +-
.../src/main/java/org/apache/camel/builder/ValueBuilder.java | 2 +-
.../org/apache/camel/builder/xml/MessageVariableResolver.java | 10 +++++-----
.../main/java/org/apache/camel/builder/xml/XPathBuilder.java | 11 ++++++-----
.../apache/camel/builder/xml/DefaultNamespaceContextTest.java | 1 +
.../camel/builder/xml/ExtractXPathWithNamespaceTest.java | 1 +
.../xml/XPathHeaderNameResultTypeAndNamespaceTest.java | 1 +
.../camel/builder/xml/XPathNamespaceResultTypeTest.java | 1 +
.../java/org/apache/camel/builder/xml/XPathNamespaceTest.java | 1 +
.../apache/camel/builder/xml/XPathNestedNamespaceTest.java | 1 +
.../src/test/java/org/apache/camel/builder/xml/XPathTest.java | 1 +
.../camel/builder/xml/XPathWithNamespacesFromDomTest.java | 1 +
.../test/java/org/apache/camel/issues/SetHeaderIssueTest.java | 2 +-
.../java/org/apache/camel/language/XMLTokenSplitTest.java | 2 +-
.../language/tokenizer/XMLTokenizeLanguageGroupingTest.java | 2 +-
.../tokenizer/XMLTokenizeLanguageStreamingFileTest.java | 2 +-
.../language/tokenizer/XMLTokenizeLanguageStreamingTest.java | 2 +-
.../camel/language/tokenizer/XMLTokenizeLanguageTest.java | 2 +-
.../tokenizer/XMLTokenizeWrapLanguageGroupingTest.java | 2 +-
.../camel/language/tokenizer/XMLTokenizeWrapLanguageTest.java | 2 +-
.../apache/camel/processor/SplitGroupMultiXmlTokenTest.java | 2 +-
.../camel/processor/SplitGroupWrappedMultiXmlTokenTest.java | 2 +-
.../org/apache/camel/processor/SplitterWithXqureyTest.java | 2 +-
.../XPathWithNamespaceBuilderFilterAndResultTypeTest.java | 2 +-
.../camel/processor/XPathWithNamespaceBuilderFilterTest.java | 2 +-
.../apache/camel/processor/XPathWithNamespacesFilterTest.java | 2 +-
.../org/apache/camel/support}/builder/xml/Namespaces.java | 2 +-
28 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
index c9b9521..7b89cab 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -24,7 +24,7 @@ import java.util.function.Supplier;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.model.ExpressionNode;
import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.support.ExpressionAdapter;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 56ae73e..fa515c4 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -20,7 +20,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
import org.apache.camel.model.language.ExpressionDefinition;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index 2ebc165..dc50ec4 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java b/core/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
index dff752e..8ae9914 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/xml/MessageVariableResolver.java
@@ -27,11 +27,11 @@ import org.apache.camel.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.builder.xml.Namespaces.ENVIRONMENT_VARIABLES;
-import static org.apache.camel.builder.xml.Namespaces.EXCHANGE_PROPERTY;
-import static org.apache.camel.builder.xml.Namespaces.IN_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.OUT_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.SYSTEM_PROPERTIES_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.ENVIRONMENT_VARIABLES;
+import static org.apache.camel.support.builder.xml.Namespaces.EXCHANGE_PROPERTY;
+import static org.apache.camel.support.builder.xml.Namespaces.IN_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.OUT_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.SYSTEM_PROPERTIES_NAMESPACE;
/**
* A variable resolver for XPath expressions which support properties on the
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
index 8fd8ebd..580abfd 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
@@ -61,6 +61,7 @@ import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.support.DefaultExchange;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.MessageHelper;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.service.ServiceSupport;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
@@ -68,11 +69,11 @@ import org.apache.camel.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.builder.xml.Namespaces.DEFAULT_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.FUNCTION_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.IN_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.OUT_NAMESPACE;
-import static org.apache.camel.builder.xml.Namespaces.isMatchingNamespaceOrEmptyNamespace;
+import static org.apache.camel.support.builder.xml.Namespaces.DEFAULT_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.FUNCTION_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.IN_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.OUT_NAMESPACE;
+import static org.apache.camel.support.builder.xml.Namespaces.isMatchingNamespaceOrEmptyNamespace;
/**
* Creates an XPath expression builder which creates a nodeset result by
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/DefaultNamespaceContextTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/DefaultNamespaceContextTest.java
index b445a24..bbb3023 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/DefaultNamespaceContextTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/DefaultNamespaceContextTest.java
@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Map;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class DefaultNamespaceContextTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
index 4243ed5..e701ae0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/ExtractXPathWithNamespaceTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.builder.xml;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderNameResultTypeAndNamespaceTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderNameResultTypeAndNamespaceTest.java
index 79a12d6..1db0a10 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderNameResultTypeAndNamespaceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathHeaderNameResultTypeAndNamespaceTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.builder.xml;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
index f5001cd..30e0bb4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceResultTypeTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.builder.xml;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.builder.xml.Namespaces;
/**
* XPath with namespace test
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
index 522263a..6f587db 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNamespaceTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.builder.xml;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNestedNamespaceTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNestedNamespaceTest.java
index 0b4787d..73af8d8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNestedNamespaceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathNestedNamespaceTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.builder.xml;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XPathNestedNamespaceTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
index 22c1a96..7a3dbe0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathTest.java
@@ -41,6 +41,7 @@ import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.util.StringHelper;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathWithNamespacesFromDomTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathWithNamespacesFromDomTest.java
index 92120b9..91fc2b2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathWithNamespacesFromDomTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/xml/XPathWithNamespacesFromDomTest.java
@@ -20,6 +20,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.apache.camel.ContextTestSupport;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XPathWithNamespacesFromDomTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
index 8a66e40..a37728b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.issues;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
index b313aa0..342f85d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
index c5b88d2..b9c147e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingFileTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingFileTest.java
index 4f23da9..e3316e3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingFileTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingFileTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingTest.java
index b39fa28..add5d4f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageStreamingTest.java
@@ -17,7 +17,7 @@
package org.apache.camel.language.tokenizer;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
public class XMLTokenizeLanguageStreamingTest extends XMLTokenizeLanguageTest {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
index 01847c8..86c0958 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageGroupingTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageGroupingTest.java
index f2c4038..50c33db 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageGroupingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageGroupingTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XMLTokenizeWrapLanguageGroupingTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageTest.java
index 282afc4..9419c0a 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeWrapLanguageTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XMLTokenizeWrapLanguageTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
index 0cf282e..e1d269d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
index 93be3aa..1414b7e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
index 121b272..0f29260 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterAndResultTypeTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterAndResultTypeTest.java
index 195cf60..509330c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterAndResultTypeTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterAndResultTypeTest.java
@@ -17,7 +17,7 @@
package org.apache.camel.processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
public class XPathWithNamespaceBuilderFilterAndResultTypeTest extends XPathWithNamespaceBuilderFilterTest {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
index 520fbb1..de50553 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
index 03cfbf7..22d9bf7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/xml/Namespaces.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/xml/Namespaces.java
similarity index 98%
rename from core/camel-core/src/main/java/org/apache/camel/builder/xml/Namespaces.java
rename to core/camel-support/src/main/java/org/apache/camel/support/builder/xml/Namespaces.java
index b08c461..d924daa 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/xml/Namespaces.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/xml/Namespaces.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.builder.xml;
+package org.apache.camel.support.builder.xml;
import java.util.HashMap;
import java.util.Map;
[camel] 23/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 28bb7dc7acc46dde39297930134ce496ce0115d4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 15:20:25 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../camel/component/mock/AssertionClause.java | 13 +-
.../camel/component/mock/MockValueBuilder.java | 378 +++++++++++++++++++++
2 files changed, 383 insertions(+), 8 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index 53e5d40..beb0d18 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -25,16 +25,13 @@ import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.StreamCache;
import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.builder.ValueBuilder;
import org.apache.camel.support.PredicateAssertHelper;
import org.apache.camel.support.language.ExpressionModel;
/**
* A builder of assertions on message exchanges
*/
-public abstract class AssertionClause extends MockExpressionClauseSupport<ValueBuilder> implements Runnable {
-
- // TODO: MockValueBuilder
+public abstract class AssertionClause extends MockExpressionClauseSupport<MockValueBuilder> implements Runnable {
protected final MockEndpoint mock;
protected volatile int currentIndex;
@@ -50,13 +47,13 @@ public abstract class AssertionClause extends MockExpressionClauseSupport<ValueB
// Builder methods
// -------------------------------------------------------------------------
- public ValueBuilder expression(Expression expression) {
+ public MockValueBuilder expression(Expression expression) {
// must override this method as we provide null in the constructor
super.expression(expression);
return new PredicateValueBuilder(expression);
}
- public ValueBuilder language(ExpressionModel expression) {
+ public MockValueBuilder language(ExpressionModel expression) {
// must override this method as we provide null in the constructor
super.expression(expression.createExpression(mock.getCamelContext()));
return new PredicateValueBuilder(getExpressionValue());
@@ -144,7 +141,7 @@ public abstract class AssertionClause extends MockExpressionClauseSupport<ValueB
/**
* Public class needed for fluent builders
*/
- public final class PredicateValueBuilder extends ValueBuilder {
+ public final class PredicateValueBuilder extends MockValueBuilder {
public PredicateValueBuilder(Expression expression) {
super(expression);
@@ -158,7 +155,7 @@ public abstract class AssertionClause extends MockExpressionClauseSupport<ValueB
}
@Override
- protected ValueBuilder onNewValueBuilder(Expression exp) {
+ protected MockValueBuilder onNewValueBuilder(Expression exp) {
return new PredicateValueBuilder(exp);
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
new file mode 100644
index 0000000..188bbc6
--- /dev/null
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -0,0 +1,378 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mock;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.ExpressionClause;
+import org.apache.camel.builder.PredicateBuilder;
+import org.apache.camel.spi.NamespaceAware;
+import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.ExpressionToPredicateAdapter;
+import org.apache.camel.support.builder.xml.Namespaces;
+
+/**
+ * A builder of expressions or predicates based on values.
+ */
+public class MockValueBuilder implements Expression, Predicate {
+ private Expression expression;
+ private boolean not;
+
+ public MockValueBuilder(Expression expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public <T> T evaluate(Exchange exchange, Class<T> type) {
+ return expression.evaluate(exchange, type);
+ }
+
+ @Override
+ public boolean matches(Exchange exchange) {
+ return PredicateBuilder.toPredicate(getExpression()).matches(exchange);
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ @Override
+ public String toString() {
+ return expression.toString();
+ }
+
+ // Predicate builders
+ // -------------------------------------------------------------------------
+
+ public Predicate matches(Expression expression) {
+ return onNewPredicate(ExpressionToPredicateAdapter.toPredicate(expression));
+ }
+
+ public ExpressionClause<Predicate> matches() {
+ // chicken-and-egg situation as we need to return an ExpressionClause
+ // which needs a right-hand side that is being built via the fluent
+ // builder that is returned, and therefore we need to use a ref
+ // to the expression (right hand side) that will be used below
+ // in the onNewPredicate where the actual matching is executed
+ final AtomicReference<Expression> ref = new AtomicReference<>();
+
+ final ExpressionClause<Predicate> answer = new ExpressionClause<>(
+ onNewPredicate(new Predicate() {
+ @Override
+ public boolean matches(Exchange exchange) {
+ Expression left = expression;
+ Expression right = ref.get();
+ return PredicateBuilder.isEqualTo(left, right).matches(exchange);
+ }
+
+ @Override
+ public String toString() {
+ return expression + " == " + ref.get();
+ }
+ }));
+
+ final Expression right = new ExpressionAdapter() {
+ @Override
+ public Object evaluate(Exchange exchange) {
+ return answer.evaluate(exchange, Object.class);
+ /*if (answer.getExpressionValue() != null) {
+ return answer.getExpressionValue().evaluate(exchange, Object.class);
+ } else {
+ return answer.getExpressionType().evaluate(exchange);
+ }*/
+ }
+ };
+ // okay now we can set the reference to the right-hand-side
+ ref.set(right);
+
+ return answer;
+ }
+
+ public Predicate isNotEqualTo(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isNotEqualTo(expression, right));
+ }
+
+ public Predicate isEqualTo(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
+ }
+
+ public Predicate isEqualToIgnoreCase(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isEqualToIgnoreCase(expression, right));
+ }
+
+ public Predicate isLessThan(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isLessThan(expression, right));
+ }
+
+ public Predicate isLessThanOrEqualTo(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isLessThanOrEqualTo(expression, right));
+ }
+
+ public Predicate isGreaterThan(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isGreaterThan(expression, right));
+ }
+
+ public Predicate isGreaterThanOrEqualTo(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.isGreaterThanOrEqualTo(expression, right));
+ }
+
+ public Predicate isInstanceOf(Class<?> type) {
+ return onNewPredicate(PredicateBuilder.isInstanceOf(expression, type));
+ }
+
+ public Predicate isNull() {
+ return onNewPredicate(PredicateBuilder.isNull(expression));
+ }
+
+ public Predicate isNotNull() {
+ return onNewPredicate(PredicateBuilder.isNotNull(expression));
+ }
+
+ public Predicate not(Predicate predicate) {
+ return onNewPredicate(PredicateBuilder.not(predicate));
+ }
+
+ public Predicate in(Object... values) {
+ List<Predicate> predicates = new ArrayList<>();
+ for (Object value : values) {
+ Expression right = asExpression(value);
+ right = ExpressionBuilder.convertToExpression(right, expression);
+ Predicate predicate = onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
+ predicates.add(predicate);
+ }
+ return in(predicates.toArray(new Predicate[predicates.size()]));
+ }
+
+ public Predicate in(Predicate... predicates) {
+ return onNewPredicate(PredicateBuilder.in(predicates));
+ }
+
+ public Predicate startsWith(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.startsWith(expression, right));
+ }
+
+ public Predicate endsWith(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.endsWith(expression, right));
+ }
+
+ /**
+ * Create a predicate that the left hand expression contains the value of
+ * the right hand expression
+ *
+ * @param value the element which is compared to be contained within this
+ * expression
+ * @return a predicate which evaluates to true if the given value expression
+ * is contained within this expression value
+ */
+ public Predicate contains(Object value) {
+ Expression right = asExpression(value);
+ return onNewPredicate(PredicateBuilder.contains(expression, right));
+ }
+
+ /**
+ * Creates a predicate which is true if this expression matches the given
+ * regular expression
+ *
+ * @param regex the regular expression to match
+ * @return a predicate which evaluates to true if the expression matches the
+ * regex
+ */
+ public Predicate regex(String regex) {
+ return onNewPredicate(PredicateBuilder.regex(expression, regex));
+ }
+
+ // Expression builders
+ // -------------------------------------------------------------------------
+
+ public MockValueBuilder tokenize() {
+ return tokenize("\n");
+ }
+
+ public MockValueBuilder tokenize(String token) {
+ Expression newExp = ExpressionBuilder.tokenizeExpression(expression, token);
+ return onNewValueBuilder(newExp);
+ }
+
+ public MockValueBuilder tokenize(String token, int group, boolean skipFirst) {
+ return tokenize(token, "" + group, skipFirst);
+ }
+
+ public MockValueBuilder tokenize(String token, String group, boolean skipFirst) {
+ Expression newExp = ExpressionBuilder.tokenizeExpression(expression, token);
+ if (group == null && skipFirst) {
+ // wrap in skip first (if group then it has its own skip first logic)
+ newExp = ExpressionBuilder.skipFirstExpression(newExp);
+ }
+ newExp = ExpressionBuilder.groupIteratorExpression(newExp, token, group, skipFirst);
+ return onNewValueBuilder(newExp);
+ }
+
+ public MockValueBuilder tokenizeXML(String tagName, String inheritNamespaceTagName) {
+ Expression newExp = ExpressionBuilder.tokenizeXMLExpression(tagName, inheritNamespaceTagName);
+ return onNewValueBuilder(newExp);
+ }
+
+ public MockValueBuilder xtokenize(String path, Namespaces namespaces) {
+ return xtokenize(path, 'i', namespaces);
+ }
+
+ public MockValueBuilder xtokenize(String path, char mode, Namespaces namespaces) {
+ Expression newExp = ExpressionBuilder.tokenizeXMLAwareExpression(path, mode);
+ ((NamespaceAware)newExp).setNamespaces(namespaces.getNamespaces());
+ return onNewValueBuilder(newExp);
+ }
+
+ public MockValueBuilder tokenizePair(String startToken, String endToken, boolean includeTokens) {
+ Expression newExp = ExpressionBuilder.tokenizePairExpression(startToken, endToken, includeTokens);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Tokenizes the string conversion of this expression using the given
+ * regular expression
+ */
+ public MockValueBuilder regexTokenize(String regex) {
+ Expression newExp = ExpressionBuilder.regexTokenizeExpression(expression, regex);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Replaces all occurrences of the regular expression with the given
+ * replacement
+ */
+ public MockValueBuilder regexReplaceAll(String regex, String replacement) {
+ Expression newExp = ExpressionBuilder.regexReplaceAll(expression, regex, replacement);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Replaces all occurrences of the regular expression with the given
+ * replacement
+ */
+ public MockValueBuilder regexReplaceAll(String regex, Expression replacement) {
+ Expression newExp = ExpressionBuilder.regexReplaceAll(expression, regex, replacement);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Converts the current value to the given type using the registered type
+ * converters
+ *
+ * @param type the type to convert the value to
+ * @return the current builder
+ */
+ public MockValueBuilder convertTo(Class<?> type) {
+ Expression newExp = ExpressionBuilder.convertToExpression(expression, type);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Converts the current value to a String using the registered type converters
+ *
+ * @return the current builder
+ */
+ public MockValueBuilder convertToString() {
+ return convertTo(String.class);
+ }
+
+ /**
+ * Appends the string evaluation of this expression with the given value
+ *
+ * @param value the value or expression to append
+ * @return the current builder
+ */
+ public MockValueBuilder append(Object value) {
+ Expression newExp = ExpressionBuilder.append(expression, asExpression(value));
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Prepends the string evaluation of this expression with the given value
+ *
+ * @param value the value or expression to prepend
+ * @return the current builder
+ */
+ public MockValueBuilder prepend(Object value) {
+ Expression newExp = ExpressionBuilder.prepend(expression, asExpression(value));
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Sorts the current value using the given comparator. The current value must be convertable
+ * to a {@link List} to allow sorting using the comparator.
+ *
+ * @param comparator the comparator used by sorting
+ * @return the current builder
+ */
+ public MockValueBuilder sort(Comparator<?> comparator) {
+ Expression newExp = ExpressionBuilder.sortExpression(expression, comparator);
+ return onNewValueBuilder(newExp);
+ }
+
+ /**
+ * Negates the built expression.
+ *
+ * @return the current builder
+ */
+ public MockValueBuilder not() {
+ not = true;
+ return this;
+ }
+
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * A strategy method to allow derived classes to deal with the newly created
+ * predicate in different ways
+ */
+ protected Predicate onNewPredicate(Predicate predicate) {
+ if (not) {
+ return PredicateBuilder.not(predicate);
+ } else {
+ return predicate;
+ }
+ }
+
+ protected Expression asExpression(Object value) {
+ if (value instanceof Expression) {
+ return (Expression)value;
+ } else {
+ return ExpressionBuilder.constantExpression(value);
+ }
+ }
+
+ protected MockValueBuilder onNewValueBuilder(Expression exp) {
+ return new MockValueBuilder(exp);
+ }
+}
[camel] 27/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1fac2390964f407e281434ef7bec26177c4dd5c9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 22:32:54 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../java/org/apache/camel/cdi/XmlCdiBeanFactory.java | 5 ++---
.../org/apache/camel/cdi/XmlProxyFactoryBean.java | 20 +++++---------------
.../org/apache/camel/processor/jpa/JpaRouteTest.java | 6 ++----
.../camel/component/slack/SlackConsumerTest.java | 4 +---
4 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
index 3386a1e..22ede86 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
@@ -270,10 +270,9 @@ final class XmlCdiBeanFactory {
}
private SyntheticBean<?> proxyFactoryBean(Bean<?> context, CamelProxyFactoryDefinition proxy, URL url) {
- if (isEmpty(proxy.getServiceRef()) && isEmpty(proxy.getServiceUrl())) {
+ if (isEmpty(proxy.getServiceUrl())) {
throw new CreationException(
- format("Missing [%s] or [%s] attribute for imported bean [%s] from resource [%s]",
- "serviceRef", "serviceUrl", proxy.getId(), url));
+ format("Missing serviceUrl attribute for imported bean [%s] from resource [%s]", proxy.getId(), url));
}
return new XmlProxyFactoryBean<>(manager,
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
index 8d6a891..1df4402 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
@@ -59,33 +59,23 @@ final class XmlProxyFactoryBean<T> extends SyntheticBean<T> {
: getReference(manager, CamelContext.class, this.context);
Endpoint endpoint;
- if (isNotEmpty(proxy.getServiceRef())) {
- endpoint = context.getRegistry().lookupByNameAndType(proxy.getServiceRef(), Endpoint.class);
+ if (isNotEmpty(proxy.getServiceUrl())) {
+ endpoint = context.getEndpoint(proxy.getServiceUrl());
} else {
- if (isNotEmpty(proxy.getServiceUrl())) {
- endpoint = context.getEndpoint(proxy.getServiceUrl());
- } else {
- throw new IllegalStateException("serviceUrl or serviceRef must not be empty!");
- }
+ throw new IllegalStateException("serviceUrl must not be empty!");
}
if (endpoint == null) {
- throw new UnsatisfiedResolutionException("Could not resolve endpoint: "
- + (isNotEmpty(proxy.getServiceRef())
- ? proxy.getServiceRef()
- : proxy.getServiceUrl()));
+ throw new UnsatisfiedResolutionException("Could not resolve endpoint: " + proxy.getServiceUrl());
}
- // binding is enabled by default
- boolean bind = proxy.getBinding() != null ? proxy.getBinding() : true;
-
try {
// Start the endpoint before we create the producer
startService(endpoint);
Producer producer = endpoint.createProducer();
// Add and start the producer
context.addService(producer, true, true);
- return createProxy(endpoint, bind, producer, (Class<T>) proxy.getServiceInterface());
+ return createProxy(endpoint, true, producer, (Class<T>) proxy.getServiceInterface());
} catch (Exception cause) {
throw new FailedToCreateProducerException(endpoint, cause);
}
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
index 946f492..20690ff 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.processor.jpa;
import javax.persistence.EntityManager;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.ValueBuilder;
import org.apache.camel.component.jpa.JpaComponent;
import org.apache.camel.component.jpa.JpaConstants;
import org.apache.camel.component.mock.MockEndpoint;
@@ -39,9 +38,8 @@ public class JpaRouteTest extends AbstractJpaTest {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- ValueBuilder header = mock.message(0).header(JpaConstants.ENTITY_MANAGER);
- header.isNotNull();
- header.isInstanceOf(EntityManager.class);
+ mock.message(0).header(JpaConstants.ENTITY_MANAGER).isNotNull();
+ mock.message(0).header(JpaConstants.ENTITY_MANAGER).isInstanceOf(EntityManager.class);
template.sendBody("direct:start", new SendEmail("someone@somewhere.org"));
diff --git a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
index 7be92ea..db29797 100644
--- a/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
+++ b/components/camel-slack/src/test/java/org/apache/camel/component/slack/SlackConsumerTest.java
@@ -34,8 +34,6 @@ import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
-
-
public class SlackConsumerTest extends CamelTestSupport {
private String token;
@@ -57,7 +55,7 @@ public class SlackConsumerTest extends CamelTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
- mock.message(0).body(SlackMessage.class).method("getText").isEqualTo(message);
+ mock.message(0).simple("${body.getText()}").isEqualTo(message);
assertMockEndpointsSatisfied();
}
[camel] 25/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit bba5a61fc05db994b70e53955fecfee311abd10f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 16:03:04 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../camel/component/mock/AssertionClause.java | 5 +-
...lauseSupport.java => MockExpressionClause.java} | 807 ++++++++++-----------
.../mock/MockExpressionClauseSupport.java | 2 +-
.../camel/component/mock/MockValueBuilder.java | 10 +-
4 files changed, 403 insertions(+), 421 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index beb0d18..cf7f05f 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -24,7 +24,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.StreamCache;
-import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.support.PredicateAssertHelper;
import org.apache.camel.support.language.ExpressionModel;
@@ -70,8 +69,8 @@ public abstract class AssertionClause extends MockExpressionClauseSupport<MockVa
/**
* Adds the given predicate to this assertion clause
*/
- public ExpressionClause<AssertionClause> predicate() {
- ExpressionClause<AssertionClause> clause = new ExpressionClause<>(this);
+ public MockExpressionClause<AssertionClause> predicate() {
+ MockExpressionClause<AssertionClause> clause = new MockExpressionClause<>(this);
addPredicate(clause);
return clause;
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
similarity index 55%
copy from core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
copy to core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
index eb58656..4dec652 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
@@ -17,56 +17,38 @@
package org.apache.camel.component.mock;
import java.util.Map;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
-import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
import org.apache.camel.Expression;
-import org.apache.camel.builder.ExpressionBuilder;
-import org.apache.camel.model.language.JsonPathExpression;
-import org.apache.camel.model.language.LanguageExpression;
-import org.apache.camel.model.language.MethodCallExpression;
-import org.apache.camel.model.language.SimpleExpression;
-import org.apache.camel.model.language.TokenizerExpression;
-import org.apache.camel.model.language.XMLTokenizerExpression;
-import org.apache.camel.model.language.XPathExpression;
-import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.Message;
+import org.apache.camel.Predicate;
+import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
/**
- * A support class for building expression clauses.
+ * Represents an expression clause within the DSL which when the expression is
+ * complete the clause continues to another part of the DSL
*/
-public class MockExpressionClauseSupport<T> {
+public class MockExpressionClause<T> implements Expression, Predicate {
+ private MockExpressionClauseSupport<T> delegate;
- // TODO: make the model.language class not here as we want to use this in camel-mock but have similar method api compatability
-
- private T result;
- private Expression expressionValue;
- private ExpressionModel expressionType;
-
- public MockExpressionClauseSupport(T result) {
- this.result = result;
+ public MockExpressionClause(T result) {
+ this.delegate = new MockExpressionClauseSupport<>(result);
}
// Helper expressions
// -------------------------------------------------------------------------
/**
- * Specify an {@link org.apache.camel.Expression} instance
+ * Specify an {@link Expression} instance
*/
public T expression(Expression expression) {
- setExpressionValue(expression);
- if (expression instanceof ExpressionModel) {
- setExpressionType((ExpressionModel) expression);
- }
- return result;
- }
-
- /**
- * Specify an {@link ExpressionModel} instance
- */
- public T language(ExpressionModel expression) {
- setExpressionType(expression);
- return result;
+ return delegate.expression(expression);
}
/**
@@ -76,112 +58,259 @@ public class MockExpressionClauseSupport<T> {
* do not use this if you want dynamic values during routing.
*/
public T constant(Object value) {
- return expression(ExpressionBuilder.constantExpression(value));
+ return delegate.constant(value);
}
/**
* An expression of the exchange
*/
public T exchange() {
- return expression(ExpressionBuilder.exchangeExpression());
+ return delegate.exchange();
+ }
+
+ /**
+ * A functional expression of the exchange
+ */
+ public T exchange(final Function<Exchange, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange);
+ }
+ });
}
/**
* An expression of an inbound message
*/
- public T inMessage() {
- return expression(ExpressionBuilder.inMessageExpression());
+ public T message() {
+ return inMessage();
+ }
+
+ /**
+ * A functional expression of an inbound message
+ */
+ public T message(final Function<Message, Object> function) {
+ return inMessage(function);
}
/**
* An expression of an inbound message
*/
+ public T inMessage() {
+ return delegate.inMessage();
+ }
+
+ /**
+ * A functional expression of an inbound message
+ */
+ public T inMessage(final Function<Message, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getIn());
+ }
+ });
+ }
+
+ /**
+ * An expression of an outbound message
+ */
public T outMessage() {
- return expression(ExpressionBuilder.outMessageExpression());
+ return delegate.outMessage();
+ }
+
+ /**
+ * A functional expression of an outbound message
+ */
+ public T outMessage(final Function<Message, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getOut());
+ }
+ });
}
/**
* An expression of an inbound message body
*/
public T body() {
- return expression(ExpressionBuilder.bodyExpression());
+ return delegate.body();
+ }
+
+ /**
+ * A functional expression of an inbound message body
+ */
+ public T body(final Function<Object, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getIn().getBody());
+ }
+ });
+ }
+
+ /**
+ * A functional expression of an inbound message body
+ */
+ public T body(final Supplier<Object> supplier) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return supplier.get();
+ }
+ });
+ }
+
+ /**
+ * A functional expression of an inbound message body and headers
+ */
+ public T body(final BiFunction<Object, Map<String, Object>, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(
+ exchange.getIn().getBody(),
+ exchange.getIn().getHeaders());
+ }
+ });
}
/**
* An expression of an inbound message body converted to the expected type
*/
public T body(Class<?> expectedType) {
- return expression(ExpressionBuilder.bodyExpression(expectedType));
+ return delegate.body(expectedType);
+ }
+
+ /**
+ * A functional expression of an inbound message body converted to the expected type
+ */
+ public <B> T body(Class<B> expectedType, final Function<B, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getIn().getBody(expectedType));
+ }
+ });
+ }
+
+ /**
+ * A functional expression of an inbound message body converted to the expected type and headers
+ */
+ public <B> T body(Class<B> expectedType, final BiFunction<B, Map<String, Object>, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(
+ exchange.getIn().getBody(expectedType),
+ exchange.getIn().getHeaders());
+ }
+ });
}
/**
* An expression of an outbound message body
*/
public T outBody() {
- return expression(ExpressionBuilder.outBodyExpression());
+ return delegate.outBody();
+ }
+
+ /**
+ * A functional expression of an outbound message body
+ */
+ public T outBody(final Function<Object, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getOut().getBody());
+ }
+ });
+ }
+
+ /**
+ * A functional expression of an outbound message body and headers
+ */
+ public T outBody(final BiFunction<Object, Map<String, Object>, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(
+ exchange.getOut().getBody(),
+ exchange.getOut().getHeaders());
+ }
+ });
}
/**
* An expression of an outbound message body converted to the expected type
*/
public T outBody(Class<?> expectedType) {
- return expression(ExpressionBuilder.outBodyExpression(expectedType));
+ return delegate.outBody(expectedType);
+ }
+
+ /**
+ * A functional expression of an outbound message body converted to the expected type
+ */
+ public <B> T outBody(Class<B> expectedType, final Function<B, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(exchange.getOut().getBody(expectedType));
+ }
+ });
+ }
+
+ /**
+ * A functional expression of an outbound message body converted to the expected type and headers
+ */
+ public <B> T outBody(Class<B> expectedType, final BiFunction<B, Map<String, Object>, Object> function) {
+ return delegate.expression(new ExpressionAdapter() {
+ public Object evaluate(Exchange exchange) {
+ return function.apply(
+ exchange.getOut().getBody(expectedType),
+ exchange.getOut().getHeaders());
+ }
+ });
}
/**
* An expression of an inbound message header of the given name
*/
public T header(String name) {
- return expression(ExpressionBuilder.headerExpression(name));
+ return delegate.header(name);
}
/**
* An expression of the inbound headers
*/
public T headers() {
- return expression(ExpressionBuilder.headersExpression());
+ return delegate.headers();
}
/**
* An expression of an outbound message header of the given name
*/
public T outHeader(String name) {
- return expression(ExpressionBuilder.outHeaderExpression(name));
+ return delegate.outHeader(name);
}
/**
* An expression of the outbound headers
*/
public T outHeaders() {
- return expression(ExpressionBuilder.outHeadersExpression());
+ return delegate.outHeaders();
}
/**
* An expression of the inbound message attachments
*/
public T attachments() {
- return expression(ExpressionBuilder.attachmentObjectValuesExpression());
- }
-
- /**
- * An expression of the exchange pattern
- */
- public T exchangePattern() {
- return expression(ExpressionBuilder.exchangePatternExpression());
+ return delegate.attachments();
}
/**
* An expression of an exchange property of the given name
*/
public T exchangeProperty(String name) {
- return expression(ExpressionBuilder.exchangePropertyExpression(name));
+ return delegate.exchangeProperty(name);
}
/**
* An expression of the exchange properties
*/
public T exchangeProperties() {
- return expression(ExpressionBuilder.exchangePropertiesExpression());
+ return delegate.exchangeProperties();
}
// Languages
@@ -189,20 +318,20 @@ public class MockExpressionClauseSupport<T> {
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
- *
+ *
* @param bean the name of the bean looked up the registry
* @return the builder to continue processing the DSL
*/
public T method(String bean) {
- return expression(ExpressionBuilder.beanExpression(bean));
+ return delegate.method(bean);
}
-
+
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
*
@@ -210,39 +339,39 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T method(Object instance) {
- return expression(new MethodCallExpression(instance));
+ return delegate.method(instance);
}
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
- *
+ *
* @param beanType the Class of the bean which we want to invoke
* @return the builder to continue processing the DSL
*/
public T method(Class<?> beanType) {
- return expression(new MethodCallExpression(beanType));
+ return delegate.method(beanType);
}
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
- *
+ *
* @param bean the name of the bean looked up the registry
* @param method the name of the method to invoke on the bean
* @return the builder to continue processing the DSL
*/
public T method(String bean, String method) {
- return expression(new MethodCallExpression(bean, method));
+ return delegate.method(bean, method);
}
-
+
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
*
@@ -251,61 +380,63 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T method(Object instance, String method) {
- return expression(new MethodCallExpression(instance, method));
+ return delegate.method(instance, method);
}
/**
* Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
+ * href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
- *
+ *
* @param beanType the Class of the bean which we want to invoke
* @param method the name of the method to invoke on the bean
* @return the builder to continue processing the DSL
*/
public T method(Class<?> beanType, String method) {
- return expression(new MethodCallExpression(beanType, method));
+ return delegate.method(beanType, method);
}
/**
* Evaluates a <a href="http://camel.apache.org/groovy.html">Groovy
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T groovy(String text) {
- return expression(ExpressionBuilder.languageExpression("groovy", text));
+ return delegate.groovy(text);
}
/**
* Evaluates a <a
* href="http://camel.apache.org/java-script.html">JavaScript
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
* @deprecated JavaScript is deprecated in Java 11 onwards
*/
@Deprecated
public T javaScript(String text) {
- return expression(ExpressionBuilder.languageExpression("js", text));
+ return delegate.javaScript(text);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a>
*
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T jsonpath(String text) {
- return expression(ExpressionBuilder.languageExpression("jsonpath", text));
+ return delegate.jsonpath(text);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a>
*
* @param text the expression to be evaluated
@@ -313,29 +444,12 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T jsonpath(String text, boolean suppressExceptions) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- return expression(expression);
+ return delegate.jsonpath(text, suppressExceptions);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a>
*
* @param text the expression to be evaluated
@@ -343,14 +457,12 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T jsonpath(String text, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
+ return delegate.jsonpath(text, resultType);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a>
*
* @param text the expression to be evaluated
@@ -359,66 +471,39 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
+ return delegate.jsonpath(text, suppressExceptions, resultType);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a>
*
* @param text the expression to be evaluated
* @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
* @param resultType the return type expected by the expression
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple, Class<?> resultType, String headerName) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setResultType(resultType);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
+ public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType, String headerName) {
+ return delegate.jsonpath(text, suppressExceptions, true, resultType, headerName);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a> with writeAsString enabled.
*
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T jsonpathWriteAsString(String text) {
- return jsonpathWriteAsString(text, false);
+ return delegate.jsonpathWriteAsString(text);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a> with writeAsString enabled.
*
* @param text the expression to be evaluated
@@ -426,57 +511,32 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T jsonpathWriteAsString(String text, boolean suppressExceptions) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- return expression(expression);
+ return delegate.jsonpathWriteAsString(text, suppressExceptions);
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions, boolean allowSimple) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
+ * Evaluates a <a
+ * href="http://camel.apache.org/jsonpath.html">Json Path
* expression</a> with writeAsString enabled.
*
* @param text the expression to be evaluated
* @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
- public T jsonpathWriteAsString(String text, boolean suppressExceptions, boolean allowSimple, String headerName) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setHeaderName(headerName);
- return expression(expression);
+ public T jsonpathWriteAsString(String text, boolean suppressExceptions, String headerName) {
+ return delegate.jsonpathWriteAsString(text, suppressExceptions, true, headerName);
}
/**
* Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T ognl(String text) {
- return expression(ExpressionBuilder.languageExpression("ognl", text));
+ return delegate.ognl(text);
}
/**
@@ -487,40 +547,40 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T mvel(String text) {
- return expression(ExpressionBuilder.languageExpression("mvel", text));
+ return delegate.mvel(text);
}
/**
- * Evaluates a {@link Expression} by looking up existing {@link Expression}
- * from the {@link org.apache.camel.spi.Registry}
- *
+ * Evaluates a <a href="http://camel.apache.org/ref-language.html">Ref
+ * expression</a>
+ *
* @param ref refers to the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T ref(String ref) {
- return expression(ExpressionBuilder.languageExpression("ref", ref));
+ return delegate.ref(ref);
}
/**
- * Evaluates an <a href="http://camel.apache.org/spel.html">SpEL
+ * Evaluates a <a href="http://camel.apache.org/spel.html">SpEL
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T spel(String text) {
- return expression(ExpressionBuilder.languageExpression("spel", text));
+ return delegate.spel(text);
}
-
+
/**
* Evaluates a <a href="http://camel.apache.org/simple.html">Simple
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T simple(String text) {
- return expression(ExpressionBuilder.languageExpression("simple", text));
+ return delegate.simple(text);
}
/**
@@ -532,54 +592,52 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T simple(String text, Class<?> resultType) {
- SimpleExpression expression = new SimpleExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
+ return delegate.simple(text, resultType);
}
/**
- * Evaluates an <a href="http://camel.apache.org/hl7.html">HL7 Terser
- * expression</a>
+ * Evaluates a token expression on the message body
*
- * @param text the expression to be evaluated
+ * @param token the token
* @return the builder to continue processing the DSL
*/
- public T hl7terser(String text) {
- return expression(ExpressionBuilder.languageExpression("hl7terser", text));
+ public T tokenize(String token) {
+ return delegate.tokenize(token);
}
/**
* Evaluates a token expression on the message body
*
* @param token the token
+ * @param regex whether the token is a regular expression or not
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token) {
- return tokenize(token, null, false);
+ public T tokenize(String token, boolean regex) {
+ return tokenize(token, regex, false);
}
/**
* Evaluates a token expression on the message body
*
* @param token the token
- * @param group to group by the given number
+ * @param regex whether the token is a regular expression or not
+ * @param skipFirst whether to skip the first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, int group) {
- return tokenize(token, null, false, group);
+ public T tokenize(String token, boolean regex, boolean skipFirst) {
+ return delegate.tokenize(token, null, regex, skipFirst);
}
/**
* Evaluates a token expression on the message body
*
* @param token the token
+ * @param regex whether the token is a regular expression or not
* @param group to group by the given number
- * @param skipFirst whether to skip the very first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, int group, boolean skipFirst) {
- return tokenize(token, null, false, group, skipFirst);
+ public T tokenize(String token, boolean regex, int group) {
+ return tokenize(token, regex, group, false);
}
/**
@@ -587,10 +645,11 @@ public class MockExpressionClauseSupport<T> {
*
* @param token the token
* @param regex whether the token is a regular expression or not
+ * @param group to group by the given number
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, boolean regex) {
- return tokenize(token, null, regex);
+ public T tokenize(String token, boolean regex, String group) {
+ return tokenize(token, regex, group, false);
}
/**
@@ -599,51 +658,47 @@ public class MockExpressionClauseSupport<T> {
* @param token the token
* @param regex whether the token is a regular expression or not
* @param group to group by the given number
+ * @param skipFirst whether to skip the first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, boolean regex, int group) {
- return tokenize(token, null, regex, group);
+ public T tokenize(String token, boolean regex, int group, boolean skipFirst) {
+ return delegate.tokenize(token, null, regex, group, skipFirst);
}
/**
- * Evaluates a token expression on the given header
+ * Evaluates a token expression on the message body
*
* @param token the token
- * @param headerName name of header to tokenize
+ * @param regex whether the token is a regular expression or not
+ * @param group to group by the given number
+ * @param skipFirst whether to skip the first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName) {
- return tokenize(token, headerName, false);
+ public T tokenize(String token, boolean regex, String group, boolean skipFirst) {
+ return delegate.tokenize(token, null, regex, group, skipFirst);
}
/**
- * Evaluates a token expression on the given header
+ * Evaluates a token expression on the message body
*
* @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
+ * @param group to group by the given number
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName, boolean regex) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- setExpressionType(expression);
- return result;
+ public T tokenize(String token, int group) {
+ return delegate.tokenize(token, group);
}
/**
- * Evaluates a token expression on the given header
+ * Evaluates a token expression on the message body
*
* @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
+ * @param group to group by the given number
+ * @param skipFirst whether to skip the first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName, boolean regex, int group) {
- return tokenize(token, headerName, regex, group, false);
+ public T tokenize(String token, int group, boolean skipFirst) {
+ return delegate.tokenize(token, group, skipFirst);
}
/**
@@ -651,18 +706,10 @@ public class MockExpressionClauseSupport<T> {
*
* @param token the token
* @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param skipFirst whether to skip the very first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName, boolean regex, boolean skipFirst) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- expression.setSkipFirst(skipFirst);
- setExpressionType(expression);
- return result;
+ public T tokenize(String token, String headerName) {
+ return delegate.tokenize(token, headerName);
}
/**
@@ -671,33 +718,23 @@ public class MockExpressionClauseSupport<T> {
* @param token the token
* @param headerName name of header to tokenize
* @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
- * @param skipFirst whether to skip the very first element
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName, boolean regex, int group, boolean skipFirst) {
- return tokenize(token, headerName, regex, "" + group, skipFirst);
+ public T tokenize(String token, String headerName, boolean regex) {
+ return delegate.tokenize(token, headerName, regex);
}
/**
- * Evaluates a token expression on the given header
+ * Evaluates a token pair expression on the message body.
+ * <p/>
+ * Tokens is not included.
*
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
- * @param skipFirst whether to skip the very first element
+ * @param startToken the start token
+ * @param endToken the end token
* @return the builder to continue processing the DSL
*/
- public T tokenize(String token, String headerName, boolean regex, String group, boolean skipFirst) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- expression.setGroup(group);
- expression.setSkipFirst(skipFirst);
- setExpressionType(expression);
- return result;
+ public T tokenizePair(String startToken, String endToken) {
+ return tokenizePair(startToken, endToken, false);
}
/**
@@ -709,390 +746,342 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T tokenizePair(String startToken, String endToken, boolean includeTokens) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(startToken);
- expression.setEndToken(endToken);
- expression.setIncludeTokens(includeTokens);
- setExpressionType(expression);
- return result;
+ return delegate.tokenizePair(startToken, endToken, includeTokens);
}
/**
- * Evaluates a token pair expression on the message body with XML content
+ * Evaluates a XML token expression on the message body with XML content
+ *
+ * @param tagName the tag name of the child nodes to tokenize
+ * @return the builder to continue processing the DSL
+ */
+ public T tokenizeXML(String tagName) {
+ return tokenizeXML(tagName, null);
+ }
+
+ /**
+ * Evaluates a XML token expression on the message body with XML content
*
* @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName optional parent or root tag name that contains namespace(s) to inherit
* @param group to group by the given number
* @return the builder to continue processing the DSL
*/
- public T tokenizeXMLPair(String tagName, String inheritNamespaceTagName, int group) {
- return tokenizeXMLPair(tagName, inheritNamespaceTagName, "" + group);
+ public T tokenizeXML(String tagName, int group) {
+ return tokenizeXML(tagName, null, group);
}
/**
* Evaluates a token pair expression on the message body with XML content
*
* @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName optional parent or root tag name that contains namespace(s) to inherit
- * @param group to group by the given number
+ * @param inheritNamespaceTagName parent or root tag name that contains namespace(s) to inherit
* @return the builder to continue processing the DSL
*/
- public T tokenizeXMLPair(String tagName, String inheritNamespaceTagName, String group) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(tagName);
- expression.setInheritNamespaceTagName(inheritNamespaceTagName);
- expression.setXml(true);
- expression.setGroup(group);
- setExpressionType(expression);
- return result;
+ public T tokenizeXML(String tagName, String inheritNamespaceTagName) {
+ return tokenizeXML(tagName, inheritNamespaceTagName, 0);
}
/**
- * Evaluates an XML token expression on the message body with XML content
+ * Evaluates a token pair expression on the message body with XML content
*
- * @param path the xpath like path notation specifying the child nodes to tokenize
- * @param mode one of 'i', 'w', or 'u' to inject the namespaces to the token, to
- * wrap the token with its ancestor contet, or to unwrap to its element child
- * @param namespaces the namespace map to the namespace bindings
+ * @param tagName the tag name of the child nodes to tokenize
+ * @param inheritNamespaceTagName parent or root tag name that contains namespace(s) to inherit
* @param group to group by the given number
* @return the builder to continue processing the DSL
*/
- public T xtokenize(String path, char mode, Namespaces namespaces, int group) {
- XMLTokenizerExpression expression = new XMLTokenizerExpression(path);
- expression.setMode(Character.toString(mode));
- expression.setNamespaces(namespaces.getNamespaces());
+ public T tokenizeXML(String tagName, String inheritNamespaceTagName, int group) {
+ return delegate.tokenizeXMLPair(tagName, inheritNamespaceTagName, group);
+ }
- if (group > 0) {
- expression.setGroup(group);
- }
- setExpressionType(expression);
- return result;
+ public T xtokenize(String path, Namespaces namespaces) {
+ return xtokenize(path, 'i', namespaces);
+ }
+
+ public T xtokenize(String path, char mode, Namespaces namespaces) {
+ return xtokenize(path, mode, namespaces, 0);
+ }
+
+ public T xtokenize(String path, char mode, Namespaces namespaces, int group) {
+ return delegate.xtokenize(path, mode, namespaces, group);
}
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T xpath(String text) {
- return expression(new XPathExpression(text));
+ return delegate.xpath(text);
}
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> on the supplied header name's contents
- *
+ *
* @param text the expression to be evaluated
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
public T xpath(String text, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setHeaderName(headerName);
- return expression(expression);
+ return delegate.xpath(text, headerName);
}
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Class<?> resultType) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
+ return delegate.xpath(text, resultType);
}
-
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type on the supplied
* header name's contents
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Class<?> resultType, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
+ return delegate.xpath(text, resultType, headerName);
}
-
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type and set of namespace
* prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
- return xpath(text, resultType, namespaces.getNamespaces());
+ return delegate.xpath(text, resultType, namespaces);
}
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type and set of namespace
* prefixes and URIs on the supplied header name's contents
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
* @param headerName the name of the header to apply the expression to
+ * @param namespaces the namespace prefix and URIs to use
+ *
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces.getNamespaces());
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
+ return delegate.xpath(text, resultType, namespaces, headerName);
}
-
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type and set of namespace
* prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return delegate.xpath(text, resultType, namespaces);
}
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Namespaces namespaces) {
- return xpath(text, namespaces.getNamespaces());
+ return delegate.xpath(text, namespaces);
}
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xpath(String text, Map<String, String> namespaces) {
- XPathExpression expression = new XPathExpression(text);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return delegate.xpath(text, namespaces);
}
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
- *
+ *
* @param text the expression to be evaluated
* @return the builder to continue processing the DSL
*/
public T xquery(String text) {
- return expression(new XQueryExpression(text));
+ return delegate.xquery(text);
}
-
+
/**
- * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery
- * expression</a>
- *
+ * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
+ * expression</a> on the supplied header name's contents
+ *
* @param text the expression to be evaluated
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
public T xquery(String text, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setHeaderName(headerName);
- return expression(expression);
+ return delegate.xquery(text, headerName);
}
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified result type
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Class<?> resultType) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
+ return delegate.xquery(text, resultType);
}
-
-
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified result type
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Class<?> resultType, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
+ return delegate.xquery(text, resultType, headerName);
}
-
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified result type and set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
- return xquery(text, resultType, namespaces.getNamespaces());
+ return delegate.xquery(text, resultType, namespaces);
}
-
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
+ * with the specified result type
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
* @param headerName the name of the header to apply the expression to
+ * @param namespaces the namespace prefix and URIs to use
+ *
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces.getNamespaces());
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
+ return delegate.xquery(text, resultType, namespaces, headerName);
}
-
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified result type and set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param resultType the return type expected by the expression
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return delegate.xquery(text, resultType, namespaces);
}
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Namespaces namespaces) {
- return xquery(text, namespaces.getNamespaces());
+ return delegate.xquery(text, namespaces);
}
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
* with the specified set of namespace prefixes and URIs
- *
+ *
* @param text the expression to be evaluated
* @param namespaces the namespace prefix and URIs to use
* @return the builder to continue processing the DSL
*/
public T xquery(String text, Map<String, String> namespaces) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return delegate.xquery(text, namespaces);
}
/**
* Evaluates a given language name with the expression text
- *
+ *
* @param language the name of the language
* @param expression the expression in the given language
* @return the builder to continue processing the DSL
*/
public T language(String language, String expression) {
- LanguageExpression exp = new LanguageExpression(language, expression);
- setExpressionType(exp);
- return result;
+ return delegate.language(language, expression);
}
// Properties
// -------------------------------------------------------------------------
public Expression getExpressionValue() {
- return expressionValue;
- }
-
- public void setExpressionValue(Expression expressionValue) {
- this.expressionValue = expressionValue;
+ return delegate.getExpressionValue();
}
public ExpressionModel getExpressionType() {
- return expressionType;
- }
-
- public void setExpressionType(ExpressionModel expressionType) {
- this.expressionType = expressionType;
+ return delegate.getExpressionType();
}
- protected Expression createExpression(CamelContext camelContext) {
- if (getExpressionValue() == null) {
- if (getExpressionType() != null) {
- setExpressionValue(getExpressionType().createExpression(camelContext));
- } else {
- throw new IllegalStateException("No expression value configured");
- }
+ @Override
+ public <T> T evaluate(Exchange exchange, Class<T> type) {
+ if (getExpressionValue() != null) {
+ return getExpressionValue().evaluate(exchange, type);
+ } else {
+ Expression exp = delegate.getExpressionType().createExpression(exchange.getContext());
+ return exp.evaluate(exchange, type);
}
- return getExpressionValue();
}
- protected void configureExpression(CamelContext camelContext, Expression expression) {
- // noop
+ @Override
+ public boolean matches(Exchange exchange) {
+ if (getExpressionValue() != null) {
+ return new ExpressionToPredicateAdapter(getExpressionValue()).matches(exchange);
+ } else {
+ Expression exp = delegate.getExpressionType().createExpression(exchange.getContext());
+ return new ExpressionToPredicateAdapter(exp).matches(exchange);
+ }
}
-
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
index eb58656..b3f81e6 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
@@ -20,7 +20,6 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
-import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.model.language.JsonPathExpression;
import org.apache.camel.model.language.LanguageExpression;
import org.apache.camel.model.language.MethodCallExpression;
@@ -29,6 +28,7 @@ import org.apache.camel.model.language.TokenizerExpression;
import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.support.builder.ExpressionBuilder;
import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
index e0c834a..7253658 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.builder.ExpressionBuilder;
@@ -67,7 +66,7 @@ public class MockValueBuilder implements Expression, Predicate {
return onNewPredicate(ExpressionToPredicateAdapter.toPredicate(expression));
}
- public ExpressionClause<Predicate> matches() {
+ public MockExpressionClause<Predicate> matches() {
// chicken-and-egg situation as we need to return an ExpressionClause
// which needs a right-hand side that is being built via the fluent
// builder that is returned, and therefore we need to use a ref
@@ -75,7 +74,7 @@ public class MockValueBuilder implements Expression, Predicate {
// in the onNewPredicate where the actual matching is executed
final AtomicReference<Expression> ref = new AtomicReference<>();
- final ExpressionClause<Predicate> answer = new ExpressionClause<>(
+ final MockExpressionClause<Predicate> answer = new MockExpressionClause<>(
onNewPredicate(new Predicate() {
@Override
public boolean matches(Exchange exchange) {
@@ -94,11 +93,6 @@ public class MockValueBuilder implements Expression, Predicate {
@Override
public Object evaluate(Exchange exchange) {
return answer.evaluate(exchange, Object.class);
- /*if (answer.getExpressionValue() != null) {
- return answer.getExpressionValue().evaluate(exchange, Object.class);
- } else {
- return answer.getExpressionType().evaluate(exchange);
- }*/
}
};
// okay now we can set the reference to the right-hand-side
[camel] 22/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9379d72d0788898d9d1ec3a64629c235bab03636
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 15:02:21 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
.../spring/remoting/CamelServiceExporter.java | 13 +++++++++-
.../remoting/spring-with-exporter-namespace.xml | 4 +--
.../spring/remoting/spring-with-exporter-proxy.xml | 4 +--
.../camel/spring/remoting/spring-with-exporter.xml | 3 ++-
.../remoting/spring-with-two-camelcontext.xml | 6 ++---
.../core/xml/CamelProxyFactoryDefinition.java | 30 ----------------------
.../core/xml/CamelServiceExporterDefinition.java | 13 ++++++++++
7 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java b/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
index 957215c..8e94c62 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/remoting/CamelServiceExporter.java
@@ -45,6 +45,7 @@ public class CamelServiceExporter extends RemoteExporter implements Initializing
private String camelContextId;
private Consumer consumer;
private String serviceRef;
+ private String method;
private ApplicationContext applicationContext;
public String getUri() {
@@ -75,6 +76,14 @@ public class CamelServiceExporter extends RemoteExporter implements Initializing
this.serviceRef = serviceRef;
}
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
public ApplicationContext getApplicationContext() {
return applicationContext;
}
@@ -102,7 +111,9 @@ public class CamelServiceExporter extends RemoteExporter implements Initializing
try {
// need to start endpoint before we create consumer
ServiceHelper.startService(endpoint);
- consumer = endpoint.createConsumer(new BeanProcessor(proxy, camelContext));
+ BeanProcessor processor = new BeanProcessor(proxy, camelContext);
+ processor.setMethod(method);
+ consumer = endpoint.createConsumer(processor);
// add and start consumer
camelContext.addService(consumer, true, true);
} catch (Exception e) {
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml
index 1d15b26..9a328ca 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-namespace.xml
@@ -31,11 +31,11 @@
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- START SNIPPET: proxy -->
<!-- Creates a proxy to the direct:say endpoint. -->
- <camel:proxy id="sayProxy" serviceUrl="direct:say" binding="false"
+ <camel:proxy id="sayProxy" serviceUrl="direct:say"
serviceInterface="org.apache.camel.spring.remoting.ISay"/>
<!-- END SNIPPET: proxy -->
<!-- START SNIPPET: export -->
- <camel:export id="say" uri="direct:sayImpl" serviceRef="sayService"
+ <camel:export id="say" uri="direct:sayImpl" serviceRef="sayService" method="say"
serviceInterface="org.apache.camel.spring.remoting.ISay"/>
<!--
The bean is defined out side of the camel
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-proxy.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-proxy.xml
index ff7f58a..b5d9537 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-proxy.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter-proxy.xml
@@ -27,9 +27,9 @@
<bean id="sayService" class="org.apache.camel.spring.remoting.SayService"/>
- <camel:proxy id="sayProxy" serviceUrl="direct:say" binding="false"
+ <camel:proxy id="sayProxy" serviceUrl="direct:say"
serviceInterface="org.apache.camel.spring.remoting.ISay"/>
- <camel:export id="say" uri="direct:sayImpl" serviceRef="sayService"
+ <camel:export id="say" uri="direct:sayImpl" serviceRef="sayService" method="say"
serviceInterface="org.apache.camel.spring.remoting.ISay"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml
index 41357ac..7c93450 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-exporter.xml
@@ -29,7 +29,7 @@
<bean id="sayProxy" class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
<property name="serviceUrl" value="direct:say"/>
<property name="serviceInterface" value="org.apache.camel.spring.remoting.ISay"/>
- <property name="binding" value="false"/>
+ <property name="binding" value="true"/>
</bean>
<!-- END SNIPPET: proxy -->
@@ -41,6 +41,7 @@
<property name="service">
<bean class="org.apache.camel.spring.remoting.SayService"/>
</property>
+ <property name="method" value="say"/>
<property name="serviceInterface" value="org.apache.camel.spring.remoting.ISay"/>
</bean>
<!-- END SNIPPET: export -->
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-two-camelcontext.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-two-camelcontext.xml
index d4e5bbfe..0136054 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-two-camelcontext.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/spring-with-two-camelcontext.xml
@@ -39,13 +39,11 @@
</camelContext>
<camel:proxy id="sayProxy1"
- binding="false"
serviceInterface="org.apache.camel.spring.remoting.ISay"
serviceUrl="direct:foo"
camelContextId="context-1"/>
<camel:proxy id="sayProxy2"
- binding="false"
serviceInterface="org.apache.camel.spring.remoting.ISay"
serviceUrl="direct:foo"
camelContextId="context-2"/>
@@ -58,11 +56,11 @@
<property name="message" value="context-2" />
</bean>
- <camel:export id="say1" uri="direct:sayImpl" serviceRef="sayService1"
+ <camel:export id="say1" uri="direct:sayImpl" serviceRef="sayService1" method="say"
serviceInterface="org.apache.camel.spring.remoting.ISay"
camelContextId="context-1"/>
- <camel:export id="say2" uri="direct:sayImpl" serviceRef="sayService2"
+ <camel:export id="say2" uri="direct:sayImpl" serviceRef="sayService2" method="say"
serviceInterface="org.apache.camel.spring.remoting.ISay"
camelContextId="context-2"/>
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelProxyFactoryDefinition.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelProxyFactoryDefinition.java
index 5437411..207dfc8 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelProxyFactoryDefinition.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelProxyFactoryDefinition.java
@@ -31,14 +31,10 @@ public class CamelProxyFactoryDefinition extends IdentifiedType {
@XmlAttribute
private String serviceUrl;
- @XmlAttribute @Deprecated
- private String serviceRef;
@XmlAttribute
private Class<?> serviceInterface;
@XmlAttribute
private String camelContextId;
- @XmlAttribute @Metadata(defaultValue = "true")
- private Boolean binding;
public String getServiceUrl() {
return serviceUrl;
@@ -51,20 +47,6 @@ public class CamelProxyFactoryDefinition extends IdentifiedType {
this.serviceUrl = serviceUrl;
}
- public String getServiceRef() {
- return serviceRef;
- }
-
- /**
- * The camel endpoint reference used to send the message to when calling the service from the interface.
- *
- * @deprecated use serviceUrl instead with the ref endpoint.
- */
- @Deprecated
- public void setServiceRef(String serviceRef) {
- this.serviceRef = serviceRef;
- }
-
public Class<?> getServiceInterface() {
return serviceInterface;
}
@@ -87,16 +69,4 @@ public class CamelProxyFactoryDefinition extends IdentifiedType {
this.camelContextId = camelContextId;
}
- public Boolean getBinding() {
- return binding;
- }
-
- /**
- * Camel parameter binding is enabled by default, which will use binding information from the method signature
- * parameters to bind to the Exchange/Message with the following annotations.
- * If disabled then a {@link org.apache.camel.component.bean.CamelInvocationHandler} is used.
- */
- public void setBinding(Boolean binding) {
- this.binding = binding;
- }
}
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
index 04fde86..70582ce 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
@@ -34,6 +34,8 @@ public class CamelServiceExporterDefinition extends IdentifiedType {
@XmlAttribute
private String serviceRef;
@XmlAttribute
+ private String method;
+ @XmlAttribute
private Class<?> serviceInterface;
@XmlAttribute
private String camelContextId;
@@ -60,6 +62,17 @@ public class CamelServiceExporterDefinition extends IdentifiedType {
this.serviceRef = serviceRef;
}
+ public String getMethod() {
+ return method;
+ }
+
+ /**
+ * Name of method to invoke on service
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
public Class<?> getServiceInterface() {
return serviceInterface;
}
[camel] 28/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 636e29bf388d896c3a459b47fb72580158612a92
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 07:34:01 2019 +0200
Move mock component out of camel-core. Work in progress.
---
MIGRATION.md | 4 +++
.../org/apache/camel/builder/NotifyBuilder.java | 30 +++++++++++++++++++---
.../camel/component/seda/SedaNoConsumerTest.java | 4 +--
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index f60ae99..6377a66 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -92,6 +92,10 @@ We have also renamed `camel-jetty9` to `camel-jetty`.
The `dataset` component has been moved out of `camel-core`, and is no longer a transient dependency from `camel-core`, and therefore you should add `camel-dataset` as dependency if you use this component.
+### Mock component
+
+The `mock` component has been moved out of `camel-core` and as part of this work, we had to remove a number of methods on its _assertion clause builder_ that were seldom in use. Also we had to remove a few methods on `NotifyBuilder` that were using the `mock` component.
+
### ActiveMQ
If you are using the `activemq-camel` component, then you should migrate to use `camel-activemq` component, where the component name has changed from `org.apache.activemq.camel.component.ActiveMQComponent` to `org.apache.camel.component.activemq.ActiveMQComponent`.
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
index 1a6153c..764e235 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
@@ -32,7 +32,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spi.CamelEvent;
import org.apache.camel.spi.CamelEvent.ExchangeCompletedEvent;
import org.apache.camel.spi.CamelEvent.ExchangeCreatedEvent;
@@ -76,6 +75,8 @@ public class NotifyBuilder {
private boolean created;
// keep state of how many wereSentTo we have added
private int wereSentToIndex;
+ // default wait time
+ private long waitTime = 10000L;
// computed value whether all the predicates matched
private volatile boolean matches;
@@ -956,6 +957,14 @@ public class NotifyBuilder {
}
/**
+ * Specifies the wait time in millis to use in the {@link #matchesWaitTime()} method.
+ */
+ public NotifyBuilder waitTime(long waitTime) {
+ this.waitTime = waitTime;
+ return this;
+ }
+
+ /**
* Creates the expression this builder should use for matching.
* <p/>
* You must call this method when you are finished building the expressions.
@@ -1031,16 +1040,29 @@ public class NotifyBuilder {
* The timeout value is by default 10 seconds.
*
* @return <tt>true</tt> if matching, <tt>false</tt> otherwise due to timeout
- * @deprecated use {@link #matches(long, TimeUnit)} instead
+ * @deprecated use {@link #matchesWaitTime()} instead
*/
@Deprecated
public boolean matchesMockWaitTime() {
+ return matchesWaitTime();
+ }
+
+ /**
+ * Does all the expressions match?
+ * <p/>
+ * This operation will wait until the match is <tt>true</tt> or otherwise a timeout occur
+ * which means <tt>false</tt> will be returned.
+ * <p/>
+ * The timeout value is by default 10 seconds.
+ *
+ * @return <tt>true</tt> if matching, <tt>false</tt> otherwise due to timeout
+ */
+ public boolean matchesWaitTime() {
if (!created) {
throw new IllegalStateException("NotifyBuilder has not been created. Invoke the create() method before matching.");
}
- // use 10 sec as default
- return matches(10000, TimeUnit.MILLISECONDS);
+ return matches(waitTime, TimeUnit.MILLISECONDS);
}
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
index 1300510..b6b622f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaNoConsumerTest.java
@@ -42,12 +42,12 @@ public class SedaNoConsumerTest extends ContextTestSupport {
});
context.start();
- NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
+ NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).waitTime(2000).create();
// no problem for in only as we do not expect a reply
template.sendBody("direct:start", "Hello World");
- notify.matches(2, TimeUnit.SECONDS);
+ assertTrue(notify.matchesWaitTime());
}
public void testInOut() throws Exception {
[camel] 31/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f559083b3d81152571a9ed08f528da04250e5838
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 09:07:58 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../springboot/MockComponentAutoConfiguration.java | 128 ---------------------
.../springboot/MockComponentConfiguration.java | 55 ---------
.../src/main/resources/META-INF/spring.factories | 1 -
3 files changed, 184 deletions(-)
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java
deleted file mode 100644
index 2de4611..0000000
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.mock.springboot;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.Generated;
-import org.apache.camel.CamelContext;
-import org.apache.camel.component.mock.MockComponent;
-import org.apache.camel.spi.ComponentCustomizer;
-import org.apache.camel.spi.HasId;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.spring.boot.ComponentConfigurationProperties;
-import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
-import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
-import org.apache.camel.spring.boot.util.GroupCondition;
-import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
-import org.apache.camel.support.IntrospectionSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
-
-/**
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-@Configuration
-@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class,
- MockComponentAutoConfiguration.GroupConditions.class})
-@AutoConfigureAfter(CamelAutoConfiguration.class)
-@EnableConfigurationProperties({ComponentConfigurationProperties.class,
- MockComponentConfiguration.class})
-public class MockComponentAutoConfiguration {
-
- private static final Logger LOGGER = LoggerFactory
- .getLogger(MockComponentAutoConfiguration.class);
- @Autowired
- private ApplicationContext applicationContext;
- @Autowired
- private CamelContext camelContext;
- @Autowired
- private MockComponentConfiguration configuration;
- @Autowired(required = false)
- private List<ComponentCustomizer<MockComponent>> customizers;
-
- static class GroupConditions extends GroupCondition {
- public GroupConditions() {
- super("camel.component", "camel.component.mock");
- }
- }
-
- @Lazy
- @Bean(name = "mock-component")
- @ConditionalOnMissingBean(MockComponent.class)
- public MockComponent configureMockComponent() throws Exception {
- MockComponent component = new MockComponent();
- component.setCamelContext(camelContext);
- Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
- for (Map.Entry<String, Object> entry : parameters.entrySet()) {
- Object value = entry.getValue();
- Class<?> paramClass = value.getClass();
- if (paramClass.getName().endsWith("NestedConfiguration")) {
- Class nestedClass = null;
- try {
- nestedClass = (Class) paramClass.getDeclaredField(
- "CAMEL_NESTED_CLASS").get(null);
- HashMap<String, Object> nestedParameters = new HashMap<>();
- IntrospectionSupport.getProperties(value, nestedParameters,
- null, false);
- Object nestedProperty = nestedClass.newInstance();
- CamelPropertiesHelper.setCamelProperties(camelContext,
- nestedProperty, nestedParameters, false);
- entry.setValue(nestedProperty);
- } catch (NoSuchFieldException e) {
- }
- }
- }
- CamelPropertiesHelper.setCamelProperties(camelContext, component,
- parameters, false);
- if (ObjectHelper.isNotEmpty(customizers)) {
- for (ComponentCustomizer<MockComponent> customizer : customizers) {
- boolean useCustomizer = (customizer instanceof HasId)
- ? HierarchicalPropertiesEvaluator.evaluate(
- applicationContext.getEnvironment(),
- "camel.component.customizer",
- "camel.component.mock.customizer",
- ((HasId) customizer).getId())
- : HierarchicalPropertiesEvaluator.evaluate(
- applicationContext.getEnvironment(),
- "camel.component.customizer",
- "camel.component.mock.customizer");
- if (useCustomizer) {
- LOGGER.debug("Configure component {}, with customizer {}",
- component, customizer);
- customizer.customize(component);
- }
- }
- }
- return component;
- }
-}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java
deleted file mode 100644
index 1d05918..0000000
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.mock.springboot;
-
-import javax.annotation.Generated;
-import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * The mock component is used for testing routes and mediation rules using
- * mocks.
- *
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-@ConfigurationProperties(prefix = "camel.component.mock")
-public class MockComponentConfiguration
- extends
- ComponentConfigurationPropertiesCommon {
-
- /**
- * Whether to enable auto configuration of the mock component. This is
- * enabled by default.
- */
- private Boolean enabled;
- /**
- * Whether the component should resolve property placeholders on itself when
- * starting. Only properties which are of String type can use property
- * placeholders.
- */
- private Boolean resolvePropertyPlaceholders = true;
-
- public Boolean getResolvePropertyPlaceholders() {
- return resolvePropertyPlaceholders;
- }
-
- public void setResolvePropertyPlaceholders(
- Boolean resolvePropertyPlaceholders) {
- this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
- }
-}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-core-starter/src/main/resources/META-INF/spring.factories
index 6b115e9..b2d9c0d 100644
--- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/resources/META-INF/spring.factories
+++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/resources/META-INF/spring.factories
@@ -17,7 +17,6 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.apache.camel.component.bean.springboot.BeanComponentAutoConfiguration,\
org.apache.camel.component.beanclass.springboot.ClassComponentAutoConfiguration,\
-org.apache.camel.component.mock.springboot.MockComponentAutoConfiguration,\
org.apache.camel.impl.springboot.GzipDataFormatAutoConfiguration,\
org.apache.camel.impl.springboot.SerializationDataFormatAutoConfiguration,\
org.apache.camel.impl.springboot.StringDataFormatAutoConfiguration,\
[camel] 38/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 354e5b483f4c495722b0e30718f9bd9ea90b6f96
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 11:29:20 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
.../remoting/MultiArgumentsWithDefaultBinding.java | 32 --------------
.../MultiArgumentsWithDefaultBindingService.java | 38 -----------------
...rgumentsWithDefaultBindingServiceInterface.java | 25 -----------
...DefaultBindingSpringRemotingPojoDirectTest.java | 49 ----------------------
...yMultiArgumentSpringRemotingPojoDirectTest.java | 48 ---------------------
...-arguments-with-default-binding-pojo-direct.xml | 35 ----------------
.../remoting/my-multi-argument-pojo-direct.xml | 35 ----------------
7 files changed, 262 deletions(-)
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBinding.java b/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBinding.java
deleted file mode 100644
index 5d8e0fc..0000000
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBinding.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.remoting;
-
-import java.util.Date;
-
-import org.apache.camel.Produce;
-
-public class MultiArgumentsWithDefaultBinding {
-
- @Produce(uri = "direct:myargs")
- MultiArgumentsWithDefaultBindingServiceInterface multiArgumentServiceInterface;
-
- public void doSomethingMultiple() {
- multiArgumentServiceInterface.doSomething("Hello World 1", "Hello World 2", new Date());
- }
-
-}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingService.java b/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingService.java
deleted file mode 100644
index e0a7f39..0000000
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingService.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.remoting;
-
-import java.util.Date;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
-
-import org.apache.camel.Consume;
-
-public class MultiArgumentsWithDefaultBindingService implements MultiArgumentsWithDefaultBindingServiceInterface {
-
- @Override
- @Consume(uri = "direct:myargs")
- public void doSomething(String arg1, String arg2, Date arg3) {
- assertEquals("Hello World 1", arg1);
- assertEquals("Hello World 2", arg2);
- assertNotNull(arg3);
- assertTrue(arg3 instanceof Date);
- }
-
-}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingServiceInterface.java b/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingServiceInterface.java
deleted file mode 100644
index 5cb801c..0000000
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingServiceInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.remoting;
-
-import java.util.Date;
-
-public interface MultiArgumentsWithDefaultBindingServiceInterface {
-
- void doSomething(String arg1, String arg2, Date arg3);
-
-}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingSpringRemotingPojoDirectTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingSpringRemotingPojoDirectTest.java
deleted file mode 100644
index 446cff3..0000000
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MultiArgumentsWithDefaultBindingSpringRemotingPojoDirectTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.remoting;
-
-import org.apache.camel.spring.SpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MultiArgumentsWithDefaultBindingSpringRemotingPojoDirectTest extends SpringTestSupport {
-
- @Override
- protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/multi-arguments-with-default-binding-pojo-direct.xml");
- }
-
- @Test
- public void testMultiArgumentPojo() throws Exception {
- try {
- // use the pojo directly to call the injected endpoint and have the
- // original runtime exception thrown
- MultiArgumentsWithDefaultBinding myMultArgumentPojo = applicationContext.getBean("multiArgumentsPojoDirect", MultiArgumentsWithDefaultBinding.class);
- myMultArgumentPojo.doSomethingMultiple();
- } catch (RuntimeException e) {
- fail(""
- + "\nShould not have failed with multiple arguments on POJO @Produce @Consume."
- + "\nValues are incorrect in the consume for doSomething(String arg1, String arg2, Date arg3)"
- + "\nProduce called with doSomething(\"Hello World 1\", \"Hello World 2\", new Date())."
- + "\nConsume got something else."
- + "\n" + e.getMessage()
- + "\n");
- }
- }
-
-}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyMultiArgumentSpringRemotingPojoDirectTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyMultiArgumentSpringRemotingPojoDirectTest.java
deleted file mode 100644
index ae0c925..0000000
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/remoting/MyMultiArgumentSpringRemotingPojoDirectTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.remoting;
-
-import org.apache.camel.spring.SpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MyMultiArgumentSpringRemotingPojoDirectTest extends SpringTestSupport {
-
- @Override
- protected AbstractXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/my-multi-argument-pojo-direct.xml");
- }
-
- @Test
- public void testMultiArgumentPojo() throws Exception {
- try {
- // use the pojo directly to call the injected endpoint and have the
- // original runtime exception thrown
- MyMultiArgument myMultArgumentPojo = applicationContext.getBean("myMultiArgumentPojoDirect", MyMultiArgument.class);
- myMultArgumentPojo.doSomethingMultiple();
- } catch (RuntimeException e) {
- fail(""
- + "\nShould not have failed with multiple arguments on POJO @Produce @Consume."
- + "\nValues are incorrect in the consume for doSomething(String arg1, String arg2, Long arg3)"
- + "\nProduce called with doSomething(\"Hello World 1\", \"Hello World 2\", new Long(\"3\"))."
- + "\nConsume got doSomething(Long(3), null, null)"
- + "\n");
- }
- }
-
-}
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/multi-arguments-with-default-binding-pojo-direct.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/multi-arguments-with-default-binding-pojo-direct.xml
deleted file mode 100644
index ddfee1f..0000000
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/multi-arguments-with-default-binding-pojo-direct.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- ">
-
- <bean id="multiArgumentsService" class="org.apache.camel.spring.remoting.MultiArgumentsWithDefaultBindingService"/>
-
- <bean id="multiArgumentsPojoDirect" class="org.apache.camel.spring.remoting.MultiArgumentsWithDefaultBinding"/>
-
- <camelContext xmlns="http://camel.apache.org/schema/spring">
-
- </camelContext>
-
-</beans>
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/my-multi-argument-pojo-direct.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/my-multi-argument-pojo-direct.xml
deleted file mode 100644
index 4b58a29..0000000
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/remoting/my-multi-argument-pojo-direct.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- ">
-
- <bean id="myMultiArgumentService" class="org.apache.camel.spring.remoting.MyMultiArgumentService"/>
-
- <bean id="myMultiArgumentPojoDirect" class="org.apache.camel.spring.remoting.MyMultiArgument"/>
-
- <camelContext xmlns="http://camel.apache.org/schema/spring">
-
- </camelContext>
-
-</beans>
[camel] 15/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2b34c484c65691b02e16e530e745383bcf66f069
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:32:58 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
.../component/jms/remoting/CalculatorImpl.java | 25 --------
.../component/jms/remoting/JmsProxyMEPTest.java | 67 ---------------------
.../camel/component/jms/remoting/JmsProxyTest.java | 68 ----------------------
3 files changed, 160 deletions(-)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/CalculatorImpl.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/CalculatorImpl.java
deleted file mode 100644
index 933c371..0000000
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/CalculatorImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jms.remoting;
-
-public class CalculatorImpl implements Calculator {
-
- @Override
- public int add(int op1, int op2) {
- return op1 + op2;
- }
-}
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyMEPTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyMEPTest.java
deleted file mode 100644
index 6e9b159..0000000
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyMEPTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jms.remoting;
-
-import javax.jms.ConnectionFactory;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.ProxyBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jms.CamelJmsTestHelper;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
-
-public class JmsProxyMEPTest extends CamelTestSupport {
-
- protected String componentName = "activemq";
- private Calculator calculatorProxy;
-
- protected CamelContext createCamelContext() throws Exception {
- CamelContext camelContext = super.createCamelContext();
-
- ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
- camelContext.addComponent(componentName, jmsComponentAutoAcknowledge(connectionFactory));
-
- // create proxy
- calculatorProxy = new ProxyBuilder(camelContext).binding(false).endpoint("direct:calculatorProxy").build(Calculator.class);
-
- return camelContext;
- }
-
- @Test
- public void testSynchronous() throws Exception {
- int result = calculatorProxy.add(30, 13);
- assertEquals(43, result);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:calculatorProxy")
- .to("log:calc")
- .to("activemq:calculator-queue?exchangePattern=InOut");
-
- from("activemq:calculator-queue?exchangePattern=InOut").bean(CalculatorImpl.class);
- }
- };
- }
-
-}
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyTest.java
deleted file mode 100644
index 57eaca9..0000000
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/remoting/JmsProxyTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jms.remoting;
-
-import javax.jms.ConnectionFactory;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.ProxyBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.jms.CamelJmsTestHelper;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
-
-public class JmsProxyTest extends CamelTestSupport {
-
- protected String componentName = "activemq";
- private Calculator calculatorProxy;
-
- protected CamelContext createCamelContext() throws Exception {
- CamelContext camelContext = super.createCamelContext();
-
- ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
- camelContext.addComponent(componentName, jmsComponentAutoAcknowledge(connectionFactory));
-
- // create proxy
- calculatorProxy = new ProxyBuilder(camelContext).binding(false).endpoint("direct:calculatorProxy").build(Calculator.class);
-
- return camelContext;
- }
-
- @Test
- public void testSynchronous() throws Exception {
- int result = calculatorProxy.add(30, 12);
- assertEquals(42, result);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:calculatorProxy")
- .to("log:calc")
- .to("activemq:calculator-queue");
-
- from("activemq:calculator-queue").bean(CalculatorImpl.class);
-
- }
- };
- }
-
-}
[camel] 05/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 60f931be87f729541b20bf6eafb8a89cd52155f9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 16:46:39 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index ddfd467..b77da58 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.support.builder.xml.Namespaces;
+// TODO: All these should be behind support language so we can separate
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
import org.apache.camel.model.language.GroovyExpression;
[camel] 16/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a7ec565a372dc155bdf9a272f56078a857de522b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:43:25 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
.../test/java/org/apache/camel/component/atom/AtomEntrySortTest.java | 4 ++--
.../test/java/org/apache/camel/component/rss/RssEntrySortTest.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java
index 2e029b6..9ef25e6 100644
--- a/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java
+++ b/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomEntrySortTest.java
@@ -33,7 +33,7 @@ public class AtomEntrySortTest extends CamelTestSupport {
@Test
public void testSortedEntries() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:sorted");
- mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate"));
+ mock.expectsAscending(ExpressionBuilder.beanExpression("myBean?method=getPubDate"));
mock.expectedMessageCount(10);
mock.setResultWaitTime(15000L);
mock.assertIsSatisfied();
@@ -42,7 +42,7 @@ public class AtomEntrySortTest extends CamelTestSupport {
@Test
public void testUnSortedEntries() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:unsorted");
- mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate"));
+ mock.expectsAscending(ExpressionBuilder.beanExpression("myBean?method=getPubDate"));
mock.expectedMessageCount(10);
mock.setResultWaitTime(2000L);
mock.assertIsNotSatisfied(2000L);
diff --git a/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
index 8d4381e..2da7600 100644
--- a/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
+++ b/components/camel-rss/src/test/java/org/apache/camel/component/rss/RssEntrySortTest.java
@@ -33,7 +33,7 @@ public class RssEntrySortTest extends CamelTestSupport {
@Test
public void testSortedEntries() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:sorted");
- mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate"));
+ mock.expectsAscending(ExpressionBuilder.beanExpression("myBean?method=getPubDate"));
mock.expectedMessageCount(10);
mock.setResultWaitTime(15000L);
mock.assertIsSatisfied();
@@ -42,7 +42,7 @@ public class RssEntrySortTest extends CamelTestSupport {
@Test
public void testUnSortedEntries() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:unsorted");
- mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate"));
+ mock.expectsAscending(ExpressionBuilder.beanExpression("myBean?method=getPubDate"));
mock.expectedMessageCount(10);
mock.setResultWaitTime(2000L);
mock.assertIsNotSatisfied(2000L);
[camel] 36/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 98f9c20c044cf55118001722e03536345b943fa0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 10:33:15 2019 +0200
Move mock component out of camel-core. Work in progress.
---
bom/camel-bom/pom.xml | 5 +++++
core/camel-headersmap/pom.xml | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 719d3e1..7299d89 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -1835,6 +1835,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/core/camel-headersmap/pom.xml b/core/camel-headersmap/pom.xml
index 8f0ae52..00419de 100644
--- a/core/camel-headersmap/pom.xml
+++ b/core/camel-headersmap/pom.xml
@@ -64,6 +64,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
[camel] 32/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c6384a92d873339a568e033c3a80bb57d55a49a0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 09:35:41 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../apache/camel/component/dataset/CustomDataSetTest.java | 11 +++++++++--
.../apache/camel/component/dataset/DataSetConsumerTest.java | 11 +++++++++--
.../apache/camel/component/dataset/DataSetPreloadTest.java | 11 +++++++++--
.../apache/camel/component/dataset/DataSetProducerTest.java | 12 ++++++++++--
.../org/apache/camel/component/dataset/DataSetSedaTest.java | 12 ++++++++++--
.../java/org/apache/camel/component/dataset/DataSetTest.java | 11 +++++++++--
.../camel/component/dataset/FileDataSetConsumerTest.java | 12 ++++++++++--
.../component/dataset/FileDataSetConsumerWithSplitTest.java | 12 ++++++++++--
.../camel/component/dataset/FileDataSetProducerTest.java | 11 +++++++++--
.../component/dataset/FileDataSetProducerWithSplitTest.java | 11 +++++++++--
.../camel/component/dataset/ListDataSetConsumerTest.java | 11 +++++++++--
.../camel/component/dataset/ListDataSetProducerTest.java | 11 +++++++++--
.../apache/camel/component/dataset/RoutePerformanceTest.java | 11 +++++++++--
platforms/karaf/features/src/main/resources/features.xml | 1 +
14 files changed, 122 insertions(+), 26 deletions(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
index 1903bd4..c5ff258 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
@@ -30,7 +31,6 @@ import org.junit.Test;
public class CustomDataSetTest extends ContextTestSupport {
- @BindToRegistry("foo")
protected DataSet dataSet = new DataSetSupport() {
Expression expression = new XPathBuilder("/message/@index").resultType(Long.class);
@@ -47,6 +47,13 @@ public class CustomDataSetTest extends ContextTestSupport {
}
};
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testUsingCustomDataSet() throws Exception {
// data set will itself set its assertions so we should just
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
index c6b2f07..4e7c5f1 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -25,7 +26,7 @@ import org.junit.Assert;
import org.junit.Test;
public class DataSetConsumerTest extends ContextTestSupport {
- @BindToRegistry("foo")
+
protected SimpleDataSet dataSet = new SimpleDataSet(5);
final String dataSetName = "foo";
@@ -35,6 +36,12 @@ public class DataSetConsumerTest extends ContextTestSupport {
final String dataSetUriWithDataSetIndexSetToStrict = dataSetUri + "&dataSetIndex=strict";
final String resultUri = "mock://result";
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
/**
* Ensure the expected message count for a consumer-only endpoint defaults to zero
*/
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
index ee708cc..1c198f9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -25,11 +26,17 @@ import org.junit.Test;
public class DataSetPreloadTest extends ContextTestSupport {
- @BindToRegistry("foo")
private SimpleDataSet dataSet = new SimpleDataSet(20);
private String uri = "dataset:foo?initialDelay=0&preloadSize=5";
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDataSetPreloadSize() throws Exception {
MockEndpoint endpoint = getMockEndpoint(uri);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
index eadc69f..0f48c5b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.NoSuchHeaderException;
@@ -26,7 +27,7 @@ import org.junit.Assert;
import org.junit.Test;
public class DataSetProducerTest extends ContextTestSupport {
- @BindToRegistry("foo")
+
protected SimpleDataSet dataSet = new SimpleDataSet(20);
final String dataSetName = "foo";
@@ -37,6 +38,13 @@ public class DataSetProducerTest extends ContextTestSupport {
final String sourceUri = "direct://source";
final String resultUri = "mock://result";
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testSendingMessagesExplicitlyToDataSetEndpointWithDataSetIndexHeader() throws Exception {
long size = dataSet.getSize();
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
index 9c229a5..749fb71 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -26,11 +27,18 @@ import org.junit.Test;
* Unit test to demonstrate high concurrency with seda. Offspring by CAMEL-605.
*/
public class DataSetSedaTest extends ContextTestSupport {
- @BindToRegistry("foo")
+
private SimpleDataSet dataSet = new SimpleDataSet(200);
private String uri = "dataset:foo?initialDelay=0&produceDelay=1";
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDataSetWithSeda() throws Exception {
MockEndpoint endpoint = getMockEndpoint(uri);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
index 65b09e1..7448c73 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
@@ -16,16 +16,23 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
public class DataSetTest extends ContextTestSupport {
- @BindToRegistry("foo")
protected SimpleDataSet dataSet = new SimpleDataSet(20);
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDataSet() throws Exception {
// data set will itself set its assertions so we should just
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
index cce4584..57e6ead 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -25,7 +26,7 @@ import org.junit.Before;
import org.junit.Test;
public class FileDataSetConsumerTest extends ContextTestSupport {
- @BindToRegistry("foo")
+
protected FileDataSet dataSet;
final String testDataFileName = "src/test/data/file-dataset-test.txt";
@@ -34,6 +35,13 @@ public class FileDataSetConsumerTest extends ContextTestSupport {
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
MockEndpoint result = getMockEndpoint(resultUri);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
index 57841cf..b505bc6 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.camel.component.dataset;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -25,7 +26,7 @@ import org.junit.Before;
import org.junit.Test;
public class FileDataSetConsumerWithSplitTest extends ContextTestSupport {
- @BindToRegistry("foo")
+
protected FileDataSet dataSet;
final String testDataFileName = "src/test/data/file-dataset-test.txt";
@@ -35,6 +36,13 @@ public class FileDataSetConsumerWithSplitTest extends ContextTestSupport {
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
MockEndpoint result = getMockEndpoint(resultUri);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
index 22d0d63..8f8793e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
@@ -22,7 +22,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -37,7 +38,6 @@ public class FileDataSetProducerTest extends ContextTestSupport {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
- @BindToRegistry("foo")
protected FileDataSet dataSet;
final String testPayload = String.format("Line 1%nLine 2%nLine 3%nLine 4%nLine 5%nLine 6%nLine 7%nLine 8%nLine 9%nLine 10%n");
@@ -46,6 +46,13 @@ public class FileDataSetProducerTest extends ContextTestSupport {
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
template.sendBodyAndHeader(sourceUri, testPayload, Exchange.DATASET_INDEX, 0);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
index 4dbb1ac..1b4b963 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
@@ -22,7 +22,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -37,7 +38,6 @@ public class FileDataSetProducerWithSplitTest extends ContextTestSupport {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
- @BindToRegistry("foo")
protected FileDataSet dataSet;
final int testDataFileRecordCount = 10;
@@ -46,6 +46,13 @@ public class FileDataSetProducerWithSplitTest extends ContextTestSupport {
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
for (int i = 0; i < testDataFileRecordCount; ++i) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
index 70146e1..5f4f45e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
@@ -19,7 +19,8 @@ package org.apache.camel.component.dataset;
import java.util.LinkedList;
import java.util.List;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -28,13 +29,19 @@ import org.junit.Test;
public class ListDataSetConsumerTest extends ContextTestSupport {
- @BindToRegistry("foo")
protected ListDataSet dataSet;
final String resultUri = "mock://result";
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
MockEndpoint result = getMockEndpoint(resultUri);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
index 982678b..6f42ecf 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
@@ -19,7 +19,8 @@ package org.apache.camel.component.dataset;
import java.util.LinkedList;
import java.util.List;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
@@ -28,13 +29,19 @@ import org.junit.Test;
public class ListDataSetProducerTest extends ContextTestSupport {
- @BindToRegistry("foo")
protected ListDataSet dataSet = new ListDataSet();
final String sourceUri = "direct://source";
final String dataSetName = "foo";
final String dataSetUri = "dataset://" + dataSetName;
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testDefaultListDataSet() throws Exception {
template.sendBodyAndHeader(dataSetUri, "<hello>world!</hello>", Exchange.DATASET_INDEX, 0);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
index fd44387..ac2edf6 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
@@ -20,7 +20,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.apache.camel.BindToRegistry;
+import javax.naming.Context;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -35,11 +36,17 @@ public class RoutePerformanceTest extends ContextTestSupport {
private int size = 250;
- @BindToRegistry("foo")
private SimpleDataSet dataSet = new SimpleDataSet(size);
private String uri = "mock:results";
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context context = super.createJndiContext();
+ context.bind("foo", dataSet);
+ return context;
+ }
+
@Test
public void testPerformance() throws Exception {
StopWatch watch = new StopWatch();
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index a41393c..f82f008 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -63,6 +63,7 @@
<bundle>mvn:org.apache.camel/camel-file/${project.version}</bundle>
<bundle>mvn:org.apache.camel/camel-language/${project.version}</bundle>
<bundle>mvn:org.apache.camel/camel-log/${project.version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-mock/${project.version}</bundle>
<bundle>mvn:org.apache.camel/camel-properties/${project.version}</bundle>
<bundle>mvn:org.apache.camel/camel-ref/${project.version}</bundle>
<bundle>mvn:org.apache.camel/camel-rest/${project.version}</bundle>
[camel] 06/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit fcc5c4e1e3f1c0120bc63b984d1b94c82bafc21f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 16:56:46 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java | 7 +++----
.../camel/impl/InterceptSendToMockEndpointStrategyCustomTest.java | 3 +--
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java b/core/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java
index 030b3d4..f608085 100644
--- a/core/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java
+++ b/core/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java
@@ -18,7 +18,6 @@ package org.apache.camel.impl;
import org.apache.camel.Endpoint;
import org.apache.camel.Producer;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spi.EndpointStrategy;
import org.apache.camel.support.EndpointHelper;
import org.apache.camel.util.StringHelper;
@@ -72,7 +71,7 @@ public class InterceptSendToMockEndpointStrategy implements EndpointStrategy {
if (endpoint instanceof DefaultInterceptSendToEndpoint) {
// endpoint already decorated
return endpoint;
- } else if (endpoint instanceof MockEndpoint) {
+ } else if (endpoint.getEndpointUri().startsWith("mock:")) {
// we should not intercept mock endpoints
return endpoint;
} else if (matchPattern(uri, endpoint, pattern)) {
@@ -91,7 +90,7 @@ public class InterceptSendToMockEndpointStrategy implements EndpointStrategy {
}
LOG.info("Adviced endpoint [{}] with mock endpoint [{}]", uri, key);
- MockEndpoint mock = endpoint.getCamelContext().getEndpoint(key, MockEndpoint.class);
+ Endpoint mock = endpoint.getCamelContext().getEndpoint(key, Endpoint.class);
Producer producer;
try {
producer = mock.createProducer();
@@ -131,7 +130,7 @@ public class InterceptSendToMockEndpointStrategy implements EndpointStrategy {
* @param mockProducer the mock producer
* @return the mock producer
*/
- protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, MockEndpoint mockEndpoint, Producer mockProducer) {
+ protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, Endpoint mockEndpoint, Producer mockProducer) {
return mockProducer;
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategyCustomTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategyCustomTest.java
index 6693988..b1f8ac8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategyCustomTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategyCustomTest.java
@@ -20,7 +20,6 @@ import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.Producer;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
public class InterceptSendToMockEndpointStrategyCustomTest extends ContextTestSupport {
@@ -30,7 +29,7 @@ public class InterceptSendToMockEndpointStrategyCustomTest extends ContextTestSu
private class MyStrategy extends InterceptSendToMockEndpointStrategy {
@Override
- protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, MockEndpoint mockEndpoint, Producer mockProducer) {
+ protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, Endpoint mockEndpoint, Producer mockProducer) {
called = true;
return mockProducer;
}
[camel] 33/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 73fb23fa465271b6094a692d5f7012c31613c404
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 09:39:46 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../main/java/org/apache/camel/builder/ExpressionClauseSupport.java | 2 +-
.../org/apache/camel/language/simple/SimpleExpressionBuilder.java | 5 ++++-
.../src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java | 3 ++-
.../src/test/java/org/apache/camel/language/XMLTokenSplitTest.java | 3 ++-
.../camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java | 2 +-
.../apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java | 2 +-
.../org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java | 6 ++----
.../apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java | 6 ++----
.../java/org/apache/camel/processor/SplitterWithXqureyTest.java | 2 +-
.../apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java | 2 +-
.../org/apache/camel/processor/XPathWithNamespacesFilterTest.java | 3 ++-
11 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index ddfd467..9dd2217 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -20,7 +20,6 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
import org.apache.camel.model.language.GroovyExpression;
@@ -39,6 +38,7 @@ import org.apache.camel.model.language.TokenizerExpression;
import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
/**
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
index 73117ff..ca80e5e 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
@@ -51,10 +51,13 @@ import org.apache.camel.util.StringHelper;
/**
* Expression builder used by the simple language.
*/
-public class SimpleExpressionBuilder {
+public final class SimpleExpressionBuilder {
private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])([^+-]+)");
+ private SimpleExpressionBuilder() {
+ }
+
/**
* Returns the expression for the exchanges inbound message header invoking methods defined
* in a simple OGNL notation
diff --git a/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
index a37728b..5c8b9de 100644
--- a/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/issues/SetHeaderIssueTest.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
package org.apache.camel.issues;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
index 342f85d..d103b15 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/XMLTokenSplitTest.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
package org.apache.camel.language;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
index b9c147e..40c6eff 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageGroupingTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XMLTokenizeLanguageGroupingTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
index 86c0958..6fd58c8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/tokenizer/XMLTokenizeLanguageTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.language.tokenizer;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class XMLTokenizeLanguageTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
index e1d269d..0982ae2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupMultiXmlTokenTest.java
@@ -15,17 +15,15 @@
* limitations under the License.
*/
package org.apache.camel.processor;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
-/**
- *
- */
public class SplitGroupMultiXmlTokenTest extends ContextTestSupport {
@Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
index 1414b7e..a548dfb 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitGroupWrappedMultiXmlTokenTest.java
@@ -15,17 +15,15 @@
* limitations under the License.
*/
package org.apache.camel.processor;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
-/**
- *
- */
public class SplitGroupWrappedMultiXmlTokenTest extends ContextTestSupport {
@Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
index 0f29260..f2c027e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterWithXqureyTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Test;
public class SplitterWithXqureyTest extends ContextTestSupport {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
index de50553..c61eb54 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespaceBuilderFilterTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.processor;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
index 22d9bf7..90553c0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/XPathWithNamespacesFilterTest.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
package org.apache.camel.processor;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.junit.Before;
import org.junit.Test;
[camel] 09/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 717f2c1cad0b1e0d92b5b88af01d61b169a4e5f5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 09:07:22 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java | 2 +-
.../camel/builder/saxon/XQueryHeaderNameResultTypeAndNamespaceTest.java | 2 +-
.../org/apache/camel/builder/saxon/XQueryWithNamespacesFilterTest.java | 2 +-
.../src/test/java/org/apache/camel/itest/issues/RssToHttpIssueTest.java | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
index 27ca982..b728172 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
@@ -21,8 +21,8 @@ import org.w3c.dom.Element;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryHeaderNameResultTypeAndNamespaceTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryHeaderNameResultTypeAndNamespaceTest.java
index 3399783..936a773 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryHeaderNameResultTypeAndNamespaceTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryHeaderNameResultTypeAndNamespaceTest.java
@@ -17,8 +17,8 @@
package org.apache.camel.builder.saxon;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
diff --git a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryWithNamespacesFilterTest.java b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryWithNamespacesFilterTest.java
index f939e34..c95528c 100644
--- a/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryWithNamespacesFilterTest.java
+++ b/components/camel-saxon/src/test/java/org/apache/camel/builder/saxon/XQueryWithNamespacesFilterTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.builder.saxon;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RssToHttpIssueTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RssToHttpIssueTest.java
index 3e9e4a5..abc88d5 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RssToHttpIssueTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RssToHttpIssueTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.itest.issues;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Ignore;
import org.junit.Test;
[camel] 21/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4194f10f1da2625b8931e0af4a31e6fd95d92f4d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 12:11:01 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../src/main/java/org/apache/camel/builder/ValueBuilder.java | 11 -----------
.../org/apache/camel/issues/TryCatchWithSplitIssueTest.java | 4 ++--
.../camel/processor/onexception/OnExceptionHandledTest.java | 1 -
3 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index b521537..ffe3465 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -337,17 +337,6 @@ public class ValueBuilder implements Expression, Predicate {
}
/**
- * Invokes the method with the given name.
- *
- * @param methodName name of method to invoke.
- * @return the current builder
- */
- public ValueBuilder method(String methodName) {
- Expression newExp = ExpressionBuilder.beanExpression(expression + "?method=" + methodName);
- return onNewValueBuilder(newExp);
- }
-
- /**
* Negates the built expression.
*
* @return the current builder
diff --git a/core/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
index 20b178e..83c2ed8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/issues/TryCatchWithSplitIssueTest.java
@@ -30,7 +30,7 @@ public class TryCatchWithSplitIssueTest extends ContextTestSupport {
MockEndpoint error = getMockEndpoint("mock:error");
error.expectedBodiesReceived("James");
error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isNotNull();
- error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).method("getMessage").isEqualTo("This is a dummy error James!");
+ error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived("Hi Claus", "Hi Willem");
@@ -45,7 +45,7 @@ public class TryCatchWithSplitIssueTest extends ContextTestSupport {
MockEndpoint error = getMockEndpoint("mock:error");
error.expectedBodiesReceived("James");
error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isNotNull();
- error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).method("getMessage").isEqualTo("This is a dummy error James!");
+ error.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
template.sendBody("direct:start", "James");
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
index 0d02081..dea9ca9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionHandledTest.java
@@ -30,7 +30,6 @@ public class OnExceptionHandledTest extends ContextTestSupport {
mock.expectedBodiesReceived("Hello World");
mock.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isNotNull();
mock.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
- mock.message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).method("getMessage").isEqualTo("Forced");
template.sendBody("direct:start", "Hello World");
[camel] 34/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b85831c3a8296437574b39c50cf5428b8d90afda
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 10:16:27 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../org/apache/camel/component/mock/AssertionClause.java | 4 ++--
.../camel/component/mock/MockExpressionClause.java | 4 ++--
.../component/mock/MockExpressionClauseSupport.java | 16 ++++++++--------
.../main/java/org/apache/camel/ExpressionFactory.java} | 10 ++++------
.../java/org/apache/camel/builder/ExpressionClause.java | 4 ++--
.../apache/camel/builder/ExpressionClauseSupport.java | 16 ++++++++--------
.../java/org/apache/camel/model/AggregateDefinition.java | 4 ++--
.../java/org/apache/camel/model/ChoiceDefinition.java | 4 ++--
.../main/java/org/apache/camel/model/ExpressionNode.java | 4 ++--
.../camel/model/language/ExpressionDefinition.java | 4 ++--
.../java/org/apache/camel/reifier/ChoiceReifier.java | 6 ++----
11 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index cf7f05f..ab502ed 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -22,10 +22,10 @@ import java.util.Set;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.StreamCache;
import org.apache.camel.support.PredicateAssertHelper;
-import org.apache.camel.support.language.ExpressionModel;
/**
* A builder of assertions on message exchanges
@@ -52,7 +52,7 @@ public abstract class AssertionClause extends MockExpressionClauseSupport<MockVa
return new PredicateValueBuilder(expression);
}
- public MockValueBuilder language(ExpressionModel expression) {
+ public MockValueBuilder language(ExpressionFactory expression) {
// must override this method as we provide null in the constructor
super.expression(expression.createExpression(mock.getCamelContext()));
return new PredicateValueBuilder(getExpressionValue());
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
index 04178ec..fa4b202 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
@@ -23,11 +23,11 @@ import java.util.function.Supplier;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Message;
import org.apache.camel.Predicate;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
-import org.apache.camel.support.language.ExpressionModel;
/**
* Represents an expression clause within the DSL which when the expression is
@@ -474,7 +474,7 @@ public class MockExpressionClause<T> implements Expression, Predicate {
return delegate.getExpressionValue();
}
- public ExpressionModel getExpressionType() {
+ public ExpressionFactory getExpressionType() {
return delegate.getExpressionType();
}
diff --git a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
index 35795b0..b518bab 100644
--- a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
+++ b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.mock;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.support.builder.ExpressionBuilder;
-import org.apache.camel.support.language.ExpressionModel;
/**
* A support class for building expression clauses.
@@ -28,7 +28,7 @@ public class MockExpressionClauseSupport<T> {
private T result;
private Expression expressionValue;
- private ExpressionModel expressionType;
+ private ExpressionFactory expressionType;
public MockExpressionClauseSupport(T result) {
this.result = result;
@@ -42,16 +42,16 @@ public class MockExpressionClauseSupport<T> {
*/
public T expression(Expression expression) {
setExpressionValue(expression);
- if (expression instanceof ExpressionModel) {
- setExpressionType((ExpressionModel) expression);
+ if (expression instanceof ExpressionFactory) {
+ setExpressionType((ExpressionFactory) expression);
}
return result;
}
/**
- * Specify an {@link ExpressionModel} instance
+ * Specify an {@link ExpressionFactory} instance
*/
- public T language(ExpressionModel expression) {
+ public T language(ExpressionFactory expression) {
setExpressionType(expression);
return result;
}
@@ -351,11 +351,11 @@ public class MockExpressionClauseSupport<T> {
this.expressionValue = expressionValue;
}
- public ExpressionModel getExpressionType() {
+ public ExpressionFactory getExpressionType() {
return expressionType;
}
- public void setExpressionType(ExpressionModel expressionType) {
+ public void setExpressionType(ExpressionFactory expressionType) {
this.expressionType = expressionType;
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionFactory.java
similarity index 81%
rename from core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
rename to core/camel-api/src/main/java/org/apache/camel/ExpressionFactory.java
index 4861651..8a7be29 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExpressionFactory.java
@@ -14,15 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.support.language;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Expression;
+package org.apache.camel;
/**
- * Represents a model that can be created as an expression (eg language).
+ * A factory for creating {@link Expression}
*/
-public interface ExpressionModel {
+@FunctionalInterface
+public interface ExpressionFactory {
/**
* Creates an expression
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
index 6dd377b..893263d 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -23,12 +23,12 @@ import java.util.function.Supplier;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Message;
import org.apache.camel.Predicate;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.builder.xml.Namespaces;
-import org.apache.camel.support.language.ExpressionModel;
/**
* Represents an expression clause within the DSL which when the expression is
@@ -1061,7 +1061,7 @@ public class ExpressionClause<T> implements Expression, Predicate {
return delegate.getExpressionValue();
}
- public ExpressionModel getExpressionType() {
+ public ExpressionFactory getExpressionType() {
return delegate.getExpressionType();
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 9dd2217..bd70189 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -20,6 +20,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
import org.apache.camel.model.language.GroovyExpression;
@@ -39,7 +40,6 @@ import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.model.language.XQueryExpression;
import org.apache.camel.support.builder.xml.Namespaces;
-import org.apache.camel.support.language.ExpressionModel;
/**
* A support class for building expression clauses.
@@ -51,7 +51,7 @@ public class ExpressionClauseSupport<T> {
private T result;
private Expression expressionValue;
- private ExpressionModel expressionType;
+ private ExpressionFactory expressionType;
public ExpressionClauseSupport(T result) {
this.result = result;
@@ -65,16 +65,16 @@ public class ExpressionClauseSupport<T> {
*/
public T expression(Expression expression) {
setExpressionValue(expression);
- if (expression instanceof ExpressionModel) {
- setExpressionType((ExpressionModel) expression);
+ if (expression instanceof ExpressionFactory) {
+ setExpressionType((ExpressionFactory) expression);
}
return result;
}
/**
- * Specify an {@link ExpressionModel} instance
+ * Specify an {@link ExpressionFactory} instance
*/
- public T language(ExpressionModel expression) {
+ public T language(ExpressionFactory expression) {
setExpressionType(expression);
return result;
}
@@ -1087,11 +1087,11 @@ public class ExpressionClauseSupport<T> {
this.expressionValue = expressionValue;
}
- public ExpressionModel getExpressionType() {
+ public ExpressionFactory getExpressionType() {
return expressionType;
}
- public void setExpressionType(ExpressionModel expressionType) {
+ public void setExpressionType(ExpressionFactory expressionType) {
this.expressionType = expressionType;
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
index a81e290..e8b6727 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
@@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.AggregationStrategy;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.builder.AggregationStrategyClause;
import org.apache.camel.builder.ExpressionClause;
@@ -41,7 +42,6 @@ import org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy;
import org.apache.camel.spi.AggregationRepository;
import org.apache.camel.spi.AsPredicate;
import org.apache.camel.spi.Metadata;
-import org.apache.camel.support.language.ExpressionModel;
/**
* Aggregates many messages into a single message
@@ -176,7 +176,7 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- ExpressionModel model = clause.getExpressionType();
+ ExpressionFactory model = clause.getExpressionType();
if (model instanceof ExpressionDefinition) {
correlationExpression = new ExpressionSubElementDefinition();
correlationExpression.setExpressionType((ExpressionDefinition) model);
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
index a782d5e..de4dd2a 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
@@ -26,12 +26,12 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.spi.AsPredicate;
import org.apache.camel.spi.Metadata;
-import org.apache.camel.support.language.ExpressionModel;
import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.ObjectHelper;
@@ -267,7 +267,7 @@ public class ChoiceDefinition extends ProcessorDefinition<ChoiceDefinition> {
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- ExpressionModel model = clause.getExpressionType();
+ ExpressionFactory model = clause.getExpressionType();
if (model instanceof ExpressionDefinition) {
when.setExpression((ExpressionDefinition) model);
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java b/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
index 7372044..596432c 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
@@ -25,10 +25,10 @@ import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.model.language.ExpressionDefinition;
-import org.apache.camel.support.language.ExpressionModel;
/**
* A base class for nodes which contain an expression and a number of outputs
@@ -115,7 +115,7 @@ public abstract class ExpressionNode extends ProcessorDefinition<ExpressionNode>
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- ExpressionModel model = clause.getExpressionType();
+ ExpressionFactory model = clause.getExpressionType();
if (model instanceof ExpressionDefinition) {
setExpression((ExpressionDefinition) model);
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
index 7eb9a4c..b74b9d2 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
@@ -35,6 +35,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.NoSuchLanguageException;
import org.apache.camel.Predicate;
import org.apache.camel.builder.ScriptHelper;
@@ -44,7 +45,6 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.RouteContext;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.IntrospectionSupport;
-import org.apache.camel.support.language.ExpressionModel;
import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.ObjectHelper;
@@ -55,7 +55,7 @@ import org.apache.camel.util.ObjectHelper;
@XmlRootElement
@XmlType(name = "expression") // must be named expression
@XmlAccessorType(XmlAccessType.FIELD)
-public class ExpressionDefinition implements Expression, Predicate, OtherAttributesAware, ExpressionModel {
+public class ExpressionDefinition implements Expression, Predicate, OtherAttributesAware, ExpressionFactory {
@XmlAttribute
@XmlID
private String id;
diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
index 1944472..11fa17e 100644
--- a/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
+++ b/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
@@ -19,12 +19,11 @@ package org.apache.camel.reifier;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.Expression;
+import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.model.ChoiceDefinition;
-import org.apache.camel.model.ExpressionNode;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.model.ProcessorDefinitionHelper;
import org.apache.camel.model.WhenDefinition;
@@ -32,7 +31,6 @@ import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.processor.ChoiceProcessor;
import org.apache.camel.processor.FilterProcessor;
import org.apache.camel.spi.RouteContext;
-import org.apache.camel.support.language.ExpressionModel;
class ChoiceReifier extends ProcessorReifier<ChoiceDefinition> {
@@ -56,7 +54,7 @@ class ChoiceReifier extends ProcessorReifier<ChoiceDefinition> {
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- ExpressionModel model = clause.getExpressionType();
+ ExpressionFactory model = clause.getExpressionType();
if (model instanceof ExpressionDefinition) {
whenClause.setExpression((ExpressionDefinition) model);
}
[camel] 11/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2aa18b39f968e4be8120ffbb1c4db7facb1ad5e5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:21:25 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
components/camel-jaxb/pom.xml | 1 +
.../converter/jaxb/FallbackTypeConverter.java | 7 -
.../camel/component/xquery/XQueryBuilder.java | 13 --
.../src/main/docs/soapjaxb-dataformat.adoc | 53 +-----
.../camel/dataformat/soap/SoapJaxbDataFormat.java | 59 +------
.../soap/MultiPartClientMarshalTest.java | 96 -----------
.../dataformat/soap/MultiPartCxfServerTest.java | 192 ---------------------
.../soap/MultiPartCxfServerTest-context.xml | 49 ------
8 files changed, 5 insertions(+), 465 deletions(-)
diff --git a/components/camel-jaxb/pom.xml b/components/camel-jaxb/pom.xml
index 27da40c..66eecfe 100644
--- a/components/camel-jaxb/pom.xml
+++ b/components/camel-jaxb/pom.xml
@@ -42,6 +42,7 @@
<dependencies>
+ <!-- needs camel-core due to stax converter -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
diff --git a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
index 08cb0a6..3e4a676 100644
--- a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
+++ b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
@@ -43,11 +43,9 @@ import javax.xml.transform.Source;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
import org.apache.camel.FallbackConverter;
-import org.apache.camel.Processor;
import org.apache.camel.StreamCache;
import org.apache.camel.TypeConversionException;
import org.apache.camel.TypeConverter;
-import org.apache.camel.component.bean.BeanInvocation;
import org.apache.camel.converter.jaxp.StaxConverter;
import org.apache.camel.spi.TypeConverterRegistry;
import org.apache.camel.support.ExchangeHelper;
@@ -94,11 +92,6 @@ public class FallbackTypeConverter {
@FallbackConverter
@Converter(fallback = true)
public Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
- if (BeanInvocation.class.isAssignableFrom(type) || Processor.class.isAssignableFrom(type)) {
- // JAXB cannot convert to a BeanInvocation / Processor, so we need to indicate this
- // to avoid Camel trying to do this when using beans with JAXB payloads
- return null;
- }
boolean prettyPrint = defaultPrettyPrint;
String property = exchange != null ? exchange.getContext().getGlobalOption(PRETTY_PRINT) : null;
diff --git a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
index 9a7c573..016f3d2 100644
--- a/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
+++ b/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
@@ -72,7 +72,6 @@ import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.RuntimeExpressionException;
import org.apache.camel.StringSource;
-import org.apache.camel.component.bean.BeanInvocation;
import org.apache.camel.converter.IOConverter;
import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.support.MessageHelper;
@@ -525,18 +524,6 @@ public abstract class XQueryBuilder implements Expression, Predicate, NamespaceA
source = getSource(exchange, body);
}
- // special for bean invocation
- if (source == null) {
- if (body instanceof BeanInvocation) {
- // if its a null bean invocation then handle that
- BeanInvocation bi = exchange.getContext().getTypeConverter().convertTo(BeanInvocation.class, body);
- if (bi.getArgs() != null && bi.getArgs().length == 1 && bi.getArgs()[0] == null) {
- // its a null argument from the bean invocation so use null as answer
- source = null;
- }
- }
- }
-
if (source == null) {
// indicate it was not possible to convert to a Source type
throw new NoTypeConversionAvailableException(body, Source.class);
diff --git a/components/camel-soap/src/main/docs/soapjaxb-dataformat.adoc b/components/camel-soap/src/main/docs/soapjaxb-dataformat.adoc
index 059e911..9e739c2 100644
--- a/components/camel-soap/src/main/docs/soapjaxb-dataformat.adoc
+++ b/components/camel-soap/src/main/docs/soapjaxb-dataformat.adoc
@@ -189,61 +189,10 @@ ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.custo
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
-------------------------------------------------------------------------------------------------------------------------------------------
-#### Multi-part Request
-
-The payload parameters for a multi-part request are initiazlied using a
-`BeanInvocation` object that reflects the signature of the target
-operation. The camel-soap DataFormat maps the content in the
-`BeanInvocation` to fields in the SOAP header and body in accordance
-with the JAX-WS mapping when the `marshal()` processor is invoked.
-
-[source,java]
-----------------------------------------------------------------------------------------
-BeanInvocation beanInvocation = new BeanInvocation();
-
-// Identify the target method
-beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName",
- GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
-
-// Populate the method arguments
-GetCustomersByName getCustomersByName = new GetCustomersByName();
-getCustomersByName.setName("Dr. Multipart");
-
-Product product = new Product();
-product.setName("Multiuse Product");
-product.setDescription("Useful for lots of things.");
-
-Object[] args = new Object[] {getCustomersByName, product};
-
-// Add the arguments to the bean invocation
-beanInvocation.setArgs(args);
-
-// Set the bean invocation object as the message body
-exchange.getIn().setBody(beanInvocation);
-----------------------------------------------------------------------------------------
-
-#### Multi-part Response
-
-A multi-part soap response may include an element in the soap body and
-will have one or more elements in the soap header. The camel-soap
-DataFormat will unmarshall the element in the soap body (if it exists)
-and place it onto the body of the out message in the exchange. Header
-elements will *not* be marshaled into their JAXB mapped object types.
-Instead, these elements are placed into the camel out message header
-`org.apache.camel.dataformat.soap.UNMARSHALLED_HEADER_LIST`. The
-elements will appear either as element instance values, or as
-JAXBElement values, depending upon the setting for the
-`ignoreJAXBElement` property. This property is inherited from
-camel-jaxb.
-
-You can also have the camel-soap DataFormate ignore header content
-all-together by setting the `ignoreUnmarshalledHeaders` value to `true`.
-
#### Holder Object mapping
JAX-WS specifies the use of a type-parameterized `javax.xml.ws.Holder`
-object for `In/Out` and `Out` parameters. A `Holder` object may be used
-when building the `BeanInvocation`, or you may use an instance of the
+object for `In/Out` and `Out` parameters. You may use an instance of the
parameterized-type directly. The camel-soap DataFormat marshals Holder
values in accordance with the JAXB mapping for the class of the
`Holder`'s value. No mapping is provided for `Holder` objects in an
diff --git a/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
index 0fcdcb3..206dbd6 100644
--- a/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
+++ b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapJaxbDataFormat.java
@@ -19,12 +19,9 @@ package org.apache.camel.dataformat.soap;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -33,8 +30,6 @@ import javax.xml.namespace.QName;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.bean.BeanInvocation;
import org.apache.camel.converter.jaxb.JaxbDataFormat;
import org.apache.camel.dataformat.soap.name.ElementNameStrategy;
import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
@@ -134,14 +129,6 @@ public class SoapJaxbDataFormat extends JaxbDataFormat {
checkElementNameStrategy(exchange);
String soapAction = getSoapActionFromExchange(exchange);
- if (soapAction == null && inputObject instanceof BeanInvocation) {
- BeanInvocation beanInvocation = (BeanInvocation) inputObject;
- WebMethod webMethod = beanInvocation.getMethod().getAnnotation(WebMethod.class);
- if (webMethod != null && webMethod.action() != null) {
- soapAction = webMethod.action();
- }
- }
-
Object envelope = adapter.doMarshal(exchange, inputObject, stream, soapAction);
// and continue in super
@@ -149,11 +136,8 @@ public class SoapJaxbDataFormat extends JaxbDataFormat {
}
/**
- * Create body content from a non Exception object. If the inputObject is a
- * BeanInvocation the following should be considered: The first parameter
- * will be used for the SOAP body. BeanInvocations with more than one
- * parameter are not supported. So the interface should be in doc lit bare
- * style.
+ * Create body content from a non Exception object.
+ * So the interface should be in doc lit bare style.
*
* @param inputObject
* object to be put into the SOAP body
@@ -168,44 +152,7 @@ public class SoapJaxbDataFormat extends JaxbDataFormat {
List<Object> headerElements) {
List<Object> bodyParts = new ArrayList<>();
List<Object> headerParts = new ArrayList<>();
- if (inputObject instanceof BeanInvocation) {
- BeanInvocation bi = (BeanInvocation)inputObject;
- Annotation[][] annotations = bi.getMethod().getParameterAnnotations();
-
- List<WebParam> webParams = new ArrayList<>();
- for (Annotation[] singleParameterAnnotations : annotations) {
- for (Annotation annotation : singleParameterAnnotations) {
- if (annotation instanceof WebParam) {
- webParams.add((WebParam)annotation);
- }
- }
- }
-
- if (webParams.size() > 0) {
- if (webParams.size() == bi.getArgs().length) {
- int index = -1;
- for (Object o : bi.getArgs()) {
- if (webParams.get(++index).header()) {
- headerParts.add(o);
- } else {
- bodyParts.add(o);
- }
- }
- } else {
- throw new RuntimeCamelException("The number of bean invocation parameters does not "
- + "match the number of parameters annotated with @WebParam for the method [ "
- + bi.getMethod().getName() + "].");
- }
- } else {
- // try to map all objects for the body
- for (Object o : bi.getArgs()) {
- bodyParts.add(o);
- }
- }
-
- } else {
- bodyParts.add(inputObject);
- }
+ bodyParts.add(inputObject);
List<Object> bodyElements = new ArrayList<>();
for (Object bodyObj : bodyParts) {
diff --git a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartClientMarshalTest.java b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartClientMarshalTest.java
deleted file mode 100644
index 9f1e705..0000000
--- a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartClientMarshalTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.dataformat.soap;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.example.customerservice.multipart.GetCustomersByName;
-import com.example.customerservice.multipart.MultiPartCustomerService;
-import com.example.customerservice.multipart.Product;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.component.xquery.XQueryBuilder;
-import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-
-public class MultiPartClientMarshalTest extends CamelTestSupport {
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
-
- @Override
- public void configure() throws Exception {
-
- ServiceInterfaceStrategy strat =
- new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
- SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
-
- from("direct:start")
- .marshal(soapDataFormat)
- .log("marshal to: ${body}")
- .end();
- }
- };
- }
-
- @Test
- public void testSendPayload() throws Exception {
-
- Exchange exchange = template.send("direct:start", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- BeanInvocation beanInvocation = new BeanInvocation();
- GetCustomersByName getCustomersByName = new GetCustomersByName();
- getCustomersByName.setName("Dr. Multipart");
- beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName",
- GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
-
- Product product = new Product();
- product.setName("Multiuse Product");
- product.setDescription("Useful for lots of things.");
-
- Object[] args = new Object[] {getCustomersByName, product};
- beanInvocation.setArgs(args);
- exchange.getIn().setBody(beanInvocation);
- }
- });
-
- if (exchange.getException() != null) {
- throw exchange.getException();
- }
-
- Map<String, String> nsMap = new HashMap<>();
- nsMap.put("soap", "http://schemas.xmlsoap.org/soap/envelope/");
- nsMap.put("example", "http://multipart.customerservice.example.com/");
- XQueryBuilder builder = XQueryBuilder.xquery("//soap:Envelope/soap:Header/example:product/name");
- builder.setNamespaces(nsMap);
- String result = builder.evaluateAsString(exchange);
- assertTrue(result.equals("Multiuse Product"));
-
-
- builder = XQueryBuilder.xquery("//soap:Envelope/soap:Body/example:getCustomersByName/name");
- builder.setNamespaces(nsMap);
- result = builder.evaluateAsString(exchange);
- assertTrue(result.equals("Dr. Multipart"));
- }
-}
diff --git a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartCxfServerTest.java b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartCxfServerTest.java
deleted file mode 100644
index 34616f5..0000000
--- a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/MultiPartCxfServerTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.dataformat.soap;
-
-import java.util.List;
-
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Holder;
-
-import com.example.customerservice.multipart.Company;
-import com.example.customerservice.multipart.Customer;
-import com.example.customerservice.multipart.GetCustomersByName;
-import com.example.customerservice.multipart.GetCustomersByNameResponse;
-import com.example.customerservice.multipart.MultiPartCustomerService;
-import com.example.customerservice.multipart.Product;
-import com.example.customerservice.multipart.SaveCustomer;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration
-public class MultiPartCxfServerTest extends RouteBuilder {
-
- protected static Endpoint endpoint;
-
- @Produce(uri = "direct:start")
- ProducerTemplate producerTemplate;
-
-
- @Override
- public void configure() throws Exception {
- ServiceInterfaceStrategy strat =
- new ServiceInterfaceStrategy(com.example.customerservice.multipart.MultiPartCustomerService.class, true);
- SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
-
- from("direct:start")
- .marshal(soapDataFormat)
- .log("marshal to: ${body}")
- .to("direct:cxfEndpoint")
- .unmarshal(soapDataFormat)
- .end();
- }
-
- @Test
- public void testSendRequestWithInPart() throws Exception {
-
- Exchange exchange = producerTemplate.send("direct:start", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- BeanInvocation beanInvocation = new BeanInvocation();
- GetCustomersByName getCustomersByName = new GetCustomersByName();
- getCustomersByName.setName("Dr. Multipart");
- beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName",
- GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
-
- Product product = new Product();
- product.setName("Multipart Product");
- product.setDescription("Useful for lots of things.");
-
- Object[] args = new Object[] {getCustomersByName, product};
- beanInvocation.setArgs(args);
- exchange.getIn().setBody(beanInvocation);
- }
- });
-
- if (exchange.getException() != null) {
- throw exchange.getException();
- }
-
- Object responseObj = exchange.getOut().getBody();
- assertTrue(responseObj instanceof GetCustomersByNameResponse);
- GetCustomersByNameResponse response = (GetCustomersByNameResponse) responseObj;
- assertTrue(response.getReturn().get(0).getName().equals("Multipart Product"));
-
- }
-
-
- @Test
- public void testSendRequestWithInAndInOutParts() throws Exception {
-
- Exchange exchange = producerTemplate.send("direct:start", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- BeanInvocation beanInvocation = new BeanInvocation();
-
- beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("saveCustomer",
- SaveCustomer.class, Product.class, Holder.class));
-
- Customer customer = new Customer();
- customer.setName("TestCustomer");
- customer.setRevenue(50000);
- SaveCustomer saveCustomer = new SaveCustomer();
- saveCustomer.setCustomer(customer);
-
- Product product = new Product();
- product.setName("Multiuse Product");
- product.setDescription("Useful for lots of things.");
-
- Holder<Company> holder = new Holder<>();
-
- Object[] args = new Object[] {saveCustomer, product, holder};
- beanInvocation.setArgs(args);
- exchange.getIn().setBody(beanInvocation);
- }
-
- });
-
- if (exchange.getException() != null) {
- throw exchange.getException();
- }
-
- @SuppressWarnings("unchecked")
- List<Object> headers = (List<Object>) exchange.getOut().getHeader(SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST);
- assertTrue(headers.size() == 1);
- Object companyHeaderObj = headers.get(0);
- assertTrue(companyHeaderObj instanceof Company);
- assertTrue(((Company)companyHeaderObj).getName().equals("MultipartSoft"));
- }
-
- /**
- * This test validates the end-to-end behavior of the service interface mapping when a parameter type
- * is defined with a different QName in two different Web method. It also tests the case where a
- * QName and type are directly reused across methods.
- */
- @Test
- public void testSendRequestWithReusedInAndInOutParts() throws Exception {
-
- Exchange exchange = producerTemplate.send("direct:start", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- BeanInvocation beanInvocation = new BeanInvocation();
-
- beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("saveCustomerToo",
- SaveCustomer.class, Product.class, Holder.class));
-
- Customer customer = new Customer();
- customer.setName("TestCustomerToo");
- customer.setRevenue(50000);
- SaveCustomer saveCustomer = new SaveCustomer();
- saveCustomer.setCustomer(customer);
-
- Product product = new Product();
- product.setName("Multiuse Product");
- product.setDescription("Useful for lots of things.");
-
- Holder<Company> holder = new Holder<>();
-
- Object[] args = new Object[] {saveCustomer, product, holder};
- beanInvocation.setArgs(args);
- exchange.getIn().setBody(beanInvocation);
- }
-
- });
-
- if (exchange.getException() != null) {
- throw exchange.getException();
- }
-
- @SuppressWarnings("unchecked")
- List<Object> headers = (List<Object>) exchange.getOut().getHeader(SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST);
- assertTrue(headers.size() == 1);
- Object companyHeaderObj = headers.get(0);
- assertTrue(companyHeaderObj instanceof Company);
- assertTrue(((Company)companyHeaderObj).getName().equals("MultipartSoft"));
- }
-
-}
diff --git a/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/MultiPartCxfServerTest-context.xml b/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/MultiPartCxfServerTest-context.xml
deleted file mode 100644
index cf15528..0000000
--- a/components/camel-soap/src/test/resources/org/apache/camel/dataformat/soap/MultiPartCxfServerTest-context.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xmlns:customer="http://multipart.customerservice.example.com/"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
- http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <import resource="classpath:META-INF/cxf/cxf.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-camel.xml" />
-
- <bean id="serviceImpl" class="org.apache.camel.dataformat.soap.MultiPartCustomerServiceImpl"/>
-
- <jaxws:endpoint id="multiPartCustomerServiceEndpoint"
- serviceName="customer:MultiPartCustomerServiceService"
- endpointName="customer:MultiPartCustomerServicePort"
- address="camel://direct:cxfEndpoint"
- implementor="#serviceImpl"
- />
-
- <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
- <routeBuilder ref="testClass" />
- </camelContext>
-
- <bean id="testClass" class="org.apache.camel.dataformat.soap.MultiPartCxfServerTest"/>
-
-</beans>
[camel] 10/38: CAMEL-13421: Remove BeanInvocation from camel-bean
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3082c33ff47bb233dec259e540242b7d3e548fe1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 09:57:55 2019 +0200
CAMEL-13421: Remove BeanInvocation from camel-bean
---
.../apache/camel/builder/ExpressionBuilder.java | 74 -------------
.../org/apache/camel/builder/ProxyBuilder.java | 17 ---
.../component/bean/AbstractBeanProcessor.java | 37 -------
.../bean/AbstractCamelInvocationHandler.java | 12 ++-
.../apache/camel/component/bean/BeanConverter.java | 65 ------------
.../camel/component/bean/BeanInvocation.java | 118 ---------------------
.../bean/BeanInvocationSerializeTest.java | 66 ------------
.../component/bean/BeanProxyNoBindingTest.java | 6 +-
.../component/bean/MyAuditServiceProxyTest.java | 3 +-
9 files changed, 12 insertions(+), 386 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index ebbe476..cda166d 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -37,19 +37,14 @@ import java.util.regex.Pattern;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelExecutionException;
-import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.InvalidPayloadException;
import org.apache.camel.Message;
-import org.apache.camel.NoSuchEndpointException;
import org.apache.camel.NoSuchLanguageException;
import org.apache.camel.NoTypeConversionAvailableException;
-import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.language.bean.BeanLanguage;
import org.apache.camel.language.simple.SimpleLanguage;
import org.apache.camel.model.language.MethodCallExpression;
import org.apache.camel.spi.ExchangeFormatter;
@@ -1269,17 +1264,6 @@ public final class ExpressionBuilder {
if (exchange.getIn().getBody() == null) {
return null;
}
-
- // if its a bean invocation then if it has no arguments then it should be threaded as null body allowed
- if (exchange.getIn().getBody() instanceof BeanInvocation) {
- // BeanInvocation would be stored directly as the message body
- // do not force any type conversion attempts as it would just be unnecessary and cost a bit performance
- // so a regular instanceof check is sufficient
- BeanInvocation bi = (BeanInvocation) exchange.getIn().getBody();
- if (bi.getArgs() == null || bi.getArgs().length == 0 || bi.getArgs()[0] == null) {
- return null;
- }
- }
}
try {
@@ -2023,64 +2007,6 @@ public final class ExpressionBuilder {
};
}
- @Deprecated
- public static Expression beanExpression(final Class<?> beanType, final String methodName) {
- return BeanLanguage.bean(beanType, methodName);
- }
-
- @Deprecated
- public static Expression beanExpression(final Object bean, final String methodName) {
- return BeanLanguage.bean(bean, methodName);
- }
-
- @Deprecated
- public static Expression beanExpression(final String beanRef, final String methodName) {
- String expression = methodName != null ? beanRef + "." + methodName : beanRef;
- return beanExpression(expression);
- }
-
- /**
- * Returns an expression processing the exchange to the given endpoint uri
- *
- * @param uri endpoint uri to send the exchange to
- * @return an expression object which will return the OUT body
- * @deprecated not in use, and not available in XML DSL
- */
- @Deprecated
- public static Expression toExpression(final String uri) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(uri).evaluate(exchange, String.class);
- Endpoint endpoint = exchange.getContext().getEndpoint(text);
- if (endpoint == null) {
- throw new NoSuchEndpointException(text);
- }
-
- Producer producer;
- try {
- producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
-
- // return the OUT body, but check for exchange pattern
- if (ExchangeHelper.isOutCapable(exchange)) {
- return exchange.getOut().getBody();
- } else {
- return exchange.getIn().getBody();
- }
- }
-
- @Override
- public String toString() {
- return "to(" + uri + ")";
- }
- };
- }
-
public static Expression fileNameExpression() {
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java
index 8ad7a60..13e874a 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ProxyBuilder.java
@@ -57,23 +57,6 @@ public final class ProxyBuilder {
}
/**
- * Whether to use binding or not.
- * <p/>
- * Binding is enabled by default. Set this to <tt>false</tt> to use old behavior without binding.
- * <p/>
- * If binding is enabled then Camel will bind the method parameters to the input {@link org.apache.camel.Message}
- * on the {@link org.apache.camel.Exchange} when invoking the proxy.
- *
- * @param binding <tt>true</tt> to use binding, <tt>false</tt> to use the old behavior with using a {@link org.apache.camel.component.bean.BeanInvocation}
- * as a provisional message body
- * @return the builder
- */
- public ProxyBuilder binding(boolean binding) {
- this.binding = binding;
- return this;
- }
-
- /**
* Builds the proxy.
*
* @param interfaceClass the service interface
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java b/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
index e7781e9..2bf8b63 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java
@@ -118,43 +118,6 @@ public abstract class AbstractBeanProcessor extends AsyncProcessorSupport {
Message in = exchange.getIn();
- // is the message proxied using a BeanInvocation?
- BeanInvocation beanInvoke = null;
- if (in.getBody() instanceof BeanInvocation) {
- // BeanInvocation would be stored directly as the message body
- // do not force any type conversion attempts as it would just be unnecessary and cost a bit performance
- // so a regular instanceof check is sufficient
- beanInvoke = (BeanInvocation) in.getBody();
- }
- if (beanInvoke != null) {
- // Now it gets a bit complicated as ProxyHelper can proxy beans which we later
- // intend to invoke (for example to proxy and invoke using spring remoting).
- // and therefore the message body contains a BeanInvocation object.
- // However this can causes problem if we in a Camel route invokes another bean,
- // so we must test whether BeanHolder and BeanInvocation is the same bean or not
- if (log.isTraceEnabled()) {
- log.trace("Exchange IN body is a BeanInvocation instance: {}", beanInvoke);
- }
- Class<?> clazz = beanInvoke.getMethod().getDeclaringClass();
- boolean sameBean = clazz.isInstance(bean);
- if (log.isDebugEnabled()) {
- log.debug("BeanHolder bean: {} and beanInvocation bean: {} is same instance: {}", bean.getClass(), clazz, sameBean);
- }
- if (sameBean) {
- try {
- beanInvoke.invoke(bean, exchange);
- if (exchange.hasOut()) {
- // propagate headers
- exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
- }
- } catch (Throwable e) {
- exchange.setException(e);
- }
- callback.done(true);
- return true;
- }
- }
-
// set explicit method name to invoke as a header, which is how BeanInfo can detect it
if (explicitMethodName != null) {
in.setHeader(Exchange.BEAN_METHOD_NAME, explicitMethodName);
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java b/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
index 6f9b178..ec92342 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/bean/AbstractCamelInvocationHandler.java
@@ -159,15 +159,19 @@ public abstract class AbstractCamelInvocationHandler implements InvocationHandle
index++;
}
} else {
- // no binding so use the old behavior with BeanInvocation as the body
- BeanInvocation invocation = new BeanInvocation(method, args);
- exchange.getIn().setBody(invocation);
+ if (args != null) {
+ if (args.length == 1) {
+ exchange.getIn().setBody(args[0]);
+ } else {
+ exchange.getIn().setBody(args);
+ }
+ }
}
if (binding) {
LOG.trace("Binding to service interface as @Body,@Header,@ExchangeProperty detected when calling proxy method: {}", method);
} else {
- LOG.trace("No binding to service interface as @Body,@Header,@ExchangeProperty not detected. Using BeanInvocation as message body when calling proxy method: {}", method);
+ LOG.trace("No binding to service interface as @Body,@Header,@ExchangeProperty not detected when calling proxy method: {}", method);
}
return doInvoke(method, exchange);
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanConverter.java b/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanConverter.java
deleted file mode 100644
index c4f0227..0000000
--- a/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanConverter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.bean;
-
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.TypeConverter;
-import org.apache.camel.spi.TypeConverterRegistry;
-
-import static org.apache.camel.TypeConverter.MISS_VALUE;
-
-/**
- * A set of converter methods for working with beans
- */
-@Converter(loader = true)
-public final class BeanConverter {
-
- private BeanConverter() {
- // Helper Class
- }
-
- @Converter(fallback = true)
- public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
- // use a fallback type converter so we can convert the embedded body if the value is BeanInvocation
- if (BeanInvocation.class.isAssignableFrom(value.getClass())) {
-
- BeanInvocation bi = (BeanInvocation) value;
- if (bi.getArgs() == null || bi.getArgs().length != 1) {
- // not possible to convert at this time as we try to convert the data passed in at first argument
- return MISS_VALUE;
- }
-
- Class<?> from = bi.getArgs()[0].getClass();
- Object body = bi.getArgs()[0];
-
- // maybe from is already the type we want
- if (type.isAssignableFrom(from)) {
- return body;
- }
-
- // no then try to lookup a type converter
- TypeConverter tc = registry.lookup(type, from);
- if (tc != null) {
- return tc.convertTo(type, exchange, body);
- }
- }
-
- return null;
- }
-
-}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanInvocation.java b/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanInvocation.java
deleted file mode 100644
index de37421..0000000
--- a/core/camel-core/src/main/java/org/apache/camel/component/bean/BeanInvocation.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.bean;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.impl.converter.ToStringTypeConverter;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Invocation of beans that can handle being serialized.
- */
-public class BeanInvocation implements Externalizable {
- private static final Logger LOG = LoggerFactory.getLogger(BeanInvocation.class);
- private Object[] args;
- private MethodBean methodBean;
- private transient Method method;
-
- static {
- ToStringTypeConverter.registerMissType(BeanInvocation.class);
- }
-
- public BeanInvocation() {
- }
-
- public BeanInvocation(Method method, Object[] args) {
- this.method = method;
- this.args = args;
- }
-
- @Override
- public String toString() {
- Object list = null;
- if (args != null) {
- list = Arrays.asList(args);
- }
- return "BeanInvocation " + method + " with " + list + "]";
- }
-
- public Object[] getArgs() {
- return args;
- }
-
- public Method getMethod() {
- return method;
- }
-
- public void setMethod(Method method) {
- this.method = method;
- }
-
- public void setArgs(Object[] args) {
- this.args = args;
- }
-
- /**
- * This causes us to invoke the endpoint Pojo using reflection.
- *
- * @param pojo the bean on which to perform this invocation
- * @param exchange the exchange carrying the method invocation
- */
- public void invoke(Object pojo, Exchange exchange) {
- try {
- Method method = getMethod();
- Object[] args = getArgs();
- LOG.trace("Invoking method: {} with args: {}", method, args);
- Object response = org.apache.camel.support.ObjectHelper.invokeMethodSafe(method, pojo, args);
- LOG.trace("Got response: {}", response);
- exchange.getOut().setBody(response);
- } catch (InvocationTargetException e) {
- exchange.setException(RuntimeCamelException.wrapRuntimeCamelException(e.getCause()));
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
- methodBean = ObjectHelper.cast(MethodBean.class, objectInput.readObject());
- try {
- method = methodBean.getMethod();
- } catch (NoSuchMethodException e) {
- throw new IOException(e);
- }
- args = ObjectHelper.cast(Object[].class, objectInput.readObject());
- }
-
- public void writeExternal(ObjectOutput objectOutput) throws IOException {
- if (methodBean == null) {
- methodBean = new MethodBean(method);
- }
- objectOutput.writeObject(methodBean);
- objectOutput.writeObject(args);
- }
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvocationSerializeTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvocationSerializeTest.java
deleted file mode 100644
index 74518ff..0000000
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanInvocationSerializeTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.bean;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Method;
-
-import org.apache.camel.TestSupport;
-import org.junit.Test;
-
-public class BeanInvocationSerializeTest extends TestSupport {
-
- @Test
- public void testSerialize() throws Exception {
- Method method = getClass().getMethod("cheese", String.class, String.class);
- BeanInvocation invocation = new BeanInvocation(method, new Object[] {"a", "b"});
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(buffer);
- out.writeObject(invocation);
- out.close();
-
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
- Object object = in.readObject();
- BeanInvocation actual = assertIsInstanceOf(BeanInvocation.class, object);
- log.debug("Received " + actual);
- }
-
- @Test
- public void testSerializeCtr() throws Exception {
- Method method = getClass().getMethod("cheese", String.class, String.class);
- BeanInvocation invocation = new BeanInvocation();
- invocation.setArgs(new Object[] {"a", "b"});
- invocation.setMethod(method);
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(buffer);
- out.writeObject(invocation);
- out.close();
-
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
- Object object = in.readObject();
- BeanInvocation actual = assertIsInstanceOf(BeanInvocation.class, object);
- log.debug("Received " + actual);
- }
-
- public void cheese(String a, String b) {
- log.debug("Called with a: {} b: {}", a, b);
- }
-
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyNoBindingTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyNoBindingTest.java
index d00e091..4b206d7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyNoBindingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanProxyNoBindingTest.java
@@ -133,7 +133,7 @@ public class BeanProxyNoBindingTest extends ContextTestSupport {
@Test
public void testProxyBuilderProxyCallAnotherBean() throws Exception {
// use ProxyBuilder to easily create the proxy
- OrderService service = new ProxyBuilder(context).endpoint("direct:bean").binding(false).build(OrderService.class);
+ OrderService service = new ProxyBuilder(context).endpoint("direct:bean").build(OrderService.class);
String reply = service.submitOrderStringReturnString("World");
assertEquals("Hello World", reply);
@@ -152,7 +152,7 @@ public class BeanProxyNoBindingTest extends ContextTestSupport {
@Test
public void testProxyBuilderProxyCallAnotherBeanWithNoArgs() throws Exception {
Endpoint endpoint = context.getEndpoint("direct:bean");
- OrderService service = new ProxyBuilder(context).endpoint(endpoint).binding(false).build(OrderService.class);
+ OrderService service = new ProxyBuilder(context).endpoint(endpoint).build(OrderService.class);
String reply = service.doAbsolutelyNothing();
assertEquals("Hi nobody", reply);
@@ -174,7 +174,7 @@ public class BeanProxyNoBindingTest extends ContextTestSupport {
@Test
public void testProxyBuilderVoidAsInOut() throws Exception {
// will by default let all exchanges be InOut
- OrderService service = new ProxyBuilder(context).endpoint("seda:delay").binding(false).build(OrderService.class);
+ OrderService service = new ProxyBuilder(context).endpoint("seda:delay").build(OrderService.class);
getMockEndpoint("mock:delay").expectedBodiesReceived("Hello World", "Bye World");
service.doNothing("Hello World");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/MyAuditServiceProxyTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/MyAuditServiceProxyTest.java
index 02f233b..2ef3090 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/MyAuditServiceProxyTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/MyAuditServiceProxyTest.java
@@ -28,8 +28,7 @@ public class MyAuditServiceProxyTest extends ContextTestSupport {
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:result").expectedHeaderReceived("uuid", "1234");
- // must enable binding on proxy
- MyAuditService service = new ProxyBuilder(context).endpoint("direct:proxy").binding(true).build(MyAuditService.class);
+ MyAuditService service = new ProxyBuilder(context).endpoint("direct:proxy").build(MyAuditService.class);
service.auditMessage("1234", "Hello World");
[camel] 24/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f4f0c7672467b7cbc0587a2917f0562c52050aad
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 15:56:23 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../apache/camel/builder/ExpressionBuilder.java | 1548 +-------------------
.../org/apache/camel/builder/PredicateBuilder.java | 524 +------
.../camel/component/mock/MockValueBuilder.java | 26 +-
.../support}/builder/BinaryPredicateSupport.java | 2 +-
.../camel/support}/builder/ExpressionBuilder.java | 44 +-
.../camel/support}/builder/PredicateBuilder.java | 11 +-
6 files changed, 12 insertions(+), 2143 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index ed3f8691..f8eb0cd 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -16,47 +16,13 @@
*/
package org.apache.camel.builder;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.regex.Pattern;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.Exchange;
import org.apache.camel.Expression;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.NoSuchLanguageException;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.spi.Language;
-import org.apache.camel.spi.PropertiesComponent;
-import org.apache.camel.spi.RouteContext;
-import org.apache.camel.spi.UnitOfWork;
-import org.apache.camel.support.ExchangeHelper;
-import org.apache.camel.support.ExpressionAdapter;
-import org.apache.camel.support.GroupIterator;
-import org.apache.camel.support.GroupTokenIterator;
-import org.apache.camel.support.LanguageSupport;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.Scanner;
import org.apache.camel.util.StringHelper;
/**
* A helper class for working with <a href="http://camel.apache.org/expression.html">expressions</a>.
*/
-public final class ExpressionBuilder {
-
- // TODO: Make this possible to have a base class in camel-support, and then extend it here, so we can have both
- // and maybe deprecate this and refer to the builder in camel-support
+public final class ExpressionBuilder extends org.apache.camel.support.builder.ExpressionBuilder {
/**
* Utility classes should not have a public constructor.
@@ -65,1157 +31,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns an expression for the inbound message attachments
- *
- * @return an expression object which will return the inbound message attachments
- */
- public static Expression attachmentObjectsExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getAttachmentObjects();
- }
-
- @Override
- public String toString() {
- return "attachmentObjects";
- }
- };
- }
-
- /**
- * Returns an expression for the inbound message attachments
- *
- * @return an expression object which will return the inbound message attachments
- */
- public static Expression attachmentObjectValuesExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getAttachmentObjects().values();
- }
-
- @Override
- public String toString() {
- return "attachmentObjects";
- }
- };
- }
-
- /**
- * Returns an expression for the inbound message attachments
- *
- * @return an expression object which will return the inbound message attachments
- */
- public static Expression attachmentsExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getAttachments();
- }
-
- @Override
- public String toString() {
- return "attachments";
- }
- };
- }
-
- /**
- * Returns an expression for the inbound message attachments
- *
- * @return an expression object which will return the inbound message attachments
- */
- public static Expression attachmentValuesExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getAttachments().values();
- }
-
- @Override
- public String toString() {
- return "attachments";
- }
- };
- }
-
- /**
- * Returns an expression for the header value with the given name
- * <p/>
- * Will fallback and look in properties if not found in headers.
- *
- * @param headerName the name of the header the expression will return
- * @return an expression object which will return the header value
- */
- public static Expression headerExpression(final String headerName) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = simpleExpression(headerName).evaluate(exchange, String.class);
- Object header = exchange.getIn().getHeader(name);
- if (header == null) {
- // fall back on a property
- header = exchange.getProperty(name);
- }
- return header;
- }
-
- @Override
- public String toString() {
- return "header(" + headerName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the header value with the given name converted to the given type
- * <p/>
- * Will fallback and look in properties if not found in headers.
- *
- * @param headerName the name of the header the expression will return
- * @param type the type to convert to
- * @return an expression object which will return the header value
- */
- public static <T> Expression headerExpression(final String headerName, final Class<T> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String name = simpleExpression(headerName).evaluate(exchange, String.class);
- Object header = exchange.getIn().getHeader(name, type);
- if (header == null) {
- // fall back on a property
- header = exchange.getProperty(name, type);
- }
- return header;
- }
-
- @Override
- public String toString() {
- return "headerAs(" + headerName + ", " + type + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the header value with the given name converted to the given type
- * <p/>
- * Will fallback and look in properties if not found in headers.
- *
- * @param headerName the name of the header the expression will return
- * @param typeName the type to convert to as a FQN class name
- * @return an expression object which will return the header value
- */
- public static Expression headerExpression(final String headerName, final String typeName) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Class<?> type;
- try {
- String text = simpleExpression(typeName).evaluate(exchange, String.class);
- type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
- } catch (ClassNotFoundException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
-
- String text = simpleExpression(headerName).evaluate(exchange, String.class);
- Object header = exchange.getIn().getHeader(text, type);
- if (header == null) {
- // fall back on a property
- header = exchange.getProperty(text, type);
- }
- return header;
- }
-
- @Override
- public String toString() {
- return "headerAs(" + headerName + ", " + typeName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the inbound message headers
- *
- * @return an expression object which will return the inbound headers
- */
- public static Expression headersExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getHeaders();
- }
-
- @Override
- public String toString() {
- return "headers";
- }
- };
- }
-
- /**
- * Returns an expression for the out header value with the given name
- * <p/>
- * Will fallback and look in properties if not found in headers.
- *
- * @param headerName the name of the header the expression will return
- * @return an expression object which will return the header value
- */
- public static Expression outHeaderExpression(final String headerName) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (!exchange.hasOut()) {
- return null;
- }
-
- String text = simpleExpression(headerName).evaluate(exchange, String.class);
- Message out = exchange.getOut();
- Object header = out.getHeader(text);
- if (header == null) {
- // let's try the exchange header
- header = exchange.getProperty(text);
- }
- return header;
- }
-
- @Override
- public String toString() {
- return "outHeader(" + headerName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the outbound message headers
- *
- * @return an expression object which will return the headers, will be <tt>null</tt> if the
- * exchange is not out capable.
- */
- public static Expression outHeadersExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // only get out headers if the MEP is out capable
- if (ExchangeHelper.isOutCapable(exchange)) {
- return exchange.getOut().getHeaders();
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "outHeaders";
- }
- };
- }
-
- /**
- * Returns an expression for the exchange pattern
- *
- * @see org.apache.camel.Exchange#getPattern()
- * @return an expression object which will return the exchange pattern
- */
- public static Expression exchangePatternExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getPattern();
- }
-
- @Override
- public String toString() {
- return "exchangePattern";
- }
- };
- }
-
- /**
- * Returns an expression for an exception set on the exchange
- *
- * @see Exchange#getException()
- * @return an expression object which will return the exception set on the exchange
- */
- public static Expression exchangeExceptionExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Exception exception = exchange.getException();
- if (exception == null) {
- exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
- }
- return exception;
- }
-
- @Override
- public String toString() {
- return "exchangeException";
- }
- };
- }
-
- /**
- * Returns an expression for an exception set on the exchange
- * <p/>
- * Is used to get the caused exception that typically have been wrapped in some sort
- * of Camel wrapper exception
- * @param type the exception type
- * @see Exchange#getException(Class)
- * @return an expression object which will return the exception set on the exchange
- */
- public static Expression exchangeExceptionExpression(final Class<Exception> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Exception exception = exchange.getException(type);
- if (exception == null) {
- exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
- return ObjectHelper.getException(type, exception);
- }
- return exception;
- }
-
- @Override
- public String toString() {
- return "exchangeException[" + type + "]";
- }
- };
- }
-
- /**
- * Returns an expression for the type converter
- *
- * @return an expression object which will return the type converter
- */
- public static Expression typeConverterExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getContext().getTypeConverter();
- }
-
- @Override
- public String toString() {
- return "typeConverter";
- }
- };
- }
-
- /**
- * Returns an expression for the {@link org.apache.camel.spi.Registry}
- *
- * @return an expression object which will return the registry
- */
- public static Expression registryExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getContext().getRegistry();
- }
-
- @Override
- public String toString() {
- return "registry";
- }
- };
- }
-
- /**
- * Returns an expression for lookup a bean in the {@link org.apache.camel.spi.Registry}
- *
- * @return an expression object which will return the bean
- */
- public static Expression refExpression(final String ref) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(ref).evaluate(exchange, String.class);
- return exchange.getContext().getRegistry().lookupByName(text);
- }
-
- @Override
- public String toString() {
- return "ref(" + ref + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the {@link org.apache.camel.CamelContext}
- *
- * @return an expression object which will return the camel context
- */
- public static Expression camelContextExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getContext();
- }
-
- @Override
- public String toString() {
- return "camelContext";
- }
- };
- }
-
- /**
- * Returns an expression for the {@link org.apache.camel.CamelContext} name
- *
- * @return an expression object which will return the camel context name
- */
- public static Expression camelContextNameExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getContext().getName();
- }
-
- @Override
- public String toString() {
- return "camelContextName";
- }
- };
- }
-
- /**
- * Returns an expression for an exception message set on the exchange
- *
- * @return an expression object which will return the exception message set on the exchange
- */
- public static Expression exchangeExceptionMessageExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Exception exception = exchange.getException();
- if (exception == null) {
- exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
- }
- return exception != null ? exception.getMessage() : null;
- }
-
- @Override
- public String toString() {
- return "exchangeExceptionMessage";
- }
- };
- }
-
- /**
- * Returns an expression for an exception stacktrace set on the exchange
- *
- * @return an expression object which will return the exception stacktrace set on the exchange
- */
- public static Expression exchangeExceptionStackTraceExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Exception exception = exchange.getException();
- if (exception == null) {
- exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
- }
- if (exception != null) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- exception.printStackTrace(pw);
- IOHelper.close(pw, sw);
- return sw.toString();
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "exchangeExceptionStackTrace";
- }
- };
- }
-
- /**
- * Returns an expression for the property value of exchange with the given name
- *
- * @param propertyName the name of the property the expression will return
- * @return an expression object which will return the property value
- */
- public static Expression exchangePropertyExpression(final String propertyName) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(propertyName).evaluate(exchange, String.class);
- return exchange.getProperty(text);
- }
-
- @Override
- public String toString() {
- return "exchangeProperty(" + propertyName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the exchange properties of exchange
- *
- * @return an expression object which will return the exchange properties
- */
- public static Expression exchangePropertiesExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getProperties();
- }
-
- @Override
- public String toString() {
- return "exchangeProperties";
- }
- };
- }
-
- /**
- * Returns an expression for the properties of the camel context
- *
- * @return an expression object which will return the properties
- */
- public static Expression camelContextPropertiesExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getContext().getGlobalOptions();
- }
-
- @Override
- public String toString() {
- return "camelContextProperties";
- }
- };
- }
-
- /**
- * Returns an expression for the property value of the camel context with the given name
- *
- * @param propertyName the name of the property the expression will return
- * @return an expression object which will return the property value
- */
- public static Expression camelContextPropertyExpression(final String propertyName) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(propertyName).evaluate(exchange, String.class);
- return exchange.getContext().getGlobalOption(text);
- }
-
- @Override
- public String toString() {
- return "camelContextProperty(" + propertyName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for a system property value with the given name
- *
- * @param propertyName the name of the system property the expression will return
- * @return an expression object which will return the system property value
- */
- public static Expression systemPropertyExpression(final String propertyName) {
- return systemPropertyExpression(propertyName, null);
- }
-
- /**
- * Returns an expression for a system property value with the given name
- *
- * @param propertyName the name of the system property the expression will return
- * @param defaultValue default value to return if no system property exists
- * @return an expression object which will return the system property value
- */
- public static Expression systemPropertyExpression(final String propertyName,
- final String defaultValue) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(propertyName).evaluate(exchange, String.class);
- String text2 = simpleExpression(defaultValue).evaluate(exchange, String.class);
- return System.getProperty(text, text2);
- }
-
- @Override
- public String toString() {
- return "systemProperty(" + propertyName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for a system environment value with the given name
- *
- * @param propertyName the name of the system environment the expression will return
- * @return an expression object which will return the system property value
- */
- public static Expression systemEnvironmentExpression(final String propertyName) {
- return systemEnvironmentExpression(propertyName, null);
- }
-
- /**
- * Returns an expression for a system environment value with the given name
- *
- * @param propertyName the name of the system environment the expression will return
- * @param defaultValue default value to return if no system environment exists
- * @return an expression object which will return the system environment value
- */
- public static Expression systemEnvironmentExpression(final String propertyName,
- final String defaultValue) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(propertyName).evaluate(exchange, String.class);
- String answer = null;
- if (text != null) {
- // lookup OS env with upper case key
- text = text.toUpperCase();
- answer = System.getenv(text);
- // some OS do not support dashes in keys, so replace with underscore
- if (answer == null) {
- String noDashKey = text.replace('-', '_');
- answer = System.getenv(noDashKey);
- }
- }
-
- if (answer == null) {
- answer = simpleExpression(defaultValue).evaluate(exchange, String.class);
- }
- return answer;
- }
-
- @Override
- public String toString() {
- return "systemEnvironment(" + propertyName + ")";
- }
- };
- }
-
- /**
- * Returns an expression for the constant value
- *
- * @param value the value the expression will return
- * @return an expression object which will return the constant value
- */
- public static Expression constantExpression(final Object value) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return value;
- }
-
- @Override
- public String toString() {
- return "" + value;
- }
- };
- }
-
- /**
- * Returns an expression for evaluating the expression/predicate using the given language
- *
- * @param expression the expression or predicate
- * @return an expression object which will evaluate the expression/predicate using the given language
- */
- public static Expression languageExpression(final String language, final String expression) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Language lan = exchange.getContext().resolveLanguage(language);
- if (lan != null) {
- return lan.createExpression(expression).evaluate(exchange, Object.class);
- } else {
- throw new NoSuchLanguageException(language);
- }
- }
-
- @Override
- public boolean matches(Exchange exchange) {
- Language lan = exchange.getContext().resolveLanguage(language);
- if (lan != null) {
- return lan.createPredicate(expression).matches(exchange);
- } else {
- throw new NoSuchLanguageException(language);
- }
- }
-
- @Override
- public String toString() {
- return "language[" + language + ":" + expression + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body
- */
- public static Expression bodyExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getBody();
- }
-
- @Override
- public String toString() {
- return "body";
- }
- };
- }
-
- /**
- * Returns a functional expression for the exchanges inbound message body
- */
- public static Expression bodyExpression(final Function<Object, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(
- exchange.getIn().getBody()
- );
- }
-
- @Override
- public String toString() {
- return "bodyExpression";
- }
- };
- }
-
- /**
- * Returns a functional expression for the exchanges inbound message body and headers
- */
- public static Expression bodyExpression(final BiFunction<Object, Map<String, Object>, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(
- exchange.getIn().getBody(),
- exchange.getIn().getHeaders()
- );
- }
-
- @Override
- public String toString() {
- return "bodyExpression";
- }
- };
- }
-
- /**
- * Returns a functional expression for the exchanges inbound message body converted to a desired type
- */
- public static <T> Expression bodyExpression(final Class<T> bodyType, final Function<T, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(
- exchange.getIn().getBody(bodyType)
- );
- }
-
- @Override
- public String toString() {
- return "bodyExpression (" + bodyType + ")";
- }
- };
- }
-
- /**
- * Returns a functional expression for the exchanges inbound message body converted to a desired type and headers
- */
- public static <T> Expression bodyExpression(final Class<T> bodyType, final BiFunction<T, Map<String, Object>, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(
- exchange.getIn().getBody(bodyType),
- exchange.getIn().getHeaders()
- );
- }
-
- @Override
- public String toString() {
- return "bodyExpression (" + bodyType + ")";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type
- */
- public static <T> Expression bodyExpression(final Class<T> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getBody(type);
- }
-
- @Override
- public String toString() {
- return "bodyAs[" + type.getName() + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type
- */
- public static Expression bodyExpression(final String name) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(name).evaluate(exchange, String.class);
- Class<?> type;
- try {
- type = exchange.getContext().getClassResolver().resolveMandatoryClass(text);
- } catch (ClassNotFoundException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- return exchange.getIn().getBody(type);
- }
-
- @Override
- public String toString() {
- return "bodyAs[" + name + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the current thread name
- */
- public static Expression threadNameExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return Thread.currentThread().getName();
- }
-
- @Override
- public String toString() {
- return "threadName";
- }
- };
- }
-
- /**
- * Returns the expression for the current step id (if any)
- */
- public static Expression stepIdExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getProperty(Exchange.STEP_ID);
- }
-
- @Override
- public String toString() {
- return "stepId";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type.
- * <p/>
- * Does <b>not</b> allow null bodies.
- */
- public static <T> Expression mandatoryBodyExpression(final Class<T> type) {
- return mandatoryBodyExpression(type, false);
- }
-
- /**
- * Returns the expression for the exchanges inbound message body converted
- * to the given type
- *
- * @param type the type
- * @param nullBodyAllowed whether null bodies is allowed and if so a null is returned,
- * otherwise an exception is thrown
- */
- public static <T> Expression mandatoryBodyExpression(final Class<T> type, final boolean nullBodyAllowed) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (nullBodyAllowed) {
- if (exchange.getIn().getBody() == null) {
- return null;
- }
- }
-
- try {
- return exchange.getIn().getMandatoryBody(type);
- } catch (InvalidPayloadException e) {
- throw CamelExecutionException.wrapCamelExecutionException(exchange, e);
- }
- }
-
- @Override
- public String toString() {
- return "mandatoryBodyAs[" + type.getName() + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges inbound message body type
- */
- public static Expression bodyTypeExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getBody().getClass();
- }
-
- @Override
- public String toString() {
- return "bodyType";
- }
- };
- }
-
- /**
- * Returns the expression for the out messages body
- */
- public static Expression outBodyExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (exchange.hasOut()) {
- return exchange.getOut().getBody();
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "outBody";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges outbound message body converted
- * to the given type
- */
- public static <T> Expression outBodyExpression(final Class<T> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (exchange.hasOut()) {
- return exchange.getOut().getBody(type);
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "outBodyAs[" + type.getName() + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the fault messages body
- */
- public static Expression faultBodyExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
- return msg.isFault() ? msg.getBody() : null;
- }
-
- @Override
- public String toString() {
- return "faultBody";
- }
- };
- }
-
- /**
- * Returns the expression for the exchanges fault message body converted
- * to the given type
- */
- public static <T> Expression faultBodyExpression(final Class<T> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
- return msg.isFault() ? msg.getBody(type) : null;
- }
-
- @Override
- public String toString() {
- return "faultBodyAs[" + type.getName() + "]";
- }
- };
- }
-
- /**
- * Returns the expression for the exchange
- */
- public static Expression exchangeExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange;
- }
-
- @Override
- public String toString() {
- return "exchange";
- }
- };
- }
-
- /**
- * Returns a functional expression for the exchange
- */
- public static Expression exchangeExpression(final Function<Exchange, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(exchange);
- }
-
- @Override
- public String toString() {
- return "exchangeExpression";
- }
- };
- }
-
- /**
- * Returns the expression for the IN message
- */
- public static Expression messageExpression() {
- return inMessageExpression();
- }
-
- /**
- * Returns a functional expression for the IN message
- */
- public static Expression messageExpression(final Function<Message, Object> function) {
- return inMessageExpression(function);
- }
-
- /**
- * Returns the expression for the IN message
- */
- public static Expression inMessageExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn();
- }
-
- @Override
- public String toString() {
- return "inMessage";
- }
- };
- }
-
- /**
- * Returns a functional expression for the IN message
- */
- public static Expression inMessageExpression(final Function<Message, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(exchange.getIn());
- }
-
- @Override
- public String toString() {
- return "inMessageExpression";
- }
- };
- }
-
- /**
- * Returns the expression for the OUT message
- */
- public static Expression outMessageExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getOut();
- }
-
- @Override
- public String toString() {
- return "outMessage";
- }
- };
- }
-
- /**
- * Returns a functional expression for the OUT message
- */
- public static Expression outMessageExpression(final Function<Message, Object> function) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return function.apply(exchange.getOut());
- }
-
- @Override
- public String toString() {
- return "outMessageExpression";
- }
- };
- }
-
- /**
- * Returns an expression which converts the given expression to the given type
- */
- public static Expression convertToExpression(final Expression expression, final Class<?> type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (type != null) {
- return expression.evaluate(exchange, type);
- } else {
- return expression;
- }
- }
-
- @Override
- public String toString() {
- return "" + expression;
- }
- };
- }
-
- /**
- * Returns an expression which converts the given expression to the given type the type
- * expression is evaluated to
- */
- public static Expression convertToExpression(final Expression expression, final Expression type) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object result = type.evaluate(exchange, Object.class);
- if (result != null) {
- return expression.evaluate(exchange, result.getClass());
- } else {
- return expression;
- }
- }
-
- @Override
- public String toString() {
- return "" + expression;
- }
- };
- }
-
- /**
- * Returns a tokenize expression which will tokenize the string with the
- * given token
- */
- public static Expression tokenizeExpression(final Expression expression,
- final String token) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(token).evaluate(exchange, String.class);
- Object value = expression.evaluate(exchange, Object.class);
- Scanner scanner = ExchangeHelper.getScanner(exchange, value, text);
- return scanner;
- }
-
- @Override
- public String toString() {
- return "tokenize(" + expression + ", " + token + ")";
- }
- };
- }
-
- /**
- * Returns an expression that skips the first element
- */
- public static Expression skipFirstExpression(final Expression expression) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object value = expression.evaluate(exchange, Object.class);
- Iterator it = exchange.getContext().getTypeConverter().tryConvertTo(Iterator.class, exchange, value);
- if (it != null) {
- // skip first
- it.next();
- return it;
- } else {
- return value;
- }
- }
-
- @Override
- public String toString() {
- return "skipFirst(" + expression + ")";
- }
- };
- }
-
- /**
* Returns an {@link TokenPairExpressionIterator} expression
*/
public static Expression tokenizePairExpression(String startToken, String endToken, boolean includeTokens) {
@@ -1240,366 +55,5 @@ public final class ExpressionBuilder {
return new XMLTokenExpressionIterator(path, mode, group);
}
- /**
- * Returns a tokenize expression which will tokenize the string with the
- * given regex
- */
- public static Expression regexTokenizeExpression(final Expression expression,
- final String regexTokenizer) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object value = expression.evaluate(exchange, Object.class);
- Scanner scanner = ExchangeHelper.getScanner(exchange, value, regexTokenizer);
- return scanner;
- }
-
- @Override
- public String toString() {
- return "regexTokenize(" + expression + ", " + regexTokenizer + ")";
- }
- };
- }
-
- public static Expression groupXmlIteratorExpression(final Expression expression, final String group) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // evaluate expression as iterator
- Iterator<?> it = expression.evaluate(exchange, Iterator.class);
- ObjectHelper.notNull(it, "expression: " + expression + " evaluated on " + exchange + " must return an java.util.Iterator");
- // must use GroupTokenIterator in xml mode as we want to concat the xml parts into a single message
- // the group can be a simple expression so evaluate it as a number
- Integer parts = exchange.getContext().resolveLanguage("simple").createExpression(group).evaluate(exchange, Integer.class);
- if (parts == null) {
- throw new RuntimeExchangeException("Group evaluated as null, must be evaluated as a positive Integer value from expression: " + group, exchange);
- } else if (parts <= 0) {
- throw new RuntimeExchangeException("Group must be a positive number, was: " + parts, exchange);
- }
- return new GroupTokenIterator(exchange, it, null, parts, false);
- }
-
- @Override
- public String toString() {
- return "group " + expression + " " + group + " times";
- }
- };
- }
-
- public static Expression groupIteratorExpression(final Expression expression, final String token, final String group, final boolean skipFirst) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // evaluate expression as iterator
- Iterator<?> it = expression.evaluate(exchange, Iterator.class);
- ObjectHelper.notNull(it, "expression: " + expression + " evaluated on " + exchange + " must return an java.util.Iterator");
- // the group can be a simple expression so evaluate it as a number
- Integer parts = exchange.getContext().resolveLanguage("simple").createExpression(group).evaluate(exchange, Integer.class);
- if (parts == null) {
- throw new RuntimeExchangeException("Group evaluated as null, must be evaluated as a positive Integer value from expression: " + group, exchange);
- } else if (parts <= 0) {
- throw new RuntimeExchangeException("Group must be a positive number, was: " + parts, exchange);
- }
- if (token != null) {
- return new GroupTokenIterator(exchange, it, token, parts, skipFirst);
- } else {
- return new GroupIterator(exchange, it, parts, skipFirst);
- }
- }
-
- @Override
- public String toString() {
- return "group " + expression + " " + group + " times";
- }
- };
- }
-
- /**
- * Returns a sort expression which will sort the expression with the given comparator.
- * <p/>
- * The expression is evaluated as a {@link List} object to allow sorting.
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public static Expression sortExpression(final Expression expression, final Comparator comparator) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- List<?> list = expression.evaluate(exchange, List.class);
- list.sort(comparator);
- return list;
- }
-
- @Override
- public String toString() {
- return "sort(" + expression + " by: " + comparator + ")";
- }
- };
- }
-
- /**
- * Transforms the expression into a String then performs the regex
- * replaceAll to transform the String and return the result
- */
- public static Expression regexReplaceAll(final Expression expression,
- final String regex, final String replacement) {
- final Pattern pattern = Pattern.compile(regex);
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = expression.evaluate(exchange, String.class);
- if (text == null) {
- return null;
- }
- return pattern.matcher(text).replaceAll(replacement);
- }
-
- @Override
- public String toString() {
- return "regexReplaceAll(" + expression + ", " + pattern.pattern() + ")";
- }
- };
- }
-
- /**
- * Transforms the expression into a String then performs the regex
- * replaceAll to transform the String and return the result
- */
- public static Expression regexReplaceAll(final Expression expression,
- final String regex, final Expression replacementExpression) {
-
- final Pattern pattern = Pattern.compile(regex);
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = expression.evaluate(exchange, String.class);
- String replacement = replacementExpression.evaluate(exchange, String.class);
- if (text == null || replacement == null) {
- return null;
- }
- return pattern.matcher(text).replaceAll(replacement);
- }
-
- @Override
- public String toString() {
- return "regexReplaceAll(" + expression + ", " + pattern.pattern() + ")";
- }
- };
- }
-
- /**
- * Appends the String evaluations of the two expressions together
- */
- public static Expression append(final Expression left, final Expression right) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return left.evaluate(exchange, String.class) + right.evaluate(exchange, String.class);
- }
-
- @Override
- public String toString() {
- return "append(" + left + ", " + right + ")";
- }
- };
- }
-
- /**
- * Prepends the String evaluations of the two expressions together
- */
- public static Expression prepend(final Expression left, final Expression right) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return right.evaluate(exchange, String.class) + left.evaluate(exchange, String.class);
- }
-
- @Override
- public String toString() {
- return "prepend(" + left + ", " + right + ")";
- }
- };
- }
-
- /**
- * Returns an expression which returns the string concatenation value of the various
- * expressions
- *
- * @param expressions the expression to be concatenated dynamically
- * @return an expression which when evaluated will return the concatenated values
- */
- public static Expression concatExpression(final Collection<Expression> expressions) {
- return concatExpression(expressions, null);
- }
-
- /**
- * Returns an expression which returns the string concatenation value of the various
- * expressions
- *
- * @param expressions the expression to be concatenated dynamically
- * @param description the text description of the expression
- * @return an expression which when evaluated will return the concatenated values
- */
- public static Expression concatExpression(final Collection<Expression> expressions, final String description) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- StringBuilder buffer = new StringBuilder();
- for (Expression expression : expressions) {
- String text = expression.evaluate(exchange, String.class);
- if (text != null) {
- buffer.append(text);
- }
- }
- return buffer.toString();
- }
-
- @Override
- public String toString() {
- if (description != null) {
- return description;
- } else {
- return "concat" + expressions;
- }
- }
- };
- }
-
- /**
- * Returns an Expression for the inbound message id
- */
- public static Expression messageIdExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getIn().getMessageId();
- }
-
- @Override
- public String toString() {
- return "messageId";
- }
- };
- }
-
- /**
- * Returns an Expression for the exchange id
- */
- public static Expression exchangeIdExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- return exchange.getExchangeId();
- }
-
- @Override
- public String toString() {
- return "exchangeId";
- }
- };
- }
-
- /**
- * Returns an Expression for the route id
- */
- public static Expression routeIdExpression() {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String answer = null;
- UnitOfWork uow = exchange.getUnitOfWork();
- RouteContext rc = uow != null ? uow.getRouteContext() : null;
- if (rc != null) {
- answer = rc.getRoute().getId();
- }
- if (answer == null) {
- // fallback and get from route id on the exchange
- answer = exchange.getFromRouteId();
- }
- return answer;
- }
-
- @Override
- public String toString() {
- return "routeId";
- }
- };
- }
-
- public static Expression simpleExpression(final String expression) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- if (LanguageSupport.hasSimpleFunction(expression)) {
- // resolve language using context to have a clear separation of packages
- // must call evaluate to return the nested language evaluate when evaluating
- // stacked expressions
- Language language = exchange.getContext().resolveLanguage("simple");
- return language.createExpression(expression).evaluate(exchange, Object.class);
- } else {
- return expression;
- }
- }
-
- @Override
- public String toString() {
- return "simple(" + expression + ")";
- }
- };
- }
-
- public static Expression beanExpression(final String expression) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- // bean is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate expression as a string
- // resolve language using context to have a clear separation of packages
- // must call evaluate to return the nested language evaluate when evaluating
- // stacked expressions
- Language language = exchange.getContext().resolveLanguage("bean");
- return language.createExpression(expression).evaluate(exchange, Object.class);
- }
-
- @Override
- public String toString() {
- return "bean(" + expression + ")";
- }
- };
- }
-
- /**
- * Returns Simple expression or fallback to Constant expression if expression str is not Simple expression.
- */
- public static Expression parseSimpleOrFallbackToConstantExpression(String str, CamelContext camelContext) {
- if (StringHelper.hasStartToken(str, "simple")) {
- return camelContext.resolveLanguage("simple").createExpression(str);
- }
- return constantExpression(str);
- }
-
- public static Expression propertiesComponentExpression(final String key, final String locations, final String defaultValue) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- String text = simpleExpression(key).evaluate(exchange, String.class);
- String text2 = simpleExpression(locations).evaluate(exchange, String.class);
- try {
- if (text2 != null) {
- // the properties component is optional as we got locations
- // getComponent will create a new component if none already exists
- PropertiesComponent pc = exchange.getContext().getPropertiesComponent(true);
- // enclose key with {{ }} to force parsing
- String[] paths = text2.split(",");
- return pc.parseUri(pc.getPrefixToken() + text + pc.getSuffixToken(), paths);
- } else {
- // the properties component is mandatory if no locations provided
- PropertiesComponent pc = exchange.getContext().getPropertiesComponent(false);
- if (pc == null) {
- throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
- + " in CamelContext to support property placeholders in expressions");
- }
- // enclose key with {{ }} to force parsing
- return pc.parseUri(pc.getPrefixToken() + text + pc.getSuffixToken());
- }
- } catch (Exception e) {
- // property with key not found, use default value if provided
- if (defaultValue != null) {
- return defaultValue;
- }
- throw RuntimeCamelException.wrapRuntimeCamelException(e);
- }
- }
-
- @Override
- public String toString() {
- return "properties(" + key + ")";
- }
- };
- }
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
index eee830e..0b6dd01 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
@@ -16,23 +16,10 @@
*/
package org.apache.camel.builder;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.Predicate;
-import org.apache.camel.support.ExpressionToPredicateAdapter;
-import org.apache.camel.support.ObjectHelper;
-
-import static org.apache.camel.util.ObjectHelper.notNull;
-
/**
* A helper class for working with predicates
*/
-public final class PredicateBuilder {
+public final class PredicateBuilder extends org.apache.camel.support.builder.PredicateBuilder {
/**
* Utility classes should not have a public constructor.
@@ -40,513 +27,4 @@ public final class PredicateBuilder {
private PredicateBuilder() {
}
- /**
- * Converts the given expression into an {@link Predicate}
- */
- public static Predicate toPredicate(final Expression expression) {
- return ExpressionToPredicateAdapter.toPredicate(expression);
- }
-
- /**
- * A helper method to return the logical not of the given predicate
- */
- public static Predicate not(final Predicate predicate) {
- notNull(predicate, "predicate");
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- return !predicate.matches(exchange);
- }
-
- @Override
- public String toString() {
- return "not (" + predicate + ")";
- }
- };
- }
-
- /**
- * A helper method to combine multiple predicates by a logical AND
- */
- public static Predicate and(final Predicate left, final Predicate right) {
- notNull(left, "left");
- notNull(right, "right");
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- return left.matches(exchange) && right.matches(exchange);
- }
-
- @Override
- public String toString() {
- return "(" + left + ") and (" + right + ")";
- }
- };
- }
-
- /**
- * A helper method to combine two predicates by a logical OR.
- * If you want to combine multiple predicates see {@link #in(Predicate...)}
- */
- public static Predicate or(final Predicate left, final Predicate right) {
- notNull(left, "left");
- notNull(right, "right");
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- return left.matches(exchange) || right.matches(exchange);
- }
-
- @Override
- public String toString() {
- return "(" + left + ") or (" + right + ")";
- }
- };
- }
-
- /**
- * Concat the given predicates into a single predicate, which matches
- * if at least one predicates matches.
- *
- * @param predicates predicates
- * @return a single predicate containing all the predicates
- */
- public static Predicate or(List<Predicate> predicates) {
- Predicate answer = null;
- for (Predicate predicate : predicates) {
- if (answer == null) {
- answer = predicate;
- } else {
- answer = or(answer, predicate);
- }
- }
- return answer;
- }
-
- /**
- * Concat the given predicates into a single predicate, which matches
- * if at least one predicates matches.
- *
- * @param predicates predicates
- * @return a single predicate containing all the predicates
- */
- public static Predicate or(Predicate... predicates) {
- return or(Arrays.asList(predicates));
- }
-
- /**
- * A helper method to return true if any of the predicates matches.
- */
- public static Predicate in(final Predicate... predicates) {
- notNull(predicates, "predicates");
-
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- for (Predicate in : predicates) {
- if (in.matches(exchange)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "in (" + Arrays.asList(predicates) + ")";
- }
- };
- }
-
- /**
- * A helper method to return true if any of the predicates matches.
- */
- public static Predicate in(List<Predicate> predicates) {
- return in(predicates.toArray(new Predicate[0]));
- }
-
- public static Predicate isEqualTo(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceEquals(exchange.getContext().getTypeConverter(), leftValue, rightValue);
- }
-
- protected String getOperationText() {
- return "==";
- }
- };
- }
-
- public static Predicate isEqualToIgnoreCase(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceEquals(exchange.getContext().getTypeConverter(), leftValue, rightValue, true);
- }
-
- protected String getOperationText() {
- return "=~";
- }
- };
- }
-
- public static Predicate isNotEqualTo(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return false;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return true;
- }
-
- return ObjectHelper.typeCoerceNotEquals(exchange.getContext().getTypeConverter(), leftValue, rightValue);
- }
-
- protected String getOperationText() {
- return "!=";
- }
- };
- }
-
- public static Predicate isLessThan(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceCompare(exchange.getContext().getTypeConverter(), leftValue, rightValue) < 0;
- }
-
- protected String getOperationText() {
- return "<";
- }
- };
- }
-
- public static Predicate isLessThanOrEqualTo(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceCompare(exchange.getContext().getTypeConverter(), leftValue, rightValue) <= 0;
- }
-
- protected String getOperationText() {
- return "<=";
- }
- };
- }
-
- public static Predicate isGreaterThan(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return false;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceCompare(exchange.getContext().getTypeConverter(), leftValue, rightValue) > 0;
- }
-
- protected String getOperationText() {
- return ">";
- }
- };
- }
-
- public static Predicate isGreaterThanOrEqualTo(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.typeCoerceCompare(exchange.getContext().getTypeConverter(), leftValue, rightValue) >= 0;
- }
-
- protected String getOperationText() {
- return ">=";
- }
- };
- }
-
- public static Predicate contains(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.contains(leftValue, rightValue);
- }
-
- protected String getOperationText() {
- return "contains";
- }
- };
- }
-
- public static Predicate containsIgnoreCase(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
-
- return ObjectHelper.containsIgnoreCase(leftValue, rightValue);
- }
-
- protected String getOperationText() {
- return "~~";
- }
- };
- }
-
- public static Predicate isNull(final Expression expression) {
- return new BinaryPredicateSupport(expression, ExpressionBuilder.constantExpression(null)) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null) {
- // the left operator is null so its true
- return true;
- }
-
- return ObjectHelper.typeCoerceEquals(exchange.getContext().getTypeConverter(), leftValue, rightValue);
- }
-
- protected String getOperationText() {
- // leave the operation text as "is not" as Camel will insert right and left expression around it
- // so it will be displayed as: XXX is null
- return "is";
- }
- };
- }
-
- public static Predicate isNotNull(final Expression expression) {
- return new BinaryPredicateSupport(expression, ExpressionBuilder.constantExpression(null)) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue != null) {
- // the left operator is not null so its true
- return true;
- }
-
- return ObjectHelper.typeCoerceNotEquals(exchange.getContext().getTypeConverter(), leftValue, rightValue);
- }
-
- protected String getOperationText() {
- // leave the operation text as "is not" as Camel will insert right and left expression around it
- // so it will be displayed as: XXX is not null
- return "is not";
- }
- };
- }
-
- public static Predicate isInstanceOf(final Expression expression, final Class<?> type) {
- notNull(expression, "expression");
- notNull(type, "type");
-
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- Object value = expression.evaluate(exchange, Object.class);
- return type.isInstance(value);
- }
-
- @Override
- public String toString() {
- return expression + " instanceof " + type.getCanonicalName();
- }
- };
- }
-
- public static Predicate startsWith(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
- String leftStr = exchange.getContext().getTypeConverter().convertTo(String.class, leftValue);
- String rightStr = exchange.getContext().getTypeConverter().convertTo(String.class, rightValue);
- if (leftStr != null && rightStr != null) {
- return leftStr.startsWith(rightStr);
- } else {
- return false;
- }
- }
-
- protected String getOperationText() {
- return "startsWith";
- }
- };
- }
-
- public static Predicate endsWith(final Expression left, final Expression right) {
- return new BinaryPredicateSupport(left, right) {
-
- protected boolean matches(Exchange exchange, Object leftValue, Object rightValue) {
- if (leftValue == null && rightValue == null) {
- // they are equal
- return true;
- } else if (leftValue == null || rightValue == null) {
- // only one of them is null so they are not equal
- return false;
- }
- String leftStr = exchange.getContext().getTypeConverter().convertTo(String.class, leftValue);
- String rightStr = exchange.getContext().getTypeConverter().convertTo(String.class, rightValue);
- if (leftStr != null && rightStr != null) {
- return leftStr.endsWith(rightStr);
- } else {
- return false;
- }
- }
-
- protected String getOperationText() {
- return "endsWith";
- }
- };
- }
-
- /**
- * Returns a predicate which is true if the expression matches the given
- * regular expression
- *
- * @param expression the expression to evaluate
- * @param regex the regular expression to match against
- * @return a new predicate
- */
- public static Predicate regex(final Expression expression, final String regex) {
- return regex(expression, Pattern.compile(regex));
- }
-
- /**
- * Returns a predicate which is true if the expression matches the given
- * regular expression
- *
- * @param expression the expression to evaluate
- * @param pattern the regular expression to match against
- * @return a new predicate
- */
- public static Predicate regex(final Expression expression, final Pattern pattern) {
- notNull(expression, "expression");
- notNull(pattern, "pattern");
-
- return new Predicate() {
- public boolean matches(Exchange exchange) {
- String value = expression.evaluate(exchange, String.class);
- if (value != null) {
- Matcher matcher = pattern.matcher(value);
- return matcher.matches();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return expression + ".matches('" + pattern + "')";
- }
- };
- }
-
- /**
- * Concat the given predicates into a single predicate, which
- * only matches if all the predicates matches.
- *
- * @param predicates predicates
- * @return a single predicate containing all the predicates
- */
- public static Predicate and(List<Predicate> predicates) {
- Predicate answer = null;
- for (Predicate predicate : predicates) {
- if (answer == null) {
- answer = predicate;
- } else {
- answer = and(answer, predicate);
- }
- }
- return answer;
- }
-
- /**
- * Concat the given predicates into a single predicate, which only matches
- * if all the predicates matches.
- *
- * @param predicates predicates
- * @return a single predicate containing all the predicates
- */
- public static Predicate and(Predicate... predicates) {
- return and(Arrays.asList(predicates));
- }
-
- /**
- * A constant predicate.
- *
- * @param answer the constant matches
- * @return a predicate that always returns the given answer.
- */
- public static Predicate constant(final boolean answer) {
- return new Predicate() {
- @Override
- public boolean matches(Exchange exchange) {
- return answer;
- }
-
- @Override
- public String toString() {
- return "" + answer;
- }
- };
- }
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
index 188bbc6..e0c834a 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -24,13 +24,11 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.builder.PredicateBuilder;
-import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
-import org.apache.camel.support.builder.xml.Namespaces;
+import org.apache.camel.support.builder.ExpressionBuilder;
+import org.apache.camel.support.builder.PredicateBuilder;
/**
* A builder of expressions or predicates based on values.
@@ -237,26 +235,6 @@ public class MockValueBuilder implements Expression, Predicate {
return onNewValueBuilder(newExp);
}
- public MockValueBuilder tokenizeXML(String tagName, String inheritNamespaceTagName) {
- Expression newExp = ExpressionBuilder.tokenizeXMLExpression(tagName, inheritNamespaceTagName);
- return onNewValueBuilder(newExp);
- }
-
- public MockValueBuilder xtokenize(String path, Namespaces namespaces) {
- return xtokenize(path, 'i', namespaces);
- }
-
- public MockValueBuilder xtokenize(String path, char mode, Namespaces namespaces) {
- Expression newExp = ExpressionBuilder.tokenizeXMLAwareExpression(path, mode);
- ((NamespaceAware)newExp).setNamespaces(namespaces.getNamespaces());
- return onNewValueBuilder(newExp);
- }
-
- public MockValueBuilder tokenizePair(String startToken, String endToken, boolean includeTokens) {
- Expression newExp = ExpressionBuilder.tokenizePairExpression(startToken, endToken, includeTokens);
- return onNewValueBuilder(newExp);
- }
-
/**
* Tokenizes the string conversion of this expression using the given
* regular expression
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/BinaryPredicateSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/BinaryPredicateSupport.java
similarity index 98%
rename from core/camel-core/src/main/java/org/apache/camel/builder/BinaryPredicateSupport.java
rename to core/camel-support/src/main/java/org/apache/camel/support/builder/BinaryPredicateSupport.java
index 3907dd3..8baa57d 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/BinaryPredicateSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/BinaryPredicateSupport.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.builder;
+package org.apache.camel.support.builder;
import org.apache.camel.BinaryPredicate;
import org.apache.camel.Exchange;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
similarity index 97%
copy from core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
copy to core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
index ed3f8691..c5fa4bd 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/ExpressionBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.builder;
+package org.apache.camel.support.builder;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -53,16 +53,7 @@ import org.apache.camel.util.StringHelper;
/**
* A helper class for working with <a href="http://camel.apache.org/expression.html">expressions</a>.
*/
-public final class ExpressionBuilder {
-
- // TODO: Make this possible to have a base class in camel-support, and then extend it here, so we can have both
- // and maybe deprecate this and refer to the builder in camel-support
-
- /**
- * Utility classes should not have a public constructor.
- */
- private ExpressionBuilder() {
- }
+public class ExpressionBuilder {
/**
* Returns an expression for the inbound message attachments
@@ -304,7 +295,7 @@ public final class ExpressionBuilder {
/**
* Returns an expression for the exchange pattern
*
- * @see org.apache.camel.Exchange#getPattern()
+ * @see Exchange#getPattern()
* @return an expression object which will return the exchange pattern
*/
public static Expression exchangePatternExpression() {
@@ -426,7 +417,7 @@ public final class ExpressionBuilder {
}
/**
- * Returns an expression for the {@link org.apache.camel.CamelContext}
+ * Returns an expression for the {@link CamelContext}
*
* @return an expression object which will return the camel context
*/
@@ -444,7 +435,7 @@ public final class ExpressionBuilder {
}
/**
- * Returns an expression for the {@link org.apache.camel.CamelContext} name
+ * Returns an expression for the {@link CamelContext} name
*
* @return an expression object which will return the camel context name
*/
@@ -1216,31 +1207,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns an {@link TokenPairExpressionIterator} expression
- */
- public static Expression tokenizePairExpression(String startToken, String endToken, boolean includeTokens) {
- return new TokenPairExpressionIterator(startToken, endToken, includeTokens);
- }
-
- /**
- * Returns an {@link TokenXMLExpressionIterator} expression
- */
- public static Expression tokenizeXMLExpression(String tagName, String inheritNamespaceTagName) {
- StringHelper.notEmpty(tagName, "tagName");
- return new TokenXMLExpressionIterator(tagName, inheritNamespaceTagName);
- }
-
- public static Expression tokenizeXMLAwareExpression(String path, char mode) {
- StringHelper.notEmpty(path, "path");
- return new XMLTokenExpressionIterator(path, mode);
- }
-
- public static Expression tokenizeXMLAwareExpression(String path, char mode, int group) {
- StringHelper.notEmpty(path, "path");
- return new XMLTokenExpressionIterator(path, mode, group);
- }
-
- /**
* Returns a tokenize expression which will tokenize the string with the
* given regex
*/
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java b/core/camel-support/src/main/java/org/apache/camel/support/builder/PredicateBuilder.java
similarity index 99%
copy from core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
copy to core/camel-support/src/main/java/org/apache/camel/support/builder/PredicateBuilder.java
index eee830e..302d100 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/builder/PredicateBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.builder;
+package org.apache.camel.support.builder;
import java.util.Arrays;
import java.util.List;
@@ -26,21 +26,14 @@ import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.ObjectHelper;
-
import static org.apache.camel.util.ObjectHelper.notNull;
/**
* A helper class for working with predicates
*/
-public final class PredicateBuilder {
+public class PredicateBuilder {
/**
- * Utility classes should not have a public constructor.
- */
- private PredicateBuilder() {
- }
-
- /**
* Converts the given expression into an {@link Predicate}
*/
public static Predicate toPredicate(final Expression expression) {
[camel] 18/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 75254855b3d09af3847f92774c8ffb9d3b9417a5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 11:08:06 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../java/org/apache/camel/builder/ExpressionBuilder.java | 4 ++--
.../java/org/apache/camel/support/LanguageSupport.java | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index cda166d..5901824 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -45,7 +45,6 @@ import org.apache.camel.NoSuchLanguageException;
import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.language.simple.SimpleLanguage;
import org.apache.camel.model.language.MethodCallExpression;
import org.apache.camel.spi.ExchangeFormatter;
import org.apache.camel.spi.Language;
@@ -57,6 +56,7 @@ import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.GroupIterator;
import org.apache.camel.support.GroupTokenIterator;
+import org.apache.camel.support.LanguageSupport;
import org.apache.camel.support.MessageHelper;
import org.apache.camel.support.processor.DefaultExchangeFormatter;
import org.apache.camel.util.FileUtil;
@@ -1970,7 +1970,7 @@ public final class ExpressionBuilder {
public static Expression simpleExpression(final String expression) {
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
- if (SimpleLanguage.hasSimpleFunction(expression)) {
+ if (LanguageSupport.hasSimpleFunction(expression)) {
// resolve language using context to have a clear separation of packages
// must call evaluate to return the nested language evaluate when evaluating
// stacked expressions
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java
index ad0750c..31ebde8 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/LanguageSupport.java
@@ -32,6 +32,8 @@ public abstract class LanguageSupport implements Language, IsSingleton, CamelCon
public static final String RESOURCE = "resource:";
+ private static final String[] SIMPLE_FUNCTION_START = new String[]{"${", "$simple{"};
+
private CamelContext camelContext;
public CamelContext getCamelContext() {
@@ -73,4 +75,18 @@ public abstract class LanguageSupport implements Language, IsSingleton, CamelCon
}
return expression;
}
+
+ /**
+ * Does the expression include a simple function.
+ *
+ * @param expression the expression
+ * @return <tt>true</tt> if one or more simple function is included in the expression
+ */
+ public static boolean hasSimpleFunction(String expression) {
+ if (expression != null) {
+ return expression.contains(SIMPLE_FUNCTION_START[0]) || expression.contains(SIMPLE_FUNCTION_START[1]);
+ }
+ return false;
+ }
+
}
[camel] 14/38: CAMEL-13422: Remove camel-rmi component
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f5719b6c50a3ab67e5436e37e39688418804ba85
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:25:52 2019 +0200
CAMEL-13422: Remove camel-rmi component
---
apache-camel/pom.xml | 10 --
bom/camel-bom/pom.xml | 10 --
.../modules/ROOT/pages/rmi-component.adoc | 159 ---------------------
...-extra-camel-componets-in-servicemix-camel.adoc | 73 ----------
.../camel-spring-boot-dependencies/pom.xml | 10 --
5 files changed, 262 deletions(-)
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index d7d8293..f34eb63 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -1153,11 +1153,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss</artifactId>
<version>${project.version}</version>
</dependency>
@@ -2602,11 +2597,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss-starter</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index a0821f4..c3c6265 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -2215,16 +2215,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/docs/components/modules/ROOT/pages/rmi-component.adoc b/docs/components/modules/ROOT/pages/rmi-component.adoc
deleted file mode 100644
index 36b1974..0000000
--- a/docs/components/modules/ROOT/pages/rmi-component.adoc
+++ /dev/null
@@ -1,159 +0,0 @@
-[[rmi-component]]
-== RMI Component
-
-*Available as of Camel version 1.0*
-
-The *rmi:* component binds Exchanges to the RMI
-protocol (JRMP).
-
-Since this binding is just using RMI, normal RMI rules still apply
-regarding what methods can be invoked. This component supports only
-Exchanges that carry a method invocation from an interface that extends
-the http://java.sun.com/j2se/1.3/docs/api/java/rmi/Remote.html[Remote]
-interface. All parameters in the method should be either
-http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html[Serializable]
-or `Remote` objects.
-
-Maven users will need to add the following dependency to their `pom.xml`
-for this component:
-
-[source,xml]
-------------------------------------------------------------
-<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>x.x.x</version>
- <!-- use the same version as your Camel core version -->
-</dependency>
-------------------------------------------------------------
-
-### URI format
-
-[source,java]
-------------------------------------------------------------------
-rmi://rmi-regisitry-host:rmi-registry-port/registry-path[?options]
-------------------------------------------------------------------
-
-For example:
-
-[source,java]
-------------------------------------
-rmi://localhost:1099/path/to/service
-------------------------------------
-
-You can append query options to the URI in the following format,
-`?option=value&option=value&...`
-
-### Options
-
-
-// component options: START
-The RMI component has no options.
-// component options: END
-
-
-
-// endpoint options: START
-The RMI endpoint is configured using URI syntax:
-
-----
-rmi:hostname:port/name
-----
-
-with the following path and query parameters:
-
-==== Path Parameters (3 parameters):
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *hostname* | Hostname of RMI server | localhost | String
-| *name* | *Required* Name to use when binding to RMI server | | String
-| *port* | Port number of RMI server | 1099 | int
-|===
-
-
-==== Query Parameters (6 parameters):
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *method* (common) | You can set the name of the method to invoke. | | String
-| *remoteInterfaces* (common) | To specific the remote interfaces. | | List
-| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
-| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler
-| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern
-| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
-|===
-// endpoint options: END
-// spring-boot-auto-configure options: START
-=== Spring Boot Auto-Configuration
-
-When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
-
-[source,xml]
-----
-<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>x.x.x</version>
- <!-- use the same version as your Camel core version -->
-</dependency>
-----
-
-
-The component supports 2 options, which are listed below.
-
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *camel.component.rmi.enabled* | Enable rmi component | true | Boolean
-| *camel.component.rmi.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
-|===
-// spring-boot-auto-configure options: END
-
-
-
-### Using
-
-To call out to an existing RMI service registered in an RMI registry,
-create a route similar to the following:
-
-[source,java]
-------------------------------------------------
-from("pojo:foo").to("rmi://localhost:1099/foo");
-------------------------------------------------
-
-To bind an existing camel processor or service in an RMI registry,
-define an RMI endpoint as follows:
-
-[source,java]
--------------------------------------------------------------------------
-RmiEndpoint endpoint= (RmiEndpoint) endpoint("rmi://localhost:1099/bar");
-endpoint.setRemoteInterfaces(ISay.class);
-from(endpoint).to("pojo:bar");
--------------------------------------------------------------------------
-
-Note that when binding an RMI consumer endpoint, you must specify the
-`Remote` interfaces exposed.
-
-In XML DSL you can do as follows from *Camel 2.7* onwards:
-
-[source,xml]
-------------------------------------------------------------------------------------------------------------------------
- <camel:route>
- <from uri="rmi://localhost:37541/helloServiceBean?remoteInterfaces=org.apache.camel.example.osgi.HelloService"/>
- <to uri="bean:helloServiceBean"/>
- </camel:route>
-------------------------------------------------------------------------------------------------------------------------
-
-### See Also
-
-* Configuring Camel
-* Component
-* Endpoint
-* Getting Started
diff --git a/docs/user-manual/en/faq/how-to-use-extra-camel-componets-in-servicemix-camel.adoc b/docs/user-manual/en/faq/how-to-use-extra-camel-componets-in-servicemix-camel.adoc
deleted file mode 100644
index f397263..0000000
--- a/docs/user-manual/en/faq/how-to-use-extra-camel-componets-in-servicemix-camel.adoc
+++ /dev/null
@@ -1,73 +0,0 @@
-[[HowtouseextraCamelcomponetsinservicemixcamel-HowtouseextraCamelcomponetsinservicemixcamel]]
-=== How to use extra Camel componets in servicemix-camel?
-
-Since ServiceMix 3's component has same hierarchies of the class loaders
-with the J2EE application server, and the components the class loader is
-separated with the SU's. And Camel has lots of components, we just
-include the camel-core and camel-spring components in the
-servicemix-camel by default. When the user want to use other camel
-component, they always add the camel-xxx component into their SU lib.
-In this way if there is a class which is loaded from the different SU
-classloader and registed into the camel-core's registry by
-servicemix-camel component , we will faced on the typical class cast
-exception in Servicemix3. Basically this exception is caused by the same
-class is loaded by different class loader.
-
-You may meet an issue of the class cast exception when deploying the
-same servicemix-camel component SU twice.
-
-In this case, when the SU is redeployed, it will create a new deployer
-which will create an application context with the class loader of
-servicemix-camel component, and then using the SU's class loader to
-create a camel context.
-Since the SU is redeployed, Servicemix will create a new class loader to
-load the SU's lib jars and resources.
-When the SU initial the rmi component, boom , we meet the situation of
-same component loaded with different class loader, The class cast
-exception is thrown out.
-
-Note, in Servicemix4's camel component, we will not get that kind of
-issue, since the OSGi will help us to manage the relationship of the
-jars.
-
-The solution is putting the camel-xxx components and third part jars
-into servicemix-camel component's lib. You need to check out the
-servicemix-camel component's pom.xml and recompile the servicemix-camel
-component by adding the camel-xxx component dependency.
-
-Let me take the latest servicemix-camel as an example:
-
-1. Checking out the servicemix-camel component's pom:
-+
-----
-svn co http://svn.apache.org/repos/asf/servicemix/components/engines/servicemix-camel/trunk/pom.xml
-----
-
-2. If you need camel-rmi component, you just put the dependency into
-the `pom.xml`:
-+
-[source,xml]
-----
-<dependency>
- <groupid>org.apache.camel</groupid>
- <artifactid>camel-rmi</artifactid>
- <version>${camel-version}</version>
-</dependency>
-----
-
-3. Running `mvn install` and copy the `servicemix-camel-*.zip` into the
-deploy directory.
-
-4. Write your servicemix-camel SU, make sure you don't include any
-camel relates jars into the SU's lib, you can use the
-`<scope>provided</scope>` to not packing the artifact.
-+
-[source,xml]
-----
-<dependency>
- <groupid>org.apache.camel</groupid>
- <artifactid>camel-rmi</artifactid>
- <version>${camel-version}</version>
- <scope>provided</scope>
-</dependency>
-----
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 55415c1..b5eccf9 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -2430,16 +2430,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss</artifactId>
<version>${project.version}</version>
</dependency>
[camel] 08/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 050789672c3a96363d360c12cf3585c8bda523dd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 21:33:43 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../apache/camel/builder/ExpressionBuilder.java | 3 +
.../camel/builder/ExpressionClauseSupport.java | 1 -
.../camel/component/mock/AssertionClause.java | 3 +-
.../mock/MockExpressionClauseSupport.java} | 80 +++++++++-------------
4 files changed, 36 insertions(+), 51 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index 5b4e215..ebbe476 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -77,6 +77,9 @@ import org.apache.camel.util.StringHelper;
*/
public final class ExpressionBuilder {
+ // TODO: Make this possible to have a base class in camel-support, and then extend it here, so we can have both
+ // and maybe deprecate this and refer to the builder in camel-support
+
private static final Pattern OFFSET_PATTERN = Pattern.compile("([+-])([^+-]+)");
/**
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index b77da58..ddfd467 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -21,7 +21,6 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
import org.apache.camel.support.builder.xml.Namespaces;
-// TODO: All these should be behind support language so we can separate
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
import org.apache.camel.model.language.GroovyExpression;
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index 795f7d5..5556cba 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -25,7 +25,6 @@ import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.StreamCache;
import org.apache.camel.builder.ExpressionClause;
-import org.apache.camel.builder.ExpressionClauseSupport;
import org.apache.camel.builder.ValueBuilder;
import org.apache.camel.support.PredicateAssertHelper;
import org.apache.camel.support.language.ExpressionModel;
@@ -33,7 +32,7 @@ import org.apache.camel.support.language.ExpressionModel;
/**
* A builder of assertions on message exchanges
*/
-public abstract class AssertionClause extends ExpressionClauseSupport<ValueBuilder> implements Runnable {
+public abstract class AssertionClause extends MockExpressionClauseSupport<ValueBuilder> implements Runnable {
protected final MockEndpoint mock;
protected volatile int currentIndex;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
similarity index 94%
copy from core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
copy to core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
index b77da58..eb58656 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
@@ -14,47 +14,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.builder;
+package org.apache.camel.component.mock;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
-import org.apache.camel.support.builder.xml.Namespaces;
-// TODO: All these should be behind support language so we can separate
-import org.apache.camel.model.language.ConstantExpression;
-import org.apache.camel.model.language.ExchangePropertyExpression;
-import org.apache.camel.model.language.GroovyExpression;
-import org.apache.camel.model.language.HeaderExpression;
-import org.apache.camel.model.language.Hl7TerserExpression;
-import org.apache.camel.model.language.JavaScriptExpression;
+import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.model.language.JsonPathExpression;
import org.apache.camel.model.language.LanguageExpression;
import org.apache.camel.model.language.MethodCallExpression;
-import org.apache.camel.model.language.MvelExpression;
-import org.apache.camel.model.language.OgnlExpression;
-import org.apache.camel.model.language.RefExpression;
import org.apache.camel.model.language.SimpleExpression;
-import org.apache.camel.model.language.SpELExpression;
import org.apache.camel.model.language.TokenizerExpression;
import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
/**
* A support class for building expression clauses.
*/
-public class ExpressionClauseSupport<T> {
+public class MockExpressionClauseSupport<T> {
- // Implementation detail: We must use the specific model.language.xxx classes to make the DSL use these specific types
- // which ensures that the route model dumped as XML uses these types, eg <header> instead of <language name="header"> etc.
+ // TODO: make the model.language class not here as we want to use this in camel-mock but have similar method api compatability
private T result;
private Expression expressionValue;
private ExpressionModel expressionType;
- public ExpressionClauseSupport(T result) {
+ public MockExpressionClauseSupport(T result) {
this.result = result;
}
@@ -87,11 +76,7 @@ public class ExpressionClauseSupport<T> {
* do not use this if you want dynamic values during routing.
*/
public T constant(Object value) {
- if (value instanceof String) {
- return expression(new ConstantExpression((String) value));
- } else {
- return expression(ExpressionBuilder.constantExpression(value));
- }
+ return expression(ExpressionBuilder.constantExpression(value));
}
/**
@@ -119,8 +104,7 @@ public class ExpressionClauseSupport<T> {
* An expression of an inbound message body
*/
public T body() {
- // reuse simple as this allows the model to represent this as a known JAXB type
- return expression(new SimpleExpression("${body}"));
+ return expression(ExpressionBuilder.bodyExpression());
}
/**
@@ -148,7 +132,7 @@ public class ExpressionClauseSupport<T> {
* An expression of an inbound message header of the given name
*/
public T header(String name) {
- return expression(new HeaderExpression(name));
+ return expression(ExpressionBuilder.headerExpression(name));
}
/**
@@ -190,7 +174,7 @@ public class ExpressionClauseSupport<T> {
* An expression of an exchange property of the given name
*/
public T exchangeProperty(String name) {
- return expression(new ExchangePropertyExpression(name));
+ return expression(ExpressionBuilder.exchangePropertyExpression(name));
}
/**
@@ -213,7 +197,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T method(String bean) {
- return expression(new MethodCallExpression(bean));
+ return expression(ExpressionBuilder.beanExpression(bean));
}
/**
@@ -292,7 +276,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T groovy(String text) {
- return expression(new GroovyExpression(text));
+ return expression(ExpressionBuilder.languageExpression("groovy", text));
}
/**
@@ -306,7 +290,7 @@ public class ExpressionClauseSupport<T> {
*/
@Deprecated
public T javaScript(String text) {
- return expression(new JavaScriptExpression(text));
+ return expression(ExpressionBuilder.languageExpression("js", text));
}
/**
@@ -317,7 +301,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T jsonpath(String text) {
- return jsonpath(text, false);
+ return expression(ExpressionBuilder.languageExpression("jsonpath", text));
}
/**
@@ -492,7 +476,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T ognl(String text) {
- return expression(new OgnlExpression(text));
+ return expression(ExpressionBuilder.languageExpression("ognl", text));
}
/**
@@ -503,7 +487,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T mvel(String text) {
- return expression(new MvelExpression(text));
+ return expression(ExpressionBuilder.languageExpression("mvel", text));
}
/**
@@ -514,7 +498,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T ref(String ref) {
- return expression(new RefExpression(ref));
+ return expression(ExpressionBuilder.languageExpression("ref", ref));
}
/**
@@ -525,7 +509,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T spel(String text) {
- return expression(new SpELExpression(text));
+ return expression(ExpressionBuilder.languageExpression("spel", text));
}
/**
@@ -536,7 +520,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T simple(String text) {
- return expression(new SimpleExpression(text));
+ return expression(ExpressionBuilder.languageExpression("simple", text));
}
/**
@@ -562,7 +546,7 @@ public class ExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T hl7terser(String text) {
- return expression(new Hl7TerserExpression(text));
+ return expression(ExpressionBuilder.languageExpression("hl7terser", text));
}
/**
@@ -765,11 +749,11 @@ public class ExpressionClauseSupport<T> {
/**
* Evaluates an XML token expression on the message body with XML content
- *
+ *
* @param path the xpath like path notation specifying the child nodes to tokenize
* @param mode one of 'i', 'w', or 'u' to inject the namespaces to the token, to
* wrap the token with its ancestor contet, or to unwrap to its element child
- * @param namespaces the namespace map to the namespace bindings
+ * @param namespaces the namespace map to the namespace bindings
* @param group to group by the given number
* @return the builder to continue processing the DSL
*/
@@ -795,11 +779,11 @@ public class ExpressionClauseSupport<T> {
public T xpath(String text) {
return expression(new XPathExpression(text));
}
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> on the supplied header name's contents
- *
+ *
* @param text the expression to be evaluated
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
@@ -809,7 +793,7 @@ public class ExpressionClauseSupport<T> {
expression.setHeaderName(headerName);
return expression(expression);
}
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type
@@ -825,7 +809,7 @@ public class ExpressionClauseSupport<T> {
return result;
}
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type on the supplied
@@ -842,7 +826,7 @@ public class ExpressionClauseSupport<T> {
setExpressionType(expression);
return result;
}
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
@@ -857,7 +841,7 @@ public class ExpressionClauseSupport<T> {
public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
return xpath(text, resultType, namespaces.getNamespaces());
}
-
+
/**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a> with the specified result type and set of namespace
@@ -938,7 +922,7 @@ public class ExpressionClauseSupport<T> {
/**
* Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery
* expression</a>
- *
+ *
* @param text the expression to be evaluated
* @param headerName the name of the header to apply the expression to
* @return the builder to continue processing the DSL
@@ -964,8 +948,8 @@ public class ExpressionClauseSupport<T> {
setExpressionType(expression);
return result;
}
-
-
+
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
@@ -996,7 +980,7 @@ public class ExpressionClauseSupport<T> {
public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
return xquery(text, resultType, namespaces.getNamespaces());
}
-
+
/**
* Evaluates an <a
* href="http://camel.apache.org/xquery.html">XQuery expression</a>
[camel] 04/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit adea00e8360f36b495cfe2da5d20c0fd38a2034f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 16:26:50 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../org/apache/camel/reifier/ChoiceReifier.java | 32 ++++++--
.../properties/XPathPropertyPlaceholderTest.java | 91 ++++++++++++++++++++++
2 files changed, 118 insertions(+), 5 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java b/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
index 27cf327..1944472 100644
--- a/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
+++ b/core/camel-core/src/main/java/org/apache/camel/reifier/ChoiceReifier.java
@@ -19,7 +19,10 @@ package org.apache.camel.reifier;
import java.util.ArrayList;
import java.util.List;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.model.ChoiceDefinition;
import org.apache.camel.model.ExpressionNode;
import org.apache.camel.model.ProcessorDefinition;
@@ -29,6 +32,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.processor.ChoiceProcessor;
import org.apache.camel.processor.FilterProcessor;
import org.apache.camel.spi.RouteContext;
+import org.apache.camel.support.language.ExpressionModel;
class ChoiceReifier extends ProcessorReifier<ChoiceDefinition> {
@@ -40,15 +44,33 @@ class ChoiceReifier extends ProcessorReifier<ChoiceDefinition> {
public Processor createProcessor(RouteContext routeContext) throws Exception {
List<FilterProcessor> filters = new ArrayList<>();
for (WhenDefinition whenClause : definition.getWhenClauses()) {
+ ExpressionDefinition exp = whenClause.getExpression();
+ if (exp.getExpressionType() != null) {
+ exp = exp.getExpressionType();
+ }
+ Predicate pre = exp.getPredicate();
+ if (pre instanceof ExpressionClause) {
+ ExpressionClause<?> clause = (ExpressionClause<?>) pre;
+ if (clause.getExpressionType() != null) {
+ // if using the Java DSL then the expression may have been set using the
+ // ExpressionClause which is a fancy builder to define expressions and predicates
+ // using fluent builders in the DSL. However we need afterwards a callback to
+ // reset the expression to the expression type the ExpressionClause did build for us
+ ExpressionModel model = clause.getExpressionType();
+ if (model instanceof ExpressionDefinition) {
+ whenClause.setExpression((ExpressionDefinition) model);
+ }
+ }
+ exp = whenClause.getExpression();
+ }
+
// also resolve properties and constant fields on embedded expressions in the when clauses
- ExpressionNode exp = whenClause;
- ExpressionDefinition expressionDefinition = exp.getExpression();
- if (expressionDefinition != null) {
+ if (exp != null) {
// resolve properties before we create the processor
- ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), expressionDefinition);
+ ProcessorDefinitionHelper.resolvePropertyPlaceholders(routeContext.getCamelContext(), exp);
// resolve constant fields (eg Exchange.FILE_NAME)
- ProcessorDefinitionHelper.resolveKnownConstantFields(expressionDefinition);
+ ProcessorDefinitionHelper.resolveKnownConstantFields(exp);
}
FilterProcessor filter = (FilterProcessor) createProcessor(routeContext, whenClause);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/properties/XPathPropertyPlaceholderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/properties/XPathPropertyPlaceholderTest.java
new file mode 100644
index 0000000..c09f9e8
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/component/properties/XPathPropertyPlaceholderTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.properties;
+
+import java.util.Properties;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.PropertiesComponent;
+import org.junit.Test;
+
+public class XPathPropertyPlaceholderTest extends ContextTestSupport {
+
+ @Test
+ public void testFilter() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:output-filter");
+ mock.expectedMessageCount(1);
+
+ template.sendBody("direct:filter", "<greeting><text>Hello, world!</text></greeting>");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testChoice() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:output-choice");
+ mock.expectedMessageCount(1);
+
+ template.sendBody("direct:choice", "<greeting><text>Bye, world!</text></greeting>");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testChoice2() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:output-choice2");
+ mock.expectedMessageCount(1);
+
+ template.sendBody("direct:choice2", "<greeting><text>Bye, world!</text></greeting>");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ Properties prop = new Properties();
+ prop.put("foo", "//greeting/text = 'Hello, world!'");
+ prop.put("bar", "//greeting/text = 'Bye, world!'");
+
+ PropertiesComponent pc = context.getPropertiesComponent(true);
+ pc.setInitialProperties(prop);
+
+ from("direct:filter")
+ .filter().xpath("{{foo}}")
+ .log("Passed filter!")
+ .to("mock:output-filter");
+
+ from("direct:choice")
+ .choice()
+ .when(xpath("{{bar}}"))
+ .log("Passed choice!")
+ .to("mock:output-choice");
+
+ from("direct:choice2")
+ .choice()
+ .when().xpath("{{bar}}")
+ .log("Passed choice2!")
+ .to("mock:output-choice2");
+ }
+ };
+ }
+
+}
[camel] 30/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit da697998e51f7e57fef7228e928db05ab33f110d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 09:03:54 2019 +0200
Move mock component out of camel-core. Work in progress.
---
MIGRATION.md | 4 ---
components/camel-dataset/pom.xml | 27 ------------------
.../src/test/resources/log4j2.properties | 32 ----------------------
core/camel-core/pom.xml | 4 +++
.../src/test/data/file-dataset-test.txt | 0
.../camel/component/dataset/BigDataSetTest.java | 4 +--
.../camel/component/dataset/CustomDataSetTest.java | 4 +--
.../component/dataset/DataSetConsumerTest.java | 17 ++++++------
.../component/dataset/DataSetEndpointTest.java | 18 ++++++------
.../component/dataset/DataSetPreloadTest.java | 9 +++---
.../component/dataset/DataSetProducerTest.java | 13 +++++----
.../camel/component/dataset/DataSetSedaTest.java | 4 +--
.../camel/component/dataset/DataSetTest.java | 4 +--
.../component/dataset/DataSetTestAnyOrderTest.java | 4 +--
.../component/dataset/DataSetTestEndpointTest.java | 7 ++---
.../dataset/DataSetTestFileSplitTest.java | 4 +--
.../component/dataset/DataSetTestFileTest.java | 4 +--
.../component/dataset/DataSetTestSedaTest.java | 4 +--
.../component/dataset/FileDataSetConsumerTest.java | 7 +++--
.../dataset/FileDataSetConsumerWithSplitTest.java | 7 +++--
.../component/dataset/FileDataSetProducerTest.java | 7 +++--
.../dataset/FileDataSetProducerWithSplitTest.java | 11 ++++----
.../component/dataset/ListDataSetConsumerTest.java | 4 +--
.../component/dataset/ListDataSetProducerTest.java | 4 +--
.../component/dataset/RoutePerformanceTest.java | 7 ++---
25 files changed, 75 insertions(+), 135 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 6377a66..504c2af 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -88,10 +88,6 @@ The `test` component has been renamed to `dataset-test` and moved out of `camel-
We have also renamed `camel-jetty9` to `camel-jetty`.
-### DataSet component
-
-The `dataset` component has been moved out of `camel-core`, and is no longer a transient dependency from `camel-core`, and therefore you should add `camel-dataset` as dependency if you use this component.
-
### Mock component
The `mock` component has been moved out of `camel-core` and as part of this work, we had to remove a number of methods on its _assertion clause builder_ that were seldom in use. Also we had to remove a few methods on `NotifyBuilder` that were using the `mock` component.
diff --git a/components/camel-dataset/pom.xml b/components/camel-dataset/pom.xml
index e307bcb..d7d5460 100644
--- a/components/camel-dataset/pom.xml
+++ b/components/camel-dataset/pom.xml
@@ -40,32 +40,5 @@
<artifactId>camel-mock</artifactId>
</dependency>
- <!-- testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
</dependencies>
</project>
diff --git a/components/camel-dataset/src/test/resources/log4j2.properties b/components/camel-dataset/src/test/resources/log4j2.properties
deleted file mode 100644
index c4e867c..0000000
--- a/components/camel-dataset/src/test/resources/log4j2.properties
+++ /dev/null
@@ -1,32 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-appender.console.type = Console
-appender.console.name = console
-appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-appender.file.type = File
-appender.file.name = file
-appender.file.fileName = target/camel-dataset-test.log
-appender.file.append = true
-appender.file.layout.type = PatternLayout
-appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-rootLogger.level = INFO
-
-rootLogger.appenderRef.file.ref = file
-#rootLogger.appenderRef.console.ref = console
diff --git a/core/camel-core/pom.xml b/core/camel-core/pom.xml
index 7ff8da9..a789e94 100644
--- a/core/camel-core/pom.xml
+++ b/core/camel-core/pom.xml
@@ -107,6 +107,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-dataset</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-direct</artifactId>
</dependency>
<dependency>
diff --git a/components/camel-dataset/src/test/data/file-dataset-test.txt b/core/camel-core/src/test/data/file-dataset-test.txt
similarity index 100%
rename from components/camel-dataset/src/test/data/file-dataset-test.txt
rename to core/camel-core/src/test/data/file-dataset-test.txt
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java
similarity index 94%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java
index 7583fa2..f2a5636 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/BigDataSetTest.java
@@ -20,14 +20,14 @@ import java.util.concurrent.TimeUnit;
import javax.naming.Context;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Ignore;
import org.junit.Test;
@Ignore("Manual test")
-public class BigDataSetTest extends CamelTestSupport {
+public class BigDataSetTest extends ContextTestSupport {
protected SimpleDataSet dataSet = new SimpleDataSet(20000);
@Test
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
similarity index 95%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
index 4e907f0..1903bd4 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/CustomDataSetTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
@@ -25,10 +26,9 @@ import org.apache.camel.builder.PredicateBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.builder.xml.XPathBuilder;
import org.apache.camel.support.PredicateAssertHelper;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-public class CustomDataSetTest extends CamelTestSupport {
+public class CustomDataSetTest extends ContextTestSupport {
@BindToRegistry("foo")
protected DataSet dataSet = new DataSetSupport() {
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
similarity index 86%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
index b6ecada..c6b2f07 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
@@ -17,15 +17,14 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.test.junit4.TestSupport;
import org.junit.Assert;
import org.junit.Test;
-public class DataSetConsumerTest extends CamelTestSupport {
+public class DataSetConsumerTest extends ContextTestSupport {
@BindToRegistry("foo")
protected SimpleDataSet dataSet = new SimpleDataSet(5);
@@ -54,7 +53,7 @@ public class DataSetConsumerTest extends CamelTestSupport {
MockEndpoint result = getMockEndpoint(resultUri);
result.expectedMessageCount((int) dataSet.getSize());
- result.assertMessagesAscending(TestSupport.header(Exchange.DATASET_INDEX));
+ result.assertMessagesAscending(header(Exchange.DATASET_INDEX));
context.start();
@@ -75,11 +74,11 @@ public class DataSetConsumerTest extends CamelTestSupport {
}
});
- assertEquals("expectedMessageCount should be the same as the DataSet size for a consumer-producer endpoint", dataSet.getSize(), getMockEndpoint(dataSetUri).getExpectedCount());
+ Assert.assertEquals("expectedMessageCount should be the same as the DataSet size for a consumer-producer endpoint", dataSet.getSize(), getMockEndpoint(dataSetUri).getExpectedCount());
MockEndpoint result = getMockEndpoint(resultUri);
result.expectedMessageCount((int) dataSet.getSize());
- result.expectsAscending(TestSupport.header(Exchange.DATASET_INDEX).convertTo(Number.class));
+ result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
context.start();
@@ -99,7 +98,7 @@ public class DataSetConsumerTest extends CamelTestSupport {
MockEndpoint result = getMockEndpoint(resultUri);
result.expectedMessageCount((int) dataSet.getSize());
result.allMessages().header(Exchange.DATASET_INDEX).isNotNull();
- result.expectsAscending(TestSupport.header(Exchange.DATASET_INDEX).convertTo(Number.class));
+ result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
context.start();
@@ -138,7 +137,7 @@ public class DataSetConsumerTest extends CamelTestSupport {
MockEndpoint result = getMockEndpoint(resultUri);
result.expectedMessageCount((int) dataSet.getSize());
result.allMessages().header(Exchange.DATASET_INDEX).isNotNull();
- result.expectsAscending(TestSupport.header(Exchange.DATASET_INDEX).convertTo(Number.class));
+ result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
context.start();
@@ -158,7 +157,7 @@ public class DataSetConsumerTest extends CamelTestSupport {
MockEndpoint result = getMockEndpoint(resultUri);
result.expectedMessageCount((int) dataSet.getSize());
result.allMessages().header(Exchange.DATASET_INDEX).isNotNull();
- result.expectsAscending(TestSupport.header(Exchange.DATASET_INDEX).convertTo(Number.class));
+ result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
context.start();
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java
similarity index 89%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java
index 9d34415..a5a5434 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetEndpointTest.java
@@ -18,14 +18,14 @@ package org.apache.camel.component.dataset;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Assert;
import org.junit.Test;
-public class DataSetEndpointTest extends CamelTestSupport {
+public class DataSetEndpointTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
@@ -38,9 +38,9 @@ public class DataSetEndpointTest extends CamelTestSupport {
endpoint.setCamelContext(context);
endpoint.setInitialDelay(0);
- assertEquals(0, endpoint.getPreloadSize());
- assertEquals(0, endpoint.getConsumeDelay());
- assertEquals(3, endpoint.getProduceDelay());
+ Assert.assertEquals(0, endpoint.getPreloadSize());
+ Assert.assertEquals(0, endpoint.getConsumeDelay());
+ Assert.assertEquals(3, endpoint.getProduceDelay());
context.addRoutes(new RouteBuilder() {
@Override
@@ -59,11 +59,11 @@ public class DataSetEndpointTest extends CamelTestSupport {
final DataSetEndpoint endpoint = new DataSetEndpoint("dataset://foo", context.getComponent("dataset"), new SimpleDataSet(2));
endpoint.setConsumeDelay(2);
- assertEquals(2, endpoint.getConsumeDelay());
+ Assert.assertEquals(2, endpoint.getConsumeDelay());
endpoint.setProduceDelay(5);
- assertEquals(5, endpoint.getProduceDelay());
+ Assert.assertEquals(5, endpoint.getProduceDelay());
endpoint.setInitialDelay(1);
- assertEquals(1, endpoint.getInitialDelay());
+ Assert.assertEquals(1, endpoint.getInitialDelay());
context.addRoutes(new RouteBuilder() {
@Override
@@ -107,7 +107,7 @@ public class DataSetEndpointTest extends CamelTestSupport {
SimpleDataSet ds = new SimpleDataSet();
ds.setSize(2);
ds.setDefaultBody("Hi");
- assertEquals("Hi", ds.getDefaultBody());
+ Assert.assertEquals("Hi", ds.getDefaultBody());
}
@Test
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
similarity index 89%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
index f2f1136..ee708cc 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetPreloadTest.java
@@ -17,12 +17,13 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
import org.junit.Test;
-public class DataSetPreloadTest extends CamelTestSupport {
+public class DataSetPreloadTest extends ContextTestSupport {
@BindToRegistry("foo")
private SimpleDataSet dataSet = new SimpleDataSet(20);
@@ -39,11 +40,11 @@ public class DataSetPreloadTest extends CamelTestSupport {
assertMockEndpointsSatisfied();
DataSetEndpoint ds = context.getEndpoint(uri, DataSetEndpoint.class);
- assertEquals(5, ds.getPreloadSize());
+ Assert.assertEquals(5, ds.getPreloadSize());
// test getter/setter
ds.setPreloadSize(7);
- assertEquals(7, ds.getPreloadSize());
+ Assert.assertEquals(7, ds.getPreloadSize());
}
@Override
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
similarity index 97%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
index 6dc7c16..eadc69f 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetProducerTest.java
@@ -17,14 +17,15 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.NoSuchHeaderException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
import org.junit.Test;
-public class DataSetProducerTest extends CamelTestSupport {
+public class DataSetProducerTest extends ContextTestSupport {
@BindToRegistry("foo")
protected SimpleDataSet dataSet = new SimpleDataSet(20);
@@ -173,7 +174,7 @@ public class DataSetProducerTest extends CamelTestSupport {
}
}
- fail("AssertionError should have been generated");
+ Assert.fail("AssertionError should have been generated");
}
@Test
@@ -327,7 +328,7 @@ public class DataSetProducerTest extends CamelTestSupport {
}
}
- fail("AssertionError should have been generated");
+ Assert.fail("AssertionError should have been generated");
}
@Test
@@ -401,7 +402,7 @@ public class DataSetProducerTest extends CamelTestSupport {
}
}
- fail("AssertionError should have been generated");
+ Assert.fail("AssertionError should have been generated");
}
@Test
@@ -446,6 +447,6 @@ public class DataSetProducerTest extends CamelTestSupport {
}
}
- fail("AssertionError should have been generated");
+ Assert.fail("AssertionError should have been generated");
}
}
\ No newline at end of file
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
similarity index 94%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
index 305f2a6..9c229a5 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetSedaTest.java
@@ -17,15 +17,15 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
/**
* Unit test to demonstrate high concurrency with seda. Offspring by CAMEL-605.
*/
-public class DataSetSedaTest extends CamelTestSupport {
+public class DataSetSedaTest extends ContextTestSupport {
@BindToRegistry("foo")
private SimpleDataSet dataSet = new SimpleDataSet(200);
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
similarity index 94%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
index 6e68e08..65b09e1 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTest.java
@@ -17,11 +17,11 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-public class DataSetTest extends CamelTestSupport {
+public class DataSetTest extends ContextTestSupport {
@BindToRegistry("foo")
protected SimpleDataSet dataSet = new SimpleDataSet(20);
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
similarity index 93%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
index a67fc79..85af448 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.camel.component.dataset;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-public class DataSetTestAnyOrderTest extends CamelTestSupport {
+public class DataSetTestAnyOrderTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
similarity index 96%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
index d5c13ac..5c4239c 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestEndpointTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.dataset;
import org.apache.camel.CamelContext;
import org.apache.camel.Consumer;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -25,13 +26,9 @@ import org.apache.camel.Producer;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-/**
- *
- */
-public class DataSetTestEndpointTest extends CamelTestSupport {
+public class DataSetTestEndpointTest extends ContextTestSupport {
private String expectedBody = "Hello World";
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java
similarity index 94%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java
index 368274d..50f2124 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileSplitTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.dataset;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-public class DataSetTestFileSplitTest extends CamelTestSupport {
+public class DataSetTestFileSplitTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java
similarity index 93%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java
index 1ee74bf..b07e667 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestFileTest.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.dataset;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-public class DataSetTestFileTest extends CamelTestSupport {
+public class DataSetTestFileTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
similarity index 92%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
index 3cbe07c..da1c6d1 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.camel.component.dataset;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-public class DataSetTestSedaTest extends CamelTestSupport {
+public class DataSetTestSedaTest extends ContextTestSupport {
@Override
public boolean isUseRouteBuilder() {
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
similarity index 91%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
index 8377c9d..cce4584 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerTest.java
@@ -17,13 +17,14 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class FileDataSetConsumerTest extends CamelTestSupport {
+public class FileDataSetConsumerTest extends ContextTestSupport {
@BindToRegistry("foo")
protected FileDataSet dataSet;
@@ -54,7 +55,7 @@ public class FileDataSetConsumerTest extends CamelTestSupport {
@Before
public void setUp() throws Exception {
dataSet = new FileDataSet(testDataFileName);
- assertEquals("Unexpected DataSet size", 1, dataSet.getSize());
+ Assert.assertEquals("Unexpected DataSet size", 1, dataSet.getSize());
super.setUp();
}
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
similarity index 90%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
index 0fa307f..57841cf 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetConsumerWithSplitTest.java
@@ -17,13 +17,14 @@
package org.apache.camel.component.dataset;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class FileDataSetConsumerWithSplitTest extends CamelTestSupport {
+public class FileDataSetConsumerWithSplitTest extends ContextTestSupport {
@BindToRegistry("foo")
protected FileDataSet dataSet;
@@ -55,7 +56,7 @@ public class FileDataSetConsumerWithSplitTest extends CamelTestSupport {
@Before
public void setUp() throws Exception {
dataSet = new FileDataSet(testDataFileName, "\n");
- assertEquals("Unexpected DataSet size", testDataFileRecordCount, dataSet.getSize());
+ Assert.assertEquals("Unexpected DataSet size", testDataFileRecordCount, dataSet.getSize());
super.setUp();
}
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
similarity index 93%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
index f349f6d..22d0d63 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerTest.java
@@ -23,15 +23,16 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-public class FileDataSetProducerTest extends CamelTestSupport {
+public class FileDataSetProducerTest extends ContextTestSupport {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -71,7 +72,7 @@ public class FileDataSetProducerTest extends CamelTestSupport {
public void setUp() throws Exception {
File fileDataset = createFileDatasetWithSystemEndOfLine();
dataSet = new FileDataSet(fileDataset);
- assertEquals("Unexpected DataSet size", 1, dataSet.getSize());
+ Assert.assertEquals("Unexpected DataSet size", 1, dataSet.getSize());
super.setUp();
}
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
similarity index 88%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
index b0d455c..4dbb1ac 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/FileDataSetProducerWithSplitTest.java
@@ -23,16 +23,16 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.test.junit4.TestSupport;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-public class FileDataSetProducerWithSplitTest extends CamelTestSupport {
+public class FileDataSetProducerWithSplitTest extends ContextTestSupport {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -40,7 +40,6 @@ public class FileDataSetProducerWithSplitTest extends CamelTestSupport {
@BindToRegistry("foo")
protected FileDataSet dataSet;
- final String testDataFileName = "src/test/data/file-dataset-test.txt";
final int testDataFileRecordCount = 10;
final String sourceUri = "direct://source";
@@ -74,8 +73,8 @@ public class FileDataSetProducerWithSplitTest extends CamelTestSupport {
@Before
public void setUp() throws Exception {
File fileDataset = createFileDatasetWithSystemEndOfLine();
- dataSet = new FileDataSet(fileDataset, TestSupport.LS);
- assertEquals("Unexpected DataSet size", testDataFileRecordCount, dataSet.getSize());
+ dataSet = new FileDataSet(fileDataset, LS);
+ Assert.assertEquals("Unexpected DataSet size", testDataFileRecordCount, dataSet.getSize());
super.setUp();
}
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
similarity index 95%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
index f3403d9..70146e1 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetConsumerTest.java
@@ -20,13 +20,13 @@ import java.util.LinkedList;
import java.util.List;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Test;
-public class ListDataSetConsumerTest extends CamelTestSupport {
+public class ListDataSetConsumerTest extends ContextTestSupport {
@BindToRegistry("foo")
protected ListDataSet dataSet;
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
similarity index 95%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
index 126df14..982678b 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/ListDataSetProducerTest.java
@@ -20,13 +20,13 @@ import java.util.LinkedList;
import java.util.List;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Before;
import org.junit.Test;
-public class ListDataSetProducerTest extends CamelTestSupport {
+public class ListDataSetProducerTest extends ContextTestSupport {
@BindToRegistry("foo")
protected ListDataSet dataSet = new ListDataSet();
diff --git a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
similarity index 91%
rename from components/camel-dataset/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
rename to core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
index 618fa6e..fd44387 100644
--- a/components/camel-dataset/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/RoutePerformanceTest.java
@@ -21,18 +21,17 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.camel.BindToRegistry;
+import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.StopWatch;
import org.junit.Test;
-import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
/**
* A route for simple performance testing that can be used when we suspect
* something is wrong. Inspired by end user on forum doing this as proof of concept.
*/
-public class RoutePerformanceTest extends CamelTestSupport {
+public class RoutePerformanceTest extends ContextTestSupport {
private int size = 250;
@@ -50,7 +49,7 @@ public class RoutePerformanceTest extends CamelTestSupport {
endpoint.expectedHeaderReceived("foo", 123);
// wait 30 sec for slow servers
- assertIsSatisfied(context, 30, TimeUnit.SECONDS);
+ MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
log.info("RoutePerformanceTest: Sent: {} Took: {} ms", size, watch.taken());
}
[camel] 26/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5ae35558be8cc17d9fef48d956f84170b42f9997
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 16:54:53 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../camel/component/mock/MockExpressionClause.java | 587 ----------------
.../mock/MockExpressionClauseSupport.java | 737 +--------------------
.../component/mock/MockAssertionClauseTest.java | 6 +-
3 files changed, 11 insertions(+), 1319 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
index 4dec652..04178ec 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
@@ -27,7 +27,6 @@ import org.apache.camel.Message;
import org.apache.camel.Predicate;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
/**
@@ -334,32 +333,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
* href="http://camel.apache.org/bean-language.html">bean language</a>
* which basically means the bean is invoked to determine the expression
* value.
- *
- * @param instance the instance of the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Object instance) {
- return delegate.method(instance);
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html">bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param beanType the Class of the bean which we want to invoke
- * @return the builder to continue processing the DSL
- */
- public T method(Class<?> beanType) {
- return delegate.method(beanType);
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html">bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
*
* @param bean the name of the bean looked up the registry
* @param method the name of the method to invoke on the bean
@@ -370,34 +343,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
}
/**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html">bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param instance the instance of the bean
- * @param method the name of the method to invoke on the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Object instance, String method) {
- return delegate.method(instance, method);
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html">bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param beanType the Class of the bean which we want to invoke
- * @param method the name of the method to invoke on the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Class<?> beanType, String method) {
- return delegate.method(beanType, method);
- }
-
- /**
* Evaluates a <a href="http://camel.apache.org/groovy.html">Groovy
* expression</a>
*
@@ -435,100 +380,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
}
/**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions) {
- return delegate.jsonpath(text, suppressExceptions);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, Class<?> resultType) {
- return delegate.jsonpath(text, resultType);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType) {
- return delegate.jsonpath(text, suppressExceptions, resultType);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType, String headerName) {
- return delegate.jsonpath(text, suppressExceptions, true, resultType, headerName);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text) {
- return delegate.jsonpathWriteAsString(text);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions) {
- return delegate.jsonpathWriteAsString(text, suppressExceptions);
- }
-
- /**
- * Evaluates a <a
- * href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions, String headerName) {
- return delegate.jsonpathWriteAsString(text, suppressExceptions, true, headerName);
- }
-
- /**
* Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL
* expression</a>
*
@@ -584,228 +435,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
}
/**
- * Evaluates a <a href="http://camel.apache.org/simple.html">Simple
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param resultType the result type
- * @return the builder to continue processing the DSL
- */
- public T simple(String text, Class<?> resultType) {
- return delegate.simple(text, resultType);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token) {
- return delegate.tokenize(token);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex) {
- return tokenize(token, regex, false);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param skipFirst whether to skip the first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, boolean skipFirst) {
- return delegate.tokenize(token, null, regex, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, int group) {
- return tokenize(token, regex, group, false);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, String group) {
- return tokenize(token, regex, group, false);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param group to group by the given number
- * @param skipFirst whether to skip the first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, int group, boolean skipFirst) {
- return delegate.tokenize(token, null, regex, group, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param group to group by the given number
- * @param skipFirst whether to skip the first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, String group, boolean skipFirst) {
- return delegate.tokenize(token, null, regex, group, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, int group) {
- return delegate.tokenize(token, group);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param group to group by the given number
- * @param skipFirst whether to skip the first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, int group, boolean skipFirst) {
- return delegate.tokenize(token, group, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName) {
- return delegate.tokenize(token, headerName);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex) {
- return delegate.tokenize(token, headerName, regex);
- }
-
- /**
- * Evaluates a token pair expression on the message body.
- * <p/>
- * Tokens is not included.
- *
- * @param startToken the start token
- * @param endToken the end token
- * @return the builder to continue processing the DSL
- */
- public T tokenizePair(String startToken, String endToken) {
- return tokenizePair(startToken, endToken, false);
- }
-
- /**
- * Evaluates a token pair expression on the message body
- *
- * @param startToken the start token
- * @param endToken the end token
- * @param includeTokens whether to include tokens
- * @return the builder to continue processing the DSL
- */
- public T tokenizePair(String startToken, String endToken, boolean includeTokens) {
- return delegate.tokenizePair(startToken, endToken, includeTokens);
- }
-
- /**
- * Evaluates a XML token expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXML(String tagName) {
- return tokenizeXML(tagName, null);
- }
-
- /**
- * Evaluates a XML token expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXML(String tagName, int group) {
- return tokenizeXML(tagName, null, group);
- }
-
- /**
- * Evaluates a token pair expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName parent or root tag name that contains namespace(s) to inherit
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXML(String tagName, String inheritNamespaceTagName) {
- return tokenizeXML(tagName, inheritNamespaceTagName, 0);
- }
-
- /**
- * Evaluates a token pair expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName parent or root tag name that contains namespace(s) to inherit
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXML(String tagName, String inheritNamespaceTagName, int group) {
- return delegate.tokenizeXMLPair(tagName, inheritNamespaceTagName, group);
- }
-
- public T xtokenize(String path, Namespaces namespaces) {
- return xtokenize(path, 'i', namespaces);
- }
-
- public T xtokenize(String path, char mode, Namespaces namespaces) {
- return xtokenize(path, mode, namespaces, 0);
- }
-
- public T xtokenize(String path, char mode, Namespaces namespaces, int group) {
- return delegate.xtokenize(path, mode, namespaces, group);
- }
-
- /**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a>
*
@@ -815,113 +444,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
public T xpath(String text) {
return delegate.xpath(text);
}
-
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> on the supplied header name's contents
- *
- * @param text the expression to be evaluated
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, String headerName) {
- return delegate.xpath(text, headerName);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType) {
- return delegate.xpath(text, resultType);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type on the supplied
- * header name's contents
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, String headerName) {
- return delegate.xpath(text, resultType, headerName);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
- return delegate.xpath(text, resultType, namespaces);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs on the supplied header name's contents
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @param namespaces the namespace prefix and URIs to use
- *
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- return delegate.xpath(text, resultType, namespaces, headerName);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
- return delegate.xpath(text, resultType, namespaces);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Namespaces namespaces) {
- return delegate.xpath(text, namespaces);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Map<String, String> namespaces) {
- return delegate.xpath(text, namespaces);
- }
/**
* Evaluates an <a
@@ -935,115 +457,6 @@ public class MockExpressionClause<T> implements Expression, Predicate {
}
/**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> on the supplied header name's contents
- *
- * @param text the expression to be evaluated
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, String headerName) {
- return delegate.xquery(text, headerName);
- }
-
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType) {
- return delegate.xquery(text, resultType);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, String headerName) {
- return delegate.xquery(text, resultType, headerName);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
- return delegate.xquery(text, resultType, namespaces);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @param namespaces the namespace prefix and URIs to use
- *
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- return delegate.xquery(text, resultType, namespaces, headerName);
- }
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
- return delegate.xquery(text, resultType, namespaces);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Namespaces namespaces) {
- return delegate.xquery(text, namespaces);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Map<String, String> namespaces) {
- return delegate.xquery(text, namespaces);
- }
-
- /**
* Evaluates a given language name with the expression text
*
* @param language the name of the language
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
index b3f81e6..35795b0 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
@@ -16,20 +16,9 @@
*/
package org.apache.camel.component.mock;
-import java.util.Map;
-
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
-import org.apache.camel.model.language.JsonPathExpression;
-import org.apache.camel.model.language.LanguageExpression;
-import org.apache.camel.model.language.MethodCallExpression;
-import org.apache.camel.model.language.SimpleExpression;
-import org.apache.camel.model.language.TokenizerExpression;
-import org.apache.camel.model.language.XMLTokenizerExpression;
-import org.apache.camel.model.language.XPathExpression;
-import org.apache.camel.model.language.XQueryExpression;
import org.apache.camel.support.builder.ExpressionBuilder;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.support.language.ExpressionModel;
/**
@@ -37,8 +26,6 @@ import org.apache.camel.support.language.ExpressionModel;
*/
public class MockExpressionClauseSupport<T> {
- // TODO: make the model.language class not here as we want to use this in camel-mock but have similar method api compatability
-
private T result;
private Expression expressionValue;
private ExpressionModel expressionType;
@@ -206,66 +193,16 @@ public class MockExpressionClauseSupport<T> {
* which basically means the bean is invoked to determine the expression
* value.
*
- * @param instance the instance of the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Object instance) {
- return expression(new MethodCallExpression(instance));
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param beanType the Class of the bean which we want to invoke
- * @return the builder to continue processing the DSL
- */
- public T method(Class<?> beanType) {
- return expression(new MethodCallExpression(beanType));
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
* @param bean the name of the bean looked up the registry
* @param method the name of the method to invoke on the bean
* @return the builder to continue processing the DSL
*/
public T method(String bean, String method) {
- return expression(new MethodCallExpression(bean, method));
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param instance the instance of the bean
- * @param method the name of the method to invoke on the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Object instance, String method) {
- return expression(new MethodCallExpression(instance, method));
- }
-
- /**
- * Evaluates an expression using the <a
- * href="http://camel.apache.org/bean-language.html>bean language</a>
- * which basically means the bean is invoked to determine the expression
- * value.
- *
- * @param beanType the Class of the bean which we want to invoke
- * @param method the name of the method to invoke on the bean
- * @return the builder to continue processing the DSL
- */
- public T method(Class<?> beanType, String method) {
- return expression(new MethodCallExpression(beanType, method));
+ if (method != null) {
+ return expression(ExpressionBuilder.languageExpression("bean", bean + "?method=" + method));
+ } else {
+ return method(bean);
+ }
}
/**
@@ -305,170 +242,6 @@ public class MockExpressionClauseSupport<T> {
}
/**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple, Class<?> resultType) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple, Class<?> resultType, String headerName) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setResultType(resultType);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text) {
- return jsonpathWriteAsString(text, false);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions, boolean allowSimple) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- return expression(expression);
- }
-
- /**
- * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path
- * expression</a> with writeAsString enabled.
- *
- * @param text the expression to be evaluated
- * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException
- * @param allowSimple whether to allow in inlined simple exceptions in the json path expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T jsonpathWriteAsString(String text, boolean suppressExceptions, boolean allowSimple, String headerName) {
- JsonPathExpression expression = new JsonPathExpression(text);
- expression.setWriteAsString(true);
- expression.setSuppressExceptions(suppressExceptions);
- expression.setAllowSimple(allowSimple);
- expression.setHeaderName(headerName);
- return expression(expression);
- }
-
- /**
* Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL
* expression</a>
*
@@ -524,21 +297,6 @@ public class MockExpressionClauseSupport<T> {
}
/**
- * Evaluates a <a href="http://camel.apache.org/simple.html">Simple
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param resultType the result type
- * @return the builder to continue processing the DSL
- */
- public T simple(String text, Class<?> resultType) {
- SimpleExpression expression = new SimpleExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
- /**
* Evaluates an <a href="http://camel.apache.org/hl7.html">HL7 Terser
* expression</a>
*
@@ -550,226 +308,6 @@ public class MockExpressionClauseSupport<T> {
}
/**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token) {
- return tokenize(token, null, false);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, int group) {
- return tokenize(token, null, false, group);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param group to group by the given number
- * @param skipFirst whether to skip the very first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, int group, boolean skipFirst) {
- return tokenize(token, null, false, group, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex) {
- return tokenize(token, null, regex);
- }
-
- /**
- * Evaluates a token expression on the message body
- *
- * @param token the token
- * @param regex whether the token is a regular expression or not
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, boolean regex, int group) {
- return tokenize(token, null, regex, group);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName) {
- return tokenize(token, headerName, false);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex, int group) {
- return tokenize(token, headerName, regex, group, false);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param skipFirst whether to skip the very first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex, boolean skipFirst) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- expression.setSkipFirst(skipFirst);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
- * @param skipFirst whether to skip the very first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex, int group, boolean skipFirst) {
- return tokenize(token, headerName, regex, "" + group, skipFirst);
- }
-
- /**
- * Evaluates a token expression on the given header
- *
- * @param token the token
- * @param headerName name of header to tokenize
- * @param regex whether the token is a regular expression or not
- * @param group to group by number of parts
- * @param skipFirst whether to skip the very first element
- * @return the builder to continue processing the DSL
- */
- public T tokenize(String token, String headerName, boolean regex, String group, boolean skipFirst) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(token);
- expression.setHeaderName(headerName);
- expression.setRegex(regex);
- expression.setGroup(group);
- expression.setSkipFirst(skipFirst);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a token pair expression on the message body
- *
- * @param startToken the start token
- * @param endToken the end token
- * @param includeTokens whether to include tokens
- * @return the builder to continue processing the DSL
- */
- public T tokenizePair(String startToken, String endToken, boolean includeTokens) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(startToken);
- expression.setEndToken(endToken);
- expression.setIncludeTokens(includeTokens);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates a token pair expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName optional parent or root tag name that contains namespace(s) to inherit
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXMLPair(String tagName, String inheritNamespaceTagName, int group) {
- return tokenizeXMLPair(tagName, inheritNamespaceTagName, "" + group);
- }
-
- /**
- * Evaluates a token pair expression on the message body with XML content
- *
- * @param tagName the tag name of the child nodes to tokenize
- * @param inheritNamespaceTagName optional parent or root tag name that contains namespace(s) to inherit
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T tokenizeXMLPair(String tagName, String inheritNamespaceTagName, String group) {
- TokenizerExpression expression = new TokenizerExpression();
- expression.setToken(tagName);
- expression.setInheritNamespaceTagName(inheritNamespaceTagName);
- expression.setXml(true);
- expression.setGroup(group);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates an XML token expression on the message body with XML content
- *
- * @param path the xpath like path notation specifying the child nodes to tokenize
- * @param mode one of 'i', 'w', or 'u' to inject the namespaces to the token, to
- * wrap the token with its ancestor contet, or to unwrap to its element child
- * @param namespaces the namespace map to the namespace bindings
- * @param group to group by the given number
- * @return the builder to continue processing the DSL
- */
- public T xtokenize(String path, char mode, Namespaces namespaces, int group) {
- XMLTokenizerExpression expression = new XMLTokenizerExpression(path);
- expression.setMode(Character.toString(mode));
- expression.setNamespaces(namespaces.getNamespaces());
-
- if (group > 0) {
- expression.setGroup(group);
- }
- setExpressionType(expression);
- return result;
- }
-
- /**
* Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
* expression</a>
*
@@ -777,135 +315,7 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T xpath(String text) {
- return expression(new XPathExpression(text));
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> on the supplied header name's contents
- *
- * @param text the expression to be evaluated
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setHeaderName(headerName);
- return expression(expression);
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type on the supplied
- * header name's contents
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
- }
-
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
- return xpath(text, resultType, namespaces.getNamespaces());
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs on the supplied header name's contents
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces.getNamespaces());
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
- }
-
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified result type and set of namespace
- * prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
- XPathExpression expression = new XPathExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Namespaces namespaces) {
- return xpath(text, namespaces.getNamespaces());
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
- * expression</a> with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xpath(String text, Map<String, String> namespaces) {
- XPathExpression expression = new XPathExpression(text);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return expression(ExpressionBuilder.languageExpression("xpath", text));
}
/**
@@ -916,136 +326,7 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T xquery(String text) {
- return expression(new XQueryExpression(text));
- }
-
- /**
- * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery
- * expression</a>
- *
- * @param text the expression to be evaluated
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setHeaderName(headerName);
- return expression(expression);
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- setExpressionType(expression);
- return result;
- }
-
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
- return xquery(text, resultType, namespaces.getNamespaces());
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @param headerName the name of the header to apply the expression to
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Namespaces namespaces, String headerName) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces.getNamespaces());
- expression.setHeaderName(headerName);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified result type and set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param resultType the return type expected by the expression
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setResultType(resultType);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Namespaces namespaces) {
- return xquery(text, namespaces.getNamespaces());
- }
-
- /**
- * Evaluates an <a
- * href="http://camel.apache.org/xquery.html">XQuery expression</a>
- * with the specified set of namespace prefixes and URIs
- *
- * @param text the expression to be evaluated
- * @param namespaces the namespace prefix and URIs to use
- * @return the builder to continue processing the DSL
- */
- public T xquery(String text, Map<String, String> namespaces) {
- XQueryExpression expression = new XQueryExpression(text);
- expression.setNamespaces(namespaces);
- setExpressionType(expression);
- return result;
+ return expression(ExpressionBuilder.languageExpression("xquery", text));
}
/**
@@ -1056,9 +337,7 @@ public class MockExpressionClauseSupport<T> {
* @return the builder to continue processing the DSL
*/
public T language(String language, String expression) {
- LanguageExpression exp = new LanguageExpression(language, expression);
- setExpressionType(exp);
- return result;
+ return expression(ExpressionBuilder.languageExpression(language, expression));
}
// Properties
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
index 1118342..127098b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockAssertionClauseTest.java
@@ -25,7 +25,7 @@ public class MockAssertionClauseTest extends ContextTestSupport {
@Test
public void testAssertionClauseAll() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.allMessages().xpath("/person[@name='James']", Boolean.class);
+ mock.allMessages().xpath("/person[@name='James']");
template.sendBody("direct:start", "<person name='James' last='Hanson'/>");
template.sendBody("direct:start", "<person name='James' last='Jackson'/>");
@@ -37,10 +37,10 @@ public class MockAssertionClauseTest extends ContextTestSupport {
public void testAssertionClausePer() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.message(0).xpath("/person[@last='Hanson']", Boolean.class);
+ mock.message(0).xpath("/person[@last='Hanson']");
mock.message(0).body().contains("Hanson");
- mock.message(1).xpath("/person[@last='Jackson']", Boolean.class);
+ mock.message(1).xpath("/person[@last='Jackson']");
mock.message(1).body().contains("Jackson");
template.sendBody("direct:start", "<person name='James' last='Hanson'/>");
[camel] 12/38: CAMEL-13422: Remove camel-rmi component
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7203092878179dc614d18e6e786a4c90093607b7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:23:16 2019 +0200
CAMEL-13422: Remove camel-rmi component
---
apache-camel/src/main/descriptors/common-bin.xml | 2 -
components/camel-rmi/pom.xml | 74 --------
.../camel-rmi/src/main/docs/rmi-component.adoc | 159 ----------------
.../apache/camel/component/rmi/RmiComponent.java | 55 ------
.../apache/camel/component/rmi/RmiConsumer.java | 126 -------------
.../apache/camel/component/rmi/RmiEndpoint.java | 165 -----------------
.../apache/camel/component/rmi/RmiProducer.java | 45 -----
.../camel/component/rmi/RmiRegistryBean.java | 57 ------
.../org/apache/camel/component/rmi/package.html | 27 ---
.../apache/camel/component/rmi/DamnException.java | 29 ---
.../apache/camel/component/rmi/EchoService.java | 34 ----
.../java/org/apache/camel/component/rmi/IEcho.java | 30 ---
.../java/org/apache/camel/component/rmi/ISay.java | 24 ---
.../camel/component/rmi/RmiConcurrencyTest.java | 97 ----------
.../camel/component/rmi/RmiDamnExceptionTest.java | 80 --------
.../rmi/RmiIllegalArgumentExceptionTest.java | 87 ---------
.../camel/component/rmi/RmiRouteEndpointTest.java | 48 -----
.../apache/camel/component/rmi/RmiRouteTest.java | 82 ---------
.../camel/component/rmi/RmiRouteTestSupport.java | 58 ------
.../org/apache/camel/component/rmi/SayService.java | 41 -----
.../camel-rmi/src/test/resources/log4j2.properties | 28 ---
components/pom.xml | 1 -
parent/pom.xml | 10 -
.../components-starter/camel-rmi-starter/pom.xml | 53 ------
.../springboot/RmiComponentAutoConfiguration.java | 128 -------------
.../rmi/springboot/RmiComponentConfiguration.java | 54 ------
.../src/main/resources/META-INF/LICENSE.txt | 203 ---------------------
.../src/main/resources/META-INF/NOTICE.txt | 11 --
.../additional-spring-configuration-metadata.json | 10 -
.../src/main/resources/META-INF/spring.factories | 18 --
.../src/main/resources/META-INF/spring.provides | 17 --
platforms/spring-boot/components-starter/pom.xml | 1 -
32 files changed, 1854 deletions(-)
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index abd6772..9730b86 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -252,7 +252,6 @@
<include>org.apache.camel:camel-rest-swagger</include>
<include>org.apache.camel:camel-restlet</include>
<include>org.apache.camel:camel-ribbon</include>
- <include>org.apache.camel:camel-rmi</include>
<include>org.apache.camel:camel-rss</include>
<include>org.apache.camel:camel-rxjava2</include>
<include>org.apache.camel:camel-saga</include>
@@ -580,7 +579,6 @@
<include>org.apache.camel:camel-rest-swagger-starter</include>
<include>org.apache.camel:camel-restlet-starter</include>
<include>org.apache.camel:camel-ribbon-starter</include>
- <include>org.apache.camel:camel-rmi-starter</include>
<include>org.apache.camel:camel-rss-starter</include>
<include>org.apache.camel:camel-rxjava2-starter</include>
<include>org.apache.camel:camel-saga-starter</include>
diff --git a/components/camel-rmi/pom.xml b/components/camel-rmi/pom.xml
deleted file mode 100644
index 8c9682a..0000000
--- a/components/camel-rmi/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-rmi</artifactId>
- <packaging>jar</packaging>
- <name>Camel :: RMI</name>
- <description>Camel RMI support</description>
-
- <properties>
- </properties>
-
- <dependencies>
-
- <!-- requires camel-core due using bean component -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/components/camel-rmi/src/main/docs/rmi-component.adoc b/components/camel-rmi/src/main/docs/rmi-component.adoc
deleted file mode 100644
index 36b1974..0000000
--- a/components/camel-rmi/src/main/docs/rmi-component.adoc
+++ /dev/null
@@ -1,159 +0,0 @@
-[[rmi-component]]
-== RMI Component
-
-*Available as of Camel version 1.0*
-
-The *rmi:* component binds Exchanges to the RMI
-protocol (JRMP).
-
-Since this binding is just using RMI, normal RMI rules still apply
-regarding what methods can be invoked. This component supports only
-Exchanges that carry a method invocation from an interface that extends
-the http://java.sun.com/j2se/1.3/docs/api/java/rmi/Remote.html[Remote]
-interface. All parameters in the method should be either
-http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html[Serializable]
-or `Remote` objects.
-
-Maven users will need to add the following dependency to their `pom.xml`
-for this component:
-
-[source,xml]
-------------------------------------------------------------
-<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>x.x.x</version>
- <!-- use the same version as your Camel core version -->
-</dependency>
-------------------------------------------------------------
-
-### URI format
-
-[source,java]
-------------------------------------------------------------------
-rmi://rmi-regisitry-host:rmi-registry-port/registry-path[?options]
-------------------------------------------------------------------
-
-For example:
-
-[source,java]
-------------------------------------
-rmi://localhost:1099/path/to/service
-------------------------------------
-
-You can append query options to the URI in the following format,
-`?option=value&option=value&...`
-
-### Options
-
-
-// component options: START
-The RMI component has no options.
-// component options: END
-
-
-
-// endpoint options: START
-The RMI endpoint is configured using URI syntax:
-
-----
-rmi:hostname:port/name
-----
-
-with the following path and query parameters:
-
-==== Path Parameters (3 parameters):
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *hostname* | Hostname of RMI server | localhost | String
-| *name* | *Required* Name to use when binding to RMI server | | String
-| *port* | Port number of RMI server | 1099 | int
-|===
-
-
-==== Query Parameters (6 parameters):
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *method* (common) | You can set the name of the method to invoke. | | String
-| *remoteInterfaces* (common) | To specific the remote interfaces. | | List
-| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
-| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler
-| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern
-| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
-|===
-// endpoint options: END
-// spring-boot-auto-configure options: START
-=== Spring Boot Auto-Configuration
-
-When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
-
-[source,xml]
-----
-<dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>x.x.x</version>
- <!-- use the same version as your Camel core version -->
-</dependency>
-----
-
-
-The component supports 2 options, which are listed below.
-
-
-
-[width="100%",cols="2,5,^1,2",options="header"]
-|===
-| Name | Description | Default | Type
-| *camel.component.rmi.enabled* | Enable rmi component | true | Boolean
-| *camel.component.rmi.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
-|===
-// spring-boot-auto-configure options: END
-
-
-
-### Using
-
-To call out to an existing RMI service registered in an RMI registry,
-create a route similar to the following:
-
-[source,java]
-------------------------------------------------
-from("pojo:foo").to("rmi://localhost:1099/foo");
-------------------------------------------------
-
-To bind an existing camel processor or service in an RMI registry,
-define an RMI endpoint as follows:
-
-[source,java]
--------------------------------------------------------------------------
-RmiEndpoint endpoint= (RmiEndpoint) endpoint("rmi://localhost:1099/bar");
-endpoint.setRemoteInterfaces(ISay.class);
-from(endpoint).to("pojo:bar");
--------------------------------------------------------------------------
-
-Note that when binding an RMI consumer endpoint, you must specify the
-`Remote` interfaces exposed.
-
-In XML DSL you can do as follows from *Camel 2.7* onwards:
-
-[source,xml]
-------------------------------------------------------------------------------------------------------------------------
- <camel:route>
- <from uri="rmi://localhost:37541/helloServiceBean?remoteInterfaces=org.apache.camel.example.osgi.HelloService"/>
- <to uri="bean:helloServiceBean"/>
- </camel:route>
-------------------------------------------------------------------------------------------------------------------------
-
-### See Also
-
-* Configuring Camel
-* Component
-* Endpoint
-* Getting Started
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
deleted file mode 100644
index 845b257..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiComponent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
-
-@Component("rmi")
-public class RmiComponent extends DefaultComponent {
-
- public RmiComponent() {
- }
-
- @Override
- protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
- RmiEndpoint rmi = new RmiEndpoint(uri, this);
-
- // lookup remote interfaces
- List<Class<?>> classes = new ArrayList<>();
- Iterator<?> it = getAndRemoveParameter(parameters, "remoteInterfaces", Iterator.class);
- while (it != null && it.hasNext()) {
- Object next = it.next();
- Class<?> clazz = getCamelContext().getTypeConverter().mandatoryConvertTo(Class.class, next);
- classes.add(clazz);
- }
-
- if (!classes.isEmpty()) {
- List<Class<?>> interfaces = classes;
- rmi.setRemoteInterfaces(interfaces);
- }
-
- setProperties(rmi, parameters);
- return rmi;
- }
-}
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
deleted file mode 100644
index 1d4fc66..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiConsumer.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.support.DefaultConsumer;
-
-/**
- * A {@link org.apache.camel.Consumer Consumer} which uses RMI's {@link UnicastRemoteObject} to consume
- * method invocations.
- */
-public class RmiConsumer extends DefaultConsumer implements InvocationHandler {
-
- private final RmiEndpoint endpoint;
- private Remote stub;
- private Remote proxy;
-
- public RmiConsumer(RmiEndpoint endpoint, Processor processor) {
- super(endpoint, processor);
- this.endpoint = endpoint;
- }
-
- @Override
- protected void doStart() throws Exception {
- Class<?>[] interfaces = new Class[endpoint.getRemoteInterfaces().size()];
- endpoint.getRemoteInterfaces().toArray(interfaces);
- proxy = (Remote)Proxy.newProxyInstance(endpoint.getClassLoader(), interfaces, this);
- stub = UnicastRemoteObject.exportObject(proxy, endpoint.getPort());
-
- try {
- Registry registry = endpoint.getRegistry();
- String name = endpoint.getName();
- registry.bind(name, stub);
-
- } catch (Exception e) {
- // Registration might fail.. clean up..
- try {
- UnicastRemoteObject.unexportObject(stub, true);
- } catch (Throwable ignore) {
- }
- stub = null;
- throw e;
- }
- super.doStart();
- }
-
- @Override
- protected void doStop() throws Exception {
- super.doStop();
- try {
- Registry registry = endpoint.getRegistry();
- registry.unbind(endpoint.getName());
- } catch (Throwable e) {
- // do our best to unregister
- }
- UnicastRemoteObject.unexportObject(proxy, true);
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (!isStarted()) {
- throw new IllegalStateException("The endpoint is not active: " + getEndpoint().getEndpointUri());
- }
- BeanInvocation invocation = new BeanInvocation(method, args);
- Exchange exchange = getEndpoint().createExchange();
- exchange.getIn().setBody(invocation);
- try {
- log.debug("Invoking {} with args {}", method, args);
- getProcessor().process(exchange);
- } catch (Exception e) {
- exchange.setException(e);
- }
-
- // is there a matching exception from the signature, then throw that
- // or fallback and ensure the exception is thrown as a RemoteException
- Throwable fault = exchange.getException();
- if (fault != null) {
- Object match = null;
- for (Class<?> type : method.getExceptionTypes()) {
- Object found = exchange.getException(type);
- if (found != null) {
- match = found;
- break;
- }
- }
- if (match instanceof Throwable) {
- // we have a match
- throw (Throwable) match;
- } else {
- throw new RemoteException("Error invoking " + method, fault);
- }
- }
- return exchange.getOut().getBody();
- }
-
- public Remote getProxy() {
- return proxy;
- }
-
- public Remote getStub() {
- return stub;
- }
-}
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
deleted file mode 100644
index be6b52f..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiEndpoint.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
-import org.apache.camel.support.DefaultEndpoint;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * The rmi component is for invoking Java RMI beans from Camel.
- */
-@UriEndpoint(firstVersion = "1.0.0", scheme = "rmi", title = "RMI", syntax = "rmi:hostname:port/name", label = "messaging")
-public class RmiEndpoint extends DefaultEndpoint {
-
- private ClassLoader classLoader;
- private URI uri;
-
- @UriPath(description = "Hostname of RMI server", defaultValue = "localhost")
- private String hostname;
- @UriPath(description = "Port number of RMI server", defaultValue = "" + Registry.REGISTRY_PORT)
- private int port;
- @UriPath(description = "Name to use when binding to RMI server") @Metadata(required = true)
- private String name;
- @UriParam
- private List<Class<?>> remoteInterfaces;
- @UriParam
- private String method;
-
- public RmiEndpoint() {
- }
-
- protected RmiEndpoint(String endpointUri, RmiComponent component) throws URISyntaxException {
- super(endpointUri, component);
- this.uri = new URI(endpointUri);
- }
-
- public boolean isSingleton() {
- return false;
- }
-
- @Override
- protected String createEndpointUri() {
- return uri.toString();
- }
-
- public Consumer createConsumer(Processor processor) throws Exception {
- ObjectHelper.notNull(uri, "uri");
- if (remoteInterfaces == null || remoteInterfaces.size() == 0) {
- throw new IllegalArgumentException("To create a RMI consumer, the RMI endpoint's remoteInterfaces property must be be configured.");
- }
- RmiConsumer answer = new RmiConsumer(this, processor);
- configureConsumer(answer);
- return answer;
- }
-
- public Producer createProducer() throws Exception {
- ObjectHelper.notNull(uri, "uri");
- return new RmiProducer(this);
- }
-
- public String getName() {
- String path = uri.getPath();
- if (path == null) {
- path = uri.getSchemeSpecificPart();
- }
- // skip leading slash
- if (path.startsWith("/")) {
- return path.substring(1);
- }
- return path;
- }
-
- public Registry getRegistry() throws RemoteException {
- if (uri.getHost() != null) {
- if (uri.getPort() == -1) {
- return LocateRegistry.getRegistry(uri.getHost());
- } else {
- return LocateRegistry.getRegistry(uri.getHost(), uri.getPort());
- }
- } else {
- return LocateRegistry.getRegistry();
- }
- }
-
- public List<Class<?>> getRemoteInterfaces() {
- return remoteInterfaces;
- }
-
- /**
- * To specific the remote interfaces.
- */
- public void setRemoteInterfaces(List<Class<?>> remoteInterfaces) {
- this.remoteInterfaces = remoteInterfaces;
- if (classLoader == null && !remoteInterfaces.isEmpty()) {
- classLoader = remoteInterfaces.get(0).getClassLoader();
- }
- }
-
- public void setRemoteInterfaces(Class<?>... remoteInterfaces) {
- setRemoteInterfaces(Arrays.asList(remoteInterfaces));
- }
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getMethod() {
- return method;
- }
-
- /**
- * You can set the name of the method to invoke.
- */
- public void setMethod(String method) {
- this.method = method;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-}
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
deleted file mode 100644
index 92b1239..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiProducer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.NotBoundException;
-import java.rmi.RemoteException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.bean.BeanHolder;
-import org.apache.camel.component.bean.BeanProcessor;
-import org.apache.camel.support.DefaultProducer;
-
-public class RmiProducer extends DefaultProducer {
-
- private BeanProcessor beanProcessor;
-
- public RmiProducer(RmiEndpoint endpoint) throws RemoteException, NotBoundException {
- super(endpoint);
- BeanHolder holder = new RmiRegistryBean(endpoint.getCamelContext(), endpoint.getName(), endpoint.getRegistry());
- beanProcessor = new BeanProcessor(holder);
- String method = endpoint.getMethod();
- if (method != null) {
- beanProcessor.setMethod(method);
- }
- }
-
- public void process(Exchange exchange) throws Exception {
- beanProcessor.process(exchange);
- }
-
-}
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiRegistryBean.java b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiRegistryBean.java
deleted file mode 100644
index 2186038..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/RmiRegistryBean.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.AccessException;
-import java.rmi.NotBoundException;
-import java.rmi.RemoteException;
-import java.rmi.registry.Registry;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.NoSuchBeanException;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.bean.ParameterMappingStrategy;
-import org.apache.camel.component.bean.RegistryBean;
-
-public class RmiRegistryBean extends RegistryBean {
-
- private final Registry registry;
-
- public RmiRegistryBean(CamelContext context, String name, Registry registry) {
- super(context, name);
- this.registry = registry;
- }
-
- public RmiRegistryBean(CamelContext context, String name, ParameterMappingStrategy parameterMappingStrategy, Registry registry) {
- super(context, name);
- this.registry = registry;
- setParameterMappingStrategy(parameterMappingStrategy);
- }
-
- @Override
- protected Object lookupBean() throws NoSuchBeanException {
- try {
- return registry.lookup(getName());
- } catch (NotBoundException e) {
- throw new NoSuchBeanException(getName(), e);
- } catch (AccessException e) {
- throw new RuntimeCamelException(e);
- } catch (RemoteException e) {
- throw new RuntimeCamelException(e);
- }
- }
-}
diff --git a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html b/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html
deleted file mode 100644
index b2e9843..0000000
--- a/components/camel-rmi/src/main/java/org/apache/camel/component/rmi/package.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<html>
-<head>
-</head>
-<body>
-
-Defines an RMI Component that can bind PojoExchanges to the Java Remote Method Protocol (JRMP).</a>
-
-</body>
-</html>
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/DamnException.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/DamnException.java
deleted file mode 100644
index a54487a..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/DamnException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-/**
- *
- */
-public class DamnException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DamnException(String s) {
- super(s);
- }
-}
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/EchoService.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/EchoService.java
deleted file mode 100644
index 091d070..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/EchoService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.RemoteException;
-
-public class EchoService implements IEcho {
-
- public String echo(String s) throws RemoteException {
- return "Echo " + s;
- }
-
- public String damn(String s) throws DamnException, RemoteException {
- throw new DamnException("Damn this did not work");
- }
-
- public String foo(String s) throws RemoteException {
- throw new IllegalArgumentException("Illegal");
- }
-}
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/IEcho.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/IEcho.java
deleted file mode 100644
index 126afa5..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/IEcho.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface IEcho extends Remote {
-
- String echo(String s) throws RemoteException;
-
- String damn(String s) throws RemoteException, DamnException;
-
- String foo(String s) throws RemoteException;
-
-}
\ No newline at end of file
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java
deleted file mode 100644
index f61d5e1..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/ISay.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface ISay extends Remote {
- String say() throws RemoteException;
-}
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiConcurrencyTest.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiConcurrencyTest.java
deleted file mode 100644
index 65654b0..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiConcurrencyTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.registry.LocateRegistry;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.JndiRegistry;
-import org.junit.Test;
-
-public class RmiConcurrencyTest extends RmiRouteTestSupport {
-
- protected int getStartPort() {
- return 37500;
- }
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- if (classPathHasSpaces()) {
- return null;
- }
-
- LocateRegistry.createRegistry(getPort());
-
- JndiRegistry context = super.createRegistry();
- context.bind("echo", new EchoService());
- return context;
- }
-
- @Test
- public void testNoConcurrentProducers() throws Exception {
- doSendMessages(1, 1);
- }
-
- @Test
- public void testConcurrentProducers() throws Exception {
- doSendMessages(10, 5);
- }
-
- private void doSendMessages(int files, int poolSize) throws Exception {
- if (classPathHasSpaces()) {
- return;
- }
-
- getMockEndpoint("mock:result").expectedMessageCount(files);
- getMockEndpoint("mock:result").assertNoDuplicates(body());
- getMockEndpoint("mock:result").message(0).body().contains("Echo");
-
- ExecutorService executor = Executors.newFixedThreadPool(poolSize);
- for (int i = 0; i < files; i++) {
- final int index = i;
- executor.submit(new Callable<Object>() {
- public Object call() throws Exception {
- template.sendBody("direct:echo", "" + index);
- return null;
- }
- });
- }
-
- assertMockEndpointsSatisfied();
- executor.shutdownNow();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // setup the jmi server endpoint
- RmiEndpoint echo = (RmiEndpoint)endpoint("rmi://localhost:" + getPort() + "/echo");
- echo.setRemoteInterfaces(IEcho.class);
- from(echo).to("bean:echo");
-
- // and our route where we call the server
- from("direct:echo").toF("rmi://localhost:%s/echo?method=echo", getPort()).to("mock:result");
- }
- };
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiDamnExceptionTest.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiDamnExceptionTest.java
deleted file mode 100644
index 5ad9569..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiDamnExceptionTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.registry.LocateRegistry;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.JndiRegistry;
-import org.junit.Test;
-
-public class RmiDamnExceptionTest extends RmiRouteTestSupport {
-
- protected int getStartPort() {
- return 37501;
- }
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- if (classPathHasSpaces()) {
- return null;
- }
-
- LocateRegistry.createRegistry(getPort());
-
- JndiRegistry context = super.createRegistry();
- context.bind("echo", new EchoService());
- return context;
- }
-
- @Test
- public void tesDamn() throws Exception {
- if (classPathHasSpaces()) {
- return;
- }
-
- getMockEndpoint("mock:result").expectedMessageCount(0);
-
- try {
- template.sendBody("direct:echo", "Hello World");
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(DamnException.class, e.getCause());
- assertEquals("Damn this did not work", e.getCause().getMessage());
- }
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // setup the jmi server endpoint
- RmiEndpoint echo = (RmiEndpoint)endpoint("rmi://localhost:" + getPort() + "/echo");
- echo.setRemoteInterfaces(IEcho.class);
- from(echo).to("bean:echo");
-
- // and our route where we call the server
- from("direct:echo").toF("rmi://localhost:%s/echo?method=damn", getPort()).to("mock:result");
- }
- };
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiIllegalArgumentExceptionTest.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiIllegalArgumentExceptionTest.java
deleted file mode 100644
index f5c070f..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiIllegalArgumentExceptionTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.JndiRegistry;
-import org.junit.Test;
-
-public class RmiIllegalArgumentExceptionTest extends RmiRouteTestSupport {
- private boolean created;
-
- protected int getStartPort() {
- return 37502;
- }
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- if (classPathHasSpaces()) {
- return null;
- }
-
- if (!created) {
- LocateRegistry.createRegistry(getPort());
- created = true;
- }
-
- JndiRegistry context = super.createRegistry();
- context.bind("echo", new EchoService());
- return context;
- }
-
- @Test
- public void tesIllegal() throws Exception {
- if (classPathHasSpaces()) {
- return;
- }
-
- getMockEndpoint("mock:result").expectedMessageCount(0);
-
- try {
- template.sendBody("direct:echo", "Hello World");
- fail("Should have thrown an exception");
- } catch (CamelExecutionException e) {
- assertIsInstanceOf(RemoteException.class, e.getCause());
- // wrapped far down
- IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause().getCause().getCause());
- assertEquals("Illegal", iae.getMessage());
- }
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // setup the jmi server endpoint
- RmiEndpoint echo = (RmiEndpoint)endpoint("rmi://localhost:" + getPort() + "/echo");
- echo.setRemoteInterfaces(IEcho.class);
- from(echo).to("bean:echo");
-
- // and our route where we call the server
- from("direct:echo").to("rmi://localhost:" + getPort() + "/echo?method=foo").to("mock:result");
- }
- };
- }
-
-}
\ No newline at end of file
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteEndpointTest.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteEndpointTest.java
deleted file mode 100644
index 63e5797..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteEndpointTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.net.URI;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-
-public class RmiRouteEndpointTest extends RmiRouteTest {
-
- @Override
- protected RouteBuilder getRouteBuilder(final CamelContext context) {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- RmiEndpoint say = new RmiEndpoint();
- say.setCamelContext(context);
- say.setUri(new URI("rmi://localhost:" + getPort() + "/bye"));
-
- from("direct:hello").to(say);
-
- // When exposing an RMI endpoint, the interfaces it exposes must
- // be configured.
- RmiEndpoint bye = new RmiEndpoint();
- bye.setCamelContext(context);
- bye.setRemoteInterfaces(ISay.class);
- bye.setUri(new URI("rmi://localhost:" + getPort() + "/bye"));
-
- from(bye).to("bean:bye");
- }
- };
- }
-}
\ No newline at end of file
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java
deleted file mode 100644
index c4e1c4e..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.rmi.registry.LocateRegistry;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.bean.ProxyHelper;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.support.jndi.JndiContext;
-import org.junit.Test;
-
-public class RmiRouteTest extends RmiRouteTestSupport {
-
- protected int getStartPort() {
- return 37503;
- }
-
- @Test
- public void testPojoRoutes() throws Exception {
- if (classPathHasSpaces()) {
- return;
- }
-
- // Boot up a local RMI registry
- LocateRegistry.createRegistry(getPort());
-
- // START SNIPPET: register
- JndiContext context = new JndiContext();
- context.bind("bye", new SayService("Good Bye!"));
-
- CamelContext camelContext = new DefaultCamelContext(context);
- // END SNIPPET: register
-
- camelContext.addRoutes(getRouteBuilder(camelContext));
-
- camelContext.start();
-
- // START SNIPPET: invoke
- Endpoint endpoint = camelContext.getEndpoint("direct:hello");
- ISay proxy = ProxyHelper.createProxy(endpoint, false, ISay.class);
- String rc = proxy.say();
- assertEquals("Good Bye!", rc);
- // END SNIPPET: invoke
-
- camelContext.stop();
- }
-
- protected RouteBuilder getRouteBuilder(final CamelContext context) {
- return new RouteBuilder() {
- // START SNIPPET: route
- // lets add simple route
- public void configure() {
- from("direct:hello").toF("rmi://localhost:%s/bye", getPort());
-
- // When exposing an RMI endpoint, the interfaces it exposes must
- // be configured.
- RmiEndpoint bye = (RmiEndpoint)endpoint("rmi://localhost:" + getPort() + "/bye");
- bye.setRemoteInterfaces(ISay.class);
- from(bye).to("bean:bye");
- }
- // END SNIPPET: route
- };
- }
-
-}
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTestSupport.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTestSupport.java
deleted file mode 100644
index 1ca6a93..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteTestSupport.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-
-public abstract class RmiRouteTestSupport extends CamelTestSupport {
- private int port;
-
- protected abstract int getStartPort();
-
-
- protected int getPort() {
- if (port == 0) {
- port = AvailablePortFinder.getNextAvailable(getStartPort());
- }
- return port;
- }
-
- protected boolean classPathHasSpaces() {
- ClassLoader cl = getClass().getClassLoader();
- if (cl instanceof URLClassLoader) {
- URLClassLoader ucl = (URLClassLoader)cl;
- URL[] urls = ucl.getURLs();
- for (URL url : urls) {
- if (url.getPath().contains(" ")) {
- log.error("=======================================================================");
- log.error(" TEST Skipped: " + this.getClass().getName());
- log.error(" Your probably on windows. We detected that the classpath");
- log.error(" has a space in it. Try running maven with the following option: ");
- log.error(" -Dmaven.repo.local=C:\\DOCUME~1\\userid\\.m2\\repository");
- log.error("=======================================================================");
- return true;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java b/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java
deleted file mode 100644
index 733ba1c..0000000
--- a/components/camel-rmi/src/test/java/org/apache/camel/component/rmi/SayService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi;
-
-public class SayService implements ISay {
- String message = "Hello";
-
- public SayService() {
- }
-
- public SayService(String message) {
- this.message = message;
- }
-
- public String say() {
- return message;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
-}
diff --git a/components/camel-rmi/src/test/resources/log4j2.properties b/components/camel-rmi/src/test/resources/log4j2.properties
deleted file mode 100644
index 4306917..0000000
--- a/components/camel-rmi/src/test/resources/log4j2.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-appender.file.type = File
-appender.file.name = file
-appender.file.fileName = target/camel-rmi-test.log
-appender.file.layout.type = PatternLayout
-appender.file.layout.pattern = %d %-5p %c{1} - %m %n
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
-rootLogger.level = INFO
-rootLogger.appenderRef.file.ref = file
diff --git a/components/pom.xml b/components/pom.xml
index aef9251..785ae5a 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -264,7 +264,6 @@
<module>camel-rest</module>
<module>camel-rest-swagger</module>
<module>camel-restlet</module>
- <module>camel-rmi</module>
<module>camel-rss</module>
<module>camel-rxjava2</module>
<module>camel-saga</module>
diff --git a/parent/pom.xml b/parent/pom.xml
index d644c4b..dbead5d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1934,11 +1934,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss</artifactId>
<version>${project.version}</version>
</dependency>
@@ -3403,11 +3398,6 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
<artifactId>camel-rss-starter</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/pom.xml b/platforms/spring-boot/components-starter/camel-rmi-starter/pom.xml
deleted file mode 100644
index da7e132..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components-starter</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- </parent>
- <artifactId>camel-rmi-starter</artifactId>
- <packaging>jar</packaging>
- <name>Spring-Boot Starter :: Camel :: RMI</name>
- <description>Spring-Boot Starter for Camel RMI support</description>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- <version>${spring-boot-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rmi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!--START OF GENERATED CODE-->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core-starter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring-boot-starter</artifactId>
- </dependency>
- <!--END OF GENERATED CODE-->
- </dependencies>
-</project>
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentAutoConfiguration.java
deleted file mode 100644
index 175e759..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentAutoConfiguration.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi.springboot;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.Generated;
-import org.apache.camel.CamelContext;
-import org.apache.camel.component.rmi.RmiComponent;
-import org.apache.camel.spi.ComponentCustomizer;
-import org.apache.camel.spi.HasId;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.spring.boot.ComponentConfigurationProperties;
-import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
-import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
-import org.apache.camel.spring.boot.util.GroupCondition;
-import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
-import org.apache.camel.support.IntrospectionSupport;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
-
-/**
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-@Configuration
-@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class,
- RmiComponentAutoConfiguration.GroupConditions.class})
-@AutoConfigureAfter(CamelAutoConfiguration.class)
-@EnableConfigurationProperties({ComponentConfigurationProperties.class,
- RmiComponentConfiguration.class})
-public class RmiComponentAutoConfiguration {
-
- private static final Logger LOGGER = LoggerFactory
- .getLogger(RmiComponentAutoConfiguration.class);
- @Autowired
- private ApplicationContext applicationContext;
- @Autowired
- private CamelContext camelContext;
- @Autowired
- private RmiComponentConfiguration configuration;
- @Autowired(required = false)
- private List<ComponentCustomizer<RmiComponent>> customizers;
-
- static class GroupConditions extends GroupCondition {
- public GroupConditions() {
- super("camel.component", "camel.component.rmi");
- }
- }
-
- @Lazy
- @Bean(name = "rmi-component")
- @ConditionalOnMissingBean(RmiComponent.class)
- public RmiComponent configureRmiComponent() throws Exception {
- RmiComponent component = new RmiComponent();
- component.setCamelContext(camelContext);
- Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
- for (Map.Entry<String, Object> entry : parameters.entrySet()) {
- Object value = entry.getValue();
- Class<?> paramClass = value.getClass();
- if (paramClass.getName().endsWith("NestedConfiguration")) {
- Class nestedClass = null;
- try {
- nestedClass = (Class) paramClass.getDeclaredField(
- "CAMEL_NESTED_CLASS").get(null);
- HashMap<String, Object> nestedParameters = new HashMap<>();
- IntrospectionSupport.getProperties(value, nestedParameters,
- null, false);
- Object nestedProperty = nestedClass.newInstance();
- CamelPropertiesHelper.setCamelProperties(camelContext,
- nestedProperty, nestedParameters, false);
- entry.setValue(nestedProperty);
- } catch (NoSuchFieldException e) {
- }
- }
- }
- CamelPropertiesHelper.setCamelProperties(camelContext, component,
- parameters, false);
- if (ObjectHelper.isNotEmpty(customizers)) {
- for (ComponentCustomizer<RmiComponent> customizer : customizers) {
- boolean useCustomizer = (customizer instanceof HasId)
- ? HierarchicalPropertiesEvaluator.evaluate(
- applicationContext.getEnvironment(),
- "camel.component.customizer",
- "camel.component.rmi.customizer",
- ((HasId) customizer).getId())
- : HierarchicalPropertiesEvaluator.evaluate(
- applicationContext.getEnvironment(),
- "camel.component.customizer",
- "camel.component.rmi.customizer");
- if (useCustomizer) {
- LOGGER.debug("Configure component {}, with customizer {}",
- component, customizer);
- customizer.customize(component);
- }
- }
- }
- return component;
- }
-}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentConfiguration.java
deleted file mode 100644
index dc0f8b0..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/java/org/apache/camel/component/rmi/springboot/RmiComponentConfiguration.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.rmi.springboot;
-
-import javax.annotation.Generated;
-import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * The rmi component is for invoking Java RMI beans from Camel.
- *
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
-@ConfigurationProperties(prefix = "camel.component.rmi")
-public class RmiComponentConfiguration
- extends
- ComponentConfigurationPropertiesCommon {
-
- /**
- * Whether to enable auto configuration of the rmi component. This is
- * enabled by default.
- */
- private Boolean enabled;
- /**
- * Whether the component should resolve property placeholders on itself when
- * starting. Only properties which are of String type can use property
- * placeholders.
- */
- private Boolean resolvePropertyPlaceholders = true;
-
- public Boolean getResolvePropertyPlaceholders() {
- return resolvePropertyPlaceholders;
- }
-
- public void setResolvePropertyPlaceholders(
- Boolean resolvePropertyPlaceholders) {
- this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
- }
-}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/LICENSE.txt
deleted file mode 100644
index 6b0b127..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/LICENSE.txt
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Camel distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- Please read the different LICENSE files present in the licenses directory of
- this distribution.
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
deleted file mode 100644
index 84341a9..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "properties": [
- {
- "defaultValue": true,
- "name": "camel.component.rmi.enabled",
- "description": "Enable rmi component",
- "type": "java.lang.Boolean"
- }
- ]
-}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index ba35439..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,18 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.component.rmi.springboot.RmiComponentAutoConfiguration
diff --git a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.provides
deleted file mode 100644
index 9f1d756..0000000
--- a/platforms/spring-boot/components-starter/camel-rmi-starter/src/main/resources/META-INF/spring.provides
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-provides: camel-rmi
diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml
index ba6a841..4f934f7 100644
--- a/platforms/spring-boot/components-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/pom.xml
@@ -304,7 +304,6 @@
<module>camel-rest-swagger-starter</module>
<module>camel-restlet-starter</module>
<module>camel-ribbon-starter</module>
- <module>camel-rmi-starter</module>
<module>camel-rss-starter</module>
<module>camel-rxjava2-starter</module>
<module>camel-saga-starter</module>
[camel] 13/38: CAMEL-13422: Remove camel-rmi component
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ad83c3f58f9d3141281c7cb886568d05371172bf
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 10:24:22 2019 +0200
CAMEL-13422: Remove camel-rmi component
---
.../karaf/features/src/main/resources/features.xml | 4 --
.../org/apache/camel/itest/karaf/CamelRmiTest.java | 34 ---------------
.../camel/itest/springboot/CamelRmiTest.java | 48 ----------------------
3 files changed, 86 deletions(-)
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 2d9c4ae..a41393c 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -2074,10 +2074,6 @@
<bundle dependency='true'>wrap:mvn:io.swagger/swagger-parser/${swagger-java-parser-version}</bundle>
<bundle>mvn:org.apache.camel/camel-rest-swagger/${project.version}</bundle>
</feature>
- <feature name='camel-rmi' version='${project.version}' start-level='50'>
- <feature version='${project.version}'>camel-core</feature>
- <bundle>mvn:org.apache.camel/camel-rmi/${project.version}</bundle>
- </feature>
<feature name='camel-rss' version='${project.version}' start-level='50'>
<feature version='${project.version}'>camel-atom</feature>
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/${jdom-bundle-version}</bundle>
diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelRmiTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelRmiTest.java
deleted file mode 100644
index e0a13c1..0000000
--- a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelRmiTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.karaf;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-
-@RunWith(PaxExam.class)
-public class CamelRmiTest extends BaseKarafTest {
-
- public static final String COMPONENT = extractName(CamelRmiTest.class);
-
- @Test
- public void test() throws Exception {
- testComponent(COMPONENT);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelRmiTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelRmiTest.java
deleted file mode 100644
index cd32993..0000000
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelRmiTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.springboot;
-
-import org.apache.camel.itest.springboot.util.ArquillianPackager;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-
-@RunWith(Arquillian.class)
-public class CamelRmiTest extends AbstractSpringBootTestSupport {
-
- @Deployment
- public static Archive<?> createSpringBootPackage() throws Exception {
- return ArquillianPackager.springBootPackage(createTestConfig());
- }
-
- public static ITestConfig createTestConfig() {
- return new ITestConfigBuilder()
- .module(inferModuleName(CamelRmiTest.class))
- .build();
- }
-
- @Test
- public void componentTests() throws Exception {
- this.runComponentTest(config);
- this.runModuleUnitTestsIfEnabled(config);
- }
-
-
-}
[camel] 29/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c2d7cfc1e4066d55d854319ff1c4a5b10d3140e8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 08:15:26 2019 +0200
Move mock component out of camel-core. Work in progress.
---
apache-camel/pom.xml | 10 +
apache-camel/src/main/descriptors/common-bin.xml | 2 +
bom/camel-bom/pom.xml | 5 +
components/camel-dataset/pom.xml | 2 +-
components/{camel-dataset => camel-mock}/pom.xml | 35 +---
.../camel-mock}/src/main/docs/mock-component.adoc | 0
.../camel/component/mock/AssertionClause.java | 0
.../apache/camel/component/mock/MockComponent.java | 0
.../apache/camel/component/mock/MockEndpoint.java | 0
.../camel/component/mock/MockExpressionClause.java | 0
.../mock/MockExpressionClauseSupport.java | 0
.../camel/component/mock/MockValueBuilder.java | 0
.../java/org/apache/camel/component/mock/Time.java | 0
.../apache/camel/component/mock/TimeClause.java | 0
.../org/apache/camel/component/mock/package.html | 0
components/pom.xml | 1 +
components/readme.adoc | 4 +-
core/camel-core/pom.xml | 4 +
core/camel-core/readme.adoc | 5 +-
docs/components/modules/ROOT/nav.adoc | 1 +
.../modules/ROOT/pages}/mock-component.adoc | 0
parent/pom.xml | 10 +
.../components-starter/camel-mock-starter/pom.xml | 53 ++++++
.../springboot/MockComponentAutoConfiguration.java | 128 +++++++++++++
.../springboot/MockComponentConfiguration.java | 55 ++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 ++
.../src/main/resources/META-INF/spring.factories | 19 ++
.../src/main/resources/META-INF/spring.provides | 17 ++
platforms/spring-boot/components-starter/pom.xml | 1 +
.../camel-spring-boot-dependencies/pom.xml | 5 +
31 files changed, 533 insertions(+), 38 deletions(-)
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index f34eb63..9ad9721 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -958,6 +958,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>
@@ -2417,6 +2422,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs-starter</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 9730b86..187c379 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -213,6 +213,7 @@
<include>org.apache.camel:camel-milo</include>
<include>org.apache.camel:camel-mina2</include>
<include>org.apache.camel:camel-mllp</include>
+ <include>org.apache.camel:camel-mock</include>
<include>org.apache.camel:camel-mongodb-gridfs</include>
<include>org.apache.camel:camel-mongodb3</include>
<include>org.apache.camel:camel-mqtt</include>
@@ -543,6 +544,7 @@
<include>org.apache.camel:camel-milo-starter</include>
<include>org.apache.camel:camel-mina2-starter</include>
<include>org.apache.camel:camel-mllp-starter</include>
+ <include>org.apache.camel:camel-mock-starter</include>
<include>org.apache.camel:camel-mongodb-gridfs-starter</include>
<include>org.apache.camel:camel-mongodb3-starter</include>
<include>org.apache.camel:camel-mqtt-starter</include>
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index c3c6265..719d3e1 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -1830,6 +1830,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/components/camel-dataset/pom.xml b/components/camel-dataset/pom.xml
index 88f459e..e307bcb 100644
--- a/components/camel-dataset/pom.xml
+++ b/components/camel-dataset/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
+ <artifactId>camel-mock</artifactId>
</dependency>
<!-- testing -->
diff --git a/components/camel-dataset/pom.xml b/components/camel-mock/pom.xml
similarity index 57%
copy from components/camel-dataset/pom.xml
copy to components/camel-mock/pom.xml
index 88f459e..4268323 100644
--- a/components/camel-dataset/pom.xml
+++ b/components/camel-mock/pom.xml
@@ -27,44 +27,17 @@
<version>3.0.0-SNAPSHOT</version>
</parent>
- <artifactId>camel-dataset</artifactId>
+ <artifactId>camel-mock</artifactId>
<packaging>jar</packaging>
- <name>Camel :: DataSet</name>
- <description>Camel DataSet component</description>
+ <name>Camel :: Mock</name>
+ <description>Camel Mock component</description>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <!-- testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
+ <artifactId>camel-support</artifactId>
</dependency>
</dependencies>
diff --git a/core/camel-core/src/main/docs/mock-component.adoc b/components/camel-mock/src/main/docs/mock-component.adoc
similarity index 100%
copy from core/camel-core/src/main/docs/mock-component.adoc
copy to components/camel-mock/src/main/docs/mock-component.adoc
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/AssertionClause.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockComponent.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/MockComponent.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/MockComponent.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClause.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/MockExpressionClauseSupport.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/Time.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/Time.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/Time.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/Time.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/TimeClause.java b/components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/TimeClause.java
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/package.html b/components/camel-mock/src/main/java/org/apache/camel/component/mock/package.html
similarity index 100%
rename from core/camel-core/src/main/java/org/apache/camel/component/mock/package.html
rename to components/camel-mock/src/main/java/org/apache/camel/component/mock/package.html
diff --git a/components/pom.xml b/components/pom.xml
index 785ae5a..673728d 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -44,6 +44,7 @@
<module>camel-directvm</module>
<module>camel-language</module>
<module>camel-log</module>
+ <module>camel-mock</module>
<module>camel-ref</module>
<module>camel-seda</module>
<module>camel-stub</module>
diff --git a/components/readme.adoc b/components/readme.adoc
index 59272a7..a5cf771 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -1,7 +1,7 @@
==== Components
// components: START
-Number of Components: 293 in 229 JAR artifacts (0 deprecated)
+Number of Components: 293 in 230 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -568,7 +568,7 @@ Number of Components: 293 in 229 JAR artifacts (0 deprecated)
| link:camel-mllp/src/main/docs/mllp-component.adoc[MLLP] (camel-mllp) +
`mllp:hostname:port` | 2.17 | Provides functionality required by Healthcare providers to communicate with other systems using the MLLP protocol.
-| link:../core/camel-core/src/main/docs/mock-component.adoc[Mock] (camel-core) +
+| link:camel-mock/src/main/docs/mock-component.adoc[Mock] (camel-mock) +
`mock:name` | 1.0 | The mock component is used for testing routes and mediation rules using mocks.
| link:camel-mongodb3/src/main/docs/mongodb3-component.adoc[MongoDB] (camel-mongodb3) +
diff --git a/core/camel-core/pom.xml b/core/camel-core/pom.xml
index 8748325..7ff8da9 100644
--- a/core/camel-core/pom.xml
+++ b/core/camel-core/pom.xml
@@ -127,6 +127,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-properties</artifactId>
</dependency>
<dependency>
diff --git a/core/camel-core/readme.adoc b/core/camel-core/readme.adoc
index 275462d..10a8a5b 100644
--- a/core/camel-core/readme.adoc
+++ b/core/camel-core/readme.adoc
@@ -5,7 +5,7 @@
// components: START
-Number of Components: 3 in 1 JAR artifacts (0 deprecated)
+Number of Components: 2 in 1 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -17,9 +17,6 @@ Number of Components: 3 in 1 JAR artifacts (0 deprecated)
| link:src/main/docs/class-component.adoc[Class] (camel-core) +
`class:beanName` | 2.4 | The Class Component is for invoking Java Classes (Java beans) from Camel.
-| link:src/main/docs/mock-component.adoc[Mock] (camel-core) +
-`mock:name` | 1.0 | The mock component is used for testing routes and mediation rules using mocks.
-
|===
// components: END
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index 4af236b..f02d54f 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -221,6 +221,7 @@
* xref:milo-server-component.adoc[OPC UA Server Component]
* xref:mina2-component.adoc[Mina2 Component]
* xref:mllp-component.adoc[MLLP Component]
+* xref:mock-component.adoc[Mock Component]
* xref:mongodb-gridfs-component.adoc[MongoDB GridFS Component]
* xref:mongodb3-component.adoc[MongoDB Component]
* xref:mqtt-component.adoc[MQTT Component]
diff --git a/core/camel-core/src/main/docs/mock-component.adoc b/docs/components/modules/ROOT/pages/mock-component.adoc
similarity index 100%
rename from core/camel-core/src/main/docs/mock-component.adoc
rename to docs/components/modules/ROOT/pages/mock-component.adoc
diff --git a/parent/pom.xml b/parent/pom.xml
index dbead5d..c48677b 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1729,6 +1729,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>
@@ -3218,6 +3223,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs-starter</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/pom.xml b/platforms/spring-boot/components-starter/camel-mock-starter/pom.xml
new file mode 100644
index 0000000..dfbfff6
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components-starter</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-mock-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Spring-Boot Starter :: Camel :: Mock</name>
+ <description>Spring-Boot Starter for Camel Mock component</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java
new file mode 100644
index 0000000..2de4611
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mock.springboot;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Generated;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.mock.MockComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spi.HasId;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
+import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
+import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+@Configuration
+@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class,
+ MockComponentAutoConfiguration.GroupConditions.class})
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MockComponentConfiguration.class})
+public class MockComponentAutoConfiguration {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MockComponentAutoConfiguration.class);
+ @Autowired
+ private ApplicationContext applicationContext;
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired
+ private MockComponentConfiguration configuration;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MockComponent>> customizers;
+
+ static class GroupConditions extends GroupCondition {
+ public GroupConditions() {
+ super("camel.component", "camel.component.mock");
+ }
+ }
+
+ @Lazy
+ @Bean(name = "mock-component")
+ @ConditionalOnMissingBean(MockComponent.class)
+ public MockComponent configureMockComponent() throws Exception {
+ MockComponent component = new MockComponent();
+ component.setCamelContext(camelContext);
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(configuration, parameters, null,
+ false);
+ for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+ Object value = entry.getValue();
+ Class<?> paramClass = value.getClass();
+ if (paramClass.getName().endsWith("NestedConfiguration")) {
+ Class nestedClass = null;
+ try {
+ nestedClass = (Class) paramClass.getDeclaredField(
+ "CAMEL_NESTED_CLASS").get(null);
+ HashMap<String, Object> nestedParameters = new HashMap<>();
+ IntrospectionSupport.getProperties(value, nestedParameters,
+ null, false);
+ Object nestedProperty = nestedClass.newInstance();
+ CamelPropertiesHelper.setCamelProperties(camelContext,
+ nestedProperty, nestedParameters, false);
+ entry.setValue(nestedProperty);
+ } catch (NoSuchFieldException e) {
+ }
+ }
+ }
+ CamelPropertiesHelper.setCamelProperties(camelContext, component,
+ parameters, false);
+ if (ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MockComponent> customizer : customizers) {
+ boolean useCustomizer = (customizer instanceof HasId)
+ ? HierarchicalPropertiesEvaluator.evaluate(
+ applicationContext.getEnvironment(),
+ "camel.component.customizer",
+ "camel.component.mock.customizer",
+ ((HasId) customizer).getId())
+ : HierarchicalPropertiesEvaluator.evaluate(
+ applicationContext.getEnvironment(),
+ "camel.component.customizer",
+ "camel.component.mock.customizer");
+ if (useCustomizer) {
+ LOGGER.debug("Configure component {}, with customizer {}",
+ component, customizer);
+ customizer.customize(component);
+ }
+ }
+ }
+ return component;
+ }
+}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java
new file mode 100644
index 0000000..1d05918
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConfiguration.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mock.springboot;
+
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * The mock component is used for testing routes and mediation rules using
+ * mocks.
+ *
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+@ConfigurationProperties(prefix = "camel.component.mock")
+public class MockComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
+
+ /**
+ * Whether to enable auto configuration of the mock component. This is
+ * enabled by default.
+ */
+ private Boolean enabled;
+ /**
+ * Whether the component should resolve property placeholders on itself when
+ * starting. Only properties which are of String type can use property
+ * placeholders.
+ */
+ private Boolean resolvePropertyPlaceholders = true;
+
+ public Boolean getResolvePropertyPlaceholders() {
+ return resolvePropertyPlaceholders;
+ }
+
+ public void setResolvePropertyPlaceholders(
+ Boolean resolvePropertyPlaceholders) {
+ this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
+ }
+}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/LICENSE.txt b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/NOTICE.txt b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..8a4e2f2
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.camel.component.mock.springboot.MockComponentAutoConfiguration
diff --git a/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.provides b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000..3e78388
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-mock-starter/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+provides: camel-mock
diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml
index 4f934f7..6af5dfd 100644
--- a/platforms/spring-boot/components-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/pom.xml
@@ -268,6 +268,7 @@
<module>camel-milo-starter</module>
<module>camel-mina2-starter</module>
<module>camel-mllp-starter</module>
+ <module>camel-mock-starter</module>
<module>camel-mongodb-gridfs-starter</module>
<module>camel-mongodb3-starter</module>
<module>camel-mqtt-starter</module>
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index b5eccf9..90ef2dd 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -2045,6 +2045,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>
[camel] 20/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e24fc7af6aec760f5fc9c71e714fb506d667accb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 11:59:02 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../apache/camel/builder/ExpressionBuilder.java | 26 ----------------------
.../org/apache/camel/builder/ValueBuilder.java | 5 ++---
.../camel/component/mock/AssertionClause.java | 2 ++
.../language/simple/SimpleExpressionBuilder.java | 8 +++----
.../camel/support/language/ExpressionModel.java | 12 +++++++---
5 files changed, 17 insertions(+), 36 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index 18ca79a..ed3f8691 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -36,7 +36,6 @@ import org.apache.camel.Message;
import org.apache.camel.NoSuchLanguageException;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.model.language.MethodCallExpression;
import org.apache.camel.spi.Language;
import org.apache.camel.spi.PropertiesComponent;
import org.apache.camel.spi.RouteContext;
@@ -814,31 +813,6 @@ public final class ExpressionBuilder {
}
/**
- * Returns the expression for invoking a method (support OGNL syntax) on the given expression
- *
- * @param exp the expression to evaluate and invoke the method on its result
- * @param ognl methods to invoke on the evaluated expression in a simple OGNL syntax
- */
- public static Expression ognlExpression(final Expression exp, final String ognl) {
- return new ExpressionAdapter() {
- public Object evaluate(Exchange exchange) {
- Object value = exp.evaluate(exchange, Object.class);
- if (value == null) {
- return null;
- }
- // ognl is able to evaluate method name if it contains nested functions
- // so we should not eager evaluate ognl as a string
- return new MethodCallExpression(value, ognl).evaluate(exchange);
- }
-
- @Override
- public String toString() {
- return "ognl(" + exp + ", " + ognl + ")";
- }
- };
- }
-
- /**
* Returns the expression for the exchanges inbound message body converted
* to the given type
*/
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index c8ac6cb..b521537 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -337,14 +337,13 @@ public class ValueBuilder implements Expression, Predicate {
}
/**
- * Invokes the method with the given name (supports OGNL syntax).
+ * Invokes the method with the given name.
*
* @param methodName name of method to invoke.
* @return the current builder
*/
public ValueBuilder method(String methodName) {
- // TODO: find alternative
- Expression newExp = ExpressionBuilder.ognlExpression(expression, methodName);
+ Expression newExp = ExpressionBuilder.beanExpression(expression + "?method=" + methodName);
return onNewValueBuilder(newExp);
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index 5556cba..53e5d40 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -34,6 +34,8 @@ import org.apache.camel.support.language.ExpressionModel;
*/
public abstract class AssertionClause extends MockExpressionClauseSupport<ValueBuilder> implements Runnable {
+ // TODO: MockValueBuilder
+
protected final MockEndpoint mock;
protected volatile int currentIndex;
private final Set<Predicate> predicates = new LinkedHashSet<>();
diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
index 8189149..73117ff 100644
--- a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java
@@ -1,13 +1,13 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
index 9b812f1..4861651 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
@@ -19,11 +19,17 @@ package org.apache.camel.support.language;
import org.apache.camel.CamelContext;
import org.apache.camel.Expression;
+/**
+ * Represents a model that can be created as an expression (eg language).
+ */
public interface ExpressionModel {
- // TODO: move to api, and maybe have a @FunctionalInterface
-
+ /**
+ * Creates an expression
+ *
+ * @param camelContext the camel context
+ * @return the created expression.
+ */
Expression createExpression(CamelContext camelContext);
-
}
[camel] 17/38: CAMEL-13422: Remove camel-rmi component
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8ed33864447bf1f3b41a47b0951a84d96020e897
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 16 11:02:43 2019 +0200
CAMEL-13422: Remove camel-rmi component
---
components/readme.adoc | 5 +-
docs/components/modules/ROOT/nav.adoc | 1 -
.../modules/ROOT/pages/soapjaxb-dataformat.adoc | 53 +---------------------
3 files changed, 2 insertions(+), 57 deletions(-)
diff --git a/components/readme.adoc b/components/readme.adoc
index b4a23e5..59272a7 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -1,7 +1,7 @@
==== Components
// components: START
-Number of Components: 294 in 230 JAR artifacts (0 deprecated)
+Number of Components: 293 in 229 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -700,9 +700,6 @@ Number of Components: 294 in 230 JAR artifacts (0 deprecated)
| link:camel-restlet/src/main/docs/restlet-component.adoc[Restlet] (camel-restlet) +
`restlet:protocol:host:port/uriPattern` | 2.0 | Component for consuming and producing Restful resources using Restlet.
-| link:camel-rmi/src/main/docs/rmi-component.adoc[RMI] (camel-rmi) +
-`rmi:hostname:port/name` | 1.0 | The rmi component is for invoking Java RMI beans from Camel.
-
| link:camel-rss/src/main/docs/rss-component.adoc[RSS] (camel-rss) +
`rss:feedUri` | 2.0 | The rss component is used for consuming RSS feeds.
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index 8941f51..4af236b 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -265,7 +265,6 @@
* xref:rest-component.adoc[REST Component]
* xref:restlet-component.adoc[Restlet Component]
* xref:ribbon.adoc[Ribbon Component]
-* xref:rmi-component.adoc[RMI Component]
* xref:rss-component.adoc[RSS Component]
* xref:rss-dataformat.adoc[RSS DataFormat]
* xref:rxjava2.adoc[RxJava2 Component]
diff --git a/docs/components/modules/ROOT/pages/soapjaxb-dataformat.adoc b/docs/components/modules/ROOT/pages/soapjaxb-dataformat.adoc
index 059e911..9e739c2 100644
--- a/docs/components/modules/ROOT/pages/soapjaxb-dataformat.adoc
+++ b/docs/components/modules/ROOT/pages/soapjaxb-dataformat.adoc
@@ -189,61 +189,10 @@ ServiceInterfaceStrategy strat = new ServiceInterfaceStrategy(com.example.custo
SoapJaxbDataFormat soapDataFormat = new SoapJaxbDataFormat("com.example.customerservice.multipart", strat);
-------------------------------------------------------------------------------------------------------------------------------------------
-#### Multi-part Request
-
-The payload parameters for a multi-part request are initiazlied using a
-`BeanInvocation` object that reflects the signature of the target
-operation. The camel-soap DataFormat maps the content in the
-`BeanInvocation` to fields in the SOAP header and body in accordance
-with the JAX-WS mapping when the `marshal()` processor is invoked.
-
-[source,java]
-----------------------------------------------------------------------------------------
-BeanInvocation beanInvocation = new BeanInvocation();
-
-// Identify the target method
-beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName",
- GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
-
-// Populate the method arguments
-GetCustomersByName getCustomersByName = new GetCustomersByName();
-getCustomersByName.setName("Dr. Multipart");
-
-Product product = new Product();
-product.setName("Multiuse Product");
-product.setDescription("Useful for lots of things.");
-
-Object[] args = new Object[] {getCustomersByName, product};
-
-// Add the arguments to the bean invocation
-beanInvocation.setArgs(args);
-
-// Set the bean invocation object as the message body
-exchange.getIn().setBody(beanInvocation);
-----------------------------------------------------------------------------------------
-
-#### Multi-part Response
-
-A multi-part soap response may include an element in the soap body and
-will have one or more elements in the soap header. The camel-soap
-DataFormat will unmarshall the element in the soap body (if it exists)
-and place it onto the body of the out message in the exchange. Header
-elements will *not* be marshaled into their JAXB mapped object types.
-Instead, these elements are placed into the camel out message header
-`org.apache.camel.dataformat.soap.UNMARSHALLED_HEADER_LIST`. The
-elements will appear either as element instance values, or as
-JAXBElement values, depending upon the setting for the
-`ignoreJAXBElement` property. This property is inherited from
-camel-jaxb.
-
-You can also have the camel-soap DataFormate ignore header content
-all-together by setting the `ignoreUnmarshalledHeaders` value to `true`.
-
#### Holder Object mapping
JAX-WS specifies the use of a type-parameterized `javax.xml.ws.Holder`
-object for `In/Out` and `Out` parameters. A `Holder` object may be used
-when building the `BeanInvocation`, or you may use an instance of the
+object for `In/Out` and `Out` parameters. You may use an instance of the
parameterized-type directly. The camel-soap DataFormat marshals Holder
values in accordance with the JAXB mapping for the class of the
`Holder`'s value. No mapping is provided for `Holder` objects in an
[camel] 02/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 31b7d364bd54eb8f73703d8d7ff1009053dfdd6a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 13:15:19 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../blueprint/handler/CamelNamespaceHandler.java | 2 +-
.../spring/handler/CamelNamespaceHandler.java | 2 +-
.../org/apache/camel/builder/ExpressionClause.java | 32 ++++++++++++++--------
.../camel/builder/ExpressionClauseSupport.java | 17 ++++++++----
.../org/apache/camel/builder/ValueBuilder.java | 7 +++--
.../camel/component/mock/AssertionClause.java | 10 +++----
.../apache/camel/model/AggregateDefinition.java | 24 +++++++++++-----
.../org/apache/camel/model/ChoiceDefinition.java | 16 +++++++++--
.../org/apache/camel/model/ExpressionNode.java | 10 ++++++-
.../apache/camel/model/ResequenceDefinition.java | 7 +++++
.../camel/model/language/ExpressionDefinition.java | 14 ++++++----
.../util/DumpModelAsXmlChoiceFilterRouteTest.java | 2 ++
.../camel/support/language/ExpressionModel.java | 29 ++++++++++++++++++++
13 files changed, 129 insertions(+), 43 deletions(-)
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
index 57a85de..330823e 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
@@ -62,7 +62,6 @@ import org.apache.camel.blueprint.CamelContextFactoryBean;
import org.apache.camel.blueprint.CamelEndpointFactoryBean;
import org.apache.camel.blueprint.CamelRestContextFactoryBean;
import org.apache.camel.blueprint.CamelRouteContextFactoryBean;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.core.xml.AbstractCamelFactoryBean;
import org.apache.camel.impl.CamelPostProcessorHelper;
import org.apache.camel.impl.DefaultCamelContextNameStrategy;
@@ -88,6 +87,7 @@ import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestDefinition;
import org.apache.camel.model.rest.VerbDefinition;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.spi.CamelContextNameStrategy;
import org.apache.camel.spi.ComponentResolver;
import org.apache.camel.spi.DataFormatResolver;
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
index 05bbf72..5acdf03 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
@@ -32,11 +32,11 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.core.xml.CamelJMXAgentDefinition;
import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
import org.apache.camel.impl.DefaultCamelContextNameStrategy;
+import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.spi.CamelContextNameStrategy;
import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.spring.CamelBeanPostProcessor;
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
index 7b89cab..eed851f 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -24,16 +24,18 @@ import java.util.function.Supplier;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
-import org.apache.camel.support.builder.xml.Namespaces;
+import org.apache.camel.Predicate;
import org.apache.camel.model.ExpressionNode;
-import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.ExpressionToPredicateAdapter;
+import org.apache.camel.support.builder.xml.Namespaces;
+import org.apache.camel.support.language.ExpressionModel;
/**
* Represents an expression clause within the DSL which when the expression is
* complete the clause continues to another part of the DSL
*/
-public class ExpressionClause<T> extends ExpressionDefinition {
+public class ExpressionClause<T> implements Expression, Predicate {
private ExpressionClauseSupport<T> delegate;
public ExpressionClause(T result) {
@@ -1062,23 +1064,31 @@ public class ExpressionClause<T> extends ExpressionDefinition {
// Properties
// -------------------------------------------------------------------------
- @Override
public Expression getExpressionValue() {
return delegate.getExpressionValue();
}
- @Override
- protected void setExpressionValue(Expression expressionValue) {
- delegate.setExpressionValue(expressionValue);
+ public ExpressionModel getExpressionType() {
+ return delegate.getExpressionType();
}
@Override
- public ExpressionDefinition getExpressionType() {
- return delegate.getExpressionType();
+ public <T> T evaluate(Exchange exchange, Class<T> type) {
+ if (getExpressionValue() != null) {
+ return getExpressionValue().evaluate(exchange, type);
+ } else {
+ Expression exp = delegate.getExpressionType().createExpression(exchange.getContext());
+ return exp.evaluate(exchange, type);
+ }
}
@Override
- protected void setExpressionType(ExpressionDefinition expressionType) {
- delegate.setExpressionType(expressionType);
+ public boolean matches(Exchange exchange) {
+ if (getExpressionValue() != null) {
+ return new ExpressionToPredicateAdapter(getExpressionValue()).matches(exchange);
+ } else {
+ Expression exp = delegate.getExpressionType().createExpression(exchange.getContext());
+ return new ExpressionToPredicateAdapter(exp).matches(exchange);
+ }
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index fa515c4..ddfd467 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -23,7 +23,6 @@ import org.apache.camel.Expression;
import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.model.language.ConstantExpression;
import org.apache.camel.model.language.ExchangePropertyExpression;
-import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.model.language.GroovyExpression;
import org.apache.camel.model.language.HeaderExpression;
import org.apache.camel.model.language.Hl7TerserExpression;
@@ -40,6 +39,7 @@ import org.apache.camel.model.language.TokenizerExpression;
import org.apache.camel.model.language.XMLTokenizerExpression;
import org.apache.camel.model.language.XPathExpression;
import org.apache.camel.model.language.XQueryExpression;
+import org.apache.camel.support.language.ExpressionModel;
/**
* A support class for building expression clauses.
@@ -51,7 +51,7 @@ public class ExpressionClauseSupport<T> {
private T result;
private Expression expressionValue;
- private ExpressionDefinition expressionType;
+ private ExpressionModel expressionType;
public ExpressionClauseSupport(T result) {
this.result = result;
@@ -65,10 +65,16 @@ public class ExpressionClauseSupport<T> {
*/
public T expression(Expression expression) {
setExpressionValue(expression);
+ if (expression instanceof ExpressionModel) {
+ setExpressionType((ExpressionModel) expression);
+ }
return result;
}
- public T expression(ExpressionDefinition expression) {
+ /**
+ * Specify an {@link ExpressionModel} instance
+ */
+ public T language(ExpressionModel expression) {
setExpressionType(expression);
return result;
}
@@ -1081,11 +1087,11 @@ public class ExpressionClauseSupport<T> {
this.expressionValue = expressionValue;
}
- public ExpressionDefinition getExpressionType() {
+ public ExpressionModel getExpressionType() {
return expressionType;
}
- public void setExpressionType(ExpressionDefinition expressionType) {
+ public void setExpressionType(ExpressionModel expressionType) {
this.expressionType = expressionType;
}
@@ -1101,6 +1107,7 @@ public class ExpressionClauseSupport<T> {
}
protected void configureExpression(CamelContext camelContext, Expression expression) {
+ // noop
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index dc50ec4..a37d742 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -24,10 +24,10 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Predicate;
-import org.apache.camel.support.builder.xml.Namespaces;
import org.apache.camel.spi.NamespaceAware;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
+import org.apache.camel.support.builder.xml.Namespaces;
/**
* A builder of expressions or predicates based on values.
@@ -92,11 +92,12 @@ public class ValueBuilder implements Expression, Predicate {
final Expression right = new ExpressionAdapter() {
@Override
public Object evaluate(Exchange exchange) {
- if (answer.getExpressionValue() != null) {
+ return answer.evaluate(exchange, Object.class);
+ /*if (answer.getExpressionValue() != null) {
return answer.getExpressionValue().evaluate(exchange, Object.class);
} else {
return answer.getExpressionType().evaluate(exchange);
- }
+ }*/
}
};
// okay now we can set the reference to the right-hand-side
diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
index b6f0a75..795f7d5 100644
--- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java
@@ -27,8 +27,8 @@ import org.apache.camel.StreamCache;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.builder.ExpressionClauseSupport;
import org.apache.camel.builder.ValueBuilder;
-import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.support.PredicateAssertHelper;
+import org.apache.camel.support.language.ExpressionModel;
/**
* A builder of assertions on message exchanges
@@ -52,13 +52,13 @@ public abstract class AssertionClause extends ExpressionClauseSupport<ValueBuild
public ValueBuilder expression(Expression expression) {
// must override this method as we provide null in the constructor
super.expression(expression);
- return new PredicateValueBuilder(getExpressionValue());
+ return new PredicateValueBuilder(expression);
}
- public ValueBuilder expression(ExpressionDefinition expression) {
+ public ValueBuilder language(ExpressionModel expression) {
// must override this method as we provide null in the constructor
- super.expression(expression);
- return new PredicateValueBuilder(expression.createExpression(mock.getCamelContext()));
+ super.expression(expression.createExpression(mock.getCamelContext()));
+ return new PredicateValueBuilder(getExpressionValue());
}
/**
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
index ff3af9e..a81e290 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
@@ -41,6 +41,7 @@ import org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy;
import org.apache.camel.spi.AggregationRepository;
import org.apache.camel.spi.AsPredicate;
import org.apache.camel.spi.Metadata;
+import org.apache.camel.support.language.ExpressionModel;
/**
* Aggregates many messages into a single message
@@ -163,18 +164,23 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
@Override
public void configureChild(ProcessorDefinition<?> output) {
- if (expression instanceof ExpressionClause) {
- ExpressionClause<?> clause = (ExpressionClause<?>) expression;
+ Expression exp = getExpression();
+ if (getExpression() != null && getExpression().getExpressionValue() != null) {
+ exp = getExpression().getExpressionValue();
+ }
+
+ if (exp instanceof ExpressionClause) {
+ ExpressionClause<?> clause = (ExpressionClause<?>) exp;
if (clause.getExpressionType() != null) {
// if using the Java DSL then the expression may have been set using the
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- expression = clause.getExpressionType();
- // set the correlation expression from the expression type, as the model definition
- // would then be accurate
- correlationExpression = new ExpressionSubElementDefinition();
- correlationExpression.setExpressionType(clause.getExpressionType());
+ ExpressionModel model = clause.getExpressionType();
+ if (model instanceof ExpressionDefinition) {
+ correlationExpression = new ExpressionSubElementDefinition();
+ correlationExpression.setExpressionType((ExpressionDefinition) model);
+ }
}
}
}
@@ -922,6 +928,10 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
this.expression = expression;
}
+ public void setExpression(Expression expression) {
+ setExpression(new ExpressionDefinition(expression));
+ }
+
protected void checkNoCompletedPredicate() {
if (getCompletionPredicate() != null) {
throw new IllegalArgumentException("There is already a completionPredicate defined for this aggregator: " + this);
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
index a926bd0..a782d5e 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java
@@ -28,8 +28,10 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.Predicate;
import org.apache.camel.builder.ExpressionClause;
+import org.apache.camel.model.language.ExpressionDefinition;
import org.apache.camel.spi.AsPredicate;
import org.apache.camel.spi.Metadata;
+import org.apache.camel.support.language.ExpressionModel;
import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.ObjectHelper;
@@ -253,14 +255,22 @@ public class ChoiceDefinition extends ProcessorDefinition<ChoiceDefinition> {
return;
}
for (WhenDefinition when : whenClauses) {
- if (when.getExpression() instanceof ExpressionClause) {
- ExpressionClause<?> clause = (ExpressionClause<?>) when.getExpression();
+ ExpressionDefinition exp = when.getExpression();
+ if (exp.getExpressionType() != null) {
+ exp = exp.getExpressionType();
+ }
+ Predicate pre = exp.getPredicate();
+ if (pre instanceof ExpressionClause) {
+ ExpressionClause<?> clause = (ExpressionClause<?>) pre;
if (clause.getExpressionType() != null) {
// if using the Java DSL then the expression may have been set using the
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- when.setExpression(clause.getExpressionType());
+ ExpressionModel model = clause.getExpressionType();
+ if (model instanceof ExpressionDefinition) {
+ when.setExpression((ExpressionDefinition) model);
+ }
}
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java b/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
index 2286858..7372044 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
@@ -28,6 +28,7 @@ import org.apache.camel.Expression;
import org.apache.camel.Predicate;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.model.language.ExpressionDefinition;
+import org.apache.camel.support.language.ExpressionModel;
/**
* A base class for nodes which contain an expression and a number of outputs
@@ -63,6 +64,10 @@ public abstract class ExpressionNode extends ProcessorDefinition<ExpressionNode>
return expression;
}
+ public void setExpression(Expression expression) {
+ setExpression(new ExpressionDefinition(expression));
+ }
+
public void setExpression(ExpressionDefinition expression) {
// favour using the helper to set the expression as it can unwrap some unwanted builders when using Java DSL
this.expression = expression;
@@ -110,7 +115,10 @@ public abstract class ExpressionNode extends ProcessorDefinition<ExpressionNode>
// ExpressionClause which is a fancy builder to define expressions and predicates
// using fluent builders in the DSL. However we need afterwards a callback to
// reset the expression to the expression type the ExpressionClause did build for us
- setExpression(clause.getExpressionType());
+ ExpressionModel model = clause.getExpressionType();
+ if (model instanceof ExpressionDefinition) {
+ setExpression((ExpressionDefinition) model);
+ }
}
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
index a463b3f..5285f3e 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
@@ -331,4 +331,11 @@ public class ResequenceDefinition extends ProcessorDefinition<ResequenceDefiniti
this.expression = expression;
}
+ /**
+ * Expression to use for re-ordering the messages, such as a header with a sequence number
+ */
+ public void setExpression(Expression expression) {
+ setExpression(new ExpressionDefinition(expression));
+ }
+
}
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
index 6e56a0b..7eb9a4c 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
@@ -44,6 +44,7 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.RouteContext;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.support.language.ExpressionModel;
import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.ObjectHelper;
@@ -54,7 +55,7 @@ import org.apache.camel.util.ObjectHelper;
@XmlRootElement
@XmlType(name = "expression") // must be named expression
@XmlAccessorType(XmlAccessType.FIELD)
-public class ExpressionDefinition implements Expression, Predicate, OtherAttributesAware {
+public class ExpressionDefinition implements Expression, Predicate, OtherAttributesAware, ExpressionModel {
@XmlAttribute
@XmlID
private String id;
@@ -97,17 +98,18 @@ public class ExpressionDefinition implements Expression, Predicate, OtherAttribu
@Override
public String toString() {
+ // favour using the output from expression value
+ if (getExpressionValue() != null) {
+ return getExpressionValue().toString();
+ }
+
StringBuilder sb = new StringBuilder();
if (getLanguage() != null) {
sb.append(getLanguage()).append("{");
}
if (getPredicate() != null) {
sb.append(getPredicate().toString());
- }
- if (getExpressionValue() != null) {
- sb.append(getExpressionValue().toString());
- }
- if (getPredicate() == null && getExpressionValue() == null && getExpression() != null) {
+ } else if (getExpression() != null) {
sb.append(getExpression());
}
if (getLanguage() != null) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
index 7205913..1f8ba3f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
@@ -32,6 +32,7 @@ public class DumpModelAsXmlChoiceFilterRouteTest extends ContextTestSupport {
assertNotNull(xml);
log.info(xml);
+ assertTrue(xml.contains("<header>dude</header>"));
assertTrue(xml.contains("<header>gold</header>"));
assertTrue(xml.contains("<header>extra-gold</header>"));
assertTrue(xml.contains("<simple>${body} contains 'Camel'</simple>"));
@@ -54,6 +55,7 @@ public class DumpModelAsXmlChoiceFilterRouteTest extends ContextTestSupport {
public void configure() throws Exception {
from("direct:start").routeId("myRoute")
.to("log:input")
+ .transform().header("dude")
.choice()
.when().header("gold")
.to("mock:gold")
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
new file mode 100644
index 0000000..9b812f1
--- /dev/null
+++ b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.support.language;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Expression;
+
+public interface ExpressionModel {
+
+ // TODO: move to api, and maybe have a @FunctionalInterface
+
+ Expression createExpression(CamelContext camelContext);
+
+
+}
[camel] 03/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b75878e52d7e81ccd5104a2415385cf863232fbe
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Apr 15 16:13:32 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../org/apache/camel/builder/ExpressionClause.java | 7 --
.../apache/camel/model/ProcessorDefinition.java | 40 ++++-----
...mlChoiceFilterRoutePropertyPlaceholderTest.java | 95 ++++++++++++++++++++++
3 files changed, 116 insertions(+), 26 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
index eed851f..6dd377b 100644
--- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -25,7 +25,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Message;
import org.apache.camel.Predicate;
-import org.apache.camel.model.ExpressionNode;
import org.apache.camel.support.ExpressionAdapter;
import org.apache.camel.support.ExpressionToPredicateAdapter;
import org.apache.camel.support.builder.xml.Namespaces;
@@ -42,12 +41,6 @@ public class ExpressionClause<T> implements Expression, Predicate {
this.delegate = new ExpressionClauseSupport<>(result);
}
- public static <T extends ExpressionNode> ExpressionClause<T> createAndSetExpression(T result) {
- ExpressionClause<T> clause = new ExpressionClause<>(result);
- result.setExpression(clause);
- return clause;
- }
-
// Helper expressions
// -------------------------------------------------------------------------
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 46f2463..37ea037 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -94,6 +94,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
index = COUNTER.getAndIncrement();
}
+ private static <T extends ExpressionNode> ExpressionClause<T> createAndSetExpression(T result) {
+ ExpressionClause<T> clause = new ExpressionClause<>(result);
+ result.setExpression(clause);
+ return clause;
+ }
+
/**
* Gets the unique index number for when this {@link ProcessorDefinition} was created by its constructor.
* <p/>
@@ -1061,8 +1067,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<IdempotentConsumerDefinition> idempotentConsumer() {
IdempotentConsumerDefinition answer = new IdempotentConsumerDefinition();
addOutput(answer);
-
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1106,7 +1111,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<? extends FilterDefinition> filter() {
FilterDefinition filter = new FilterDefinition();
addOutput(filter);
- return ExpressionClause.createAndSetExpression(filter);
+ return createAndSetExpression(filter);
}
/**
@@ -1189,7 +1194,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<ValidateDefinition> validate() {
ValidateDefinition answer = new ValidateDefinition();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1397,7 +1402,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
RecipientListDefinition<Type> answer = new RecipientListDefinition<>();
answer.setDelimiter(delimiter);
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1410,7 +1415,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<RecipientListDefinition<Type>> recipientList() {
RecipientListDefinition<Type> answer = new RecipientListDefinition<>();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1463,7 +1468,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<RoutingSlipDefinition<Type>> routingSlip() {
RoutingSlipDefinition<Type> answer = new RoutingSlipDefinition<>();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1499,7 +1504,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<DynamicRouterDefinition<Type>> dynamicRouter() {
DynamicRouterDefinition<Type> answer = new DynamicRouterDefinition<>();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1564,7 +1569,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<SplitDefinition> split() {
SplitDefinition answer = new SplitDefinition();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1712,7 +1717,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<DelayDefinition> delay() {
DelayDefinition answer = new DelayDefinition();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1735,8 +1740,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<ThrottleDefinition> throttle() {
ThrottleDefinition answer = new ThrottleDefinition();
addOutput(answer);
-
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -1823,7 +1827,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<LoopDefinition> loop() {
LoopDefinition loop = new LoopDefinition();
addOutput(loop);
- return ExpressionClause.createAndSetExpression(loop);
+ return createAndSetExpression(loop);
}
/**
@@ -1864,10 +1868,8 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<LoopDefinition> loopDoWhile() {
LoopDefinition loop = new LoopDefinition();
loop.setDoWhile(true);
-
addOutput(loop);
-
- return ExpressionClause.createAndSetExpression(loop);
+ return createAndSetExpression(loop);
}
/**
@@ -2671,7 +2673,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public <T> ExpressionClause<SortDefinition<T>> sort() {
SortDefinition<T> answer = new SortDefinition<>();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -2852,7 +2854,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<EnrichDefinition> enrich() {
EnrichDefinition answer = new EnrichDefinition();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
@@ -3107,7 +3109,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public ExpressionClause<PollEnrichDefinition> pollEnrich() {
PollEnrichDefinition answer = new PollEnrichDefinition();
addOutput(answer);
- return ExpressionClause.createAndSetExpression(answer);
+ return createAndSetExpression(answer);
}
/**
diff --git a/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRoutePropertyPlaceholderTest.java b/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRoutePropertyPlaceholderTest.java
new file mode 100644
index 0000000..b369dcc
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRoutePropertyPlaceholderTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.util;
+
+import java.util.Properties;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.ModelHelper;
+import org.apache.camel.spi.PropertiesComponent;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DumpModelAsXmlChoiceFilterRoutePropertyPlaceholderTest extends ContextTestSupport {
+
+ @Test
+ public void testDumpModelAsXml() throws Exception {
+ String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("myRoute"));
+ assertNotNull(xml);
+ log.info(xml);
+
+ assertTrue(xml.contains("<header>{{duke}}</header>"));
+ assertTrue(xml.contains("<header>{{best}}</header>"));
+ assertTrue(xml.contains("<header>{{extra}}</header>"));
+ assertTrue(xml.contains("<simple>${body} contains 'Camel'</simple>"));
+ }
+
+ @Test
+ public void testDumpModelAsXmAl() throws Exception {
+ String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("a"));
+ assertNotNull(xml);
+ log.info(xml);
+
+ assertTrue(xml.contains("message=\"{{mypath}}\""));
+ assertTrue(xml.contains("<constant>bar</constant>"));
+ assertTrue(xml.contains("<expressionDefinition>header{test} is not null</expressionDefinition>"));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ Properties prop = new Properties();
+ prop.put("duke", "dude");
+ prop.put("best", "gold");
+ prop.put("extra", "extra-gold");
+ prop.put("mypath", "xpath");
+
+ PropertiesComponent pc = context.getPropertiesComponent(true);
+ pc.setInitialProperties(prop);
+
+ from("direct:start").routeId("myRoute")
+ .to("log:input")
+ .transform().header("{{duke}}")
+ .choice()
+ .when().header("{{best}}")
+ .to("mock:gold")
+ .filter().header("{{extra}}")
+ .to("mock:extra-gold")
+ .endChoice()
+ .when().simple("${body} contains 'Camel'")
+ .to("mock:camel")
+ .otherwise()
+ .to("mock:other")
+ .end()
+ .to("mock:result");
+
+ from("seda:a").routeId("a")
+ .setProperty("foo").constant("bar")
+ .choice()
+ .when(header("test").isNotNull()).log("not null")
+ .when(xpath("/foo/bar")).log("{{mypath}}")
+ .end()
+ .to("mock:a");
+ }
+ };
+ }
+}
[camel] 37/38: Move mock component out of camel-core. Work in
progress.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mock
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 79437094fd39a73f9eb6a5479383fc0999da48fa
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 17 11:12:59 2019 +0200
Move mock component out of camel-core. Work in progress.
---
.../spring-boot-dm/camel-spring-boot-dependencies/pom.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 90ef2dd..9b151ca 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -2050,6 +2050,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-mongodb-gridfs</artifactId>
<version>${project.version}</version>
</dependency>