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 2023/01/12 12:54:50 UTC
[camel] 01/03: Remove camel-test in v4 (junit 4)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6526080fee8accc42fa9917502ca22cfd4ced787
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 12 13:42:53 2023 +0100
Remove camel-test in v4 (junit 4)
---
components/camel-test/camel-test/pom.xml | 166 ---
.../services/org/apache/camel/other.properties | 7 -
.../camel-test/src/generated/resources/test.json | 15 -
.../camel-test/camel-test/src/main/docs/test.adoc | 56 -
.../org/apache/camel/test/AvailablePortFinder.java | 94 --
.../AvailablePortFinderPropertiesFunction.java | 116 --
.../test/ExcludingPackageScanClassResolver.java | 34 -
.../camel/test/TestSupportNodeIdFactory.java | 31 -
.../camel/test/junit4/CamelTearDownRule.java | 50 -
.../apache/camel/test/junit4/CamelTestSupport.java | 1150 --------------------
.../apache/camel/test/junit4/CamelTestWatcher.java | 45 -
.../camel/test/junit4/ExchangeTestSupport.java | 56 -
.../camel/test/junit4/LanguageTestSupport.java | 98 --
.../org/apache/camel/test/junit4/TestSupport.java | 565 ----------
.../apache/camel/test/AvailablePortFinderTest.java | 106 --
.../apache/camel/test/CamelTestSupportTest.java | 71 --
.../camel/test/RouteFilterPatternExcludeTest.java | 57 -
.../test/RouteFilterPatternIncludeExcludeTest.java | 65 --
.../camel/test/RouteFilterPatternIncludeTest.java | 57 -
.../camel/test/patterns/AdviceWithLambdaTest.java | 57 -
.../test/patterns/AdviceWithNotStartedTest.java | 72 --
.../camel/test/patterns/AsyncSendMockTest.java | 49 -
.../CreateCamelContextPerTestFalseTest.java | 116 --
.../CreateCamelContextPerTestTrueTest.java | 148 ---
.../camel/test/patterns/DebugJUnit4Test.java | 87 --
.../patterns/DebugNoLazyTypeConverterTest.java | 92 --
.../org/apache/camel/test/patterns/DebugTest.java | 87 --
.../FilterCreateCamelContextPerClassTest.java | 65 --
.../test/patterns/FilterFluentTemplateTest.java | 75 --
.../camel/test/patterns/FilterJUnit4Test.java | 69 --
.../org/apache/camel/test/patterns/FilterTest.java | 75 --
.../camel/test/patterns/GetMockEndpointTest.java | 46 -
.../patterns/IsMockEndpointsAndSkipJUnit4Test.java | 63 --
.../test/patterns/IsMockEndpointsFileTest.java | 69 --
.../test/patterns/IsMockEndpointsJUnit4Test.java | 70 --
.../camel/test/patterns/IsMockEndpointsTest.java | 63 --
.../patterns/MockEndpointFailNoHeaderTest.java | 63 --
.../apache/camel/test/patterns/MyProduceBean.java | 32 -
.../org/apache/camel/test/patterns/MySender.java | 25 -
.../camel/test/patterns/ProduceBeanTest.java | 47 -
.../RouteBuilderConfigureExceptionTest.java | 54 -
.../RouteProcessorDumpRouteCoverageTest.java | 58 -
.../test/patterns/SimpleMockEndpointsTest.java | 52 -
.../apache/camel/test/patterns/SimpleMockTest.java | 46 -
.../test/patterns/SimpleNotifyBuilderTest.java | 57 -
.../test/patterns/SimpleWeaveAddMockLastTest.java | 62 --
...rridePropertiesWithPropertiesComponentTest.java | 78 --
.../camel-test/src/test/resources/jndi.properties | 22 -
.../src/test/resources/log4j2.properties | 30 -
components/camel-test/pom.xml | 1 -
50 files changed, 4769 deletions(-)
diff --git a/components/camel-test/camel-test/pom.xml b/components/camel-test/camel-test/pom.xml
deleted file mode 100644
index 811c6271a17..00000000000
--- a/components/camel-test/camel-test/pom.xml
+++ /dev/null
@@ -1,166 +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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-test</artifactId>
- <packaging>jar</packaging>
-
- <name>Camel :: Test (deprecated)</name>
- <description>Camel unit testing</description>
-
- <properties>
- <firstVersion>2.9.0</firstVersion>
- <label>testing,java</label>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core-engine</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core-languages</artifactId>
- </dependency>
-
- <!-- common deps used in tests -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-bean</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-browse</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-controlbus</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-dataformat</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-dataset</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-direct</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-directvm</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-file</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-language</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-log</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-mock</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-ref</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-rest</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-saga</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-scheduler</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-seda</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-stub</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-timer</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-validator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-vm</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-xpath</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-xslt</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-xml-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-management</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-</project>
diff --git a/components/camel-test/camel-test/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-test/camel-test/src/generated/resources/META-INF/services/org/apache/camel/other.properties
deleted file mode 100644
index 1e2398c8ece..00000000000
--- a/components/camel-test/camel-test/src/generated/resources/META-INF/services/org/apache/camel/other.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-name=test
-groupId=org.apache.camel
-artifactId=camel-test
-version=4.0.0-SNAPSHOT
-projectName=Camel :: Test (deprecated)
-projectDescription=Camel unit testing
diff --git a/components/camel-test/camel-test/src/generated/resources/test.json b/components/camel-test/camel-test/src/generated/resources/test.json
deleted file mode 100644
index c90a7e30630..00000000000
--- a/components/camel-test/camel-test/src/generated/resources/test.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "other": {
- "kind": "other",
- "name": "test",
- "title": "Test",
- "description": "Camel unit testing",
- "deprecated": true,
- "firstVersion": "2.9.0",
- "label": "testing,java",
- "supportLevel": "Stable",
- "groupId": "org.apache.camel",
- "artifactId": "camel-test",
- "version": "4.0.0-SNAPSHOT"
- }
-}
diff --git a/components/camel-test/camel-test/src/main/docs/test.adoc b/components/camel-test/camel-test/src/main/docs/test.adoc
deleted file mode 100644
index 00a031db926..00000000000
--- a/components/camel-test/camel-test/src/main/docs/test.adoc
+++ /dev/null
@@ -1,56 +0,0 @@
-= Test Component (deprecated)
-:doctitle: Test
-:shortname: test
-:artifactid: camel-test
-:description: Camel unit testing
-:since: 2.9
-:supportlevel: Stable-deprecated
-:deprecated: *deprecated*
-
-*Since Camel {since}*
-
-The `camel-test` module is used for unit testing Camel.
-
-WARNING: This module is deprecated. Use xref:components:others:test-junit5.adoc[camel-test-junit5] instead.
-
-The class `org.apache.camel.test.junit4.CamelTestSupport` provides a base JUnit class which you would extend
-and implement your Camel unit test.
-
-== Simple unit test example
-
-As shown below is a basic junit test which uses `camel-test`. The `createRouteBuilder` method is used
-for build the routes to be tested. Then the methods with `@Test` annotations are JUnit test methods which
-will be executed. The base class `CamelTestSupport` has a number of helper methods to configure testing,
-see more at the javadoc of this class.
-
-[source,java]
-----
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class SimpleMockTest extends CamelTestSupport {
-
- @Test
- public void testMock() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .to("mock:result");
- }
- };
- }
-
-}
-----
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinder.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinder.java
deleted file mode 100644
index 7a12771b8c3..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinder.java
+++ /dev/null
@@ -1,94 +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.test;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Finds currently available server ports.
- */
-@Deprecated
-public final class AvailablePortFinder {
-
- private static final Logger LOG = LoggerFactory.getLogger(AvailablePortFinder.class);
-
- /**
- * Creates a new instance.
- */
- private AvailablePortFinder() {
- // Do nothing
- }
-
- /**
- * Gets the next available port.
- *
- * @throws IllegalStateException if there are no ports available
- * @return the available port
- */
- public static int getNextAvailable() {
- return probePort(0);
- }
-
- /**
- * Gets the next available port in the given range.
- *
- * @param fromPort port number start range.
- * @param toPort port number end range.
- *
- * @throws IllegalStateException if there are no ports available
- * @return the available port
- */
- public static int getNextAvailable(int fromPort, int toPort) {
- for (int i = fromPort; i <= toPort; i++) {
- try {
- return probePort(i);
- } catch (IllegalStateException e) {
- // do nothing, let's try the next port
- }
- }
- throw new IllegalStateException("Cannot find free port");
- }
-
- /**
- * Probe a port to see if it is free
- *
- * @param port an integer port number to be tested. If port is 0, then the next available port is
- * returned.
- * @throws IllegalStateException if the port is not free or, in case of port 0, if there are no ports available at
- * all.
- * @return the port number itself if the port is free or, in case of port 0, the first
- * available port number.
- */
- private static int probePort(int port) {
- try (ServerSocket ss = new ServerSocket()) {
- ss.setReuseAddress(true);
- ss.bind(new InetSocketAddress((InetAddress) null, port), 1);
- int probedPort = ss.getLocalPort();
- LOG.info("Available port is -> {}", probedPort);
- return probedPort;
- } catch (IOException e) {
- throw new IllegalStateException("Cannot find free port", e);
- }
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinderPropertiesFunction.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinderPropertiesFunction.java
deleted file mode 100644
index 57c36d6a641..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinderPropertiesFunction.java
+++ /dev/null
@@ -1,116 +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.test;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.camel.spi.PropertiesFunction;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.StringHelper;
-
-/**
- * A {@link PropertiesFunction} that reserves network ports and place them in a cache for reuse.
- * <p/>
- * The first time the function is invoked for a given name, an unused network port is determined and cached in an hash
- * map with the given name as key so each time this function is invoked for the same name, the previously discovered
- * port will be returned.
- * <p/>
- * This is useful for testing purpose where you can write a route like:
- *
- * <pre>
- * {@code
- * from("undertow:http://0.0.0.0:{{available-port:server-port}}")
- * .to("mock:result");
- * }
- * </pre>
- *
- * And then you can invoke with {@link org.apache.camel.ProducerTemplate} like:
- *
- * <pre>
- * {@code
- * template.sendBody("undertow:http://0.0.0.0:{{available-port:server-port}}", "the body");
- * }
- * </pre>
- *
- * Doing so avoid the need to compute the port and pass it to the various method or store it as a global variable in the
- * test class.
- *
- * @see AvailablePortFinder
- */
-@Deprecated
-public class AvailablePortFinderPropertiesFunction implements PropertiesFunction {
- private final Map<String, String> portMapping;
-
- public AvailablePortFinderPropertiesFunction() {
- this.portMapping = new ConcurrentHashMap<>();
- }
-
- @Override
- public String getName() {
- return "available-port";
- }
-
- @Override
- public String apply(String remainder) {
- if (ObjectHelper.isEmpty(remainder)) {
- return remainder;
- }
-
- String name = StringHelper.before(remainder, ":");
- String range = StringHelper.after(remainder, ":");
-
- if (name == null) {
- name = remainder;
- }
-
- final Integer from;
- final Integer to;
-
- if (range != null) {
- String f = StringHelper.before(range, "-");
- if (ObjectHelper.isEmpty(f)) {
- throw new IllegalArgumentException(
- "Unable to parse from range, range should be defined in the as from-to, got: " + range);
- }
-
- String t = StringHelper.after(range, "-");
- if (ObjectHelper.isEmpty(t)) {
- throw new IllegalArgumentException(
- "Unable to parse to range, range should be defined in the as from-to, got: " + range);
- }
-
- from = Integer.parseInt(f);
- to = Integer.parseInt(t);
- } else {
- from = null;
- to = null;
- }
-
- return this.portMapping.computeIfAbsent(name, n -> {
- final int port;
-
- if (from != null && to != null) {
- port = AvailablePortFinder.getNextAvailable(from, to);
- } else {
- port = AvailablePortFinder.getNextAvailable();
- }
-
- return Integer.toString(port);
- });
- }
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java
deleted file mode 100644
index 2895fdf27d0..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.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.test;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.apache.camel.impl.engine.DefaultPackageScanClassResolver;
-import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
-import org.apache.camel.impl.scan.InvertingPackageScanFilter;
-
-@Deprecated
-public class ExcludingPackageScanClassResolver extends DefaultPackageScanClassResolver {
-
- public void setExcludedClasses(Set<Class<?>> excludedClasses) {
- Set<Class<?>> parents = excludedClasses == null ? Collections.<Class<?>> emptySet() : excludedClasses;
- addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(parents)));
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/TestSupportNodeIdFactory.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/TestSupportNodeIdFactory.java
deleted file mode 100644
index ef9780e1ef3..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/TestSupportNodeIdFactory.java
+++ /dev/null
@@ -1,31 +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.test;
-
-import org.apache.camel.impl.engine.DefaultNodeIdFactory;
-
-@Deprecated
-public class TestSupportNodeIdFactory extends DefaultNodeIdFactory {
-
- /**
- * Start tests with fresh counters
- */
- public static void resetCounters() {
- resetAllCounters();
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTearDownRule.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTearDownRule.java
deleted file mode 100644
index c1986e1b1d5..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTearDownRule.java
+++ /dev/null
@@ -1,50 +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.test.junit4;
-
-import org.junit.rules.ExternalResource;
-
-/**
- * A JUnit rule to tear down Camel when using createCamelContextPerClass=true.
- */
-@Deprecated
-public class CamelTearDownRule extends ExternalResource {
-
- private final ThreadLocal<CamelTestSupport> testSupport;
-
- public CamelTearDownRule(ThreadLocal<CamelTestSupport> testSupport) {
- this.testSupport = testSupport;
- }
-
- @Override
- protected void before() throws Throwable {
- super.before();
- }
-
- @Override
- protected void after() {
- CamelTestSupport support = testSupport.get();
- if (support != null && support.isCreateCamelContextPerClass()) {
- try {
- support.tearDownCreateCamelContextPerClass();
- } catch (Exception e) {
- // ignore
- }
- }
- super.after();
- }
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
deleted file mode 100644
index b5ffcabfd5a..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
+++ /dev/null
@@ -1,1150 +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.test.junit4;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ConsumerTemplate;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.ExtendedCamelContext;
-import org.apache.camel.FluentProducerTemplate;
-import org.apache.camel.Message;
-import org.apache.camel.NamedNode;
-import org.apache.camel.NoSuchEndpointException;
-import org.apache.camel.Predicate;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.Route;
-import org.apache.camel.RouteConfigurationsBuilder;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.Service;
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.api.management.ManagedCamelContext;
-import org.apache.camel.api.management.mbean.ManagedCamelContextMBean;
-import org.apache.camel.api.management.mbean.ManagedProcessorMBean;
-import org.apache.camel.api.management.mbean.ManagedRouteMBean;
-import org.apache.camel.builder.AdviceWith;
-import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.InterceptSendToMockEndpointStrategy;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.debugger.DefaultDebugger;
-import org.apache.camel.model.Model;
-import org.apache.camel.model.ModelCamelContext;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.spi.CamelBeanPostProcessor;
-import org.apache.camel.spi.Language;
-import org.apache.camel.spi.PropertiesComponent;
-import org.apache.camel.spi.Registry;
-import org.apache.camel.support.BreakpointSupport;
-import org.apache.camel.support.EndpointHelper;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.StopWatch;
-import org.apache.camel.util.TimeUtils;
-import org.apache.camel.util.URISupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A useful base class which creates a {@link org.apache.camel.CamelContext} with some routes along with a
- * {@link org.apache.camel.ProducerTemplate} for use in the test case Do <tt>not</tt> use this class for Spring Boot
- * testing, instead use <code>@RunWith(CamelSpringBootRunner.class)</code>.
- */
-@Deprecated
-public abstract class CamelTestSupport extends TestSupport {
-
- /**
- * JVM system property which can be set to true to turn on dumping route coverage statistics.
- */
- public static final String ROUTE_COVERAGE_ENABLED = "CamelTestRouteCoverage";
-
- // CHECKSTYLE:OFF
- private static final Logger LOG = LoggerFactory.getLogger(CamelTestSupport.class);
- private static ThreadLocal<ModelCamelContext> threadCamelContext = new ThreadLocal<>();
- private static ThreadLocal<ProducerTemplate> threadTemplate = new ThreadLocal<>();
- private static ThreadLocal<FluentProducerTemplate> threadFluentTemplate = new ThreadLocal<>();
- private static ThreadLocal<ConsumerTemplate> threadConsumer = new ThreadLocal<>();
- private static ThreadLocal<Service> threadService = new ThreadLocal<>();
- protected Properties extra;
- protected volatile ModelCamelContext context;
- protected volatile ProducerTemplate template;
- protected volatile FluentProducerTemplate fluentTemplate;
- protected volatile ConsumerTemplate consumer;
- protected volatile Service camelContextService;
- private boolean useRouteBuilder = true;
- private final DebugBreakpoint breakpoint = new DebugBreakpoint();
- private final StopWatch watch = new StopWatch();
- private final Map<String, String> fromEndpoints = new HashMap<>();
- private static final ThreadLocal<AtomicInteger> TESTS = new ThreadLocal<>();
- private static final ThreadLocal<CamelTestSupport> INSTANCE = new ThreadLocal<>();
- private CamelTestWatcher camelTestWatcher = new CamelTestWatcher();
- @ClassRule
- public static final CamelTearDownRule CAMEL_TEAR_DOWN_RULE = new CamelTearDownRule(INSTANCE);
- // CHECKSTYLE:ON
-
- /**
- * Use the RouteBuilder or not
- *
- * @return <tt>true</tt> then {@link CamelContext} will be auto started, <tt>false</tt> then {@link CamelContext}
- * will <b>not</b> be auto started (you will have to start it manually)
- */
- public boolean isUseRouteBuilder() {
- return useRouteBuilder;
- }
-
- public void setUseRouteBuilder(boolean useRouteBuilder) {
- this.useRouteBuilder = useRouteBuilder;
- }
-
- /**
- * Whether to dump route coverage stats at the end of the test.
- * <p/>
- * This allows tooling or manual inspection of the stats, so you can generate a route trace diagram of which EIPs
- * have been in use and which have not. Similar concepts as a code coverage report.
- * <p/>
- * You can also turn on route coverage globally via setting JVM system property
- * <tt>CamelTestRouteCoverage=true</tt>.
- *
- * @return <tt>true</tt> to write route coverage status in an xml file in the <tt>target/camel-route-coverage</tt>
- * directory after the test has finished.
- */
- public boolean isDumpRouteCoverage() {
- return false;
- }
-
- /**
- * Override when using <a href="http://camel.apache.org/advicewith.html">advice with</a> and return <tt>true</tt>.
- * This helps knowing advice with is to be used, and {@link CamelContext} will not be started before the advice with
- * takes place. This helps by ensuring the advice with has been property setup before the {@link CamelContext} is
- * started
- * <p/>
- * <b>Important:</b> Its important to start {@link CamelContext} manually from the unit test after you are done
- * doing all the advice with.
- *
- * @return <tt>true</tt> if you use advice with in your unit tests.
- */
- public boolean isUseAdviceWith() {
- return false;
- }
-
- /**
- * Override to control whether {@link CamelContext} should be setup per test or per class.
- * <p/>
- * By default it will be setup/teardown per test (per test method). If you want to re-use {@link CamelContext}
- * between test methods you can override this method and return <tt>true</tt>
- * <p/>
- * <b>Important:</b> Use this with care as the {@link CamelContext} will carry over state from previous tests, such
- * as endpoints, components etc. So you cannot use this in all your tests.
- * <p/>
- * Setting up {@link CamelContext} uses the {@link #doPreSetup()}, {@link #doSetUp()}, and {@link #doPostSetup()}
- * methods in that given order.
- *
- * @return <tt>true</tt> per class, <tt>false</tt> per test.
- */
- public boolean isCreateCamelContextPerClass() {
- return false;
- }
-
- /**
- * Override to enable auto mocking endpoints based on the pattern.
- * <p/>
- * Return <tt>*</tt> to mock all endpoints.
- *
- * @see EndpointHelper#matchEndpoint(CamelContext, String, String)
- */
- public String isMockEndpoints() {
- return null;
- }
-
- /**
- * Override to enable auto mocking endpoints based on the pattern, and <b>skip</b> sending to original endpoint.
- * <p/>
- * Return <tt>*</tt> to mock all endpoints.
- *
- * @see EndpointHelper#matchEndpoint(CamelContext, String, String)
- */
- public String isMockEndpointsAndSkip() {
- return null;
- }
-
- public void replaceRouteFromWith(String routeId, String fromEndpoint) {
- fromEndpoints.put(routeId, fromEndpoint);
- }
-
- /**
- * Used for filtering routes routes matching the given pattern, which follows the following rules:
- * <p>
- * - Match by route id - Match by route input endpoint uri
- * <p>
- * The matching is using exact match, by wildcard and regular expression.
- * <p>
- * For example to only include routes which starts with foo in their route id's, use: include=foo* And to
- * exclude routes which starts from JMS endpoints, use: exclude=jms:*
- * <p>
- * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use:
- * exclude=foo*,bar*
- * <p>
- * Exclude takes precedence over include.
- */
- public String getRouteFilterIncludePattern() {
- return null;
- }
-
- /**
- * Used for filtering routes routes matching the given pattern, which follows the following rules:
- * <p>
- * - Match by route id - Match by route input endpoint uri
- * <p>
- * The matching is using exact match, by wildcard and regular expression.
- * <p>
- * For example to only include routes which starts with foo in their route id's, use: include=foo* And to
- * exclude routes which starts from JMS endpoints, use: exclude=jms:*
- * <p>
- * Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use:
- * exclude=foo*,bar*
- * <p>
- * Exclude takes precedence over include.
- */
- public String getRouteFilterExcludePattern() {
- return null;
- }
-
- /**
- * Override to enable debugger
- * <p/>
- * Is default <tt>false</tt>
- */
- public boolean isUseDebugger() {
- return false;
- }
-
- public Service getCamelContextService() {
- return camelContextService;
- }
-
- public Service camelContextService() {
- return camelContextService;
- }
-
- public CamelContext context() {
- return context;
- }
-
- public ProducerTemplate template() {
- return template;
- }
-
- public FluentProducerTemplate fluentTemplate() {
- return fluentTemplate;
- }
-
- public ConsumerTemplate consumer() {
- return consumer;
- }
-
- /**
- * Allows a service to be registered a separate lifecycle service to start and stop the context; such as for Spring
- * when the ApplicationContext is started and stopped, rather than directly stopping the CamelContext
- */
- public void setCamelContextService(Service service) {
- camelContextService = service;
- threadService.set(camelContextService);
- }
-
- @Before
- public void setUp() throws Exception {
- LOG.info("********************************************************************************");
- LOG.info("Testing: {} ({})", getTestMethodName(), getClass().getName());
- LOG.info("********************************************************************************");
-
- if (isCreateCamelContextPerClass()) {
- INSTANCE.set(this);
- AtomicInteger v = TESTS.get();
- if (v == null) {
- v = new AtomicInteger();
- TESTS.set(v);
- }
- if (v.getAndIncrement() == 0) {
- LOG.debug("Setup CamelContext before running first test");
- // test is per class, so only setup once (the first time)
- doSpringBootCheck();
- setupResources();
- doPreSetup();
- doSetUp();
- doPostSetup();
- } else {
- LOG.debug("Reset between test methods");
- // and in between tests we must do IoC and reset mocks
- postProcessTest();
- resetMocks();
- }
- } else {
- // test is per test so always setup
- doSpringBootCheck();
- setupResources();
- doPreSetup();
- doSetUp();
- doPostSetup();
- }
-
- // only start timing after all the setup
- watch.restart();
- }
-
- /**
- * Strategy to perform any pre setup, before {@link CamelContext} is created
- */
- protected void doPreSetup() throws Exception {
- // noop
- }
-
- /**
- * Strategy to perform any post setup after {@link CamelContext} is created
- */
- protected void doPostSetup() throws Exception {
- // noop
- }
-
- /**
- * Detects if this is a Spring-Boot test and throws an exception, as these base classes is not intended for testing
- * Camel on Spring Boot.
- */
- protected void doSpringBootCheck() {
- boolean springBoot = hasClassAnnotation("org.springframework.boot.test.context.SpringBootTest");
- if (springBoot) {
- throw new RuntimeException(
- "Spring Boot detected: The CamelTestSupport/CamelSpringTestSupport class is not intended for Camel testing with Spring Boot."
- + " Prefer to not extend this class, but use @RunWith(CamelSpringBootRunner.class) instead.");
- }
- }
-
- private void doSetUp() throws Exception {
- LOG.debug("setUp test");
- // jmx is enabled if we have configured to use it, or if dump route coverage is enabled (it requires JMX)
- boolean jmx = useJmx() || isRouteCoverageEnabled();
- if (jmx) {
- enableJMX();
- } else {
- disableJMX();
- }
-
- context = (ModelCamelContext) createCamelContext();
- threadCamelContext.set(context);
-
- assertNotNull("No context found!", context);
-
- // add custom beans
- bindToRegistry(context.getRegistry());
-
- // reduce default shutdown timeout to avoid waiting for 300 seconds
- context.getShutdownStrategy().setTimeout(getShutdownTimeout());
-
- // set debugger if enabled
- if (isUseDebugger()) {
- if (context.getStatus().equals(ServiceStatus.Started)) {
- LOG.info("Cannot setting the Debugger to the starting CamelContext, stop the CamelContext now.");
- // we need to stop the context first to setup the debugger
- context.stop();
- }
- context.setDebugging(true);
- context.setDebugger(new DefaultDebugger());
- context.getDebugger().addBreakpoint(breakpoint);
- // note: when stopping CamelContext it will automatically remove the breakpoint
- }
-
- template = context.createProducerTemplate();
- template.start();
- fluentTemplate = context.createFluentProducerTemplate();
- fluentTemplate.start();
- consumer = context.createConsumerTemplate();
- consumer.start();
-
- threadTemplate.set(template);
- threadFluentTemplate.set(fluentTemplate);
- threadConsumer.set(consumer);
-
- // enable auto mocking if enabled
- String pattern = isMockEndpoints();
- if (pattern != null) {
- context.adapt(ExtendedCamelContext.class)
- .registerEndpointCallback(new InterceptSendToMockEndpointStrategy(pattern));
- }
- pattern = isMockEndpointsAndSkip();
- if (pattern != null) {
- context.adapt(ExtendedCamelContext.class)
- .registerEndpointCallback(new InterceptSendToMockEndpointStrategy(pattern, true));
- }
-
- // configure properties component (mandatory for testing)
- PropertiesComponent pc = context.getPropertiesComponent();
- if (extra == null) {
- extra = useOverridePropertiesWithPropertiesComponent();
- }
- if (extra != null && !extra.isEmpty()) {
- pc.setOverrideProperties(extra);
- }
- Boolean ignore = ignoreMissingLocationWithPropertiesComponent();
- if (ignore != null) {
- pc.setIgnoreMissingLocation(ignore);
- }
-
- String include = getRouteFilterIncludePattern();
- String exclude = getRouteFilterExcludePattern();
- if (include != null || exclude != null) {
- LOG.info("Route filtering pattern: include={}, exclude={}", include, exclude);
- context.getExtension(Model.class).setRouteFilterPattern(include, exclude);
- }
-
- // prepare for in-between tests
- postProcessTest();
-
- if (isUseRouteBuilder()) {
- RoutesBuilder[] builders = createRouteBuilders();
- // add configuration before routes
- for (RoutesBuilder builder : builders) {
- if (builder instanceof RouteConfigurationsBuilder) {
- log.debug("Using created route configuration: {}", builder);
- context.addRoutesConfigurations((RouteConfigurationsBuilder) builder);
- }
- }
- for (RoutesBuilder builder : builders) {
- log.debug("Using created route builder: {}", builder);
- context.addRoutes(builder);
- }
- replaceFromEndpoints();
- boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
- if (skip) {
- LOG.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
- } else if (isUseAdviceWith()) {
- LOG.info("Skipping starting CamelContext as isUseAdviceWith is set to true.");
- } else {
- startCamelContext();
- }
- } else {
- replaceFromEndpoints();
- LOG.debug("Using route builder from the created context: {}", context);
- }
- LOG.debug("Routing Rules are: {}", context.getRoutes());
-
- assertValidContext(context);
- }
-
- private void replaceFromEndpoints() throws Exception {
- for (final Map.Entry<String, String> entry : fromEndpoints.entrySet()) {
- AdviceWith.adviceWith(context.getRouteDefinition(entry.getKey()), context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- replaceFromWith(entry.getValue());
- }
- });
- }
- }
-
- private boolean isRouteCoverageEnabled() {
- return System.getProperty(ROUTE_COVERAGE_ENABLED, "false").equalsIgnoreCase("true") || isDumpRouteCoverage();
- }
-
- @After
- public void tearDown() throws Exception {
- long time = watch.taken();
-
- LOG.info("********************************************************************************");
- LOG.info("Testing done: {} ({})", getTestMethodName(), getClass().getName());
- LOG.info("Took: {} ({} millis)", TimeUtils.printDuration(time, true), time);
-
- // if we should dump route stats, then write that to a file
- if (isRouteCoverageEnabled()) {
- String className = this.getClass().getSimpleName();
- String dir = "target/camel-route-coverage";
- String name = className + "-" + getTestMethodName() + ".xml";
-
- ManagedCamelContext mc = context != null ? context.getExtension(ManagedCamelContext.class) : null;
- ManagedCamelContextMBean managedCamelContext = mc != null ? mc.getManagedCamelContext() : null;
- if (managedCamelContext == null) {
- LOG.warn("Cannot dump route coverage to file as JMX is not enabled. "
- + "Add camel-management JAR as dependency and/or override useJmx() method to enable JMX in the unit test classes.");
- } else {
- logCoverageSummary(managedCamelContext);
-
- String xml = managedCamelContext.dumpRoutesCoverageAsXml();
- String combined = "<camelRouteCoverage>\n" + gatherTestDetailsAsXml() + xml + "\n</camelRouteCoverage>";
-
- File file = new File(dir);
- // ensure dir exists
- file.mkdirs();
- file = new File(dir, name);
-
- LOG.info("Dumping route coverage to file: {}", file);
- InputStream is = new ByteArrayInputStream(combined.getBytes());
- OutputStream os = new FileOutputStream(file, false);
- IOHelper.copyAndCloseInput(is, os);
- IOHelper.close(os);
- }
- }
- LOG.info("********************************************************************************");
-
- if (isCreateCamelContextPerClass()) {
- // will tear down test specially in CamelTearDownRule
- } else {
- LOG.debug("tearDown()");
- doStopTemplates(consumer, template, fluentTemplate);
- doStopCamelContext(context, camelContextService);
- doPostTearDown();
- cleanupResources();
- }
- }
-
- void tearDownCreateCamelContextPerClass() throws Exception {
- LOG.debug("tearDownCreateCamelContextPerClass()");
- TESTS.remove();
- doStopTemplates(threadConsumer.get(), threadTemplate.get(), threadFluentTemplate.get());
- doStopCamelContext(threadCamelContext.get(), threadService.get());
- doPostTearDown();
- cleanupResources();
- }
-
- /**
- * Strategy to perform any post action, after {@link CamelContext} is stopped
- */
- protected void doPostTearDown() throws Exception {
- // noop
- }
-
- /**
- * Strategy to perform resources setup, before {@link CamelContext} is created
- */
- protected void setupResources() throws Exception {
- // noop
- }
-
- /**
- * Strategy to perform resources cleanup, after {@link CamelContext} is stopped
- */
- protected void cleanupResources() throws Exception {
- // noop
- }
-
- /**
- * Logs route coverage summary: - which routes are uncovered - what is the coverage of each processor in each route
- */
- private void logCoverageSummary(ManagedCamelContextMBean managedCamelContext) throws Exception {
- StringBuilder builder = new StringBuilder("\nCoverage summary\n");
-
- int routes = managedCamelContext.getTotalRoutes();
-
- long contextExchangesTotal = managedCamelContext.getExchangesTotal();
-
- List<String> uncoveredRoutes = new ArrayList<>();
-
- StringBuilder routesSummary = new StringBuilder();
- routesSummary.append("\tProcessor coverage\n");
-
- MBeanServer server = context.getManagementStrategy().getManagementAgent().getMBeanServer();
-
- Map<String, List<ManagedProcessorMBean>> processorsForRoute = findProcessorsForEachRoute(server);
-
- // log processor coverage for each route
- for (Route route : context.getRoutes()) {
- ManagedRouteMBean managedRoute = context.getExtension(ManagedCamelContext.class).getManagedRoute(route.getId());
- if (managedRoute.getExchangesTotal() == 0) {
- uncoveredRoutes.add(route.getId());
- }
-
- long routeCoveragePercentage = Math.round((double) managedRoute.getExchangesTotal() / contextExchangesTotal * 100);
- routesSummary.append("\t\tRoute ").append(route.getId()).append(" total: ").append(managedRoute.getExchangesTotal())
- .append(" (").append(routeCoveragePercentage).append("%)\n");
-
- if (server != null) {
- List<ManagedProcessorMBean> processors = processorsForRoute.get(route.getId());
- if (processors != null) {
- for (ManagedProcessorMBean managedProcessor : processors) {
- String processorId = managedProcessor.getProcessorId();
- long processorExchangesTotal = managedProcessor.getExchangesTotal();
- long processorCoveragePercentage
- = Math.round((double) processorExchangesTotal / contextExchangesTotal * 100);
- routesSummary.append("\t\t\tProcessor ").append(processorId).append(" total: ")
- .append(processorExchangesTotal).append(" (").append(processorCoveragePercentage)
- .append("%)\n");
- }
- }
- }
- }
-
- int used = routes - uncoveredRoutes.size();
-
- long contextPercentage = Math.round((double) used / routes * 100);
- builder.append("\tRoute coverage: ").append(used).append(" out of ").append(routes).append(" routes used (")
- .append(contextPercentage).append("%)\n");
- builder.append("\t\tCamelContext (").append(managedCamelContext.getCamelId()).append(") total: ")
- .append(contextExchangesTotal).append("\n");
-
- if (!uncoveredRoutes.isEmpty()) {
- builder.append("\t\tUncovered routes: ").append(uncoveredRoutes.stream().collect(Collectors.joining(", ")))
- .append("\n");
- }
-
- builder.append(routesSummary);
- LOG.info(builder.toString());
- }
-
- /**
- * Groups all processors from Camel context by route id
- */
- private Map<String, List<ManagedProcessorMBean>> findProcessorsForEachRoute(MBeanServer server)
- throws MalformedObjectNameException, MBeanException, AttributeNotFoundException, InstanceNotFoundException,
- ReflectionException {
- String domain = context.getManagementStrategy().getManagementAgent().getMBeanServerDefaultDomain();
-
- Map<String, List<ManagedProcessorMBean>> processorsForRoute = new HashMap<>();
-
- ObjectName processorsObjectName
- = new ObjectName(domain + ":context=" + context.getManagementName() + ",type=processors,name=*");
- Set<ObjectName> objectNames = server.queryNames(processorsObjectName, null);
-
- for (ObjectName objectName : objectNames) {
- String routeId = server.getAttribute(objectName, "RouteId").toString();
- String name = objectName.getKeyProperty("name");
- name = ObjectName.unquote(name);
-
- ManagedProcessorMBean managedProcessor = context.getExtension(ManagedCamelContext.class).getManagedProcessor(name);
-
- if (managedProcessor != null) {
- if (processorsForRoute.get(routeId) == null) {
- List<ManagedProcessorMBean> processorsList = new ArrayList<>();
- processorsList.add(managedProcessor);
-
- processorsForRoute.put(routeId, processorsList);
- } else {
- processorsForRoute.get(routeId).add(managedProcessor);
- }
- }
- }
-
- // sort processors by position in route definition
- for (Map.Entry<String, List<ManagedProcessorMBean>> entry : processorsForRoute.entrySet()) {
- Collections.sort(entry.getValue(), Comparator.comparing(ManagedProcessorMBean::getIndex));
- }
-
- return processorsForRoute;
- }
-
- /**
- * Gathers test details as xml
- */
- private String gatherTestDetailsAsXml() {
- StringBuilder sb = new StringBuilder();
- sb.append("<test>\n");
- sb.append(" <class>").append(getClass().getName()).append("</class>\n");
- sb.append(" <method>").append(getTestMethodName()).append("</method>\n");
- sb.append(" <time>").append(getCamelTestWatcher().timeTaken()).append("</time>\n");
- sb.append("</test>\n");
- return sb.toString();
- }
-
- /**
- * Returns the timeout to use when shutting down (unit in seconds).
- * <p/>
- * Will default use 10 seconds.
- *
- * @return the timeout to use
- */
- protected int getShutdownTimeout() {
- return 10;
- }
-
- /**
- * Whether or not JMX should be used during testing.
- *
- * @return <tt>false</tt> by default.
- */
- protected boolean useJmx() {
- return false;
- }
-
- /**
- * Whether or not type converters should be lazy loaded (notice core converters is always loaded)
- *
- * @return <tt>false</tt> by default.
- */
- @Deprecated
- protected boolean isLazyLoadingTypeConverter() {
- return false;
- }
-
- /**
- * Override this method to include and override properties with the Camel {@link PropertiesComponent}.
- *
- * @return additional properties to add/override.
- */
- protected Properties useOverridePropertiesWithPropertiesComponent() {
- return null;
- }
-
- @Rule
- public CamelTestWatcher getCamelTestWatcher() {
- return camelTestWatcher;
- }
-
- /**
- * Whether to ignore missing locations with the {@link PropertiesComponent}. For example when unit testing you may
- * want to ignore locations that are not available in the environment you use for testing.
- *
- * @return <tt>true</tt> to ignore, <tt>false</tt> to not ignore, and <tt>null</tt> to leave as configured on the
- * {@link PropertiesComponent}
- */
- protected Boolean ignoreMissingLocationWithPropertiesComponent() {
- return null;
- }
-
- protected void postProcessTest() throws Exception {
- context = threadCamelContext.get();
- template = threadTemplate.get();
- fluentTemplate = threadFluentTemplate.get();
- consumer = threadConsumer.get();
- camelContextService = threadService.get();
- applyCamelPostProcessor();
- }
-
- /**
- * Applies the {@link CamelBeanPostProcessor} to this instance.
- * <p>
- * Derived classes using IoC / DI frameworks may wish to turn this into a NoOp such as for CDI we would just use CDI
- * to inject this
- */
- protected void applyCamelPostProcessor() throws Exception {
- // use the bean post processor if the test class is not dependency injected already by Spring Framework
- boolean spring = hasClassAnnotation("org.springframework.boot.test.context.SpringBootTest",
- "org.springframework.context.annotation.ComponentScan");
- if (!spring) {
- context.getExtension(ExtendedCamelContext.class).getBeanPostProcessor().postProcessBeforeInitialization(this,
- getClass().getName());
- context.getExtension(ExtendedCamelContext.class).getBeanPostProcessor().postProcessAfterInitialization(this,
- getClass().getName());
- }
- }
-
- /**
- * Does this test class have any of the following annotations on the class-level.
- */
- protected boolean hasClassAnnotation(String... names) {
- for (String name : names) {
- for (Annotation ann : getClass().getAnnotations()) {
- String annName = ann.annotationType().getName();
- if (annName.equals(name)) {
- return true;
- }
- }
- }
- return false;
- }
-
- protected void stopCamelContext() throws Exception {
- doStopCamelContext(context, camelContextService);
- }
-
- private static void doStopCamelContext(CamelContext context, Service camelContextService) throws Exception {
- if (camelContextService != null) {
- if (camelContextService == threadService.get()) {
- threadService.remove();
- }
- camelContextService.stop();
- } else {
- if (context != null) {
- if (context == threadCamelContext.get()) {
- threadCamelContext.remove();
- }
- context.stop();
- }
- }
- }
-
- private static void doStopTemplates(
- ConsumerTemplate consumer, ProducerTemplate template, FluentProducerTemplate fluentTemplate)
- throws Exception {
- if (consumer != null) {
- if (consumer == threadConsumer.get()) {
- threadConsumer.remove();
- }
- consumer.stop();
- }
- if (template != null) {
- if (template == threadTemplate.get()) {
- threadTemplate.remove();
- }
- template.stop();
- }
- if (fluentTemplate != null) {
- if (fluentTemplate == threadFluentTemplate.get()) {
- threadFluentTemplate.remove();
- }
- fluentTemplate.stop();
- }
- }
-
- protected void startCamelContext() throws Exception {
- if (camelContextService != null) {
- camelContextService.start();
- } else {
- if (context instanceof DefaultCamelContext) {
- DefaultCamelContext defaultCamelContext = (DefaultCamelContext) context;
- if (!defaultCamelContext.isStarted()) {
- defaultCamelContext.start();
- }
- } else {
- context.start();
- }
- }
- }
-
- protected CamelContext createCamelContext() throws Exception {
- // for backwards compatibility
- Registry registry = createCamelRegistry();
- CamelContext context;
- if (registry != null) {
- context = new DefaultCamelContext(registry);
- } else {
- context = new DefaultCamelContext();
- }
- return context;
- }
-
- /**
- * Allows to bind custom beans to the Camel {@link Registry}.
- */
- protected void bindToRegistry(Registry registry) throws Exception {
- // noop
- }
-
- /**
- * Override to use a custom {@link Registry}.
- * <p>
- * However if you need to bind beans to the registry then this is possible already with the bind method on
- * registry," and there is no need to override this method.
- */
- protected Registry createCamelRegistry() throws Exception {
- return null;
- }
-
- /**
- * Factory method which derived classes can use to create a {@link RouteBuilder} to define the routes for testing
- */
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() {
- // no routes added by default
- }
- };
- }
-
- /**
- * Factory method which derived classes can use to create an array of {@link org.apache.camel.builder.RouteBuilder}s
- * to define the routes for testing
- *
- * @see #createRouteBuilder()
- */
- protected RoutesBuilder[] createRouteBuilders() throws Exception {
- return new RoutesBuilder[] { createRouteBuilder() };
- }
-
- /**
- * Resolves a mandatory endpoint for the given URI or an exception is thrown
- *
- * @param uri the Camel <a href="">URI</a> to use to create or resolve an endpoint
- * @return the endpoint
- */
- protected Endpoint resolveMandatoryEndpoint(String uri) {
- return resolveMandatoryEndpoint(context, uri);
- }
-
- /**
- * Resolves a mandatory endpoint for the given URI and expected type or an exception is thrown
- *
- * @param uri the Camel <a href="">URI</a> to use to create or resolve an endpoint
- * @return the endpoint
- */
- protected <T extends Endpoint> T resolveMandatoryEndpoint(String uri, Class<T> endpointType) {
- return resolveMandatoryEndpoint(context, uri, endpointType);
- }
-
- /**
- * Resolves the mandatory Mock endpoint using a URI of the form <code>mock:someName</code>
- *
- * @param uri the URI which typically starts with "mock:" and has some name
- * @return the mandatory mock endpoint or an exception is thrown if it could not be resolved
- */
- protected MockEndpoint getMockEndpoint(String uri) {
- return getMockEndpoint(uri, true);
- }
-
- /**
- * Resolves the {@link MockEndpoint} using a URI of the form <code>mock:someName</code>, optionally creating it if
- * it does not exist. This implementation will lookup existing mock endpoints and match on the mock queue name, eg
- * mock:foo and mock:foo?retainFirst=5 would match as the queue name is foo.
- *
- * @param uri the URI which typically starts with "mock:" and has some name
- * @param create whether or not to allow the endpoint to be created if it doesn't exist
- * @return the mock endpoint or an {@link NoSuchEndpointException} is thrown if it could not
- * be resolved
- * @throws NoSuchEndpointException is the mock endpoint does not exists
- */
- protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuchEndpointException {
- // look for existing mock endpoints that has the same queue name, and to do that we need to
- // normalize uri and strip out query parameters and whatnot
- String n;
- try {
- n = URISupport.normalizeUri(uri);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeException(e);
- }
- // strip query
- int idx = n.indexOf('?');
- if (idx != -1) {
- n = n.substring(0, idx);
- }
- final String target = n;
-
- // lookup endpoints in registry and try to find it
- MockEndpoint found = (MockEndpoint) context.getEndpointRegistry().values().stream()
- .filter(e -> e instanceof MockEndpoint)
- .filter(e -> {
- String t = e.getEndpointUri();
- // strip query
- int idx2 = t.indexOf('?');
- if (idx2 != -1) {
- t = t.substring(0, idx2);
- }
- return t.equals(target);
- }).findFirst().orElse(null);
-
- if (found != null) {
- return found;
- }
-
- if (create) {
- return resolveMandatoryEndpoint(uri, MockEndpoint.class);
- } else {
- throw new NoSuchEndpointException(String.format("MockEndpoint %s does not exist.", uri));
- }
- }
-
- /**
- * Sends a message to the given endpoint URI with the body value
- *
- * @param endpointUri the URI of the endpoint to send to
- * @param body the body for the message
- */
- protected void sendBody(String endpointUri, final Object body) {
- template.send(endpointUri, new Processor() {
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- in.setBody(body);
- }
- });
- }
-
- /**
- * Sends a message to the given endpoint URI with the body value and specified headers
- *
- * @param endpointUri the URI of the endpoint to send to
- * @param body the body for the message
- * @param headers any headers to set on the message
- */
- protected void sendBody(String endpointUri, final Object body, final Map<String, Object> headers) {
- template.send(endpointUri, new Processor() {
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- in.setBody(body);
- for (Map.Entry<String, Object> entry : headers.entrySet()) {
- in.setHeader(entry.getKey(), entry.getValue());
- }
- }
- });
- }
-
- /**
- * Sends messages to the given endpoint for each of the specified bodies
- *
- * @param endpointUri the endpoint URI to send to
- * @param bodies the bodies to send, one per message
- */
- protected void sendBodies(String endpointUri, Object... bodies) {
- for (Object body : bodies) {
- sendBody(endpointUri, body);
- }
- }
-
- /**
- * Creates an exchange with the given body
- */
- protected Exchange createExchangeWithBody(Object body) {
- return createExchangeWithBody(context, body);
- }
-
- /**
- * Asserts that the given language name and expression evaluates to the given value on a specific exchange
- */
- protected void assertExpression(Exchange exchange, String languageName, String expressionText, Object expectedValue) {
- Language language = assertResolveLanguage(languageName);
-
- Expression expression = language.createExpression(expressionText);
- assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);
-
- assertExpression(expression, exchange, expectedValue);
- }
-
- /**
- * Asserts that the given language name and predicate expression evaluates to the expected value on the message
- * exchange
- */
- protected void assertPredicate(String languageName, String expressionText, Exchange exchange, boolean expected) {
- Language language = assertResolveLanguage(languageName);
-
- Predicate predicate = language.createPredicate(expressionText);
- assertNotNull("No Predicate could be created for text: " + expressionText + " language: " + language, predicate);
-
- assertPredicate(predicate, exchange, expected);
- }
-
- /**
- * Asserts that the language name can be resolved
- */
- protected Language assertResolveLanguage(String languageName) {
- Language language = context.resolveLanguage(languageName);
- assertNotNull("No language found for name: " + languageName, language);
- return language;
- }
-
- /**
- * Asserts that all the expectations of the Mock endpoints are valid
- */
- protected void assertMockEndpointsSatisfied() throws InterruptedException {
- MockEndpoint.assertIsSatisfied(context);
- }
-
- /**
- * Asserts that all the expectations of the Mock endpoints are valid
- */
- protected void assertMockEndpointsSatisfied(long timeout, TimeUnit unit) throws InterruptedException {
- MockEndpoint.assertIsSatisfied(context, timeout, unit);
- }
-
- /**
- * Reset all Mock endpoints.
- */
- protected void resetMocks() {
- MockEndpoint.resetMocks(context);
- }
-
- protected void assertValidContext(CamelContext context) {
- assertNotNull("No context found!", context);
- }
-
- protected <T extends Endpoint> T getMandatoryEndpoint(String uri, Class<T> type) {
- T endpoint = context.getEndpoint(uri, type);
- assertNotNull("No endpoint found for uri: " + uri, endpoint);
- return endpoint;
- }
-
- protected Endpoint getMandatoryEndpoint(String uri) {
- Endpoint endpoint = context.getEndpoint(uri);
- assertNotNull("No endpoint found for uri: " + uri, endpoint);
- return endpoint;
- }
-
- /**
- * Disables the JMX agent. Must be called before the {@link #setUp()} method.
- */
- protected void disableJMX() {
- DefaultCamelContext.setDisableJmx(true);
- }
-
- /**
- * Enables the JMX agent. Must be called before the {@link #setUp()} method.
- */
- protected void enableJMX() {
- DefaultCamelContext.setDisableJmx(false);
- }
-
- /**
- * Single step debugs and Camel invokes this method before entering the given processor
- */
- protected void debugBefore(
- Exchange exchange, Processor processor, ProcessorDefinition<?> definition,
- String id, String label) {
- }
-
- /**
- * Single step debugs and Camel invokes this method after processing the given processor
- */
- protected void debugAfter(
- Exchange exchange, Processor processor, ProcessorDefinition<?> definition,
- String id, String label, long timeTaken) {
- }
-
- /**
- * To easily debug by overriding the <tt>debugBefore</tt> and <tt>debugAfter</tt> methods.
- */
- private class DebugBreakpoint extends BreakpointSupport {
-
- @Override
- public void beforeProcess(Exchange exchange, Processor processor, NamedNode definition) {
- CamelTestSupport.this.debugBefore(exchange, processor, (ProcessorDefinition) definition, definition.getId(),
- definition.getLabel());
- }
-
- @Override
- public void afterProcess(Exchange exchange, Processor processor, NamedNode definition, long timeTaken) {
- CamelTestSupport.this.debugAfter(exchange, processor, (ProcessorDefinition) definition, definition.getId(),
- definition.getLabel(), timeTaken);
- }
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestWatcher.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestWatcher.java
deleted file mode 100644
index 6dfa2572bbe..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestWatcher.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.test.junit4;
-
-import org.apache.camel.util.StopWatch;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-/**
- * A JUnit {@link org.junit.rules.TestWatcher} that is used to time how long the test takes.
- */
-@Deprecated
-public class CamelTestWatcher extends TestWatcher {
-
- private final StopWatch watch = new StopWatch();
-
- @Override
- protected void starting(Description description) {
- watch.restart();
- }
-
- @Override
- protected void finished(Description description) {
- watch.taken();
- }
-
- public long timeTaken() {
- return watch.taken();
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
deleted file mode 100644
index cf4aefe7cc4..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
+++ /dev/null
@@ -1,56 +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.test.junit4;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.support.DefaultExchange;
-import org.junit.Before;
-
-/**
- * A base class for a test which requires a {@link org.apache.camel.CamelContext} and a populated {@link Exchange}
- */
-@Deprecated
-public abstract class ExchangeTestSupport extends CamelTestSupport {
- protected Exchange exchange;
-
- /**
- * A factory method to create an Exchange implementation
- */
- protected Exchange createExchange() {
- return new DefaultExchange(context);
- }
-
- /**
- * A strategy method to populate an exchange with some example values for use by language plugins
- */
- protected void populateExchange(Exchange exchange) {
- Message in = exchange.getIn();
- in.setHeader("foo", "abc");
- in.setHeader("bar", 123);
- in.setBody("<hello id='m123'>world!</hello>");
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- exchange = createExchange();
- assertNotNull("No exchange created!", exchange);
- populateExchange(exchange);
- }
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/LanguageTestSupport.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/LanguageTestSupport.java
deleted file mode 100644
index 54afb7bb182..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/LanguageTestSupport.java
+++ /dev/null
@@ -1,98 +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.test.junit4;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.spi.Language;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A useful base class for testing the language plugins in Camel
- */
-@Deprecated
-public abstract class LanguageTestSupport extends ExchangeTestSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(LanguageTestSupport.class);
-
- protected abstract String getLanguageName();
-
- /**
- * Asserts that the given predicate expression evaluated on the current language and message exchange evaluates to
- * true
- */
- protected void assertPredicate(String expression) {
- assertPredicate(exchange, expression, true);
- }
-
- /**
- * Asserts that the given predicate expression evaluated on the current language and message exchange evaluates to
- * false
- */
- protected void assertPredicateFails(String expression) {
- assertPredicate(exchange, expression, false);
- }
-
- /**
- * Asserts that the given predicate expression evaluated on the current language and message exchange evaluates to
- * the expected value
- */
- protected void assertPredicate(String expression, boolean expected) {
- assertPredicate(exchange, expression, expected);
- }
-
- protected void assertPredicate(Exchange exchange, String expression, boolean expected) {
- assertPredicate(getLanguageName(), expression, exchange, expected);
- }
-
- /**
- * Asserts that this language expression evaluates to the given value on the given exchange
- */
- protected void assertExpression(Exchange exchange, String expressionText, Object expectedValue) {
- assertExpression(exchange, getLanguageName(), expressionText, expectedValue);
- }
-
- /**
- * Asserts that this language expression evaluates to the given value on the current exchange
- */
- protected void assertExpression(String expressionText, Object expectedValue) {
- assertExpression(exchange, expressionText, expectedValue);
- }
-
- /**
- * Asserts that the expression evaluates to one of the two given values
- */
- protected void assertExpression(String expressionText, String expectedValue, String orThisExpectedValue) {
- Language language = assertResolveLanguage(getLanguageName());
-
- Expression expression = language.createExpression(expressionText);
- assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);
-
- Object value;
- if (expectedValue != null) {
- value = expression.evaluate(exchange, expectedValue.getClass());
- } else {
- value = expression.evaluate(exchange, Object.class);
- }
- LOG.debug("Evaluated expression: {} on exchange: {} result: {}", expression, exchange, value);
-
- assertTrue("Expression: " + expression + " on Exchange: " + exchange,
- expectedValue.equals(value) || orThisExpectedValue.equals(value));
- }
-
-}
diff --git a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java b/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
deleted file mode 100644
index 3e7c5250020..00000000000
--- a/components/camel-test/camel-test/src/main/java/org/apache/camel/test/junit4/TestSupport.java
+++ /dev/null
@@ -1,565 +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.test.junit4;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.camel.CamelContext;
-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.Predicate;
-import org.apache.camel.Route;
-import org.apache.camel.builder.Builder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.builder.ValueBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.support.PredicateAssertHelper;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A bunch of useful testing methods
- */
-@Deprecated
-public abstract class TestSupport extends Assert {
-
- protected static final String LS = System.lineSeparator();
- private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class);
- protected Logger log = LoggerFactory.getLogger(getClass());
- private TestName testName = new TestName();
- private CamelTestWatcher camelTestWatcher = new CamelTestWatcher();
-
- // Builder methods for expressions used when testing
- // -------------------------------------------------------------------------
-
- /**
- * Returns a value builder for the given header
- */
- public static ValueBuilder header(String name) {
- return Builder.header(name);
- }
-
- /**
- * Returns a value builder for the given property
- *
- * @deprecated use {@link #exchangeProperty(String)}
- */
- @Deprecated
- public static ValueBuilder property(String name) {
- return Builder.exchangeProperty(name);
- }
-
- /**
- * Returns a value builder for the given exchange property
- */
- public static ValueBuilder exchangeProperty(String name) {
- return Builder.exchangeProperty(name);
- }
-
- /**
- * Returns a predicate and value builder for the inbound body on an exchange
- */
- public static ValueBuilder body() {
- return Builder.body();
- }
-
- /**
- * Returns a predicate and value builder for the inbound message body as a specific type
- */
- public static <T> ValueBuilder bodyAs(Class<T> type) {
- return Builder.bodyAs(type);
- }
-
- /**
- * Returns a value builder for the given system property
- */
- public static ValueBuilder systemProperty(String name) {
- return Builder.systemProperty(name);
- }
-
- /**
- * Returns a value builder for the given system property
- */
- public static ValueBuilder systemProperty(String name, String defaultValue) {
- return Builder.systemProperty(name, defaultValue);
- }
-
- // Assertions
- // -----------------------------------------------------------------------
-
- public static <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
- assertNotNull("Expected an instance of type: " + expectedType.getName() + " but was null", value);
- assertTrue("Object should be of type " + expectedType.getName() + " but was: " + value + " with the type: "
- + value.getClass().getName(),
- expectedType.isInstance(value));
- return expectedType.cast(value);
- }
-
- public static void assertEndpointUri(Endpoint endpoint, String uri) {
- assertNotNull("Endpoint is null when expecting endpoint for: " + uri, endpoint);
- assertEquals("Endpoint uri for: " + endpoint, uri, endpoint.getEndpointUri());
- }
-
- /**
- * Asserts the In message on the exchange contains the expected value
- */
- public static Object assertInMessageHeader(Exchange exchange, String name, Object expected) {
- return assertMessageHeader(exchange.getIn(), name, expected);
- }
-
- /**
- * Asserts the Out message on the exchange contains the expected value
- */
- public static Object assertOutMessageHeader(Exchange exchange, String name, Object expected) {
- return assertMessageHeader(exchange.getOut(), name, expected);
- }
-
- /**
- * Asserts that the given exchange has an OUT message of the given body value
- *
- * @param exchange the exchange which should have an OUT message
- * @param expected the expected value of the OUT message
- * @throws InvalidPayloadException is thrown if the payload is not the expected class type
- */
- public static void assertInMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException {
- assertNotNull("Should have a response exchange!", exchange);
-
- Object actual;
- if (expected == null) {
- actual = exchange.getIn().getMandatoryBody();
- assertEquals("in body of: " + exchange, expected, actual);
- } else {
- actual = exchange.getIn().getMandatoryBody(expected.getClass());
- }
- assertEquals("in body of: " + exchange, expected, actual);
-
- LOG.debug("Received response: {} with in: {}", exchange, exchange.getIn());
- }
-
- /**
- * Asserts that the given exchange has an OUT message of the given body value
- *
- * @param exchange the exchange which should have an OUT message
- * @param expected the expected value of the OUT message
- * @throws InvalidPayloadException is thrown if the payload is not the expected class type
- */
- public static void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException {
- assertNotNull("Should have a response exchange!", exchange);
-
- Object actual;
- if (expected == null) {
- actual = exchange.getOut().getMandatoryBody();
- assertEquals("output body of: " + exchange, expected, actual);
- } else {
- actual = exchange.getOut().getMandatoryBody(expected.getClass());
- }
- assertEquals("output body of: " + exchange, expected, actual);
-
- LOG.debug("Received response: {} with out: {}", exchange, exchange.getOut());
- }
-
- public static Object assertMessageHeader(Message message, String name, Object expected) {
- Object value = message.getHeader(name);
- assertEquals("Header: " + name + " on Message: " + message, expected, value);
- return value;
- }
-
- /**
- * Asserts that the given expression when evaluated returns the given answer
- */
- public static Object assertExpression(Expression expression, Exchange exchange, Object expected) {
- Object value;
- if (expected != null) {
- value = expression.evaluate(exchange, expected.getClass());
- } else {
- value = expression.evaluate(exchange, Object.class);
- }
-
- LOG.debug("Evaluated expression: {} on exchange: {} result: {}", expression, exchange, value);
-
- assertEquals("Expression: " + expression + " on Exchange: " + exchange, expected, value);
- return value;
- }
-
- /**
- * Asserts that the predicate returns the expected value on the exchange
- */
- public static void assertPredicateMatches(Predicate predicate, Exchange exchange) {
- assertPredicate(predicate, exchange, true);
- }
-
- /**
- * Asserts that the predicate returns the expected value on the exchange
- */
- public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) {
- try {
- PredicateAssertHelper.assertMatches(predicate, "Predicate should match: ", exchange);
- } catch (AssertionError e) {
- LOG.debug("Caught expected assertion error: {}", e.getMessage(), e);
- }
- assertPredicate(predicate, exchange, false);
- }
-
- /**
- * Asserts that the predicate returns the expected value on the exchange
- */
- public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean expected) {
- if (expected) {
- PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange);
- }
- boolean value = predicate.matches(exchange);
-
- LOG.debug("Evaluated predicate: {} on exchange: {} result: {}", predicate, exchange, value);
-
- assertEquals("Predicate: " + predicate + " on Exchange: " + exchange, expected, value);
- return value;
- }
-
- /**
- * Resolves an endpoint and asserts that it is found
- */
- public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
- Endpoint endpoint = context.getEndpoint(uri);
-
- assertNotNull("No endpoint found for URI: " + uri, endpoint);
-
- return endpoint;
- }
-
- /**
- * Resolves an endpoint and asserts that it is found
- */
- public static <T extends Endpoint> T resolveMandatoryEndpoint(
- CamelContext context, String uri,
- Class<T> endpointType) {
- T endpoint = context.getEndpoint(uri, endpointType);
-
- assertNotNull("No endpoint found for URI: " + uri, endpoint);
-
- return endpoint;
- }
-
- /**
- * Creates an exchange with the given body
- */
- protected Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
- Exchange exchange = new DefaultExchange(camelContext);
- Message message = exchange.getIn();
- message.setHeader("testClass", getClass().getName());
- message.setBody(body);
- return exchange;
- }
-
- public static <T> T assertOneElement(List<T> list) {
- assertEquals("Size of list should be 1: " + list, 1, list.size());
- return list.get(0);
- }
-
- /**
- * Asserts that a list is of the given size
- */
- public static <T> List<T> assertListSize(List<T> list, int size) {
- return assertListSize("List", list, size);
- }
-
- /**
- * Asserts that a list is of the given size
- */
- public static <T> List<T> assertListSize(String message, List<T> list, int size) {
- assertEquals(message + " should be of size: "
- + size + " but is: " + list,
- size, list.size());
- return list;
- }
-
- /**
- * Asserts that a list is of the given size
- */
- public static <T> Collection<T> assertCollectionSize(Collection<T> list, int size) {
- return assertCollectionSize("List", list, size);
- }
-
- /**
- * Asserts that a list is of the given size
- */
- public static <T> Collection<T> assertCollectionSize(String message, Collection<T> list, int size) {
- assertEquals(message + " should be of size: "
- + size + " but is: " + list,
- size, list.size());
- return list;
- }
-
- /**
- * A helper method to create a list of Route objects for a given route builder
- */
- public static List<Route> getRouteList(RouteBuilder builder) throws Exception {
- CamelContext context = new DefaultCamelContext();
- context.addRoutes(builder);
- context.start();
- List<Route> answer = context.getRoutes();
- context.stop();
- return answer;
- }
-
- /**
- * Asserts that the text contains the given string
- *
- * @param text the text to compare
- * @param containedText the text which must be contained inside the other text parameter
- */
- public static void assertStringContains(String text, String containedText) {
- assertNotNull("Text should not be null!", text);
- assertTrue("Text: " + text + " does not contain: " + containedText, text.contains(containedText));
- }
-
- /**
- * Recursively delete a directory, useful to zapping test data
- *
- * @param file the directory to be deleted
- * @return <tt>false</tt> if error deleting directory
- */
- public static boolean deleteDirectory(String file) {
- return deleteDirectory(new File(file));
- }
-
- /**
- * Recursively delete a directory, useful to zapping test data
- *
- * @param file the directory to be deleted
- * @return <tt>false</tt> if error deleting directory
- */
- public static boolean deleteDirectory(File file) {
- int tries = 0;
- int maxTries = 5;
- boolean exists = true;
- while (exists && tries < maxTries) {
- recursivelyDeleteDirectory(file);
- tries++;
- exists = file.exists();
- if (exists) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // Ignore
- }
- }
- }
- return !exists;
- }
-
- private static void recursivelyDeleteDirectory(File file) {
- if (!file.exists()) {
- return;
- }
-
- if (file.isDirectory()) {
- File[] files = file.listFiles();
- for (File child : files) {
- recursivelyDeleteDirectory(child);
- }
- }
- boolean success = file.delete();
- if (!success) {
- LOG.warn("Deletion of file: {} failed", file.getAbsolutePath());
- }
- }
-
- /**
- * create the directory
- *
- * @param file the directory to be created
- */
- public static void createDirectory(String file) {
- File dir = new File(file);
- dir.mkdirs();
- }
-
- /**
- * To be used for folder/directory comparison that works across different platforms such as Window, Mac and Linux.
- */
- public static void assertDirectoryEquals(String expected, String actual) {
- assertDirectoryEquals(null, expected, actual);
- }
-
- /**
- * To be used for folder/directory comparison that works across different platforms such as Window, Mac and Linux.
- */
- public static void assertDirectoryEquals(String message, String expected, String actual) {
- // must use single / as path separators
- String expectedPath = expected.replace('\\', '/');
- String actualPath = actual.replace('\\', '/');
-
- if (message != null) {
- assertEquals(message, expectedPath, actualPath);
- } else {
- assertEquals(expectedPath, actualPath);
- }
- }
-
- /**
- * To be used to check is a directory is found in the file system
- */
- public static void assertDirectoryExists(String filename) {
- File file = new File(filename);
- assertTrue("Directory " + filename + " should exist", file.exists());
- assertTrue("Directory " + filename + " should be a directory", file.isDirectory());
- }
-
- /**
- * To be used to check is a file is found in the file system
- */
- public static void assertFileExists(String filename) {
- File file = new File(filename);
- assertTrue("File " + filename + " should exist", file.exists());
- assertTrue("File " + filename + " should be a file", file.isFile());
- }
-
- /**
- * To be used to check is a file is <b>not</b> found in the file system
- */
- public static void assertFileNotExists(String filename) {
- File file = new File(filename);
- assertFalse("File " + filename + " should not exist", file.exists());
- }
-
- /**
- * Is this OS the given platform.
- * <p/>
- * Uses <tt>os.name</tt> from the system properties to determine the OS.
- *
- * @param platform such as Windows
- * @return <tt>true</tt> if its that platform.
- */
- public static boolean isPlatform(String platform) {
- String osName = System.getProperty("os.name").toLowerCase(Locale.US);
- return osName.contains(platform.toLowerCase(Locale.US));
- }
-
- /**
- * Is this Java by the given vendor.
- * <p/>
- * Uses <tt>java.vendor</tt> from the system properties to determine the vendor.
- *
- * @param vendor such as IBM
- * @return <tt>true</tt> if its that vendor.
- */
- public static boolean isJavaVendor(String vendor) {
- String javaVendor = System.getProperty("java.vendor").toLowerCase(Locale.US);
- return javaVendor.contains(vendor.toLowerCase(Locale.US));
- }
-
- /**
- * Is this Java 1.5
- *
- * @return <tt>true</tt> if its Java 1.5, <tt>false</tt> if its not (for example Java 1.6 or better)
- * @deprecated will be removed in the future as Camel requires JDK1.8+
- */
- @Deprecated
- public static boolean isJava15() {
- return getJavaMajorVersion() == 5;
- }
-
- /**
- * Is this Java 1.6
- *
- * @return <tt>true</tt> if its Java 1.6, <tt>false</tt> if its not (for example Java 1.7 or better)
- * @deprecated will be removed in the future as Camel requires JDK1.8+
- */
- @Deprecated
- public static boolean isJava16() {
- return getJavaMajorVersion() == 6;
-
- }
-
- /**
- * Is this Java 1.7
- *
- * @return <tt>true</tt> if its Java 1.7, <tt>false</tt> if its not (for example Java 1.6 or older)
- * @deprecated will be removed in the future as Camel requires JDK1.8+
- */
- @Deprecated
- public static boolean isJava17() {
- return getJavaMajorVersion() == 7;
-
- }
-
- /**
- * Is this Java 1.8
- *
- * @return <tt>true</tt> if its Java 1.8, <tt>false</tt> if its not (for example Java 1.7 or older)
- */
- public static boolean isJava18() {
- return getJavaMajorVersion() == 8;
-
- }
-
- /**
- * Is this Java 1.9
- *
- * @return <tt>true</tt> if its Java 1.9, <tt>false</tt> if its not (for example Java 1.8 or older)
- */
- public static boolean isJava19() {
- return getJavaMajorVersion() == 9;
-
- }
-
- /**
- * Returns the current major Java version e.g 8.
- * <p/>
- * Uses <tt>java.specification.version</tt> from the system properties to determine the major version.
- *
- * @return the current major Java version.
- */
- public static int getJavaMajorVersion() {
- String javaSpecVersion = System.getProperty("java.specification.version");
- if (javaSpecVersion.contains(".")) { //before jdk 9
- return Integer.parseInt(javaSpecVersion.split("\\.")[1]);
- } else {
- return Integer.parseInt(javaSpecVersion);
- }
- }
-
- /**
- * Gets the current test name
- *
- * @return the test name
- */
- @Rule
- public TestName getTestName() {
- return testName;
- }
-
- /**
- * Gets the current test method name
- *
- * @return the method name
- */
- public String getTestMethodName() {
- return testName.getMethodName();
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
deleted file mode 100644
index 6c2eab3b82f..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/AvailablePortFinderTest.java
+++ /dev/null
@@ -1,106 +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.test;
-
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MulticastSocket;
-import java.net.ServerSocket;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-public class AvailablePortFinderTest {
-
- @Test
- public void testNotAvailableTcpPort() throws Exception {
- int p1 = AvailablePortFinder.getNextAvailable();
- ServerSocket socket = new ServerSocket(p1);
- int p2 = AvailablePortFinder.getNextAvailable();
- Assert.assertNotEquals("Port " + p1 + " Port2 " + p2, p1, p2);
- socket.close();
- }
-
- @Test
- public void testNotAvailableUdpPort() throws Exception {
- int p1 = AvailablePortFinder.getNextAvailable();
- DatagramSocket socket = new DatagramSocket(p1);
- int p2 = AvailablePortFinder.getNextAvailable();
- Assert.assertNotEquals("Port " + p1 + " Port2 " + p2, p1, p2);
- socket.close();
- }
-
- @Test
- public void testNotAvailableMulticastPort() throws Exception {
- int p1 = AvailablePortFinder.getNextAvailable();
- MulticastSocket socket = new MulticastSocket(null);
- socket.setReuseAddress(false); // true is default for MulticastSocket, we wan to fail if port is occupied
- socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), p1));
- int p2 = AvailablePortFinder.getNextAvailable();
- Assert.assertNotEquals("Port " + p1 + " Port2 " + p2, p1, p2);
- socket.close();
- }
-
- @Test
- public void testPortRange() throws Exception {
- int p1 = AvailablePortFinder.getNextAvailable(49152, 65535);
- ServerSocket socket1 = new ServerSocket(p1);
- int p2 = AvailablePortFinder.getNextAvailable(49152, 65535);
- ServerSocket socket2 = new ServerSocket(p2);
- socket1.close();
- socket2.close();
- }
-
- @Test
- public void testAvailablePortFinderPropertiesFunction() throws Exception {
- AvailablePortFinderPropertiesFunction function = new AvailablePortFinderPropertiesFunction();
-
- assertThat(function.apply("test")).isSameAs(function.apply("test"));
- assertThat(function.apply("")).isEqualTo("");
- assertThat(function.apply(null)).isNull();
- }
-
- @Test
- public void testAvailablePortFinderPropertiesFunctionWithRange() throws Exception {
- // range
- assertThat(Integer.parseInt(function("test:1024-49151"))).isBetween(1024, 49150);
-
- // validation
- assertThatThrownBy(() -> function("test:")).isInstanceOf(IllegalArgumentException.class);
- assertThatThrownBy(() -> function("test:-")).isInstanceOf(IllegalArgumentException.class);
-
- assertThatThrownBy(() -> function("test:1024"))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unable to parse from range");
-
- assertThatThrownBy(() -> function("test:1024-"))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unable to parse to range");
-
- assertThatThrownBy(() -> function("test:-1234"))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unable to parse from range");
- }
-
- private static String function(String remainder) {
- return new AvailablePortFinderPropertiesFunction().apply(remainder);
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
deleted file mode 100644
index 060dcd6f696..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/CamelTestSupportTest.java
+++ /dev/null
@@ -1,71 +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.test;
-
-import org.apache.camel.NoSuchEndpointException;
-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 CamelTestSupportTest extends CamelTestSupport {
-
- @Override
- @Before
- public void setUp() throws Exception {
- replaceRouteFromWith("routeId", "direct:start");
- super.setUp();
- }
-
- @Test
- public void replacesFromEndpoint() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Test(expected = NoSuchEndpointException.class)
- public void exceptionThrownWhenEndpointNotFoundAndNoCreate() {
- getMockEndpoint("mock:bogus", false);
- }
-
- @Test(expected = NoSuchEndpointException.class)
- public void exceptionThrownWhenEndpointNotAMockEndpoint() {
- getMockEndpoint("direct:something", false);
- }
-
- @Test
- public void autoCreateNoneExisting() {
- MockEndpoint mock = getMockEndpoint("mock:bogus2", true);
- assertNotNull(mock);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:something")
- .id("routeId")
- .to("mock:result");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternExcludeTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternExcludeTest.java
deleted file mode 100644
index f5bca0d5200..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternExcludeTest.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.test;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class RouteFilterPatternExcludeTest extends CamelTestSupport {
-
- @Override
- public String getRouteFilterExcludePattern() {
- return "bar*";
- }
-
- @Test
- public void testRouteFilter() throws Exception {
- assertEquals(1, context.getRoutes().size());
- assertEquals(1, context.getRouteDefinitions().size());
- assertEquals("foo", context.getRouteDefinitions().get(0).getId());
-
- getMockEndpoint("mock:foo").expectedMessageCount(1);
-
- template.sendBody("direct:foo", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo").routeId("foo")
- .to("mock:foo");
-
- from("direct:bar").routeId("bar")
- .to("mock:bar");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeExcludeTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeExcludeTest.java
deleted file mode 100644
index 3c8261b32e0..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeExcludeTest.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.test;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class RouteFilterPatternIncludeExcludeTest extends CamelTestSupport {
-
- @Override
- public String getRouteFilterIncludePattern() {
- return "foo*";
- }
-
- @Override
- public String getRouteFilterExcludePattern() {
- return "jms:*";
- }
-
- @Test
- public void testRouteFilter() throws Exception {
- assertEquals(1, context.getRoutes().size());
- assertEquals(1, context.getRouteDefinitions().size());
- assertEquals("foo", context.getRouteDefinitions().get(0).getId());
-
- getMockEndpoint("mock:foo").expectedMessageCount(1);
-
- template.sendBody("direct:foo", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo").routeId("foo")
- .to("mock:foo");
-
- from("direct:bar").routeId("bar")
- .to("mock:bar");
-
- from("jms:beer").routeId("foolish")
- .to("mock:beer");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeTest.java
deleted file mode 100644
index ce6d262d279..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/RouteFilterPatternIncludeTest.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.test;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class RouteFilterPatternIncludeTest extends CamelTestSupport {
-
- @Override
- public String getRouteFilterIncludePattern() {
- return "foo*";
- }
-
- @Test
- public void testRouteFilter() throws Exception {
- assertEquals(1, context.getRoutes().size());
- assertEquals(1, context.getRouteDefinitions().size());
- assertEquals("foo", context.getRouteDefinitions().get(0).getId());
-
- getMockEndpoint("mock:foo").expectedMessageCount(1);
-
- template.sendBody("direct:foo", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:foo").routeId("foo")
- .to("mock:foo");
-
- from("direct:bar").routeId("bar")
- .to("mock:bar");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java
deleted file mode 100644
index 612626cc839..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.AdviceWith;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class AdviceWithLambdaTest extends CamelTestSupport {
-
- @Override
- public boolean isUseAdviceWith() {
- return true;
- }
-
- @Test
- public void testAdviceWith() throws Exception {
- getMockEndpoint("mock:result").expectedMessageCount(1);
-
- // advice the route in one line
- AdviceWith.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result"));
-
- // 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/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java
deleted file mode 100644
index 65e20925f42..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithNotStartedTest.java
+++ /dev/null
@@ -1,72 +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.test.patterns;
-
-import java.util.concurrent.RejectedExecutionException;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.AdviceWith;
-import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class AdviceWithNotStartedTest extends CamelTestSupport {
-
- @Override
- public boolean isUseAdviceWith() {
- return true;
- }
-
- @Test
- public void testNotStarted() throws Exception {
- AdviceWith.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/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AsyncSendMockTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AsyncSendMockTest.java
deleted file mode 100644
index 6f47f37f3af..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/AsyncSendMockTest.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.test.patterns;
-
-import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AsyncSendMockTest extends CamelTestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(AsyncSendMockTest.class);
-
- @Override
- public String isMockEndpoints() {
- return "seda*";
- }
-
- @Test
- public void testmakeAsyncApiCall() {
- try {
- getMockEndpoint("mock:seda:start").expectedHeaderReceived("username", "admin123");
- getMockEndpoint("mock:seda:start").expectedBodiesReceived("Hello");
- DefaultExchange dfex = new DefaultExchange(context);
- dfex.getIn().setHeader("username", "admin123");
- dfex.getIn().setHeader("password", "admin");
- dfex.getIn().setBody("Hello");
- template.asyncSend("seda:start", dfex);
- assertMockEndpointsSatisfied();
- } catch (Exception e) {
- LOG.warn("Failed to make async call to api: {}", e.getMessage(), e);
- assertTrue("Failed to make async call to api", false);
- }
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestFalseTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestFalseTest.java
deleted file mode 100644
index 059d88ba209..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestFalseTest.java
+++ /dev/null
@@ -1,116 +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.test.patterns;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CreateCamelContextPerTestFalseTest extends CamelTestSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(CreateCamelContextPerTestFalseTest.class);
-
- private static final AtomicInteger CREATED_CONTEXTS = new AtomicInteger();
- private static final AtomicInteger POST_TEAR_DOWN = new AtomicInteger();
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected ProducerTemplate template;
-
- @Override
- public boolean isCreateCamelContextPerClass() {
- return false;
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- LOG.info("createCamelContext()");
- CREATED_CONTEXTS.incrementAndGet();
- return super.createCamelContext();
- }
-
- @Override
- protected void doPostTearDown() throws Exception {
- LOG.info("doPostTearDown()");
- POST_TEAR_DOWN.incrementAndGet();
- super.doPostTearDown();
- }
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
-
- assertTrue("Should create 1 or more CamelContext per test class", CREATED_CONTEXTS.get() >= 1);
- }
-
- @Test
- public void testSendAnotherMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
-
- assertTrue("Should create 1 or more CamelContext per test class", CREATED_CONTEXTS.get() >= 1);
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- resultEndpoint.expectedMessageCount(0);
-
- template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue");
-
- resultEndpoint.assertIsSatisfied();
-
- assertTrue("Should create 1 or more CamelContext per test class", CREATED_CONTEXTS.get() >= 1);
- }
-
- @AfterClass
- public static void validateTearDown() throws Exception {
- assertEquals(3, CREATED_CONTEXTS.get());
- assertEquals(3, POST_TEAR_DOWN.get());
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestTrueTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestTrueTest.java
deleted file mode 100644
index dd1e9db45d5..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/CreateCamelContextPerTestTrueTest.java
+++ /dev/null
@@ -1,148 +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.test.patterns;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-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.AfterClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CreateCamelContextPerTestTrueTest extends CamelTestSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(CreateCamelContextPerTestTrueTest.class);
-
- private static final AtomicInteger CREATED_CONTEXTS = new AtomicInteger();
- private static final AtomicInteger POST_TEAR_DOWN = new AtomicInteger();
- private static final CountDownLatch LATCH = new CountDownLatch(1);
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected ProducerTemplate template;
-
- @Override
- public boolean isCreateCamelContextPerClass() {
- return true;
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- LOG.info("createCamelContext()");
- CREATED_CONTEXTS.incrementAndGet();
- return super.createCamelContext();
- }
-
- @Override
- protected void doPostTearDown() throws Exception {
- LOG.info("doPostTearDown()");
- POST_TEAR_DOWN.incrementAndGet();
- super.doPostTearDown();
- LATCH.await(5, TimeUnit.SECONDS);
- }
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
-
- assertEquals("Should only create 1 CamelContext per test class", 1, CREATED_CONTEXTS.get());
- assertEquals("Should not call postTearDown yet", 0, POST_TEAR_DOWN.get());
- }
-
- @Test
- public void testSendAnotherMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
-
- assertEquals("Should only create 1 CamelContext per test class", 1, CREATED_CONTEXTS.get());
- assertEquals("Should not call postTearDown yet", 0, POST_TEAR_DOWN.get());
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- resultEndpoint.expectedMessageCount(0);
-
- template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue");
-
- resultEndpoint.assertIsSatisfied();
-
- assertEquals("Should only create 1 CamelContext per test class", 1, CREATED_CONTEXTS.get());
- assertEquals("Should not call postTearDown yet", 0, POST_TEAR_DOWN.get());
- }
-
- @AfterClass
- public static void shouldTearDown() throws Exception {
- // we are called before doPostTearDown so lets wait for that to be called
- Runnable r = () -> {
- try {
- StopWatch watch = new StopWatch();
- while (watch.taken() < 5000) {
- LOG.debug("Checking for tear down called correctly");
- if (POST_TEAR_DOWN.get() == 1) {
- LATCH.countDown();
- break;
- } else {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- break;
- }
- }
- }
- } finally {
- LOG.info("Should only call postTearDown 1 time per test class, called: " + POST_TEAR_DOWN.get());
- assertEquals("Should only call postTearDown 1 time per test class", 1, POST_TEAR_DOWN.get());
- }
- };
- Thread t = new Thread(r);
- t.setDaemon(false);
- t.setName("shouldTearDown checker");
- t.start();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugJUnit4Test.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugJUnit4Test.java
deleted file mode 100644
index 7dbd5c9bdbf..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugJUnit4Test.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.test.patterns;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class DebugJUnit4Test extends CamelTestSupport {
-
- // START SNIPPET: e1
- @Override
- public boolean isUseDebugger() {
- // must enable debugger
- return true;
- }
-
- @Override
- protected void debugBefore(
- Exchange exchange, Processor processor,
- ProcessorDefinition<?> definition, String id, String shortName) {
- // this method is invoked before we are about to enter the given processor
- // from your Java editor you can just add a breakpoint in the code line below
- log.info("Before " + definition + " with body " + exchange.getIn().getBody());
- }
- // END SNIPPET: e1
-
- @Test
- public void testDebugger() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
-
- // send a message
- template.sendBody("direct:start", "World");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testTwo() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(2);
- getMockEndpoint("mock:b").expectedMessageCount(2);
-
- // send a message
- template.sendBody("direct:start", "World");
- template.sendBody("direct:start", "Camel");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- // START SNIPPET: e2
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // this is the route we want to debug
- from("direct:start")
- .to("mock:a")
- .transform(body().prepend("Hello "))
- .to("mock:b");
- }
- };
- }
- // END SNIPPET: e2
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugNoLazyTypeConverterTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugNoLazyTypeConverterTest.java
deleted file mode 100644
index b66550f98df..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugNoLazyTypeConverterTest.java
+++ /dev/null
@@ -1,92 +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.test.patterns;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class DebugNoLazyTypeConverterTest extends CamelTestSupport {
-
- @Override
- protected boolean isLazyLoadingTypeConverter() {
- return false;
- }
-
- // START SNIPPET: e1
- @Override
- public boolean isUseDebugger() {
- // must enable debugger
- return true;
- }
-
- @Override
- protected void debugBefore(
- Exchange exchange, Processor processor,
- ProcessorDefinition<?> definition, String id, String shortName) {
- // this method is invoked before we are about to enter the given processor
- // from your Java editor you can just add a breakpoint in the code line below
- log.info("Before " + definition + " with body " + exchange.getIn().getBody());
- }
- // END SNIPPET: e1
-
- @Test
- public void testDebugger() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
-
- // send a message
- template.sendBody("direct:start", "World");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testTwo() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(2);
- getMockEndpoint("mock:b").expectedMessageCount(2);
-
- // send a message
- template.sendBody("direct:start", "World");
- template.sendBody("direct:start", "Camel");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- // START SNIPPET: e2
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // this is the route we want to debug
- from("direct:start")
- .to("mock:a")
- .transform(body().prepend("Hello "))
- .to("mock:b");
- }
- };
- }
- // END SNIPPET: e2
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.java
deleted file mode 100644
index c8aa322df55..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.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.test.patterns;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class DebugTest extends CamelTestSupport {
-
- // START SNIPPET: e1
- @Override
- public boolean isUseDebugger() {
- // must enable debugger
- return true;
- }
-
- @Override
- protected void debugBefore(
- Exchange exchange, Processor processor,
- ProcessorDefinition<?> definition, String id, String shortName) {
- // this method is invoked before we are about to enter the given processor
- // from your Java editor you can just add a breakpoint in the code line below
- log.info("Before " + definition + " with body " + exchange.getIn().getBody());
- }
- // END SNIPPET: e1
-
- @Test
- public void testDebugger() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(1);
- getMockEndpoint("mock:b").expectedMessageCount(1);
-
- // send a message
- template.sendBody("direct:start", "World");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testTwo() throws Exception {
- // set mock expectations
- getMockEndpoint("mock:a").expectedMessageCount(2);
- getMockEndpoint("mock:b").expectedMessageCount(2);
-
- // send a message
- template.sendBody("direct:start", "World");
- template.sendBody("direct:start", "Camel");
-
- // assert mocks
- assertMockEndpointsSatisfied();
- }
-
- // START SNIPPET: e2
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // this is the route we want to debug
- from("direct:start")
- .to("mock:a")
- .transform(body().prepend("Hello "))
- .to("mock:b");
- }
- };
- }
- // END SNIPPET: e2
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterCreateCamelContextPerClassTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterCreateCamelContextPerClassTest.java
deleted file mode 100644
index 256f4e326e2..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterCreateCamelContextPerClassTest.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.test.patterns;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- * Tests filtering using Camel Test
- */
-// START SNIPPET: example
-public class FilterCreateCamelContextPerClassTest extends CamelTestSupport {
-
- @Override
- public boolean isCreateCamelContextPerClass() {
- // we override this method and return true, to tell Camel test-kit that
- // it should only create CamelContext once (per class), so we will
- // re-use the CamelContext between each test method in this class
- return true;
- }
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- getMockEndpoint("mock:result").expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader("direct:start", expectedBody, "foo", "bar");
-
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- getMockEndpoint("mock:result").expectedMessageCount(0);
-
- template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterFluentTemplateTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterFluentTemplateTest.java
deleted file mode 100644
index 913ecbef143..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterFluentTemplateTest.java
+++ /dev/null
@@ -1,75 +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.test.patterns;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.FluentProducerTemplate;
-import org.apache.camel.Produce;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- * Tests filtering using Camel Test
- */
-// START SNIPPET: example
-// tag::example[]
-public class FilterFluentTemplateTest extends CamelTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected FluentProducerTemplate fluentTemplate;
-
- @Override
- public boolean isDumpRouteCoverage() {
- return true;
- }
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- fluentTemplate.withBody(expectedBody).withHeader("foo", "bar").send();
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- resultEndpoint.expectedMessageCount(0);
-
- fluentTemplate.withBody("<notMatched/>").withHeader("foo", "notMatchedHeaderValue").send();
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
-// end::example[]
-// END SNIPPET: example
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterJUnit4Test.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterJUnit4Test.java
deleted file mode 100644
index 9213e5b180e..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterJUnit4Test.java
+++ /dev/null
@@ -1,69 +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.test.patterns;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- * Tests filtering using Camel Test
- */
-// START SNIPPET: example
-public class FilterJUnit4Test extends CamelTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected ProducerTemplate template;
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- resultEndpoint.expectedMessageCount(0);
-
- template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue");
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-
-}
-// END SNIPPET: example
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java
deleted file mode 100644
index 8ad2636b9fe..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java
+++ /dev/null
@@ -1,75 +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.test.patterns;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- * Tests filtering using Camel Test
- */
-// START SNIPPET: example
-// tag::example[]
-public class FilterTest extends CamelTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected ProducerTemplate template;
-
- @Override
- public boolean isDumpRouteCoverage() {
- return true;
- }
-
- @Test
- public void testSendMatchingMessage() throws Exception {
- String expectedBody = "<matched/>";
-
- resultEndpoint.expectedBodiesReceived(expectedBody);
-
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Test
- public void testSendNotMatchingMessage() throws Exception {
- resultEndpoint.expectedMessageCount(0);
-
- template.sendBodyAndHeader("<notMatched/>", "foo", "notMatchedHeaderValue");
-
- resultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
-// end::example[]
-// END SNIPPET: example
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/GetMockEndpointTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/GetMockEndpointTest.java
deleted file mode 100644
index 50387a0a344..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/GetMockEndpointTest.java
+++ /dev/null
@@ -1,46 +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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class GetMockEndpointTest extends CamelTestSupport {
-
- @Test
- public void testMock() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .to("mock:result?failFast=false");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsAndSkipJUnit4Test.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsAndSkipJUnit4Test.java
deleted file mode 100644
index da82ca07a7c..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsAndSkipJUnit4Test.java
+++ /dev/null
@@ -1,63 +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.test.patterns;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.seda.SedaEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-// START SNIPPET: e1
-// tag::e1[]
-public class IsMockEndpointsAndSkipJUnit4Test extends CamelTestSupport {
-
- @Override
- public String isMockEndpointsAndSkip() {
- // override this method and return the pattern for which endpoints to mock,
- // and skip sending to the original endpoint.
- return "direct:foo";
- }
-
- @Test
- public void testMockEndpointAndSkip() throws Exception {
- // notice we have automatic mocked the direct:foo endpoints and the name of the endpoints is "mock:uri"
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
- getMockEndpoint("mock:direct:foo").expectedMessageCount(1);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
-
- // the message was not send to the direct:foo route and thus not sent to the seda endpoint
- SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
- assertEquals(0, seda.getCurrentQueueSize());
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start").to("direct:foo").to("mock:result");
-
- from("direct:foo").transform(constant("Bye World")).to("seda:foo");
- }
- };
- }
-}
-// end::e1[]
-// END SNIPPET: e1
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsFileTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsFileTest.java
deleted file mode 100644
index bd27bf66213..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsFileTest.java
+++ /dev/null
@@ -1,69 +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.test.patterns;
-
-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.junit.Before;
-import org.junit.Test;
-
-public class IsMockEndpointsFileTest extends CamelTestSupport {
-
- @Override
- @Before
- public void setUp() throws Exception {
- deleteDirectory("target/input");
- deleteDirectory("target/messages");
- super.setUp();
- }
-
- @Override
- public String isMockEndpoints() {
- // override this method and return the pattern for which endpoints to mock.
- return "file:target*";
- }
-
- @Test
- public void testMockFileEndpoints() throws Exception {
- // notice we have automatic mocked all endpoints and the name of the endpoints is "mock:uri"
- MockEndpoint camel = getMockEndpoint("mock:file:target/messages/camel");
- camel.expectedMessageCount(1);
-
- MockEndpoint other = getMockEndpoint("mock:file:target/messages/others");
- other.expectedMessageCount(1);
-
- template.sendBodyAndHeader("file:target/input", "Hello Camel", Exchange.FILE_NAME, "camel.txt");
- template.sendBodyAndHeader("file:target/input", "Hello World", Exchange.FILE_NAME, "world.txt");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("file:target/input")
- .choice()
- .when(bodyAs(String.class).contains("Camel")).to("file:target/messages/camel")
- .otherwise().to("file:target/messages/others");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsJUnit4Test.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsJUnit4Test.java
deleted file mode 100644
index d8cf4c04813..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsJUnit4Test.java
+++ /dev/null
@@ -1,70 +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.test.patterns;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-// START SNIPPET: e1
-// tag::e1[]
-public class IsMockEndpointsJUnit4Test extends CamelTestSupport {
-
- @Override
- public String isMockEndpoints() {
- // override this method and return the pattern for which endpoints to mock.
- // use * to indicate all
- return "*";
- }
-
- @Test
- public void testMockAllEndpoints() throws Exception {
- // notice we have automatic mocked all endpoints and the name of the endpoints is "mock:uri"
- getMockEndpoint("mock:direct:start").expectedBodiesReceived("Hello World");
- getMockEndpoint("mock:direct:foo").expectedBodiesReceived("Hello World");
- getMockEndpoint("mock:log:foo").expectedBodiesReceived("Bye World");
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
-
- // additional test to ensure correct endpoints in registry
- assertNotNull(context.hasEndpoint("direct:start"));
- assertNotNull(context.hasEndpoint("direct:foo"));
- assertNotNull(context.hasEndpoint("log:foo"));
- assertNotNull(context.hasEndpoint("mock:result"));
- // all the endpoints was mocked
- assertNotNull(context.hasEndpoint("mock:direct:start"));
- assertNotNull(context.hasEndpoint("mock:direct:foo"));
- assertNotNull(context.hasEndpoint("mock:log:foo"));
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start").to("direct:foo").to("log:foo").to("mock:result");
-
- from("direct:foo").transform(constant("Bye World"));
- }
- };
- }
-}
-// end::e1[]
-// END SNIPPET: e1
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsTest.java
deleted file mode 100644
index 46a5ab567ae..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/IsMockEndpointsTest.java
+++ /dev/null
@@ -1,63 +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.test.patterns;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class IsMockEndpointsTest extends CamelTestSupport {
-
- @Override
- public String isMockEndpoints() {
- return "*";
- }
-
- @Test
- public void testMockAllEndpoints() throws Exception {
- getMockEndpoint("mock:direct:start").expectedBodiesReceived("Hello World");
- getMockEndpoint("mock:direct:foo").expectedBodiesReceived("Hello World");
- getMockEndpoint("mock:log:foo").expectedBodiesReceived("Bye World");
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
-
- // additional test to ensure correct endpoints in registry
- assertNotNull(context.hasEndpoint("direct:start"));
- assertNotNull(context.hasEndpoint("direct:foo"));
- assertNotNull(context.hasEndpoint("log:foo"));
- assertNotNull(context.hasEndpoint("mock:result"));
- // all the endpoints was mocked
- assertNotNull(context.hasEndpoint("mock:direct:start"));
- assertNotNull(context.hasEndpoint("mock:direct:foo"));
- assertNotNull(context.hasEndpoint("mock:log:foo"));
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start").to("direct:foo").to("log:foo").to("mock:result");
-
- from("direct:foo").transform(constant("Bye World"));
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MockEndpointFailNoHeaderTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MockEndpointFailNoHeaderTest.java
deleted file mode 100644
index c9dd28ab6f7..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MockEndpointFailNoHeaderTest.java
+++ /dev/null
@@ -1,63 +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.test.patterns;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class MockEndpointFailNoHeaderTest extends CamelTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint resultEndpoint;
-
- @Produce("direct:start")
- protected ProducerTemplate template;
-
- @Override
- public boolean isDumpRouteCoverage() {
- return true;
- }
-
- @Test
- public void withHeaderTestCase() throws InterruptedException {
- String expectedBody = "<matched/>";
- resultEndpoint.expectedHeaderReceived("foo", "bar");
- template.sendBodyAndHeader(expectedBody, "foo", "bar");
- resultEndpoint.assertIsSatisfied();
- }
-
- @Test
- public void noHeaderTestCase() throws InterruptedException {
- resultEndpoint.expectedHeaderReceived("foo", "bar");
- resultEndpoint.setResultWaitTime(1); // speedup test
- resultEndpoint.assertIsNotSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
deleted file mode 100644
index d8864c9795d..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MyProduceBean.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.test.patterns;
-
-import org.apache.camel.Produce;
-
-/**
- *
- */
-public class MyProduceBean {
-
- @Produce("mock:result")
- MySender sender;
-
- public void doSomething(String body) {
- sender.send(body);
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.java
deleted file mode 100644
index 0319c98fe74..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/MySender.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.test.patterns;
-
-/**
- *
- */
-public interface MySender {
-
- void send(String body);
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
deleted file mode 100644
index 18252120757..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
+++ /dev/null
@@ -1,47 +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.test.patterns;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-/**
- *
- */
-public class ProduceBeanTest extends CamelTestSupport {
-
- @Test
- public void testProduceBean() throws Exception {
- getMockEndpoint("mock:result").expectedMessageCount(1);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .bean(MyProduceBean.class, "doSomething");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteBuilderConfigureExceptionTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteBuilderConfigureExceptionTest.java
deleted file mode 100644
index c4fee21da0f..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteBuilderConfigureExceptionTest.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.test.patterns;
-
-import org.apache.camel.Predicate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RouteBuilderConfigureExceptionTest extends CamelTestSupport {
-
- private Predicate iAmNull;
-
- @Override
- @Before
- public void setUp() throws Exception {
- try {
- super.setUp();
- fail("Should have thrown exception");
- } catch (Exception e) {
- // expected
- }
- }
-
- @Test
- public void testFoo() throws Exception {
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("direct:start")
- .choice()
- .when(iAmNull).to("mock:dead");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteProcessorDumpRouteCoverageTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteProcessorDumpRouteCoverageTest.java
deleted file mode 100644
index 3d4fb665932..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/RouteProcessorDumpRouteCoverageTest.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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Test;
-
-public class RouteProcessorDumpRouteCoverageTest extends CamelTestSupport {
-
- @Override
- public boolean isDumpRouteCoverage() {
- return true;
- }
-
- @Test
- public void testProcessor() throws Exception {
- String out = template.requestBody("direct:start", "Hello World", String.class);
- assertEquals("Bye World", out);
- }
-
- @Override
- @After
- public void tearDown() throws Exception {
- super.tearDown();
-
- // should create that file when test is done
- assertFileExists("target/camel-route-coverage/RouteProcessorDumpRouteCoverageTest-testProcessor.xml");
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .process(exchange -> exchange.getMessage().setBody("Bye World"));
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java
deleted file mode 100644
index dcc7cb19dee..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockEndpointsTest.java
+++ /dev/null
@@ -1,52 +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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class SimpleMockEndpointsTest extends CamelTestSupport {
-
- @Override
- public String isMockEndpointsAndSkip() {
- return "seda:queue";
- }
-
- @Test
- public void testMockAndSkip() throws Exception {
- getMockEndpoint("mock:seda:queue").expectedBodiesReceived("Bye Camel");
-
- template.sendBody("seda:start", "Camel");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:start")
- .transform(simple("Bye ${body}"))
- .to("seda:queue");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java
deleted file mode 100644
index c9b89aa6e08..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleMockTest.java
+++ /dev/null
@@ -1,46 +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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class SimpleMockTest extends CamelTestSupport {
-
- @Test
- public void testMock() throws Exception {
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .to("mock:result");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleNotifyBuilderTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleNotifyBuilderTest.java
deleted file mode 100644
index ddf747dbeab..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleNotifyBuilderTest.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.test.patterns;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.NotifyBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class SimpleNotifyBuilderTest extends CamelTestSupport {
-
- @Test
- public void testNotifyBuilder() throws Exception {
- NotifyBuilder notify = new NotifyBuilder(context)
- .from("seda:start")
- .wereSentTo("seda:queue")
- .whenDone(10)
- .create();
-
- for (int i = 0; i < 10; i++) {
- template.sendBody("seda:start", "Camel" + i);
- }
-
- boolean matches = notify.matches(10, TimeUnit.SECONDS);
- assertTrue(matches);
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:start")
- .transform(simple("Bye ${body}"))
- .to("seda:queue");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java
deleted file mode 100644
index a1212040524..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/SimpleWeaveAddMockLastTest.java
+++ /dev/null
@@ -1,62 +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.test.patterns;
-
-import org.apache.camel.RoutesBuilder;
-import org.apache.camel.builder.AdviceWith;
-import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class SimpleWeaveAddMockLastTest extends CamelTestSupport {
-
- @Override
- public boolean isUseAdviceWith() {
- return true;
- }
-
- @Test
- public void testWeaveAddMockLast() throws Exception {
- AdviceWith.adviceWith(context.getRouteDefinitions().get(0), context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- weaveAddLast().to("mock:result");
- }
- });
- context.start();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
-
- template.sendBody("seda:start", "Camel");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RoutesBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("seda:start")
- .transform(simple("Bye ${body}"))
- .to("seda:queue");
- }
- };
- }
-
-}
diff --git a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/UseOverridePropertiesWithPropertiesComponentTest.java b/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/UseOverridePropertiesWithPropertiesComponentTest.java
deleted file mode 100644
index 9440effa69f..00000000000
--- a/components/camel-test/camel-test/src/test/java/org/apache/camel/test/patterns/UseOverridePropertiesWithPropertiesComponentTest.java
+++ /dev/null
@@ -1,78 +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.test.patterns;
-
-import java.util.Properties;
-
-import org.apache.camel.builder.AdviceWith;
-import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Before;
-import org.junit.Test;
-
-public class UseOverridePropertiesWithPropertiesComponentTest extends CamelTestSupport {
-
- @Override
- public boolean isUseAdviceWith() {
- return true;
- }
-
- @Before
- public void doSomethingBefore() throws Exception {
- AdviceWithRouteBuilder mocker = new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- replaceFromWith("direct:sftp");
-
- interceptSendToEndpoint("file:*")
- .skipSendToOriginalEndpoint()
- .to("mock:file");
- }
- };
- AdviceWith.adviceWith(context.getRouteDefinition("myRoute"), context, mocker);
- }
-
- @Override
- protected Properties useOverridePropertiesWithPropertiesComponent() {
- Properties pc = new Properties();
- pc.put("ftp.username", "scott");
- pc.put("ftp.password", "tiger");
- return pc;
- }
-
- @Test
- public void testOverride() throws Exception {
- context.start();
-
- getMockEndpoint("mock:file").expectedMessageCount(1);
-
- template.sendBody("direct:sftp", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("ftp:somepath?username={{ftp.username}}&password={{ftp.password}}").routeId("myRoute")
- .to("file:target/out");
- }
- };
- }
-}
diff --git a/components/camel-test/camel-test/src/test/resources/jndi.properties b/components/camel-test/camel-test/src/test/resources/jndi.properties
deleted file mode 100644
index 7f9b32b1616..00000000000
--- a/components/camel-test/camel-test/src/test/resources/jndi.properties
+++ /dev/null
@@ -1,22 +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.
-## ---------------------------------------------------------------------------
-
-# START SNIPPET: jndi
-
-java.naming.factory.initial = org.apache.camel.support.jndi.CamelInitialContextFactory
-
-# END SNIPPET: jndi
diff --git a/components/camel-test/camel-test/src/test/resources/log4j2.properties b/components/camel-test/camel-test/src/test/resources/log4j2.properties
deleted file mode 100644
index 53994e6cc04..00000000000
--- a/components/camel-test/camel-test/src/test/resources/log4j2.properties
+++ /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.
-## ---------------------------------------------------------------------------
-
-appender.file.type = File
-appender.file.name = file
-appender.file.fileName = target/camel-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
-logger.springframework.name = org.springframework
-logger.springframework.level = WARN
-rootLogger.level = INFO
-rootLogger.appenderRef.file.ref = file
diff --git a/components/camel-test/pom.xml b/components/camel-test/pom.xml
index af38c2e6915..36e8411cbe9 100644
--- a/components/camel-test/pom.xml
+++ b/components/camel-test/pom.xml
@@ -33,7 +33,6 @@
<description>Camel Test parent</description>
<modules>
- <module>camel-test</module>
<module>camel-test-junit5</module>
<module>camel-test-spring-junit5</module>
<module>camel-test-main-junit5</module>