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/05/22 07:27:42 UTC
[camel] 01/03: CAMEL-13555: Producer and consumer template/cache
should check if camel is started when being used
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c45fb9ee4f9335257ebf4020b469aa151eb6007c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed May 22 09:18:55 2019 +0200
CAMEL-13555: Producer and consumer template/cache should check if camel is started when being used
---
MIGRATION.md | 1 +
.../test/patterns/AdviceWithNotStartedTest.java | 72 +++++++++++++
.../java/org/apache/camel/spi/ProducerCache.java | 114 ++++++++++++++++++++-
.../camel/support/service/ServiceSupport.java | 2 +-
.../camel/impl/engine/DefaultConsumerCache.java | 14 +++
.../camel/impl/engine/DefaultConsumerTemplate.java | 4 +-
.../camel/impl/engine/DefaultProducerCache.java | 108 ++-----------------
.../component/dataset/DataSetTestAnyOrderTest.java | 6 --
.../component/dataset/DataSetTestSedaTest.java | 6 --
.../SendToNonExistingDirectEndpointTest.java | 2 +
.../file/ConsumerTemplateFileShutdownTest.java | 4 -
.../component/file/FileBrowsableEndpointTest.java | 6 +-
.../file/FileConsumerFileExpressionTest.java | 9 --
...leConsumerFileExpressionThrowExceptionTest.java | 7 --
.../component/file/FileConsumerTemplateTest.java | 5 -
.../component/file/FileConvertBodyToUTF8Test.java | 6 --
.../file/FileEagerDeleteTargetFileTest.java | 4 -
.../component/file/FilePollingConsumerTest.java | 5 -
.../file/FileProducerMoveExistingStrategyTest.java | 4 -
.../file/FileProducerMoveExistingTest.java | 4 -
.../file/FileProducerTempFileExistsIssueTest.java | 5 -
.../component/file/FileSortByExpressionTest.java | 7 --
.../file/FileSortByIgnoreCaseExpressionTest.java | 5 -
.../file/FileSortByNestedExpressionTest.java | 5 -
.../camel/component/file/FileSorterRefTest.java | 19 ++--
.../component/file/FileToFileWithFlattenTest.java | 5 -
.../file/FilerProducerDoneFileNameTest.java | 5 +-
.../camel/component/file/NewFileProduceTest.java | 6 +-
.../LanguageLoadScriptFromFileUpdateTest.java | 5 +-
.../seda/FileSedaShutdownCompleteAllTasksTest.java | 4 -
.../ThreadsCoreAndMaxPoolInvalidTest.java | 5 -
31 files changed, 222 insertions(+), 232 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 4ff7b5d..05e0a66 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -377,6 +377,7 @@ The APIs that could find, and explain EIPs, components, endpoints etc has been r
The default for use breadcrumbs has been changed from `true` to `false`.
+The `ProducerTemplate` and `ConsumerTemplate` now fails when being used, if `CamelContext` has not been started first.
### XML DSL Migration
diff --git a/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java b/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java
new file mode 100644
index 0000000..b807e57
--- /dev/null
+++ b/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.test.patterns;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.reifier.RouteReifier;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import java.util.concurrent.RejectedExecutionException;
+
+public class AdviceWithNotStartedTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseAdviceWith() {
+ return true;
+ }
+
+ @Test
+ public void testNotStarted() throws Exception {
+ RouteReifier.adviceWith(context.getRouteDefinition("foo"), context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ weaveAddLast().to("mock:result");
+ }
+ });
+
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ try {
+ template.sendBody("direct:start", "Hello World");
+ fail("Should throw exception");
+ } catch (CamelExecutionException e) {
+ assertIsInstanceOf(RejectedExecutionException.class, e.getCause());
+ }
+
+ // start Camel
+ context.start();
+
+ template.sendBody("direct:start", "Bye World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").routeId("foo")
+ .to("log:foo");
+ }
+ };
+ }
+}
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java b/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java
index 8032074..d34cf5f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java
@@ -17,6 +17,7 @@
package org.apache.camel.spi;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.RejectedExecutionException;
import org.apache.camel.AsyncCallback;
import org.apache.camel.AsyncProcessor;
@@ -25,51 +26,156 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
+import org.apache.camel.Producer;
import org.apache.camel.Service;
+/**
+ * Cache containing created {@link Producer}.
+ */
public interface ProducerCache extends Service {
+ /**
+ * Acquires a pooled producer which you <b>must</b> release back again after usage using the
+ * {@link #releaseProducer(org.apache.camel.Endpoint, org.apache.camel.AsyncProducer)} method.
+ *
+ * @param endpoint the endpoint
+ * @return the producer
+ */
AsyncProducer acquireProducer(Endpoint endpoint);
+ /**
+ * Releases an acquired producer back after usage.
+ *
+ * @param endpoint the endpoint
+ * @param producer the producer to release
+ */
void releaseProducer(Endpoint endpoint, AsyncProducer producer);
+ /**
+ * Sends the exchange to the given endpoint.
+ * <p>
+ * This method will <b>not</b> throw an exception. If processing of the given
+ * Exchange failed then the exception is stored on the provided Exchange
+ *
+ * @param endpoint the endpoint to send the exchange to
+ * @param exchange the exchange to send
+ * @throws RejectedExecutionException is thrown if CamelContext is stopped
+ */
Exchange send(Endpoint endpoint, Exchange exchange, Processor resultProcessor);
- CompletableFuture<Exchange> asyncSendExchange(Endpoint endpoint, ExchangePattern pattern,
- Processor processor, Processor resultProcessor, Exchange inExchange, CompletableFuture<Exchange> exchangeFuture);
+ /**
+ * Asynchronously sends an exchange to an endpoint using a supplied
+ * {@link Processor} to populate the exchange
+ * <p>
+ * This method will <b>neither</b> throw an exception <b>nor</b> complete future exceptionally.
+ * If processing of the given Exchange failed then the exception is stored on the return Exchange
+ *
+ * @param endpoint the endpoint to send the exchange to
+ * @param pattern the message {@link ExchangePattern} such as
+ * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
+ * @param processor the transformer used to populate the new exchange
+ * @param resultProcessor a processor to process the exchange when the send is complete.
+ * @param exchange an exchange to use in processing. Exchange will be created if parameter is null.
+ * @param future the preexisting future to complete when processing is done or null if to create new one
+ * @return future that completes with exchange when processing is done. Either passed into future parameter
+ * or new one if parameter was null
+ */
+ CompletableFuture<Exchange> asyncSendExchange(Endpoint endpoint, ExchangePattern pattern,
+ Processor processor, Processor resultProcessor, Exchange exchange, CompletableFuture<Exchange> future);
+ /**
+ * Gets the source which uses this cache
+ *
+ * @return the source
+ */
Object getSource();
+ /**
+ * Returns the current size of the cache
+ *
+ * @return the current size
+ */
int size();
+ /**
+ * Gets the maximum cache size (capacity).
+ *
+ * @return the capacity
+ */
int getCapacity();
+ /**
+ * Gets the cache hits statistic
+ * <p/>
+ * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
+ *
+ * @return the hits
+ */
long getHits();
+ /**
+ * Gets the cache misses statistic
+ * <p/>
+ * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
+ *
+ * @return the misses
+ */
long getMisses();
+ /**
+ * Gets the cache evicted statistic
+ * <p/>
+ * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
+ *
+ * @return the evicted
+ */
long getEvicted();
+ /**
+ * Resets the cache statistics
+ */
void resetCacheStatistics();
+ /**
+ * Purges this cache
+ */
void purge();
+ /**
+ * Cleanup the cache (purging stale entries)
+ */
void cleanUp();
boolean isEventNotifierEnabled();
+ /**
+ * Whether {@link org.apache.camel.spi.EventNotifier} is enabled
+ */
void setEventNotifierEnabled(boolean eventNotifierEnabled);
+ /**
+ * Gets the endpoint statistics
+ */
EndpointUtilizationStatistics getEndpointUtilizationStatistics();
- boolean doInAsyncProducer(Endpoint endpoint, Exchange exchange, AsyncCallback callback, AsyncProducerCallback asyncProducerCallback);
+ /**
+ * Sends an exchange to an endpoint using a supplied callback supporting the asynchronous routing engine.
+ * <p/>
+ * If an exception was thrown during processing, it would be set on the given Exchange
+ *
+ * @param endpoint the endpoint to send the exchange to
+ * @param exchange the exchange, can be <tt>null</tt> if so then create a new exchange from the producer
+ * @param callback the asynchronous callback
+ * @param producerCallback the producer template callback to be executed
+ * @return (doneSync) <tt>true</tt> to continue execute synchronously, <tt>false</tt> to continue being executed asynchronously
+ */
+ boolean doInAsyncProducer(Endpoint endpoint, Exchange exchange, AsyncCallback callback, AsyncProducerCallback producerCallback);
/**
* Callback for sending a exchange message to a endpoint using an {@link AsyncProcessor} capable producer.
* <p/>
* Using this callback as a template pattern ensures that Camel handles the resource handling and will
* start and stop the given producer, to avoid resource leaks.
- *
*/
interface AsyncProducerCallback {
diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
index 71119d7..c2bce51 100644
--- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
+++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceSupport.java
@@ -268,7 +268,7 @@ public abstract class ServiceSupport implements StatefulService {
@Override
public boolean isStopped() {
- return status == STOPPED || status == SHUTTINGDOWN || status == SHUTDOWN || status == FAILED;
+ return status == NEW || status == INITIALIZED || status == STOPPED || status == SHUTTINGDOWN || status == SHUTDOWN || status == FAILED;
}
@Override
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerCache.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerCache.java
index 644044b..d266d94 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerCache.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerCache.java
@@ -27,6 +27,8 @@ import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
+import java.util.concurrent.RejectedExecutionException;
+
/**
* Cache containing created {@link org.apache.camel.Consumer}.
*/
@@ -94,6 +96,10 @@ public class DefaultConsumerCache extends ServiceSupport implements ConsumerCach
}
public Exchange receive(Endpoint endpoint) {
+ if (camelContext.isStopped()) {
+ throw new RejectedExecutionException("CamelContext is stopped");
+ }
+
log.debug("<<<< {}", endpoint);
PollingConsumer consumer = null;
try {
@@ -107,6 +113,10 @@ public class DefaultConsumerCache extends ServiceSupport implements ConsumerCach
}
public Exchange receive(Endpoint endpoint, long timeout) {
+ if (camelContext.isStopped()) {
+ throw new RejectedExecutionException("CamelContext is stopped");
+ }
+
log.debug("<<<< {}", endpoint);
PollingConsumer consumer = null;
try {
@@ -120,6 +130,10 @@ public class DefaultConsumerCache extends ServiceSupport implements ConsumerCach
}
public Exchange receiveNoWait(Endpoint endpoint) {
+ if (camelContext.isStopped()) {
+ throw new RejectedExecutionException("CamelContext is stopped");
+ }
+
log.debug("<<<< {}", endpoint);
PollingConsumer consumer = null;
try {
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerTemplate.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerTemplate.java
index f22d5e7..187712a 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerTemplate.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultConsumerTemplate.java
@@ -32,9 +32,7 @@ import org.apache.camel.support.service.ServiceSupport;
import static org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException;
/**
- * Template (named like Spring's TransactionTemplate & JmsTemplate
- * et al) for working with Camel and consuming {@link org.apache.camel.Message} instances in an
- * {@link Exchange} from an {@link Endpoint}.
+ * Default implementation of {@link ConsumerTemplate}.
*/
public class DefaultConsumerTemplate extends ServiceSupport implements ConsumerTemplate {
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultProducerCache.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultProducerCache.java
index 986f828..c4ced57 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultProducerCache.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultProducerCache.java
@@ -17,6 +17,7 @@
package org.apache.camel.impl.engine;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.RejectedExecutionException;
import org.apache.camel.AsyncCallback;
import org.apache.camel.AsyncProcessor;
@@ -27,7 +28,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.FailedToCreateProducerException;
import org.apache.camel.Processor;
-import org.apache.camel.Producer;
import org.apache.camel.processor.CamelInternalProcessor;
import org.apache.camel.processor.SharedCamelInternalProcessor;
import org.apache.camel.spi.EndpointUtilizationStatistics;
@@ -39,7 +39,7 @@ import org.apache.camel.support.service.ServiceSupport;
import org.apache.camel.util.StopWatch;
/**
- * Cache containing created {@link Producer}.
+ * Default implementation of {@link ProducerCache}.
*/
public class DefaultProducerCache extends ServiceSupport implements ProducerCache {
@@ -74,9 +74,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
return eventNotifierEnabled;
}
- /**
- * Whether {@link org.apache.camel.spi.EventNotifier} is enabled
- */
public void setEventNotifierEnabled(boolean eventNotifierEnabled) {
this.eventNotifierEnabled = eventNotifierEnabled;
}
@@ -96,22 +93,10 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
return camelContext;
}
- /**
- * Gets the source which uses this cache
- *
- * @return the source
- */
public Object getSource() {
return source;
}
- /**
- * Acquires a pooled producer which you <b>must</b> release back again after usage using the
- * {@link #releaseProducer(org.apache.camel.Endpoint, org.apache.camel.AsyncProducer)} method.
- *
- * @param endpoint the endpoint
- * @return the producer
- */
public AsyncProducer acquireProducer(Endpoint endpoint) {
try {
AsyncProducer producer = producers.acquire(endpoint);
@@ -124,26 +109,16 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
}
}
- /**
- * Releases an acquired producer back after usage.
- *
- * @param endpoint the endpoint
- * @param producer the producer to release
- */
public void releaseProducer(Endpoint endpoint, AsyncProducer producer) {
producers.release(endpoint, producer);
}
- /**
- * Sends the exchange to the given endpoint.
- * <p>
- * This method will <b>not</b> throw an exception. If processing of the given
- * Exchange failed then the exception is stored on the provided Exchange
- *
- * @param endpoint the endpoint to send the exchange to
- * @param exchange the exchange to send
- */
public Exchange send(Endpoint endpoint, Exchange exchange, Processor resultProcessor) {
+ if (camelContext.isStopped()) {
+ exchange.setException(new RejectedExecutionException("CamelContext is stopped"));
+ return exchange;
+ }
+
AsyncProducer producer = acquireProducer(endpoint);
try {
// now lets dispatch
@@ -197,6 +172,7 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
* @return future that completes with exchange when processing is done. Either passed into future parameter
* or new one if parameter was null
*/
+ @Deprecated
public CompletableFuture<Exchange> asyncSend(Endpoint endpoint,
ExchangePattern pattern,
Processor processor,
@@ -205,23 +181,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
return asyncSendExchange(endpoint, pattern, processor, resultProcessor, null, future);
}
- /**
- * Asynchronously sends an exchange to an endpoint using a supplied
- * {@link Processor} to populate the exchange
- * <p>
- * This method will <b>neither</b> throw an exception <b>nor</b> complete future exceptionally.
- * If processing of the given Exchange failed then the exception is stored on the return Exchange
- *
- * @param endpoint the endpoint to send the exchange to
- * @param pattern the message {@link ExchangePattern} such as
- * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
- * @param processor the transformer used to populate the new exchange
- * @param resultProcessor a processor to process the exchange when the send is complete.
- * @param exchange an exchange to use in processing. Exchange will be created if parameter is null.
- * @param future the preexisting future to complete when processing is done or null if to create new one
- * @return future that completes with exchange when processing is done. Either passed into future parameter
- * or new one if parameter was null
- */
public CompletableFuture<Exchange> asyncSendExchange(Endpoint endpoint,
ExchangePattern pattern,
Processor processor,
@@ -259,17 +218,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
return future;
}
- /**
- * Sends an exchange to an endpoint using a supplied callback supporting the asynchronous routing engine.
- * <p/>
- * If an exception was thrown during processing, it would be set on the given Exchange
- *
- * @param endpoint the endpoint to send the exchange to
- * @param exchange the exchange, can be <tt>null</tt> if so then create a new exchange from the producer
- * @param callback the asynchronous callback
- * @param producerCallback the producer template callback to be executed
- * @return (doneSync) <tt>true</tt> to continue execute synchronously, <tt>false</tt> to continue being executed asynchronously
- */
public boolean doInAsyncProducer(Endpoint endpoint,
Exchange exchange,
AsyncCallback callback,
@@ -381,11 +329,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
}
}
- /**
- * Returns the current size of the cache
- *
- * @return the current size
- */
public int size() {
int size = producers.size();
@@ -393,51 +336,22 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
return size;
}
- /**
- * Gets the maximum cache size (capacity).
- *
- * @return the capacity
- */
public int getCapacity() {
return maxCacheSize;
}
- /**
- * Gets the cache hits statistic
- * <p/>
- * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
- *
- * @return the hits
- */
public long getHits() {
return producers.getHits();
}
- /**
- * Gets the cache misses statistic
- * <p/>
- * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
- *
- * @return the misses
- */
public long getMisses() {
return producers.getMisses();
}
- /**
- * Gets the cache evicted statistic
- * <p/>
- * Will return <tt>-1</tt> if it cannot determine this if a custom cache was used.
- *
- * @return the evicted
- */
public long getEvicted() {
return producers.getEvicted();
}
- /**
- * Resets the cache statistics
- */
public void resetCacheStatistics() {
producers.resetStatistics();
if (statistics != null) {
@@ -445,9 +359,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
}
}
- /**
- * Purges this cache
- */
public synchronized void purge() {
try {
producers.stop();
@@ -460,9 +371,6 @@ public class DefaultProducerCache extends ServiceSupport implements ProducerCach
}
}
- /**
- * Cleanup the cache (purging stale entries)
- */
public void cleanUp() {
producers.cleanUp();
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
index 85af448..f36b8d4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestAnyOrderTest.java
@@ -22,11 +22,6 @@ import org.junit.Test;
public class DataSetTestAnyOrderTest extends ContextTestSupport {
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testAnyOrder() throws Exception {
template.sendBody("seda:testme", "Bye World");
@@ -39,7 +34,6 @@ public class DataSetTestAnyOrderTest extends ContextTestSupport {
.to("dataset-test:seda:testme?anyOrder=true&timeout=0");
}
});
- context.start();
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
index da1c6d1..11a953c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetTestSedaTest.java
@@ -22,11 +22,6 @@ import org.junit.Test;
public class DataSetTestSedaTest extends ContextTestSupport {
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testSeda() throws Exception {
template.sendBody("seda:testme", "Hello World");
@@ -38,7 +33,6 @@ public class DataSetTestSedaTest extends ContextTestSupport {
.to("dataset-test:seda:testme?timeout=0");
}
});
- context.start();
template.sendBody("direct:start", "Hello World");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java
index 3112e4e..670f9c2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java
@@ -30,6 +30,8 @@ public class SendToNonExistingDirectEndpointTest extends ContextTestSupport {
@Test
public void testDirect() throws Exception {
+ context.start();
+
context.getComponent("direct", DirectComponent.class).setBlock(false);
try {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/ConsumerTemplateFileShutdownTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/ConsumerTemplateFileShutdownTest.java
index bb9d818..f6405f9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/ConsumerTemplateFileShutdownTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/ConsumerTemplateFileShutdownTest.java
@@ -40,8 +40,4 @@ public class ConsumerTemplateFileShutdownTest extends ContextTestSupport {
consumer.stop();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
index 5a464df..fb319df 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileBrowsableEndpointTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.component.file;
+
import java.io.File;
import java.util.List;
@@ -37,11 +38,6 @@ public class FileBrowsableEndpointTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testBrowsableNoFiles() throws Exception {
BrowsableEndpoint browse = context.getEndpoint("file:target/data/browse?initialDelay=0&delay=10", BrowsableEndpoint.class);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java
index 8c0cbc6..c5cf616 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionTest.java
@@ -38,11 +38,6 @@ public class FileConsumerFileExpressionTest extends ContextTestSupport {
}
@Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("counter", new MyGuidGenerator());
@@ -67,8 +62,6 @@ public class FileConsumerFileExpressionTest extends ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Goodday World");
- context.start();
-
assertMockEndpointsSatisfied();
}
@@ -92,8 +85,6 @@ public class FileConsumerFileExpressionTest extends ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Goodday World");
- context.start();
-
assertMockEndpointsSatisfied();
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
index 37ec5ba..a8b8208 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerFileExpressionThrowExceptionTest.java
@@ -49,11 +49,6 @@ public class FileConsumerFileExpressionThrowExceptionTest extends ContextTestSup
}
@Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("counter", new MyGuidGenerator());
@@ -74,8 +69,6 @@ public class FileConsumerFileExpressionThrowExceptionTest extends ContextTestSup
}
});
- context.start();
-
await().atMost(2, TimeUnit.SECONDS).until(() -> LATCH.getCount() == 0);
// and we should rollback X number of times
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerTemplateTest.java
index 59cc032..68d2963 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerTemplateTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerTemplateTest.java
@@ -31,11 +31,6 @@ public class FileConsumerTemplateTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testFileConsumerTemplate() throws Exception {
template.sendBodyAndHeader("file:target/data/consumer", "Hello World", Exchange.FILE_NAME, "hello.txt");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConvertBodyToUTF8Test.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConvertBodyToUTF8Test.java
index 71bc165..a760be2 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConvertBodyToUTF8Test.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConvertBodyToUTF8Test.java
@@ -39,11 +39,6 @@ public class FileConvertBodyToUTF8Test extends ContextTestSupport {
template.sendBodyAndHeader("file://target/data/utf8", body, Exchange.FILE_NAME, "utf8.txt");
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testFileUTF8() throws Exception {
context.addRoutes(new RouteBuilder() {
@@ -54,7 +49,6 @@ public class FileConvertBodyToUTF8Test extends ContextTestSupport {
.to("mock:result");
}
});
- context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileEagerDeleteTargetFileTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileEagerDeleteTargetFileTest.java
index 624ac3b..eb0de89 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileEagerDeleteTargetFileTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileEagerDeleteTargetFileTest.java
@@ -62,8 +62,4 @@ public class FileEagerDeleteTargetFileTest extends ContextTestSupport {
assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FilePollingConsumerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FilePollingConsumerTest.java
index 09527d7..e51550d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FilePollingConsumerTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FilePollingConsumerTest.java
@@ -36,11 +36,6 @@ public class FilePollingConsumerTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testPollingConsumer() throws Exception {
template.sendBodyAndHeader("file:target/data/enrich", "Hello World", Exchange.FILE_NAME, "hello.txt");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java
index ceed04f..31e11fc3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingStrategyTest.java
@@ -130,8 +130,4 @@ public class FileProducerMoveExistingStrategyTest extends ContextTestSupport {
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingTest.java
index 019f6df..c3be96f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerMoveExistingTest.java
@@ -128,8 +128,4 @@ public class FileProducerMoveExistingTest extends ContextTestSupport {
assertEquals("Old file", context.getTypeConverter().convertTo(String.class, new File("target/data/file/renamed-hello.txt")));
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerTempFileExistsIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerTempFileExistsIssueTest.java
index 1f5903b..6685137 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerTempFileExistsIssueTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerTempFileExistsIssueTest.java
@@ -32,11 +32,6 @@ public class FileProducerTempFileExistsIssueTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testIllegalConfiguration() throws Exception {
try {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByExpressionTest.java
index b2d8024..f6fa8cc 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByExpressionTest.java
@@ -36,11 +36,6 @@ public class FileSortByExpressionTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
private void prepareFolder(String folder) {
template.sendBodyAndHeader("file:target/data/filesorter/" + folder, "Hello Paris",
Exchange.FILE_NAME, "paris.dat");
@@ -62,7 +57,6 @@ public class FileSortByExpressionTest extends ContextTestSupport {
from(fileUrl + "a/?initialDelay=0&delay=10&sortBy=file:ext").to("mock:result");
}
});
- context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello Paris", "Hello London", "Hello Copenhagen");
@@ -81,7 +75,6 @@ public class FileSortByExpressionTest extends ContextTestSupport {
.convertBodyTo(String.class).to("mock:reverse");
}
});
- context.start();
MockEndpoint reverse = getMockEndpoint("mock:reverse");
reverse.expectedBodiesReceived("Hello Copenhagen", "Hello London", "Hello Paris");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByIgnoreCaseExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByIgnoreCaseExpressionTest.java
index 8e914c2..abf956f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByIgnoreCaseExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByIgnoreCaseExpressionTest.java
@@ -36,11 +36,6 @@ public class FileSortByIgnoreCaseExpressionTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
private void prepareFolder(String folder) {
template.sendBodyAndHeader("file:target/data/filesorter/" + folder, "Hello Paris",
Exchange.FILE_NAME, "report-3.dat");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByNestedExpressionTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByNestedExpressionTest.java
index bc4f5af..99eebe4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByNestedExpressionTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSortByNestedExpressionTest.java
@@ -36,11 +36,6 @@ public class FileSortByNestedExpressionTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
private void prepareFolder(String folder) {
template.sendBodyAndHeader("file:target/data/filesorter/" + folder, "Hello Paris",
Exchange.FILE_NAME, "paris.txt");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSorterRefTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSorterRefTest.java
index 27202f6..df77d2c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileSorterRefTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileSorterRefTest.java
@@ -33,11 +33,6 @@ public class FileSorterRefTest extends ContextTestSupport {
private String fileUrl = "file://target/data/filesorter/?initialDelay=0&delay=10&sorter=#mySorter";
@Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("mySorter", new MyFileSorter<>());
@@ -50,25 +45,25 @@ public class FileSorterRefTest extends ContextTestSupport {
deleteDirectory("target/data/filesorter");
super.setUp();
+ }
+
+ @Test
+ public void testSortFiles() throws Exception {
template.sendBodyAndHeader("file:target/data/filesorter/", "Hello Paris",
- Exchange.FILE_NAME, "paris.txt");
+ Exchange.FILE_NAME, "paris.txt");
template.sendBodyAndHeader("file:target/data/filesorter/", "Hello London",
- Exchange.FILE_NAME, "london.txt");
+ Exchange.FILE_NAME, "london.txt");
template.sendBodyAndHeader("file:target/data/filesorter/", "Hello Copenhagen",
- Exchange.FILE_NAME, "copenhagen.txt");
- }
+ Exchange.FILE_NAME, "copenhagen.txt");
- @Test
- public void testSortFiles() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from(fileUrl).convertBodyTo(String.class).to("mock:result");
}
});
- context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello Copenhagen", "Hello London", "Hello Paris");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileWithFlattenTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileWithFlattenTest.java
index b09678f..37d27e7 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileWithFlattenTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileToFileWithFlattenTest.java
@@ -28,11 +28,6 @@ public class FileToFileWithFlattenTest extends ContextTestSupport {
private String fileUrl = "file://target/data/flatten-in";
@Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @Override
@Before
public void setUp() throws Exception {
deleteDirectory("target/data/flatten-in");
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
index 112af54..e5af55f 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.component.file;
+
import java.io.File;
import java.util.Properties;
@@ -138,8 +139,4 @@ public class FilerProducerDoneFileNameTest extends ContextTestSupport {
assertEquals("Done file should exists", true, done.exists());
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
index 851010d..8b1a4f3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.apache.camel.component.file;
+
import java.io.File;
import java.util.HashMap;
@@ -37,11 +38,6 @@ public class NewFileProduceTest extends ContextTestSupport {
super.setUp();
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
@Test
public void testNewFileProducer() throws Exception {
FileComponent comp = new FileComponent();
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromFileUpdateTest.java b/core/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromFileUpdateTest.java
index b80930a..e60c5c3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromFileUpdateTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/language/LanguageLoadScriptFromFileUpdateTest.java
@@ -32,6 +32,9 @@ public class LanguageLoadScriptFromFileUpdateTest extends ContextTestSupport {
@Test
public void testLanguage() throws Exception {
+ // create script to start with
+ template.sendBodyAndHeader("file:target/data/script", "Hello ${body}", Exchange.FILE_NAME, "myscript.txt");
+
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Bye World");
template.sendBody("direct:start", "World");
@@ -47,8 +50,6 @@ public class LanguageLoadScriptFromFileUpdateTest extends ContextTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- // create script to start with
- template.sendBodyAndHeader("file:target/data/script", "Hello ${body}", Exchange.FILE_NAME, "myscript.txt");
// START SNIPPET: e1
from("direct:start")
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/FileSedaShutdownCompleteAllTasksTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/FileSedaShutdownCompleteAllTasksTest.java
index b0b4f01..a216ca0 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/FileSedaShutdownCompleteAllTasksTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/FileSedaShutdownCompleteAllTasksTest.java
@@ -91,8 +91,4 @@ public class FileSedaShutdownCompleteAllTasksTest extends ContextTestSupport {
assertEquals("Should complete all messages", 5, bar.getReceivedCounter());
}
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
index 0f67611..967815d 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolInvalidTest.java
@@ -22,11 +22,6 @@ import org.junit.Test;
public class ThreadsCoreAndMaxPoolInvalidTest extends ContextTestSupport {
- @Override
- public boolean isUseRouteBuilder() {
- return super.isUseRouteBuilder();
- }
-
@Test
public void testInvalidSyntax() throws Exception {
try {