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 2014/09/21 17:35:47 UTC
[1/7] CAMEL-7835: camel-test-spring40 for spring 4.0 only. And
camel-test-spring for spring 4.1 or newer.
Repository: camel
Updated Branches:
refs/heads/master 366ad8d0b -> 873720994
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
deleted file mode 100644
index 229e3c9..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
+++ /dev/null
@@ -1,21 +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.spring;
-
-public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest
- extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest {
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
deleted file mode 100644
index 20bc31a..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
+++ /dev/null
@@ -1,33 +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.spring;
-
-import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-
-@SuppressWarnings("deprecation")
-@LazyLoadTypeConverters(false)
-public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Test
- @Override
- public void testLazyLoadTypeConverters() {
- assertFalse(camelContext.isLazyLoadTypeConverters());
- assertFalse(camelContext2.isLazyLoadTypeConverters());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java
deleted file mode 100644
index d20e72b..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.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.spring;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.seda.SedaEndpoint;
-import org.apache.camel.impl.InterceptSendToEndpoint;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-@MockEndpointsAndSkip("seda:*")
-public class CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @EndpointInject(uri = "mock:seda:context2.seda", context = "camelContext2")
- protected MockEndpoint mock;
-
- @EndpointInject(uri = "seda:context2.seda", context = "camelContext2")
- private InterceptSendToEndpoint original;
-
- @Test
- @Override
- public void testPositive() throws Exception {
- assertEquals(ServiceStatus.Started, camelContext.getStatus());
- assertEquals(ServiceStatus.Started, camelContext2.getStatus());
-
- mockA.expectedBodiesReceived("David");
- mockB.expectedBodiesReceived("Hello David");
- mock.expectedBodiesReceived("Hello David");
-
- start.sendBody("David");
- start2.sendBody("David");
-
- MockEndpoint.assertIsSatisfied(camelContext);
- MockEndpoint.assertIsSatisfied(camelContext2);
- assertTrue("Original endpoint was invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
deleted file mode 100644
index 73dac9f..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.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.spring;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.seda.SedaEndpoint;
-import org.apache.camel.impl.InterceptSendToEndpoint;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-@MockEndpoints("seda:context2.seda")
-public class CamelSpringJUnit4ClassRunnerMockEndpointsTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @EndpointInject(uri = "mock:seda:context2.seda", context = "camelContext2")
- protected MockEndpoint mock;
-
- @EndpointInject(uri = "seda:context2.seda", context = "camelContext2")
- private InterceptSendToEndpoint original;
-
- @Test
- @Override
- public void testPositive() throws Exception {
-
- assertEquals(ServiceStatus.Started, camelContext.getStatus());
- assertEquals(ServiceStatus.Started, camelContext2.getStatus());
-
- mockA.expectedBodiesReceived("David");
- mockB.expectedBodiesReceived("Hello David");
- mockC.expectedBodiesReceived("David");
- mock.expectedBodiesReceived("Hello David");
-
- start.sendBody("David");
- start2.sendBody("David");
-
- MockEndpoint.assertIsSatisfied(camelContext);
- MockEndpoint.assertIsSatisfied(camelContext2);
- assertTrue("Original endpoint should be invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().size() == 1);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
deleted file mode 100644
index 8b1504f..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
+++ /dev/null
@@ -1,127 +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.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.management.DefaultManagementStrategy;
-import org.apache.camel.util.StopWatch;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.annotation.DirtiesContext.ClassMode;
-import org.springframework.test.context.BootstrapWith;
-import org.springframework.test.context.ContextConfiguration;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-// START SNIPPET: e1
-@RunWith(CamelSpringJUnit4ClassRunner.class)
-// must tell Spring to bootstrap with Camel
-@BootstrapWith(CamelTestContextBootstrapper.class)
-@ContextConfiguration()
-// Put here to prevent Spring context caching across tests and test methods since some tests inherit
-// from this test and therefore use the same Spring context. Also because we want to reset the
-// Camel context and mock endpoints between test methods automatically.
-@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
-public class CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Autowired
- protected CamelContext camelContext;
-
- @Autowired
- protected CamelContext camelContext2;
-
- @EndpointInject(uri = "mock:a", context = "camelContext")
- protected MockEndpoint mockA;
-
- @EndpointInject(uri = "mock:b", context = "camelContext")
- protected MockEndpoint mockB;
-
- @EndpointInject(uri = "mock:c", context = "camelContext2")
- protected MockEndpoint mockC;
-
- @Produce(uri = "direct:start", context = "camelContext")
- protected ProducerTemplate start;
-
- @Produce(uri = "direct:start2", context = "camelContext2")
- protected ProducerTemplate start2;
-
- @Test
- public void testPositive() throws Exception {
- assertEquals(ServiceStatus.Started, camelContext.getStatus());
- assertEquals(ServiceStatus.Started, camelContext2.getStatus());
-
- mockA.expectedBodiesReceived("David");
- mockB.expectedBodiesReceived("Hello David");
- mockC.expectedBodiesReceived("David");
-
- start.sendBody("David");
- start2.sendBody("David");
-
- MockEndpoint.assertIsSatisfied(camelContext);
- MockEndpoint.assertIsSatisfied(camelContext2);
- }
-
- @Test
- public void testJmx() throws Exception {
- assertEquals(DefaultManagementStrategy.class, camelContext.getManagementStrategy().getClass());
- }
-
- @Test
- public void testShutdownTimeout() throws Exception {
- assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
- assertEquals(TimeUnit.SECONDS, camelContext.getShutdownStrategy().getTimeUnit());
- }
-
- @Test
- public void testStopwatch() {
- StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
-
- assertNotNull(stopWatch);
- assertTrue(stopWatch.taken() < 100);
- }
-
- @Test
- public void testExcludedRoute() {
- assertNotNull(camelContext.getRoute("excludedRoute"));
- }
-
- @Test
- public void testProvidesBreakpoint() {
- assertNull(camelContext.getDebugger());
- assertNull(camelContext2.getDebugger());
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testLazyLoadTypeConverters() {
- assertTrue(camelContext.isLazyLoadTypeConverters());
- assertTrue(camelContext2.isLazyLoadTypeConverters());
- }
-}
-// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
deleted file mode 100644
index 98d47e8..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
+++ /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.
- */
-package org.apache.camel.test.spring;
-
-public class CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest
- extends CamelSpringJUnit4ClassRunnerProvidesBreakpointTest {
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
deleted file mode 100644
index ae2d637..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.spring;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.impl.BreakpointSupport;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.spi.Breakpoint;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class CamelSpringJUnit4ClassRunnerProvidesBreakpointTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @ProvidesBreakpoint
- public static Breakpoint createBreakpoint() {
- return new TestBreakpoint();
- }
-
- @Test
- @Override
- public void testProvidesBreakpoint() {
- assertNotNull(camelContext.getDebugger());
- assertNotNull(camelContext2.getDebugger());
-
- start.sendBody("David");
-
- assertNotNull(camelContext.getDebugger());
- assertNotNull(camelContext.getDebugger().getBreakpoints());
- assertEquals(1, camelContext.getDebugger().getBreakpoints().size());
-
- assertTrue(camelContext.getDebugger().getBreakpoints().get(0) instanceof TestBreakpoint);
- assertTrue(((TestBreakpoint) camelContext.getDebugger().getBreakpoints().get(0)).isBreakpointHit());
- }
-
- private static final class TestBreakpoint extends BreakpointSupport {
-
- private boolean breakpointHit;
-
- @Override
- public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
- breakpointHit = true;
- }
-
- public boolean isBreakpointHit() {
- return breakpointHit;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
deleted file mode 100644
index c011d1f..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.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.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-@ShutdownTimeout
-public class CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest
- extends CamelSpringJUnit4ClassRunnerShutdownTimeoutTest {
-
- @Test
- @Override
- public void testShutdownTimeout() throws Exception {
- assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
- assertEquals(TimeUnit.SECONDS, camelContext.getShutdownStrategy().getTimeUnit());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
deleted file mode 100644
index 9f66625..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
+++ /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.
- */
-package org.apache.camel.test.spring;
-
-public class CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest
- extends CamelSpringJUnit4ClassRunnerShutdownTimeoutTest {
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
deleted file mode 100644
index 85a80ba..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.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.spring;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-@ShutdownTimeout(value = 11, timeUnit = TimeUnit.MILLISECONDS)
-public class CamelSpringJUnit4ClassRunnerShutdownTimeoutTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Test
- @Override
- public void testShutdownTimeout() throws Exception {
- assertEquals(11, camelContext.getShutdownStrategy().getTimeout());
- assertEquals(TimeUnit.MILLISECONDS, camelContext.getShutdownStrategy().getTimeUnit());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
deleted file mode 100644
index 7cf5e06..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.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.spring;
-
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.util.StopWatch;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@UseAdviceWith
-public class CamelSpringJUnit4ClassRunnerUseAdviceWithTest extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Before
- public void testContextStarted() throws Exception {
-
- assertEquals(ServiceStatus.Stopped, camelContext.getStatus());
- assertEquals(ServiceStatus.Stopped, camelContext2.getStatus());
- camelContext.start();
- camelContext2.start();
-
- // just sleep a little to simulate testing take a bit time
- Thread.sleep(1000);
- }
-
- @Test
- public void testStopwatch() {
- StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
-
- assertNotNull(stopWatch);
- long taken = stopWatch.taken();
- assertTrue(taken + " > 0, but was: " + taken, taken > 0);
- assertTrue(taken + " < 3000, but was: " + taken, taken < 3000);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
deleted file mode 100644
index 7e7445c..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
+++ /dev/null
@@ -1,51 +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.spring;
-
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-// START SNIPPET: e1
-
-/**
- * Just extend the CamelSpringTestSupport and use Camel test kit for easy Camel based unit testing.
- */
-public class CamelSpringTestSupportActiveProfileTest extends CamelSpringTestSupport {
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- // must not refresh when using active profiles
- // lets reuse the xml file from the other test
- return new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml"}, false);
- }
-
- @Override
- protected String[] activeProfiles() {
- // return the active profiles to be used
- return new String[]{"test"};
- }
-
- @Test
- public void testLoadActiveProfile() throws InterruptedException {
- getMockEndpoint("mock:test").expectedBodiesReceived("Hello World");
- template.sendBody("direct:start", "World");
- assertMockEndpointsSatisfied();
- }
-
-}
-// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
deleted file mode 100644
index 52059c4..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.spring;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class TestRouteBuilder extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
-
- from("direct:z")
- .routeId("excludedRoute")
- .to("log:org.apache.camel.test.junit4.spring");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/jndi.properties b/components/camel-test-spring41/src/test/resources/jndi.properties
deleted file mode 100644
index 5961589..0000000
--- a/components/camel-test-spring41/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.util.jndi.CamelInitialContextFactory
-
-# END SNIPPET: jndi
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/log4j.properties b/components/camel-test-spring41/src/test/resources/log4j.properties
deleted file mode 100644
index 1eb13a5..0000000
--- a/components/camel-test-spring41/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,37 +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.
-## ------------------------------------------------------------------------
-
-#
-# The logging properties used for testing
-#
-log4j.rootLogger=INFO, file
-
-log4j.logger.org.springframework=WARN
-#log4j.logger.org.apache.camel=DEBUG
-#log4j.logger.org.apache.camel.test.junit4=DEBUG
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-# File appender
-log4j.appender.file=org.apache.log4j.FileAppender
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
-log4j.appender.file.file=target/camel-spring-test.log
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
deleted file mode 100644
index 76b18ed..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
- <camelContext xmlns="http://camel.apache.org/schema/spring">
-
- <onException>
- <exception>java.lang.Exception</exception>
- <handled>
- <constant>true</constant>
- </handled>
- <to uri="mock:error"/>
- </onException>
-
- <route id="RouteA">
- <from uri="direct:startA"/>
- <to uri="mock:resultA"/>
- </route>
-
- <route id="RouteB">
- <from uri="direct:startB"/>
- <to uri="mock:resultB"/>
- </route>
-
- </camelContext>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
deleted file mode 100644
index 81b9093..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
- <camelContext xmlns="http://camel.apache.org/schema/spring">
-
- <route>
- <from uri="direct:start"/>
- <to uri="log:foo"/>
- <to uri="seda:foo"/>
- </route>
-
- </camelContext>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
deleted file mode 100644
index a697e1d..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
-
- <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:start"/>
- <transform>
- <simple>${in.body} rocks!</simple>
- </transform>
- </route>
- </camelContext>
-
- <!--bean id="camelPostProcessBean" class="org.apache.camel.spring.CamelBeanPostProcessor" /-->
-
- <bean id="myProduceBean" class="org.apache.camel.test.patterns.MyProduceBean"/>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
deleted file mode 100644
index 525ed01..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
-<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
-
- <route>
- <from uri="direct:start"/>
- <bean beanType="org.apache.camel.test.patterns.MyProduceBean"/>
- </route>
- </camelContext>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
deleted file mode 100644
index 081ae23..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
-
- <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true" >
-
- <route>
- <from uri="direct:start" />
- <to uri="mock:a" />
- <transform>
- <simple>Hello ${body}</simple>
- </transform>
- <to uri="mock:b" />
- </route>
- </camelContext>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
deleted file mode 100644
index ceacb2d..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
- <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:start" />
- <transform>
- <simple>Hello ${body}</simple>
- </transform>
- <to uri="properties:{{cool.end}}" />
- </route>
- </camelContext>
-
- <!-- setup the profile for testing -->
- <beans profile="test">
- <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
- <property name="location" value="classpath:org/apache/camel/test/spring/test.properties"/>
- </bean>
- </beans>
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
deleted file mode 100644
index ee2e7ce..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
-
- <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true">
- <packageScan>
- <package>org.apache.camel.test.spring</package>
- </packageScan>
- <route>
- <from uri="direct:start"/>
- <to uri="mock:a"/>
- <transform>
- <simple>Hello ${body}</simple>
- </transform>
- <to uri="mock:b"/>
- </route>
- </camelContext>
-
- <camelContext id="camelContext2" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true">
- <route>
- <from uri="direct:start2"/>
- <to uri="mock:c"/>
- <transform>
- <simple>Hello ${body}</simple>
- </transform>
- <to uri="log:org.apache.camel.test.junit4.spring"/>
- <to uri="seda:context2.seda"/>
- </route>
- </camelContext>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/test.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/test.properties b/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/test.properties
deleted file mode 100644
index f891086..0000000
--- a/components/camel-test-spring41/src/test/resources/org/apache/camel/test/spring/test.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-## ---------------------------------------------------------------------------
-## Licensed to the Apache Software Foundation (ASF) under one or more
-## contributor license agreements. See the NOTICE file distributed with
-## this work for additional information regarding copyright ownership.
-## The ASF licenses this file to You under the Apache License, Version 2.0
-## (the "License"); you may not use this file except in compliance with
-## the License. You may obtain a copy of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-## ---------------------------------------------------------------------------
-
-cool.end=mock:test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index adab222..dd8e8c4 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -38,7 +38,7 @@
<module>camel-test-blueprint</module>
<module>camel-test-spring</module>
<module>camel-test-spring3</module>
- <module>camel-test-spring41</module>
+ <module>camel-test-spring40</module>
<module>camel-core-osgi</module>
<module>camel-core-xml</module>
<module>camel-blueprint</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index fcda654..5c9ea80 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -410,8 +410,8 @@
<spring-version-range>[3.2,4)</spring-version-range>
<spring-version>${spring4-version}</spring-version>
<spring32-version>3.2.11.RELEASE</spring32-version>
- <spring4-version>4.0.7.RELEASE</spring4-version>
- <spring41-version>4.1.0.RELEASE</spring41-version>
+ <spring40-version>4.0.7.RELEASE</spring40-version>
+ <spring4-version>4.1.0.RELEASE</spring4-version>
<spring-osgi-version>1.2.1</spring-osgi-version>
<spring-security-version>3.2.5.RELEASE</spring-security-version>
<spring-ws-version>2.1.4.RELEASE</spring-ws-version>
@@ -1361,7 +1361,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring41</artifactId>
+ <artifactId>camel-test-spring40</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
[4/7] CAMEL-7835: camel-test-spring40 for spring 4.0 only. And
camel-test-spring for spring 4.1 or newer.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
new file mode 100644
index 0000000..1f16ebc
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
@@ -0,0 +1,39 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.springframework.test.context.TestContext;
+import org.springframework.test.context.support.AbstractTestExecutionListener;
+
+/**
+ * Provides reset to pre-test state behavior for global enable/disable of JMX
+ * support in Camel through the use of {@link DisableJmx}.
+ * Tries to ensure that the pre-test value is restored.
+ */
+public class DisableJmxTestExecutionListener extends AbstractTestExecutionListener {
+
+ @Override
+ public void afterTestClass(TestContext testContext) throws Exception {
+ if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ } else {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, CamelSpringTestHelper.getOriginalJmxDisabled());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
new file mode 100644
index 0000000..2b1617d
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
@@ -0,0 +1,44 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.RoutesBuilder;
+
+/**
+ * Indicates if certain route builder classes should be excluded from discovery.
+ * Initializes a {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given
+ * classes from being resolved. Typically this is used at test time to exclude certain routes,
+ * which might otherwise be noisy, from being discovered and initialized.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface ExcludeRoutes {
+
+ /**
+ * The classes to exclude from resolution when using package scanning.
+ */
+ Class<? extends RoutesBuilder>[] value() default {};
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
new file mode 100644
index 0000000..dc5e349
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
@@ -0,0 +1,44 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates if the {@code CamelContext}s that are bootstrapped during the test through the use of Spring Test
+ * loaded application contexts should use lazy loading of type converters.
+ *
+ * @deprecated See <a href="https://issues.apache.org/jira/browse/CAMEL-5011">CAMEL-5011</a> for more details.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+@Deprecated
+public @interface LazyLoadTypeConverters {
+
+ /**
+ * Whether the test annotated with this annotation should be run with lazy type converter loading in Camel.
+ * Defaults to {@code false}.
+ */
+ boolean value() default false;
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpoints.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
new file mode 100644
index 0000000..ff3f282
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
@@ -0,0 +1,43 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
+
+/**
+ * Triggers the auto-mocking of endpoints whose URIs match the provided filter. The default
+ * filter is "*" which matches all endpoints. See {@link InterceptSendToMockEndpointStrategy} for
+ * more details on the registration of the mock endpoints.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface MockEndpoints {
+
+ /**
+ * The pattern to use for matching endpoints to enable mocking on.
+ */
+ String value() default "*";
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
new file mode 100644
index 0000000..1eb7e0f
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
@@ -0,0 +1,43 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
+
+/**
+ * Triggers the auto-mocking of endpoints whose URIs match the provided filter with the added provision
+ * that the endpoints are also skipped. The default filter is "*" which matches all endpoints.
+ * See {@link InterceptSendToMockEndpointStrategy} for more details on the registration of the mock endpoints.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface MockEndpointsAndSkip {
+
+ /**
+ * The pattern to use for matching endpoints to enable mocking on.
+ */
+ String value() default "*";
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
new file mode 100644
index 0000000..3aea7d8
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
@@ -0,0 +1,36 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.spi.Breakpoint;
+
+/**
+ * Indicates that the annotated method returns a {@link Breakpoint} for use in the test. Useful for intercepting
+ * traffic to all endpoints or simply for setting a break point in an IDE for debugging. The method must
+ * be {@code public}, {@code static}, take no arguments, and return {@link Breakpoint}.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD})
+public @interface ProvidesBreakpoint {
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
new file mode 100644
index 0000000..2ce1ccd
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Indicates to set the shutdown timeout of all {@code CamelContext}s instantiated through the
+ * use of Spring Test loaded application contexts. If no annotation is used, the timeout is
+ * automatically reduced to 10 seconds by the test framework. If the annotation is present the
+ * shutdown timeout is set based on the value of {@link #value()}.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface ShutdownTimeout {
+
+ /**
+ * The shutdown timeout to set on the {@code CamelContext}(s).
+ * Defaults to {@code 10} seconds.
+ */
+ int value() default 10;
+
+ /**
+ * The time unit that {@link #value()} is in.
+ */
+ TimeUnit timeUnit() default TimeUnit.SECONDS;
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
new file mode 100644
index 0000000..d3cc369
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
@@ -0,0 +1,60 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.TestContext;
+import org.springframework.test.context.support.AbstractTestExecutionListener;
+
+/**
+ * An execution listener that simulates the timing output built in to {@link org.apache.camel.test.junit4.CamelTestSupport}.
+ */
+public class StopWatchTestExecutionListener extends AbstractTestExecutionListener {
+
+ protected static ThreadLocal<StopWatch> threadStopWatch = new ThreadLocal<StopWatch>();
+
+ /**
+ * Exists primarily for testing purposes, but allows for access to the underlying stop watch instance for a test.
+ */
+ public static StopWatch getStopWatch() {
+ return threadStopWatch.get();
+ }
+
+ @Override
+ public void beforeTestMethod(TestContext testContext) throws Exception {
+ StopWatch stopWatch = new StopWatch();
+ threadStopWatch.set(stopWatch);
+
+ stopWatch.restart();
+ }
+
+ @Override
+ public void afterTestMethod(TestContext testContext) throws Exception {
+ long time = threadStopWatch.get().stop();
+ threadStopWatch.remove();
+ Logger log = LoggerFactory.getLogger(testContext.getTestClass());
+
+ log.info("********************************************************************************");
+ log.info("Testing done: " + testContext.getTestMethod().getName() + "(" + testContext.getTestClass().getName() + ")");
+ log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
+ log.info("********************************************************************************");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
new file mode 100644
index 0000000..71487d1
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.camel.CamelContext;
+
+/**
+ * Indicates the use of {@code adviceWith()} within the test class. If a class is annotated with
+ * this annotation and {@link UseAdviceWith#value()} returns true, any
+ * {@code CamelContext}s bootstrapped during the test through the use of Spring Test loaded
+ * application contexts will not be started automatically. The test author is responsible for
+ * injecting the Camel contexts into the test and executing {@link CamelContext#start()} on them
+ * at the appropriate time after any advice has been applied to the routes in the Camel context(s).
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface UseAdviceWith {
+
+ /**
+ * Whether the test annotated with this annotation should be treated as if
+ * {@code adviceWith()} is in use in the test and the Camel contexts should not be started
+ * automatically.
+ * Defaults to {@code true}.
+ */
+ boolean value() default true;
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/resources/META-INF/LICENSE.txt b/components/camel-test-spring40/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-test-spring40/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/resources/META-INF/NOTICE.txt b/components/camel-test-spring40/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-test-spring40/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java
new file mode 100644
index 0000000..839dbf9
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java
@@ -0,0 +1,116 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class AdviceWithOnExceptionMultipleIssueTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml");
+ }
+
+ @Override
+ public boolean isUseAdviceWith() {
+ return true;
+ }
+
+ @Test
+ public void testSimpleMultipleAdvice() throws Exception {
+ context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("mock:resultA").process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ }
+ });
+ }
+ });
+
+ context.getRouteDefinition("RouteB").adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ }
+ });
+
+ context.start();
+
+ getMockEndpoint("mock:resultA").expectedMessageCount(1);
+ template.sendBody("direct:startA", "a trigger");
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testMultipleAdviceWithExceptionThrown() throws Exception {
+ context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("mock:resultA").process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ throw new Exception("my exception");
+ }
+ });
+ }
+ });
+
+ context.start();
+
+ getMockEndpoint("mock:resultA").expectedMessageCount(0);
+ template.sendBody("direct:startA", "a trigger");
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testMultipleAdvice() throws Exception {
+ context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("mock:resultA").process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ throw new Exception("my exception");
+ }
+ });
+ }
+ });
+
+ context.getRouteDefinition("RouteB").adviceWith(context, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ }
+ });
+
+ context.start();
+
+ getMockEndpoint("mock:resultA").expectedMessageCount(0);
+ template.sendBody("direct:startA", "a trigger");
+ assertMockEndpointsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java
new file mode 100644
index 0000000..d1bf95e
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java
@@ -0,0 +1,46 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class MockEndpointsAndSkipTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml");
+ }
+
+ @Override
+ public String isMockEndpointsAndSkip() {
+ return "seda*";
+ }
+
+ @Test
+ public void testHelloWorld() throws Exception {
+ getMockEndpoint("mock:seda:foo").expectedBodiesReceived("Hello World");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
new file mode 100644
index 0000000..0a13b66
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
@@ -0,0 +1,40 @@
+/**
+ * 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.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+public class DebugSpringCamelContextTest extends DebugSpringTest {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // there is no route to be used
+ }
+ };
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/applicationContext.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
new file mode 100644
index 0000000..482e2ef
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class DebugSpringTest extends CamelSpringTestSupport {
+ private boolean debugged;
+
+ @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());
+ debugged = true;
+ }
+
+
+ @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();
+ assertTrue("The debugger is not called!", debugged);
+ }
+
+ @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");
+ }
+ };
+ }
+
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new GenericApplicationContext();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
new file mode 100644
index 0000000..100b349
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+/**
+ *
+ */
+public class MyProduceBean {
+
+ @Produce(uri = "mock:result")
+ MySender sender;
+
+ @EndpointInject(uri = "direct:start")
+ ProducerTemplate template;
+
+ public void doSomething(String body) {
+ sender.send(body);
+ }
+
+ public ProducerTemplate getProducerTemplate() {
+ return template;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MySender.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MySender.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MySender.java
new file mode 100644
index 0000000..e36c042
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/MySender.java
@@ -0,0 +1,25 @@
+/**
+ * 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);
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
new file mode 100644
index 0000000..5d9417f
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class ProduceBeanTest extends CamelSpringTestSupport {
+
+ @Test
+ public void testProduceBean() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanTest.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
new file mode 100644
index 0000000..fd794c6
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ProducerBeanInjectTest extends Assert {
+
+ @Test
+ public void checkProducerBeanInjection() {
+ AbstractApplicationContext applicationContext = createApplicationContext();
+ MyProduceBean bean = applicationContext.getBean("myProduceBean", MyProduceBean.class);
+ assertNotNull("The producerTemplate should not be null.", bean.getProducerTemplate());
+ assertEquals("Get a wrong response", "Camel rocks!", bean.getProducerTemplate().requestBody("Camel"));
+ }
+
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanInjectTest.xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java
new file mode 100644
index 0000000..2478bf0
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+
+// START SNIPPET: e1
+
+/**
+ * Spring style testing with annotations to configure and setup the test.
+ * <p/>
+ * As we do next extend any base test class, we need to inject our resources
+ * for testing such as the {@link CamelContext} and {@link ProducerTemplate}.
+ */
+@ContextConfiguration
+@ActiveProfiles("test")
+@RunWith(CamelSpringJUnit4ClassRunner.class)
+public class CamelSpringActiveProfileTest {
+
+ @Autowired
+ protected CamelContext camelContext;
+ @Produce(uri = "direct:start", context = "camelContext")
+ protected ProducerTemplate start;
+
+ @Test
+ public void testLoadActiveProfile() throws InterruptedException {
+ MockEndpoint mock = camelContext.getEndpoint("mock:test", MockEndpoint.class);
+ mock.expectedBodiesReceived("Hello World");
+ start.sendBody("World");
+ mock.assertIsSatisfied();
+ }
+
+}
+// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
new file mode 100644
index 0000000..89c1105
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
@@ -0,0 +1,32 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.management.DefaultManagementStrategy;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+@DisableJmx
+public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest
+ extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
+
+ @Test
+ public void testJmx() throws Exception {
+ assertEquals(DefaultManagementStrategy.class, camelContext.getManagementStrategy().getClass());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
new file mode 100644
index 0000000..b0630e5
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
@@ -0,0 +1,21 @@
+/**
+ * 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.spring;
+
+public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest
+ extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
new file mode 100644
index 0000000..67cfd7b
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.management.ManagedManagementStrategy;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+@DisableJmx(false)
+public class CamelSpringJUnit4ClassRunnerDisableJmxTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Test
+ @Override
+ public void testJmx() throws Exception {
+ assertEquals(ManagedManagementStrategy.class, camelContext.getManagementStrategy().getClass());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
new file mode 100644
index 0000000..1d9d2ad
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.spring;
+
+import static org.junit.Assert.assertNull;
+
+@ExcludeRoutes(TestRouteBuilder.class)
+public class CamelSpringJUnit4ClassRunnerExcludeRoutesTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Override
+ public void testExcludedRoute() {
+ assertNull(camelContext.getRoute("excludedRoute"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
new file mode 100644
index 0000000..37d2c1d
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+@SuppressWarnings("deprecation")
+@LazyLoadTypeConverters(true)
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest
+ extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest {
+
+ @Test
+ @Override
+ public void testLazyLoadTypeConverters() {
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
new file mode 100644
index 0000000..229e3c9
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
@@ -0,0 +1,21 @@
+/**
+ * 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.spring;
+
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest
+ extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest {
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
new file mode 100644
index 0000000..20bc31a
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
@@ -0,0 +1,33 @@
+/**
+ * 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.spring;
+
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+
+@SuppressWarnings("deprecation")
+@LazyLoadTypeConverters(false)
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Test
+ @Override
+ public void testLazyLoadTypeConverters() {
+ assertFalse(camelContext.isLazyLoadTypeConverters());
+ assertFalse(camelContext2.isLazyLoadTypeConverters());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java
new file mode 100644
index 0000000..d20e72b
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.seda.SedaEndpoint;
+import org.apache.camel.impl.InterceptSendToEndpoint;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@MockEndpointsAndSkip("seda:*")
+public class CamelSpringJUnit4ClassRunnerMockEndpointsAndSkipTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @EndpointInject(uri = "mock:seda:context2.seda", context = "camelContext2")
+ protected MockEndpoint mock;
+
+ @EndpointInject(uri = "seda:context2.seda", context = "camelContext2")
+ private InterceptSendToEndpoint original;
+
+ @Test
+ @Override
+ public void testPositive() throws Exception {
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived("David");
+ mockB.expectedBodiesReceived("Hello David");
+ mock.expectedBodiesReceived("Hello David");
+
+ start.sendBody("David");
+ start2.sendBody("David");
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ MockEndpoint.assertIsSatisfied(camelContext2);
+ assertTrue("Original endpoint was invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
new file mode 100644
index 0000000..73dac9f
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.seda.SedaEndpoint;
+import org.apache.camel.impl.InterceptSendToEndpoint;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@MockEndpoints("seda:context2.seda")
+public class CamelSpringJUnit4ClassRunnerMockEndpointsTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @EndpointInject(uri = "mock:seda:context2.seda", context = "camelContext2")
+ protected MockEndpoint mock;
+
+ @EndpointInject(uri = "seda:context2.seda", context = "camelContext2")
+ private InterceptSendToEndpoint original;
+
+ @Test
+ @Override
+ public void testPositive() throws Exception {
+
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived("David");
+ mockB.expectedBodiesReceived("Hello David");
+ mockC.expectedBodiesReceived("David");
+ mock.expectedBodiesReceived("Hello David");
+
+ start.sendBody("David");
+ start2.sendBody("David");
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ MockEndpoint.assertIsSatisfied(camelContext2);
+ assertTrue("Original endpoint should be invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().size() == 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
new file mode 100644
index 0000000..337d387
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
@@ -0,0 +1,126 @@
+/**
+ * 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.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.management.DefaultManagementStrategy;
+import org.apache.camel.util.StopWatch;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+import org.springframework.test.context.ContextConfiguration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+// START SNIPPET: e1
+@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration
+// Put here to prevent Spring context caching across tests and test methods since some tests inherit
+// from this test and therefore use the same Spring context. Also because we want to reset the
+// Camel context and mock endpoints between test methods automatically.
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+public class CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Autowired
+ protected CamelContext camelContext;
+
+ @Autowired
+ protected CamelContext camelContext2;
+
+ @EndpointInject(uri = "mock:a", context = "camelContext")
+ protected MockEndpoint mockA;
+
+ @EndpointInject(uri = "mock:b", context = "camelContext")
+ protected MockEndpoint mockB;
+
+ @EndpointInject(uri = "mock:c", context = "camelContext2")
+ protected MockEndpoint mockC;
+
+ @Produce(uri = "direct:start", context = "camelContext")
+ protected ProducerTemplate start;
+
+ @Produce(uri = "direct:start2", context = "camelContext2")
+ protected ProducerTemplate start2;
+
+ @Test
+ public void testPositive() throws Exception {
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived("David");
+ mockB.expectedBodiesReceived("Hello David");
+ mockC.expectedBodiesReceived("David");
+
+ start.sendBody("David");
+ start2.sendBody("David");
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ MockEndpoint.assertIsSatisfied(camelContext2);
+ }
+
+ @Test
+ public void testJmx() throws Exception {
+ assertEquals(DefaultManagementStrategy.class, camelContext.getManagementStrategy().getClass());
+ }
+
+ @Test
+ public void testShutdownTimeout() throws Exception {
+ assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.SECONDS, camelContext.getShutdownStrategy().getTimeUnit());
+ }
+
+ @Test
+ public void testStopwatch() {
+ StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
+
+ assertNotNull(stopWatch);
+ assertTrue(stopWatch.taken() < 100);
+ }
+
+ @Test
+ public void testExcludedRoute() {
+ assertNotNull(camelContext.getRoute("excludedRoute"));
+ }
+
+ @Test
+ public void testProvidesBreakpoint() {
+ assertNull(camelContext.getDebugger());
+ assertNull(camelContext2.getDebugger());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testLazyLoadTypeConverters() {
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
+// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
new file mode 100644
index 0000000..98d47e8
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
@@ -0,0 +1,22 @@
+/**
+ * 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.spring;
+
+public class CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest
+ extends CamelSpringJUnit4ClassRunnerProvidesBreakpointTest {
+
+}
[2/7] CAMEL-7835: camel-test-spring40 for spring 4.0 only. And
camel-test-spring for spring 4.1 or newer.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
deleted file mode 100644
index aa75c0e..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
+++ /dev/null
@@ -1,99 +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.spring;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.camel.spring.SpringCamelContext;
-
-import org.springframework.context.ApplicationContext;
-
-/**
- * Helper that provides state information across the levels of Spring Test that do not expose the
- * necessary context/state for integration of Camel testing features into Spring test. Also
- * provides utility methods.
- * <p/>
- * Note that this class makes use of {@link ThreadLocal}s to maintain some state. It is imperative
- * that the state setters and getters are accessed within the scope of a single thread in order
- * for this class to work right.
- */
-public final class CamelSpringTestHelper {
-
- private static ThreadLocal<String> originalJmxDisabledValue = new ThreadLocal<String>();
- private static ThreadLocal<Class<?>> testClazz = new ThreadLocal<Class<?>>();
-
- private CamelSpringTestHelper() {
- }
-
- public static String getOriginalJmxDisabled() {
- return originalJmxDisabledValue.get();
- }
-
- public static void setOriginalJmxDisabledValue(String originalValue) {
- originalJmxDisabledValue.set(originalValue);
- }
-
- public static Class<?> getTestClass() {
- return testClazz.get();
- }
-
- public static void setTestClass(Class<?> testClass) {
- testClazz.set(testClass);
- }
-
- /**
- * Returns all methods defined in {@code clazz} and its superclasses/interfaces.
- */
- public static Collection<Method> getAllMethods(Class<?> clazz) {
- Set<Method> methods = new LinkedHashSet<Method>();
- Class<?> currentClass = clazz;
-
- while (currentClass != null) {
- methods.addAll(Arrays.asList(clazz.getMethods()));
- currentClass = currentClass.getSuperclass();
- }
-
- return methods;
- }
-
- /**
- * Executes {@code strategy} against all {@link SpringCamelContext}s found in the Spring context.
- * This method reduces the amount of repeated find and loop code throughout this class.
- *
- * @param context the Spring context to search
- * @param strategy the strategy to execute against the found {@link SpringCamelContext}s
- *
- * @throws Exception if there is an error executing any of the strategies
- */
- public static void doToSpringCamelContexts(ApplicationContext context, DoToSpringCamelContextsStrategy strategy) throws Exception {
- Map<String, SpringCamelContext> contexts = context.getBeansOfType(SpringCamelContext.class);
-
- for (Entry<String, SpringCamelContext> entry : contexts.entrySet()) {
- strategy.execute(entry.getKey(), entry.getValue());
- }
- }
-
- public interface DoToSpringCamelContextsStrategy {
- void execute(String contextName, SpringCamelContext camelContext) throws Exception;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
deleted file mode 100644
index b855b40..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
+++ /dev/null
@@ -1,220 +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.spring;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.spring.CamelBeanPostProcessor;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.test.ExcludingPackageScanClassResolver;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-
-/**
- * @version
- */
-public abstract class CamelSpringTestSupport extends CamelTestSupport {
- protected static ThreadLocal<AbstractApplicationContext> threadAppContext = new ThreadLocal<AbstractApplicationContext>();
- protected static Object lock = new Object();
-
- protected AbstractApplicationContext applicationContext;
- protected abstract AbstractApplicationContext createApplicationContext();
-
- /**
- * Lets post process this test instance to process any Camel annotations.
- * Note that using Spring Test or Guice is a more powerful approach.
- */
- @Override
- public void postProcessTest() throws Exception {
- super.postProcessTest();
- if (isCreateCamelContextPerClass()) {
- applicationContext = threadAppContext.get();
- }
-
- // use the bean post processor from camel-spring
- CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
- processor.setApplicationContext(applicationContext);
- processor.setCamelContext(context);
- processor.postProcessBeforeInitialization(this, getClass().getName());
- processor.postProcessAfterInitialization(this, getClass().getName());
- }
-
- @Override
- public void doPreSetup() throws Exception {
- if (!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
- // tell camel-spring it should not trigger starting CamelContext, since we do that later
- // after we are finished setting up the unit test
- synchronized (lock) {
- SpringCamelContext.setNoStart(true);
- if (isCreateCamelContextPerClass()) {
- applicationContext = threadAppContext.get();
- if (applicationContext == null) {
- applicationContext = doCreateApplicationContext();
- threadAppContext.set(applicationContext);
- }
- } else {
- applicationContext = doCreateApplicationContext();
- }
- SpringCamelContext.setNoStart(false);
- }
- } else {
- log.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
- }
- }
-
- private AbstractApplicationContext doCreateApplicationContext() {
- AbstractApplicationContext context = createApplicationContext();
- assertNotNull("Should have created a valid Spring application context", context);
-
- String[] profiles = activeProfiles();
- if (profiles != null && profiles.length > 0) {
- // the context must not be active
- if (context.isActive()) {
- throw new IllegalStateException("Cannot active profiles: " + Arrays.asList(profiles) + " on active Spring application context: " + context
- + ". The code in your createApplicationContext() method should be adjusted to create the application context with refresh = false as parameter");
- }
- log.info("Spring activating profiles: {}", Arrays.asList(profiles));
- context.getEnvironment().setActiveProfiles(profiles);
- }
-
- // ensure the context has been refreshed at least once
- if (!context.isActive()) {
- context.refresh();
- }
-
- return context;
- }
-
- @Override
- @After
- public void tearDown() throws Exception {
- super.tearDown();
-
- if (!isCreateCamelContextPerClass()) {
- IOHelper.close(applicationContext);
- applicationContext = null;
- }
- }
-
- @AfterClass
- public static void tearSpringDownAfterClass() throws Exception {
- if (threadAppContext.get() != null) {
- IOHelper.close(threadAppContext.get());
- threadAppContext.remove();
- }
- }
-
- /**
- * Create a parent context that initializes a
- * {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given classes from
- * being resolved. Typically this is used at test time to exclude certain routes,
- * which might otherwise be just noisy, from being discovered and initialized.
- * <p/>
- * To use this filtering mechanism it is necessary to provide the
- * {@link org.springframework.context.ApplicationContext} returned from here as the parent context to
- * your test context e.g.
- *
- * <pre>
- * protected AbstractXmlApplicationContext createApplicationContext() {
- * return new ClassPathXmlApplicationContext(new String[] {"test-context.xml"}, getRouteExcludingApplicationContext());
- * }
- * </pre>
- *
- * This will, in turn, call the template methods <code>excludedRoutes</code>
- * and <code>excludedRoute</code> to determine the classes to be excluded from scanning.
- *
- * @return ApplicationContext a parent {@link org.springframework.context.ApplicationContext} configured
- * to exclude certain classes from package scanning
- */
- protected ApplicationContext getRouteExcludingApplicationContext() {
- GenericApplicationContext routeExcludingContext = new GenericApplicationContext();
- routeExcludingContext.registerBeanDefinition("excludingResolver", new RootBeanDefinition(ExcludingPackageScanClassResolver.class));
- routeExcludingContext.refresh();
-
- ExcludingPackageScanClassResolver excludingResolver = routeExcludingContext.getBean("excludingResolver", ExcludingPackageScanClassResolver.class);
- List<Class<?>> excluded = Arrays.asList(excludeRoutes());
- excludingResolver.setExcludedClasses(new HashSet<Class<?>>(excluded));
-
- return routeExcludingContext;
- }
-
- /**
- * Template method used to exclude {@link org.apache.camel.Route} from the test time context
- * route scanning
- *
- * @return Class[] the classes to be excluded from test time context route scanning
- */
- protected Class<?>[] excludeRoutes() {
- Class<?> excludedRoute = excludeRoute();
- return excludedRoute != null ? new Class[] {excludedRoute} : new Class[0];
- }
-
- /**
- * Template method used to exclude a {@link org.apache.camel.Route} from the test camel context
- */
- protected Class<?> excludeRoute() {
- return null;
- }
-
- /**
- * Looks up the mandatory spring bean of the given name and type, failing if
- * it is not present or the correct type
- */
- public <T> T getMandatoryBean(Class<T> type, String name) {
- Object value = applicationContext.getBean(name);
- assertNotNull("No spring bean found for name <" + name + ">", value);
- if (type.isInstance(value)) {
- return type.cast(value);
- } else {
- fail("Spring bean <" + name + "> is not an instanceof " + type.getName() + " but is of type " + ObjectHelper.className(value));
- return null;
- }
- }
-
- /**
- * Which active profiles should be used.
- * <p/>
- * <b>Important:</b> When using active profiles, then the code in {@link #createApplicationContext()} should create
- * the Spring {@link org.springframework.context.support.AbstractApplicationContext} without refreshing. For example creating an
- * {@link org.springframework.context.support.ClassPathXmlApplicationContext} you would need to pass in
- * <tt>false</tt> in the refresh parameter, in the constructor.
- * Camel will thrown an {@link IllegalStateException} if this is not correct stating this problem.
- * The reason is that we cannot active profiles <b>after</b> a Spring application context has already
- * been refreshed, and is active.
- *
- * @return an array of active profiles to use, use <tt>null</tt> to not use any active profiles.
- */
- protected String[] activeProfiles() {
- return null;
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- // don't start the springCamelContext if we
- return SpringCamelContext.springCamelContext(applicationContext, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java
deleted file mode 100644
index 169eed1..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.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.spring;
-
-import org.springframework.test.context.ContextLoader;
-import org.springframework.test.context.support.DefaultTestContextBootstrapper;
-
-/**
- * To boostrap Camel for testing with Spring 4.1 onwards.
- */
-public class CamelTestContextBootstrapper extends DefaultTestContextBootstrapper {
-
- @Override
- protected Class<? extends ContextLoader> getDefaultContextLoaderClass(Class<?> testClass) {
- return CamelSpringTestContextLoader.class;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmx.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmx.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmx.java
deleted file mode 100644
index 1dd0ab1..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmx.java
+++ /dev/null
@@ -1,43 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates if JMX should be globally disabled in the {@code CamelContext}s that are bootstrapped
- * during the test through the use of Spring Test loaded application contexts. Note that the
- * presence of this annotation will result in the manipulation of System Properties that
- * will affect Camel contexts constructed outside of the Spring Test loaded application contexts.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface DisableJmx {
-
- /**
- * Whether the test annotated with this annotation should be run with JMX disabled in Camel.
- * Defaults to {@code true}.
- */
- boolean value() default true;
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
deleted file mode 100644
index 1f16ebc..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
+++ /dev/null
@@ -1,39 +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.spring;
-
-import org.apache.camel.management.JmxSystemPropertyKeys;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-/**
- * Provides reset to pre-test state behavior for global enable/disable of JMX
- * support in Camel through the use of {@link DisableJmx}.
- * Tries to ensure that the pre-test value is restored.
- */
-public class DisableJmxTestExecutionListener extends AbstractTestExecutionListener {
-
- @Override
- public void afterTestClass(TestContext testContext) throws Exception {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED, CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
deleted file mode 100644
index 2b1617d..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
+++ /dev/null
@@ -1,44 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.RoutesBuilder;
-
-/**
- * Indicates if certain route builder classes should be excluded from discovery.
- * Initializes a {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given
- * classes from being resolved. Typically this is used at test time to exclude certain routes,
- * which might otherwise be noisy, from being discovered and initialized.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface ExcludeRoutes {
-
- /**
- * The classes to exclude from resolution when using package scanning.
- */
- Class<? extends RoutesBuilder>[] value() default {};
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
deleted file mode 100644
index dc5e349..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
+++ /dev/null
@@ -1,44 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates if the {@code CamelContext}s that are bootstrapped during the test through the use of Spring Test
- * loaded application contexts should use lazy loading of type converters.
- *
- * @deprecated See <a href="https://issues.apache.org/jira/browse/CAMEL-5011">CAMEL-5011</a> for more details.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-@Deprecated
-public @interface LazyLoadTypeConverters {
-
- /**
- * Whether the test annotated with this annotation should be run with lazy type converter loading in Camel.
- * Defaults to {@code false}.
- */
- boolean value() default false;
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpoints.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
deleted file mode 100644
index ff3f282..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
+++ /dev/null
@@ -1,43 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
-
-/**
- * Triggers the auto-mocking of endpoints whose URIs match the provided filter. The default
- * filter is "*" which matches all endpoints. See {@link InterceptSendToMockEndpointStrategy} for
- * more details on the registration of the mock endpoints.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface MockEndpoints {
-
- /**
- * The pattern to use for matching endpoints to enable mocking on.
- */
- String value() default "*";
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
deleted file mode 100644
index 1eb7e0f..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/MockEndpointsAndSkip.java
+++ /dev/null
@@ -1,43 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
-
-/**
- * Triggers the auto-mocking of endpoints whose URIs match the provided filter with the added provision
- * that the endpoints are also skipped. The default filter is "*" which matches all endpoints.
- * See {@link InterceptSendToMockEndpointStrategy} for more details on the registration of the mock endpoints.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface MockEndpointsAndSkip {
-
- /**
- * The pattern to use for matching endpoints to enable mocking on.
- */
- String value() default "*";
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
deleted file mode 100644
index 3aea7d8..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
+++ /dev/null
@@ -1,36 +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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.spi.Breakpoint;
-
-/**
- * Indicates that the annotated method returns a {@link Breakpoint} for use in the test. Useful for intercepting
- * traffic to all endpoints or simply for setting a break point in an IDE for debugging. The method must
- * be {@code public}, {@code static}, take no arguments, and return {@link Breakpoint}.
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface ProvidesBreakpoint {
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
deleted file mode 100644
index 2ce1ccd..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Indicates to set the shutdown timeout of all {@code CamelContext}s instantiated through the
- * use of Spring Test loaded application contexts. If no annotation is used, the timeout is
- * automatically reduced to 10 seconds by the test framework. If the annotation is present the
- * shutdown timeout is set based on the value of {@link #value()}.
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface ShutdownTimeout {
-
- /**
- * The shutdown timeout to set on the {@code CamelContext}(s).
- * Defaults to {@code 10} seconds.
- */
- int value() default 10;
-
- /**
- * The time unit that {@link #value()} is in.
- */
- TimeUnit timeUnit() default TimeUnit.SECONDS;
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
deleted file mode 100644
index 8796dfe..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.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.spring;
-
-import org.apache.camel.util.StopWatch;
-import org.apache.camel.util.TimeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-/**
- * An execution listener that simulates the timing output built in to {@link org.apache.camel.test.junit4.CamelTestSupport}.
- */
-public class StopWatchTestExecutionListener extends AbstractTestExecutionListener {
-
- protected static ThreadLocal<StopWatch> threadStopWatch = new ThreadLocal<StopWatch>();
-
- /**
- * Exists primarily for testing purposes, but allows for access to the underlying stop watch instance for a test.
- */
- public static StopWatch getStopWatch() {
- return threadStopWatch.get();
- }
-
- @Override
- public void beforeTestMethod(TestContext testContext) throws Exception {
- StopWatch stopWatch = new StopWatch();
- threadStopWatch.set(stopWatch);
- }
-
- @Override
- public void afterTestMethod(TestContext testContext) throws Exception {
- StopWatch watch = threadStopWatch.get();
- if (watch != null) {
- long time = watch.stop();
- Logger log = LoggerFactory.getLogger(testContext.getTestClass());
-
- log.info("********************************************************************************");
- log.info("Testing done: " + testContext.getTestMethod().getName() + "(" + testContext.getTestClass().getName() + ")");
- log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
- log.info("********************************************************************************");
-
- threadStopWatch.remove();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
deleted file mode 100644
index 71487d1..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/UseAdviceWith.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.spring;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.camel.CamelContext;
-
-/**
- * Indicates the use of {@code adviceWith()} within the test class. If a class is annotated with
- * this annotation and {@link UseAdviceWith#value()} returns true, any
- * {@code CamelContext}s bootstrapped during the test through the use of Spring Test loaded
- * application contexts will not be started automatically. The test author is responsible for
- * injecting the Camel contexts into the test and executing {@link CamelContext#start()} on them
- * at the appropriate time after any advice has been applied to the routes in the Camel context(s).
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface UseAdviceWith {
-
- /**
- * Whether the test annotated with this annotation should be treated as if
- * {@code adviceWith()} is in use in the test and the Camel contexts should not be started
- * automatically.
- * Defaults to {@code true}.
- */
- boolean value() default true;
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/resources/META-INF/LICENSE.txt b/components/camel-test-spring41/src/main/resources/META-INF/LICENSE.txt
deleted file mode 100755
index 6b0b127..0000000
--- a/components/camel-test-spring41/src/main/resources/META-INF/LICENSE.txt
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/resources/META-INF/NOTICE.txt b/components/camel-test-spring41/src/main/resources/META-INF/NOTICE.txt
deleted file mode 100644
index 2e215bf..0000000
--- a/components/camel-test-spring41/src/main/resources/META-INF/NOTICE.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Camel distribution. ==
- =========================================================================
-
- This product includes software developed by
- The Apache Software Foundation (http://www.apache.org/).
-
- Please read the different LICENSE files present in the licenses directory of
- this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java
deleted file mode 100644
index 839dbf9..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.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.issues;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.AdviceWithRouteBuilder;
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- *
- */
-public class AdviceWithOnExceptionMultipleIssueTest extends CamelSpringTestSupport {
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml");
- }
-
- @Override
- public boolean isUseAdviceWith() {
- return true;
- }
-
- @Test
- public void testSimpleMultipleAdvice() throws Exception {
- context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- interceptSendToEndpoint("mock:resultA").process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- }
- });
- }
- });
-
- context.getRouteDefinition("RouteB").adviceWith(context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- }
- });
-
- context.start();
-
- getMockEndpoint("mock:resultA").expectedMessageCount(1);
- template.sendBody("direct:startA", "a trigger");
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testMultipleAdviceWithExceptionThrown() throws Exception {
- context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- interceptSendToEndpoint("mock:resultA").process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- throw new Exception("my exception");
- }
- });
- }
- });
-
- context.start();
-
- getMockEndpoint("mock:resultA").expectedMessageCount(0);
- template.sendBody("direct:startA", "a trigger");
- assertMockEndpointsSatisfied();
- }
-
- @Test
- public void testMultipleAdvice() throws Exception {
- context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- interceptSendToEndpoint("mock:resultA").process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- throw new Exception("my exception");
- }
- });
- }
- });
-
- context.getRouteDefinition("RouteB").adviceWith(context, new AdviceWithRouteBuilder() {
- @Override
- public void configure() throws Exception {
- }
- });
-
- context.start();
-
- getMockEndpoint("mock:resultA").expectedMessageCount(0);
- template.sendBody("direct:startA", "a trigger");
- assertMockEndpointsSatisfied();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.java
deleted file mode 100644
index d1bf95e..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/issues/MockEndpointsAndSkipTest.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.issues;
-
-import org.apache.camel.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MockEndpointsAndSkipTest extends CamelSpringTestSupport {
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml");
- }
-
- @Override
- public String isMockEndpointsAndSkip() {
- return "seda*";
- }
-
- @Test
- public void testHelloWorld() throws Exception {
- getMockEndpoint("mock:seda:foo").expectedBodiesReceived("Hello World");
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
deleted file mode 100644
index 0a13b66..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringCamelContextTest.java
+++ /dev/null
@@ -1,40 +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.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-public class DebugSpringCamelContextTest extends DebugSpringTest {
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- // there is no route to be used
- }
- };
- }
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/applicationContext.xml");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
deleted file mode 100644
index 482e2ef..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
+++ /dev/null
@@ -1,81 +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.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-
-public class DebugSpringTest extends CamelSpringTestSupport {
- private boolean debugged;
-
- @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());
- debugged = true;
- }
-
-
- @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();
- assertTrue("The debugger is not called!", debugged);
- }
-
- @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");
- }
- };
- }
-
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- return new GenericApplicationContext();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
deleted file mode 100644
index 100b349..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MyProduceBean.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.patterns;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-
-/**
- *
- */
-public class MyProduceBean {
-
- @Produce(uri = "mock:result")
- MySender sender;
-
- @EndpointInject(uri = "direct:start")
- ProducerTemplate template;
-
- public void doSomething(String body) {
- sender.send(body);
- }
-
- public ProducerTemplate getProducerTemplate() {
- return template;
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MySender.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MySender.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/MySender.java
deleted file mode 100644
index e36c042..0000000
--- a/components/camel-test-spring41/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);
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
deleted file mode 100644
index 5d9417f..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProduceBeanTest.java
+++ /dev/null
@@ -1,42 +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.test.spring.CamelSpringTestSupport;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/**
- *
- */
-public class ProduceBeanTest extends CamelSpringTestSupport {
-
- @Test
- public void testProduceBean() throws Exception {
- getMockEndpoint("mock:result").expectedMessageCount(1);
-
- template.sendBody("direct:start", "Hello World");
-
- assertMockEndpointsSatisfied();
- }
-
- @Override
- protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanTest.xml");
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
deleted file mode 100644
index fd794c6..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/patterns/ProducerBeanInjectTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.patterns;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class ProducerBeanInjectTest extends Assert {
-
- @Test
- public void checkProducerBeanInjection() {
- AbstractApplicationContext applicationContext = createApplicationContext();
- MyProduceBean bean = applicationContext.getBean("myProduceBean", MyProduceBean.class);
- assertNotNull("The producerTemplate should not be null.", bean.getProducerTemplate());
- assertEquals("Get a wrong response", "Camel rocks!", bean.getProducerTemplate().requestBody("Camel"));
- }
-
- protected AbstractApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/test/patterns/ProduceBeanInjectTest.xml");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.java
deleted file mode 100644
index 2478bf0..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringActiveProfileTest.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.spring;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-
-// START SNIPPET: e1
-
-/**
- * Spring style testing with annotations to configure and setup the test.
- * <p/>
- * As we do next extend any base test class, we need to inject our resources
- * for testing such as the {@link CamelContext} and {@link ProducerTemplate}.
- */
-@ContextConfiguration
-@ActiveProfiles("test")
-@RunWith(CamelSpringJUnit4ClassRunner.class)
-public class CamelSpringActiveProfileTest {
-
- @Autowired
- protected CamelContext camelContext;
- @Produce(uri = "direct:start", context = "camelContext")
- protected ProducerTemplate start;
-
- @Test
- public void testLoadActiveProfile() throws InterruptedException {
- MockEndpoint mock = camelContext.getEndpoint("mock:test", MockEndpoint.class);
- mock.expectedBodiesReceived("Hello World");
- start.sendBody("World");
- mock.assertIsSatisfied();
- }
-
-}
-// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
deleted file mode 100644
index 89c1105..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.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.spring;
-
-import org.apache.camel.management.DefaultManagementStrategy;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-@DisableJmx
-public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest
- extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
-
- @Test
- public void testJmx() throws Exception {
- assertEquals(DefaultManagementStrategy.class, camelContext.getManagementStrategy().getClass());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
deleted file mode 100644
index b0630e5..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
+++ /dev/null
@@ -1,21 +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.spring;
-
-public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest
- extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
deleted file mode 100644
index 67cfd7b..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
+++ /dev/null
@@ -1,33 +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.spring;
-
-import org.apache.camel.management.ManagedManagementStrategy;
-
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-@DisableJmx(false)
-public class CamelSpringJUnit4ClassRunnerDisableJmxTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Test
- @Override
- public void testJmx() throws Exception {
- assertEquals(ManagedManagementStrategy.class, camelContext.getManagementStrategy().getClass());
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
deleted file mode 100644
index 1d9d2ad..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.spring;
-
-import static org.junit.Assert.assertNull;
-
-@ExcludeRoutes(TestRouteBuilder.class)
-public class CamelSpringJUnit4ClassRunnerExcludeRoutesTest
- extends CamelSpringJUnit4ClassRunnerPlainTest {
-
- @Override
- public void testExcludedRoute() {
- assertNull(camelContext.getRoute("excludedRoute"));
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java b/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
deleted file mode 100644
index 37d2c1d..0000000
--- a/components/camel-test-spring41/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
+++ /dev/null
@@ -1,33 +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.spring;
-
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
-@SuppressWarnings("deprecation")
-@LazyLoadTypeConverters(true)
-public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest
- extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest {
-
- @Test
- @Override
- public void testLazyLoadTypeConverters() {
- assertTrue(camelContext.isLazyLoadTypeConverters());
- assertTrue(camelContext2.isLazyLoadTypeConverters());
- }
-}
[6/7] git commit: Polished
Posted by da...@apache.org.
Polished
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a345799b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a345799b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a345799b
Branch: refs/heads/master
Commit: a345799bac056ae1e0a5ac08d62a59811d500b2f
Parents: 7764c32
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 21 17:25:22 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 21 17:25:52 2014 +0200
----------------------------------------------------------------------
components/camel-test-spring/pom.xml | 2 +-
components/camel-test-spring3/pom.xml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a345799b/components/camel-test-spring/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/pom.xml b/components/camel-test-spring/pom.xml
index a15f34a..dcc2152 100644
--- a/components/camel-test-spring/pom.xml
+++ b/components/camel-test-spring/pom.xml
@@ -28,7 +28,7 @@
<artifactId>camel-test-spring</artifactId>
<packaging>bundle</packaging>
- <name>Camel :: Test :: Spring</name>
+ <name>Camel :: Test :: Spring 4.1+</name>
<description>Camel Testing Library using JUnit and Spring 4.1+</description>
<properties>
http://git-wip-us.apache.org/repos/asf/camel/blob/a345799b/components/camel-test-spring3/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring3/pom.xml b/components/camel-test-spring3/pom.xml
index 7417b34..581c7b3 100644
--- a/components/camel-test-spring3/pom.xml
+++ b/components/camel-test-spring3/pom.xml
@@ -27,8 +27,8 @@
<artifactId>camel-test-spring3</artifactId>
<packaging>bundle</packaging>
- <name>Camel :: Test :: Spring</name>
- <description>Camel Testing Library using JUnit and Spring3</description>
+ <name>Camel :: Test :: Spring 3.x</name>
+ <description>Camel Testing Library using JUnit and Spring 3.x</description>
<properties>
<camel.osgi.export.pkg>org.apache.camel.test.spring.*</camel.osgi.export.pkg>
[3/7] CAMEL-7835: camel-test-spring40 for spring 4.0 only. And
camel-test-spring for spring 4.1 or newer.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
new file mode 100644
index 0000000..ae2d637
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.BreakpointSupport;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.spi.Breakpoint;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class CamelSpringJUnit4ClassRunnerProvidesBreakpointTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @ProvidesBreakpoint
+ public static Breakpoint createBreakpoint() {
+ return new TestBreakpoint();
+ }
+
+ @Test
+ @Override
+ public void testProvidesBreakpoint() {
+ assertNotNull(camelContext.getDebugger());
+ assertNotNull(camelContext2.getDebugger());
+
+ start.sendBody("David");
+
+ assertNotNull(camelContext.getDebugger());
+ assertNotNull(camelContext.getDebugger().getBreakpoints());
+ assertEquals(1, camelContext.getDebugger().getBreakpoints().size());
+
+ assertTrue(camelContext.getDebugger().getBreakpoints().get(0) instanceof TestBreakpoint);
+ assertTrue(((TestBreakpoint) camelContext.getDebugger().getBreakpoints().get(0)).isBreakpointHit());
+ }
+
+ private static final class TestBreakpoint extends BreakpointSupport {
+
+ private boolean breakpointHit;
+
+ @Override
+ public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
+ breakpointHit = true;
+ }
+
+ public boolean isBreakpointHit() {
+ return breakpointHit;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
new file mode 100644
index 0000000..c011d1f
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
@@ -0,0 +1,34 @@
+/**
+ * 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.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+@ShutdownTimeout
+public class CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest
+ extends CamelSpringJUnit4ClassRunnerShutdownTimeoutTest {
+
+ @Test
+ @Override
+ public void testShutdownTimeout() throws Exception {
+ assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.SECONDS, camelContext.getShutdownStrategy().getTimeUnit());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
new file mode 100644
index 0000000..9f66625
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
@@ -0,0 +1,22 @@
+/**
+ * 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.spring;
+
+public class CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest
+ extends CamelSpringJUnit4ClassRunnerShutdownTimeoutTest {
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
new file mode 100644
index 0000000..85a80ba
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
@@ -0,0 +1,34 @@
+/**
+ * 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.spring;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+@ShutdownTimeout(value = 11, timeUnit = TimeUnit.MILLISECONDS)
+public class CamelSpringJUnit4ClassRunnerShutdownTimeoutTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Test
+ @Override
+ public void testShutdownTimeout() throws Exception {
+ assertEquals(11, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.MILLISECONDS, camelContext.getShutdownStrategy().getTimeUnit());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
new file mode 100644
index 0000000..7cf5e06
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
@@ -0,0 +1,52 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.util.StopWatch;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@UseAdviceWith
+public class CamelSpringJUnit4ClassRunnerUseAdviceWithTest extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Before
+ public void testContextStarted() throws Exception {
+
+ assertEquals(ServiceStatus.Stopped, camelContext.getStatus());
+ assertEquals(ServiceStatus.Stopped, camelContext2.getStatus());
+ camelContext.start();
+ camelContext2.start();
+
+ // just sleep a little to simulate testing take a bit time
+ Thread.sleep(1000);
+ }
+
+ @Test
+ public void testStopwatch() {
+ StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
+
+ assertNotNull(stopWatch);
+ long taken = stopWatch.taken();
+ assertTrue(taken + " > 0, but was: " + taken, taken > 0);
+ assertTrue(taken + " < 3000, but was: " + taken, taken < 3000);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
new file mode 100644
index 0000000..7e7445c
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/CamelSpringTestSupportActiveProfileTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.spring;
+
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+// START SNIPPET: e1
+
+/**
+ * Just extend the CamelSpringTestSupport and use Camel test kit for easy Camel based unit testing.
+ */
+public class CamelSpringTestSupportActiveProfileTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ // must not refresh when using active profiles
+ // lets reuse the xml file from the other test
+ return new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml"}, false);
+ }
+
+ @Override
+ protected String[] activeProfiles() {
+ // return the active profiles to be used
+ return new String[]{"test"};
+ }
+
+ @Test
+ public void testLoadActiveProfile() throws InterruptedException {
+ getMockEndpoint("mock:test").expectedBodiesReceived("Hello World");
+ template.sendBody("direct:start", "World");
+ assertMockEndpointsSatisfied();
+ }
+
+}
+// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
new file mode 100644
index 0000000..52059c4
--- /dev/null
+++ b/components/camel-test-spring40/src/test/java/org/apache/camel/test/spring/TestRouteBuilder.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class TestRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:z")
+ .routeId("excludedRoute")
+ .to("log:org.apache.camel.test.junit4.spring");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/jndi.properties b/components/camel-test-spring40/src/test/resources/jndi.properties
new file mode 100644
index 0000000..5961589
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/jndi.properties
@@ -0,0 +1,22 @@
+## ---------------------------------------------------------------------------
+## 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.util.jndi.CamelInitialContextFactory
+
+# END SNIPPET: jndi
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/log4j.properties b/components/camel-test-spring40/src/test/resources/log4j.properties
new file mode 100644
index 0000000..1eb13a5
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/log4j.properties
@@ -0,0 +1,37 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for testing
+#
+log4j.rootLogger=INFO, file
+
+log4j.logger.org.springframework=WARN
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.test.junit4=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
+log4j.appender.file.file=target/camel-spring-test.log
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
new file mode 100644
index 0000000..76b18ed
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <onException>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to uri="mock:error"/>
+ </onException>
+
+ <route id="RouteA">
+ <from uri="direct:startA"/>
+ <to uri="mock:resultA"/>
+ </route>
+
+ <route id="RouteB">
+ <from uri="direct:startB"/>
+ <to uri="mock:resultB"/>
+ </route>
+
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
new file mode 100644
index 0000000..81b9093
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/issues/MockEndpointsAndSkipTest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:start"/>
+ <to uri="log:foo"/>
+ <to uri="seda:foo"/>
+ </route>
+
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
new file mode 100644
index 0000000..a697e1d
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanInjectTest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+
+ <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <transform>
+ <simple>${in.body} rocks!</simple>
+ </transform>
+ </route>
+ </camelContext>
+
+ <!--bean id="camelPostProcessBean" class="org.apache.camel.spring.CamelBeanPostProcessor" /-->
+
+ <bean id="myProduceBean" class="org.apache.camel.test.patterns.MyProduceBean"/>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
new file mode 100644
index 0000000..525ed01
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/ProduceBeanTest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:start"/>
+ <bean beanType="org.apache.camel.test.patterns.MyProduceBean"/>
+ </route>
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
new file mode 100644
index 0000000..081ae23
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/patterns/applicationContext.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+
+ <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true" >
+
+ <route>
+ <from uri="direct:start" />
+ <to uri="mock:a" />
+ <transform>
+ <simple>Hello ${body}</simple>
+ </transform>
+ <to uri="mock:b" />
+ </route>
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
new file mode 100644
index 0000000..ceacb2d
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:start" />
+ <transform>
+ <simple>Hello ${body}</simple>
+ </transform>
+ <to uri="properties:{{cool.end}}" />
+ </route>
+ </camelContext>
+
+ <!-- setup the profile for testing -->
+ <beans profile="test">
+ <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+ <property name="location" value="classpath:org/apache/camel/test/spring/test.properties"/>
+ </bean>
+ </beans>
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
new file mode 100644
index 0000000..ee2e7ce
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+ <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true">
+ <packageScan>
+ <package>org.apache.camel.test.spring</package>
+ </packageScan>
+ <route>
+ <from uri="direct:start"/>
+ <to uri="mock:a"/>
+ <transform>
+ <simple>Hello ${body}</simple>
+ </transform>
+ <to uri="mock:b"/>
+ </route>
+ </camelContext>
+
+ <camelContext id="camelContext2" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true">
+ <route>
+ <from uri="direct:start2"/>
+ <to uri="mock:c"/>
+ <transform>
+ <simple>Hello ${body}</simple>
+ </transform>
+ <to uri="log:org.apache.camel.test.junit4.spring"/>
+ <to uri="seda:context2.seda"/>
+ </route>
+ </camelContext>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/test.properties
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/test.properties b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/test.properties
new file mode 100644
index 0000000..f891086
--- /dev/null
+++ b/components/camel-test-spring40/src/test/resources/org/apache/camel/test/spring/test.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+cool.end=mock:test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/pom.xml b/components/camel-test-spring41/pom.xml
deleted file mode 100644
index 8f5666b..0000000
--- a/components/camel-test-spring41/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>2.15-SNAPSHOT</version>
- </parent>
-
- <artifactId>camel-test-spring41</artifactId>
- <packaging>bundle</packaging>
- <name>Camel :: Test :: Spring 4.1</name>
- <description>Camel Testing Library using JUnit and Spring 4.1</description>
-
- <properties>
- <camel.osgi.export.pkg>org.apache.camel.test.spring.*</camel.osgi.export.pkg>
- <spring-version>${spring41-version}</spring-version>
- <spring4-version>${spring41-version}</spring4-version>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <!-- we need to override the other spring version -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>${spring4-version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring4-version}</version>
- </dependency>
-
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
deleted file mode 100644
index a3bb4a3..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
+++ /dev/null
@@ -1,321 +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.spring;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.impl.DefaultDebugger;
-import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
-import org.apache.camel.management.JmxSystemPropertyKeys;
-import org.apache.camel.spi.Breakpoint;
-import org.apache.camel.spi.Debugger;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.AnnotationConfigUtils;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.test.context.MergedContextConfiguration;
-import org.springframework.test.context.support.DelegatingSmartContextLoader;
-
-import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
-
-
-
-/**
- * CamelSpringDelegatingTestContextLoader which fixes issues in Camel's JavaConfigContextLoader. (adds support for Camel's test annotations)
- * <br>
- * <em>This loader can handle either classes or locations for configuring the context.</em>
- * <br>
- * NOTE: This TestContextLoader doesn't support the annotation of ExcludeRoutes now.
- */
-public class CamelSpringDelegatingTestContextLoader extends DelegatingSmartContextLoader {
-
- protected final Logger logger = LoggerFactory.getLogger(getClass());
-
- @Override
- public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
-
- Class<?> testClass = getTestClass();
-
- if (logger.isDebugEnabled()) {
- logger.debug("Loading ApplicationContext for merged context configuration [{}].", mergedConfig);
- }
-
- // Pre CamelContext(s) instantiation setup
- handleDisableJmx(null, testClass);
-
- try {
- SpringCamelContext.setNoStart(true);
- ConfigurableApplicationContext context = (ConfigurableApplicationContext) super.loadContext(mergedConfig);
- SpringCamelContext.setNoStart(false);
- return loadContext(context, testClass);
- } finally {
- cleanup(testClass);
- }
- }
-
- /**
- * Performs the bulk of the Spring application context loading/customization.
- *
- * @param context the partially configured context. The context should have the bean definitions loaded, but nothing else.
- * @param testClass the test class being executed
- * @return the initialized (refreshed) Spring application context
- *
- * @throws Exception if there is an error during initialization/customization
- */
- public ApplicationContext loadContext(ConfigurableApplicationContext context, Class<?> testClass)
- throws Exception {
-
- AnnotationConfigUtils.registerAnnotationConfigProcessors((BeanDefinitionRegistry) context);
-
- // Post CamelContext(s) instantiation but pre CamelContext(s) start setup
- handleProvidesBreakpoint(context, testClass);
- handleShutdownTimeout(context, testClass);
- handleMockEndpoints(context, testClass);
- handleMockEndpointsAndSkip(context, testClass);
-
- // CamelContext(s) startup
- handleCamelContextStartup(context, testClass);
-
- return context;
- }
-
- /**
- * Cleanup/restore global state to defaults / pre-test values after the test setup
- * is complete.
- *
- * @param testClass the test class being executed
- */
- protected void cleanup(Class<?> testClass) {
- SpringCamelContext.setNoStart(false);
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED,
- CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
- }
-
- /**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleDisableJmx(ConfigurableApplicationContext context, Class<?> testClass) {
- CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (testClass.getAnnotation(DisableJmx.class).value()) {
- logger.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
-
- } else {
- logger.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- }
- } else {
- logger.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- }
- }
-
- /**
- * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
- * as it is needed in
- *
- * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
- * @param testClass the test class being processed
- *
- * @throws Exception if there is an error processing the class
- */
- protected void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length != 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
- } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not public.");
- }
-
- try {
- breakpoints.add((Breakpoint) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- if (breakpoints.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- Debugger debugger = camelContext.getDebugger();
- if (debugger == null) {
- debugger = new DefaultDebugger();
- camelContext.setDebugger(debugger);
- }
-
- for (Breakpoint breakpoint : breakpoints) {
- logger.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
- debugger.addBreakpoint(breakpoint);
- }
- }
- });
- }
- }
-
-
- /**
- * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleShutdownTimeout(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- final int shutdownTimeout;
- final TimeUnit shutdownTimeUnit;
- if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
- shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
- shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
- } else {
- shutdownTimeout = 10;
- shutdownTimeUnit = TimeUnit.SECONDS;
- }
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- logger.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", new Object[]{shutdownTimeout, shutdownTimeUnit, contextName});
- camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
- camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
- }
- });
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpoints(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpoints.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- logger.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
- }
- });
- }
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
- * original endpoint.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpointsAndSkip(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- logger.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints, true));
- }
- });
- }
- }
-
-
- /**
- * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleCamelContextStartup(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
- if (skip) {
- logger.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
- } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
- if (testClass.getAnnotation(UseAdviceWith.class).value()) {
- logger.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
- skip = true;
- } else {
- logger.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
- skip = false;
- }
- }
-
- if (!skip) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
- public void execute(String contextName,
- SpringCamelContext camelContext) throws Exception {
- logger.info("Starting CamelContext with name [{}].", contextName);
- camelContext.start();
- }
- });
- }
- }
-
- /**
- * Returns the class under test in order to enable inspection of annotations while the
- * Spring context is being created.
- *
- * @return the test class that is being executed
- * @see CamelSpringTestHelper
- */
- protected Class<?> getTestClass() {
- return CamelSpringTestHelper.getTestClass();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
deleted file mode 100644
index 3d88020..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.test.spring;
-
-import java.util.List;
-
-import org.junit.runners.model.InitializationError;
-import org.springframework.test.context.TestContextManager;
-import org.springframework.test.context.TestExecutionListener;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * An implementation bringing the functionality of {@link org.apache.camel.test.spring.CamelSpringTestSupport} to
- * Spring Test based test cases. This approach allows developers to implement tests
- * for their Spring based applications/routes using the typical Spring Test conventions
- * for test development.
- */
-public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
-
- public CamelSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError {
- super(clazz);
- }
-
- /**
- * Returns the specialized manager instance that provides tight integration between Camel testing
- * features and Spring.
- *
- * @return a new instance of {@link CamelTestContextManager}.
- */
- @Override
- protected TestContextManager createTestContextManager(Class<?> clazz) {
- return new CamelTestContextManager(clazz);
- }
-
- /**
- * An implementation providing additional integration between Spring Test and Camel
- * testing features.
- */
- public static final class CamelTestContextManager extends TestContextManager {
-
- public CamelTestContextManager(Class<?> testClass) {
- super(testClass);
-
- // inject Camel first, and then disable jmx and add the stop-watch
- List<TestExecutionListener> list = getTestExecutionListeners();
- list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
- list.add(new DisableJmxTestExecutionListener());
- list.add(new StopWatchTestExecutionListener());
- registerTestExecutionListeners(list);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
deleted file mode 100644
index e973b44..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
+++ /dev/null
@@ -1,473 +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.spring;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.impl.DefaultDebugger;
-import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
-import org.apache.camel.management.JmxSystemPropertyKeys;
-import org.apache.camel.spi.Breakpoint;
-import org.apache.camel.spi.Debugger;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.test.ExcludingPackageScanClassResolver;
-import org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.AnnotationConfigUtils;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.test.context.MergedContextConfiguration;
-import org.springframework.test.context.support.AbstractContextLoader;
-import org.springframework.test.context.support.AbstractGenericContextLoader;
-import org.springframework.test.context.support.GenericXmlContextLoader;
-import org.springframework.util.StringUtils;
-
-import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
-
-/**
- * Replacement for the default {@link GenericXmlContextLoader} that provides hooks for
- * processing some class level Camel related test annotations.
- */
-public class CamelSpringTestContextLoader extends AbstractContextLoader {
-
- private static final Logger LOG = LoggerFactory.getLogger(CamelSpringTestContextLoader.class);
-
- /**
- * Modeled after the Spring implementation in {@link AbstractGenericContextLoader},
- * this method creates and refreshes the application context while providing for
- * processing of additional Camel specific post-refresh actions. We do not provide the
- * pre-post hooks for customization seen in {@link AbstractGenericContextLoader} because
- * they probably are unnecessary for 90+% of users.
- * <p/>
- * For some functionality, we cannot use {@link org.springframework.test.context.TestExecutionListener} because we need
- * to both produce the desired outcome during application context loading, and also cleanup
- * after ourselves even if the test class never executes. Thus the listeners, which
- * only run if the application context is successfully initialized are insufficient to
- * provide the behavior described above.
- */
- @Override
- public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
- Class<?> testClass = getTestClass();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Loading ApplicationContext for merged context configuration [{}].", mergedConfig);
- }
-
- try {
- GenericApplicationContext context = createContext(testClass, mergedConfig);
- context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles());
- loadBeanDefinitions(context, mergedConfig);
- return loadContext(context, testClass);
- } finally {
- cleanup(testClass);
- }
- }
-
- /**
- * Modeled after the Spring implementation in {@link AbstractGenericContextLoader},
- * this method creates and refreshes the application context while providing for
- * processing of additional Camel specific post-refresh actions. We do not provide the
- * pre-post hooks for customization seen in {@link AbstractGenericContextLoader} because
- * they probably are unnecessary for 90+% of users.
- * <p/>
- * For some functionality, we cannot use {@link org.springframework.test.context.TestExecutionListener} because we need
- * to both produce the desired outcome during application context loading, and also cleanup
- * after ourselves even if the test class never executes. Thus the listeners, which
- * only run if the application context is successfully initialized are insufficient to
- * provide the behavior described above.
- */
- @Override
- public ApplicationContext loadContext(String... locations) throws Exception {
-
- Class<?> testClass = getTestClass();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Loading ApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "].");
- }
-
- try {
- GenericApplicationContext context = createContext(testClass, null);
- loadBeanDefinitions(context, locations);
- return loadContext(context, testClass);
- } finally {
- cleanup(testClass);
- }
- }
-
- /**
- * Returns "<code>-context.xml</code>".
- */
- @Override
- public String getResourceSuffix() {
- return "-context.xml";
- }
-
- /**
- * Performs the bulk of the Spring application context loading/customization.
- *
- * @param context the partially configured context. The context should have the bean definitions loaded, but nothing else.
- * @param testClass the test class being executed
- * @return the initialized (refreshed) Spring application context
- *
- * @throws Exception if there is an error during initialization/customization
- */
- protected ApplicationContext loadContext(GenericApplicationContext context, Class<?> testClass) throws Exception {
-
- AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
-
- // Pre CamelContext(s) instantiation setup
- handleDisableJmx(context, testClass);
-
- // Temporarily disable CamelContext start while the contexts are instantiated.
- SpringCamelContext.setNoStart(true);
- context.refresh();
- context.registerShutdownHook();
- // Turn CamelContext startup back on since the context's have now been instantiated.
- SpringCamelContext.setNoStart(false);
-
- // Post CamelContext(s) instantiation but pre CamelContext(s) start setup
- handleProvidesBreakpoint(context, testClass);
- handleShutdownTimeout(context, testClass);
- handleMockEndpoints(context, testClass);
- handleMockEndpointsAndSkip(context, testClass);
- handleLazyLoadTypeConverters(context, testClass);
-
- // CamelContext(s) startup
- handleCamelContextStartup(context, testClass);
-
- return context;
- }
-
- /**
- * Cleanup/restore global state to defaults / pre-test values after the test setup
- * is complete.
- *
- * @param testClass the test class being executed
- */
- protected void cleanup(Class<?> testClass) {
- SpringCamelContext.setNoStart(false);
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED,
- CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
- }
-
- protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(mergedConfig.getLocations());
- }
-
- protected void loadBeanDefinitions(GenericApplicationContext context, String... locations) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(locations);
- }
-
- /**
- * Creates and starts the Spring context while optionally starting any loaded Camel contexts.
- *
- * @param testClass the test class that is being executed
- * @return the loaded Spring context
- */
- protected GenericApplicationContext createContext(Class<?> testClass, MergedContextConfiguration mergedConfig) {
- ApplicationContext parentContext = null;
- GenericApplicationContext routeExcludingContext = null;
-
- if (mergedConfig != null) {
- parentContext = mergedConfig.getParentApplicationContext();
-
- }
-
- if (testClass.isAnnotationPresent(ExcludeRoutes.class)) {
- Class<?>[] excludedClasses = testClass.getAnnotation(ExcludeRoutes.class).value();
-
- if (excludedClasses.length > 0) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Setting up package scanning excluded classes as ExcludeRoutes "
- + "annotation was found. Excluding [" + StringUtils.arrayToCommaDelimitedString(excludedClasses) + "].");
- }
-
- if (parentContext == null) {
- routeExcludingContext = new GenericApplicationContext();
- } else {
- routeExcludingContext = new GenericApplicationContext(parentContext);
- }
- routeExcludingContext.registerBeanDefinition("excludingResolver", new RootBeanDefinition(ExcludingPackageScanClassResolver.class));
- routeExcludingContext.refresh();
-
- ExcludingPackageScanClassResolver excludingResolver = routeExcludingContext.getBean("excludingResolver", ExcludingPackageScanClassResolver.class);
- List<Class<?>> excluded = Arrays.asList(excludedClasses);
- excludingResolver.setExcludedClasses(new HashSet<Class<?>>(excluded));
- } else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Not enabling package scanning excluded classes as ExcludeRoutes "
- + "annotation was found but no classes were excluded.");
- }
- }
- }
-
- GenericApplicationContext context;
-
- if (routeExcludingContext != null) {
- context = new GenericApplicationContext(routeExcludingContext);
- } else {
- if (parentContext != null) {
- context = new GenericApplicationContext(parentContext);
- } else {
- context = new GenericApplicationContext();
- }
- }
-
- return context;
- }
-
- /**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleDisableJmx(GenericApplicationContext context, Class<?> testClass) {
- CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (testClass.getAnnotation(DisableJmx.class).value()) {
- LOG.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- } else {
- LOG.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- }
- } else {
- LOG.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- }
- }
-
- /**
- * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
- * as it is needed in
- *
- * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
- * @param testClass the test class being processed
- *
- * @throws Exception if there is an error processing the class
- */
- protected void handleProvidesBreakpoint(GenericApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length != 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
- } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not public.");
- }
-
- try {
- breakpoints.add((Breakpoint) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- if (breakpoints.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- Debugger debugger = camelContext.getDebugger();
- if (debugger == null) {
- debugger = new DefaultDebugger();
- camelContext.setDebugger(debugger);
- }
-
- for (Breakpoint breakpoint : breakpoints) {
- LOG.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
- debugger.addBreakpoint(breakpoint);
- }
- }
- });
- }
- }
-
-
- /**
- * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleShutdownTimeout(GenericApplicationContext context, Class<?> testClass) throws Exception {
- final int shutdownTimeout;
- final TimeUnit shutdownTimeUnit;
- if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
- shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
- shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
- } else {
- shutdownTimeout = 10;
- shutdownTimeUnit = TimeUnit.SECONDS;
- }
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", new Object[]{shutdownTimeout, shutdownTimeUnit, contextName});
- camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
- camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
- }
- });
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpoints(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpoints.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
- }
- });
- }
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
- * original endpoint.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpointsAndSkip(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints, true));
- }
- });
- }
- }
-
- @SuppressWarnings("deprecation")
- protected void handleLazyLoadTypeConverters(GenericApplicationContext context, Class<?> testClass) throws Exception {
- final boolean lazy;
-
- if (testClass.isAnnotationPresent(LazyLoadTypeConverters.class)) {
- lazy = testClass.getAnnotation(LazyLoadTypeConverters.class).value();
- } else {
- lazy = true;
- }
-
- if (lazy) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Enabling lazy loading of type converters on CamelContext with name [{}].", contextName);
- camelContext.setLazyLoadTypeConverters(lazy);
- }
- });
- }
- }
-
- /**
- * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleCamelContextStartup(GenericApplicationContext context, Class<?> testClass) throws Exception {
- boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
- if (skip) {
- LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
- } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
- if (testClass.getAnnotation(UseAdviceWith.class).value()) {
- LOG.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
- skip = true;
- } else {
- LOG.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
- skip = false;
- }
- }
-
- if (!skip) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName,
- SpringCamelContext camelContext) throws Exception {
- LOG.info("Starting CamelContext with name [{}].", contextName);
- camelContext.start();
- }
- });
- }
- }
-
- /**
- * Returns the class under test in order to enable inspection of annotations while the
- * Spring context is being created.
- *
- * @return the test class that is being executed
- * @see CamelSpringTestHelper
- */
- protected Class<?> getTestClass() {
- return CamelSpringTestHelper.getTestClass();
- }
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java b/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
deleted file mode 100644
index c96943d..0000000
--- a/components/camel-test-spring41/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
+++ /dev/null
@@ -1,36 +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.spring;
-
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-/**
- * Helper for {@link CamelSpringTestContextLoader} that sets the test class state
- * in {@link CamelSpringTestHelper} almost immediately before the loader initializes
- * the Spring context.
- * <p/>
- * Implemented as a listener as the state can be set on a {@code ThreadLocal} and we are pretty sure
- * that the same thread will be used to initialize the Spring context.
- */
-public class CamelSpringTestContextLoaderTestExecutionListener extends AbstractTestExecutionListener {
-
- @Override
- public void prepareTestInstance(TestContext testContext) throws Exception {
- CamelSpringTestHelper.setTestClass(testContext.getTestClass());
- }
-}
[7/7] git commit: CAMEL-7835: Added itest for spring 4.0.x
Posted by da...@apache.org.
CAMEL-7835: Added itest for spring 4.0.x
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/87372099
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/87372099
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/87372099
Branch: refs/heads/master
Commit: 87372099454814552ef7c4e08e756d784cbed3b2
Parents: a345799
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 21 17:35:32 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 21 17:35:32 2014 +0200
----------------------------------------------------------------------
tests/camel-itest-spring40/pom.xml | 75 +++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../camel/itest/spring40/JmsRouteTest.java | 48 +++++
.../src/test/resources/log4j.properties | 37 ++++
.../camel/itest/spring40/JmsRouteTest.xml | 47 +++++
tests/pom.xml | 1 +
7 files changed, 422 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/pom.xml b/tests/camel-itest-spring40/pom.xml
new file mode 100644
index 0000000..e342f48
--- /dev/null
+++ b/tests/camel-itest-spring40/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>tests</artifactId>
+ <version>2.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-itest-spring40</artifactId>
+ <name>Camel :: Integration Tests :: Spring 4.0</name>
+ <description>Integration Test against Spring 4.0</description>
+
+ <!-- force using spring 4.0.x -->
+ <properties>
+ <spring-version>${spring40-version}</spring-version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jms</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-camel</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring40</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/src/main/resources/META-INF/LICENSE.txt b/tests/camel-itest-spring40/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/tests/camel-itest-spring40/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/src/main/resources/META-INF/NOTICE.txt b/tests/camel-itest-spring40/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/tests/camel-itest-spring40/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/src/test/java/org/apache/camel/itest/spring40/JmsRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/src/test/java/org/apache/camel/itest/spring40/JmsRouteTest.java b/tests/camel-itest-spring40/src/test/java/org/apache/camel/itest/spring40/JmsRouteTest.java
new file mode 100644
index 0000000..12b8b28
--- /dev/null
+++ b/tests/camel-itest-spring40/src/test/java/org/apache/camel/itest/spring40/JmsRouteTest.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.spring40;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class JmsRouteTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractApplicationContext createApplicationContext() {
+ // must create application context with refrehs = false when using active profiles
+ return new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/itest/spring40/JmsRouteTest.xml"}, false);
+ }
+
+ @Override
+ protected String[] activeProfiles() {
+ return new String[]{"test"};
+ }
+
+ @Test
+ public void testJmsRoute() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("activemq:queue:foo", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/src/test/resources/log4j.properties b/tests/camel-itest-spring40/src/test/resources/log4j.properties
new file mode 100644
index 0000000..11b6b28
--- /dev/null
+++ b/tests/camel-itest-spring40/src/test/resources/log4j.properties
@@ -0,0 +1,37 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq.spring=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %-10.10X{camel.exchangeId} - %-10.10X{camel.messageId} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-itest-spring40-test.log
+log4j.appender.out.append=true
+
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/camel-itest-spring40/src/test/resources/org/apache/camel/itest/spring40/JmsRouteTest.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring40/src/test/resources/org/apache/camel/itest/spring40/JmsRouteTest.xml b/tests/camel-itest-spring40/src/test/resources/org/apache/camel/itest/spring40/JmsRouteTest.xml
new file mode 100644
index 0000000..6ee9a57
--- /dev/null
+++ b/tests/camel-itest-spring40/src/test/resources/org/apache/camel/itest/spring40/JmsRouteTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="activemq:queue:foo"/>
+ <to uri="activemq:queue:bar"/>
+ </route>
+ <route>
+ <from uri="activemq:queue:bar"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+
+ <!-- setup the profile for testing -->
+ <beans profile="test">
+ <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="connectionFactory">
+ <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://localhost?broker.persistent=false&broker.useJmx=false"/>
+ </bean>
+ </property>
+ </bean>
+ </beans>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/87372099/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
index 60128ff..3d4fcda 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -37,6 +37,7 @@
<module>camel-itest</module>
<module>camel-itest-cdi</module>
<module>camel-itest-spring32</module>
+ <module>camel-itest-spring40</module>
<module>camel-blueprint-cxf-test</module>
<module>camel-partial-classpath-test</module>
<module>camel-typeconverterscan-test</module>
[5/7] git commit: CAMEL-7835: camel-test-spring40 for spring 4.0
only. And camel-test-spring for spring 4.1 or newer.
Posted by da...@apache.org.
CAMEL-7835: camel-test-spring40 for spring 4.0 only. And camel-test-spring for spring 4.1 or newer.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7764c326
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7764c326
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7764c326
Branch: refs/heads/master
Commit: 7764c326406b8484e0094a711883df92db70d934
Parents: 366ad8d
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 21 16:59:28 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 21 16:59:28 2014 +0200
----------------------------------------------------------------------
apache-camel/pom.xml | 2 +-
.../src/main/descriptors/common-bin.xml | 2 +-
components/camel-test-spring/pom.xml | 4 +-
.../spring/CamelSpringJUnit4ClassRunner.java | 42 +-
.../spring/CamelTestContextBootstrapper.java | 31 ++
.../spring/StopWatchTestExecutionListener.java | 20 +-
.../CamelSpringJUnit4ClassRunnerPlainTest.java | 9 +-
components/camel-test-spring40/pom.xml | 95 ++++
.../CamelSpringDelegatingTestContextLoader.java | 321 +++++++++++++
.../spring/CamelSpringJUnit4ClassRunner.java | 88 ++++
.../spring/CamelSpringTestContextLoader.java | 473 +++++++++++++++++++
...gTestContextLoaderTestExecutionListener.java | 36 ++
.../test/spring/CamelSpringTestHelper.java | 99 ++++
.../test/spring/CamelSpringTestSupport.java | 220 +++++++++
.../apache/camel/test/spring/DisableJmx.java | 43 ++
.../spring/DisableJmxTestExecutionListener.java | 39 ++
.../apache/camel/test/spring/ExcludeRoutes.java | 44 ++
.../test/spring/LazyLoadTypeConverters.java | 44 ++
.../apache/camel/test/spring/MockEndpoints.java | 43 ++
.../camel/test/spring/MockEndpointsAndSkip.java | 43 ++
.../camel/test/spring/ProvidesBreakpoint.java | 36 ++
.../camel/test/spring/ShutdownTimeout.java | 49 ++
.../spring/StopWatchTestExecutionListener.java | 60 +++
.../apache/camel/test/spring/UseAdviceWith.java | 49 ++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../AdviceWithOnExceptionMultipleIssueTest.java | 116 +++++
.../test/issues/MockEndpointsAndSkipTest.java | 46 ++
.../patterns/DebugSpringCamelContextTest.java | 40 ++
.../camel/test/patterns/DebugSpringTest.java | 81 ++++
.../camel/test/patterns/MyProduceBean.java | 41 ++
.../apache/camel/test/patterns/MySender.java | 25 +
.../camel/test/patterns/ProduceBeanTest.java | 42 ++
.../test/patterns/ProducerBeanInjectTest.java | 38 ++
.../spring/CamelSpringActiveProfileTest.java | 56 +++
...ssRunnerDisableJmxInheritedOverrideTest.java | 32 ++
...Unit4ClassRunnerDisableJmxInheritedTest.java | 21 +
...elSpringJUnit4ClassRunnerDisableJmxTest.java | 33 ++
...pringJUnit4ClassRunnerExcludeRoutesTest.java | 29 ++
...LoadTypeConvertersInheritedOverrideTest.java | 33 ++
...nnerLazyLoadTypeConvertersInheritedTest.java | 21 +
...t4ClassRunnerLazyLoadTypeConvertersTest.java | 33 ++
...nit4ClassRunnerMockEndpointsAndSkipTest.java | 56 +++
...pringJUnit4ClassRunnerMockEndpointsTest.java | 57 +++
.../CamelSpringJUnit4ClassRunnerPlainTest.java | 126 +++++
...sRunnerProvidesBreakpointInherritedTest.java | 22 +
...JUnit4ClassRunnerProvidesBreakpointTest.java | 67 +++
...nerShutdownTimeoutInheritedOverrideTest.java | 34 ++
...ClassRunnerShutdownTimeoutInheritedTest.java | 22 +
...ingJUnit4ClassRunnerShutdownTimeoutTest.java | 34 ++
...pringJUnit4ClassRunnerUseAdviceWithTest.java | 52 ++
...CamelSpringTestSupportActiveProfileTest.java | 51 ++
.../camel/test/spring/TestRouteBuilder.java | 30 ++
.../src/test/resources/jndi.properties | 22 +
.../src/test/resources/log4j.properties | 37 ++
.../AdviceWithOnExceptionMultipleIssueTest.xml | 47 ++
.../test/issues/MockEndpointsAndSkipTest.xml | 35 ++
.../test/patterns/ProduceBeanInjectTest.xml | 39 ++
.../camel/test/patterns/ProduceBeanTest.xml | 33 ++
.../camel/test/patterns/applicationContext.xml | 38 ++
.../CamelSpringActiveProfileTest-context.xml | 41 ++
...SpringJUnit4ClassRunnerPlainTest-context.xml | 50 ++
.../apache/camel/test/spring/test.properties | 18 +
components/camel-test-spring41/pom.xml | 96 ----
.../CamelSpringDelegatingTestContextLoader.java | 321 -------------
.../spring/CamelSpringJUnit4ClassRunner.java | 68 ---
.../spring/CamelSpringTestContextLoader.java | 473 -------------------
...gTestContextLoaderTestExecutionListener.java | 36 --
.../test/spring/CamelSpringTestHelper.java | 99 ----
.../test/spring/CamelSpringTestSupport.java | 220 ---------
.../spring/CamelTestContextBootstrapper.java | 31 --
.../apache/camel/test/spring/DisableJmx.java | 43 --
.../spring/DisableJmxTestExecutionListener.java | 39 --
.../apache/camel/test/spring/ExcludeRoutes.java | 44 --
.../test/spring/LazyLoadTypeConverters.java | 44 --
.../apache/camel/test/spring/MockEndpoints.java | 43 --
.../camel/test/spring/MockEndpointsAndSkip.java | 43 --
.../camel/test/spring/ProvidesBreakpoint.java | 36 --
.../camel/test/spring/ShutdownTimeout.java | 49 --
.../spring/StopWatchTestExecutionListener.java | 62 ---
.../apache/camel/test/spring/UseAdviceWith.java | 49 --
.../src/main/resources/META-INF/LICENSE.txt | 203 --------
.../src/main/resources/META-INF/NOTICE.txt | 11 -
.../AdviceWithOnExceptionMultipleIssueTest.java | 116 -----
.../test/issues/MockEndpointsAndSkipTest.java | 46 --
.../patterns/DebugSpringCamelContextTest.java | 40 --
.../camel/test/patterns/DebugSpringTest.java | 81 ----
.../camel/test/patterns/MyProduceBean.java | 41 --
.../apache/camel/test/patterns/MySender.java | 25 -
.../camel/test/patterns/ProduceBeanTest.java | 42 --
.../test/patterns/ProducerBeanInjectTest.java | 38 --
.../spring/CamelSpringActiveProfileTest.java | 56 ---
...ssRunnerDisableJmxInheritedOverrideTest.java | 32 --
...Unit4ClassRunnerDisableJmxInheritedTest.java | 21 -
...elSpringJUnit4ClassRunnerDisableJmxTest.java | 33 --
...pringJUnit4ClassRunnerExcludeRoutesTest.java | 29 --
...LoadTypeConvertersInheritedOverrideTest.java | 33 --
...nnerLazyLoadTypeConvertersInheritedTest.java | 21 -
...t4ClassRunnerLazyLoadTypeConvertersTest.java | 33 --
...nit4ClassRunnerMockEndpointsAndSkipTest.java | 56 ---
...pringJUnit4ClassRunnerMockEndpointsTest.java | 57 ---
.../CamelSpringJUnit4ClassRunnerPlainTest.java | 127 -----
...sRunnerProvidesBreakpointInherritedTest.java | 22 -
...JUnit4ClassRunnerProvidesBreakpointTest.java | 67 ---
...nerShutdownTimeoutInheritedOverrideTest.java | 34 --
...ClassRunnerShutdownTimeoutInheritedTest.java | 22 -
...ingJUnit4ClassRunnerShutdownTimeoutTest.java | 34 --
...pringJUnit4ClassRunnerUseAdviceWithTest.java | 52 --
...CamelSpringTestSupportActiveProfileTest.java | 51 --
.../camel/test/spring/TestRouteBuilder.java | 30 --
.../src/test/resources/jndi.properties | 22 -
.../src/test/resources/log4j.properties | 37 --
.../AdviceWithOnExceptionMultipleIssueTest.xml | 47 --
.../test/issues/MockEndpointsAndSkipTest.xml | 35 --
.../test/patterns/ProduceBeanInjectTest.xml | 39 --
.../camel/test/patterns/ProduceBeanTest.xml | 33 --
.../camel/test/patterns/applicationContext.xml | 38 --
.../CamelSpringActiveProfileTest-context.xml | 41 --
...SpringJUnit4ClassRunnerPlainTest-context.xml | 50 --
.../apache/camel/test/spring/test.properties | 18 -
components/pom.xml | 2 +-
parent/pom.xml | 6 +-
122 files changed, 3660 insertions(+), 3661 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 892150c..b22eb69 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -704,7 +704,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring41</artifactId>
+ <artifactId>camel-test-spring40</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index f5145f5..e061006 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -187,7 +187,7 @@
<include>org.apache.camel:camel-test-blueprint</include>
<include>org.apache.camel:camel-test-spring</include>
<include>org.apache.camel:camel-test-spring3</include>
- <include>org.apache.camel:camel-test-spring41</include>
+ <include>org.apache.camel:camel-test-spring40</include>
<include>org.apache.camel:camel-testng</include>
<include>org.apache.camel:camel-twitter</include>
<include>org.apache.camel:camel-urlrewrite</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/pom.xml b/components/camel-test-spring/pom.xml
index 3e8057d..a15f34a 100644
--- a/components/camel-test-spring/pom.xml
+++ b/components/camel-test-spring/pom.xml
@@ -28,8 +28,8 @@
<artifactId>camel-test-spring</artifactId>
<packaging>bundle</packaging>
- <name>Camel :: Test :: Spring 4.0</name>
- <description>Camel Testing Library using JUnit and Spring 4.0</description>
+ <name>Camel :: Test :: Spring</name>
+ <description>Camel Testing Library using JUnit and Spring 4.1+</description>
<properties>
<camel.osgi.export.pkg>org.apache.camel.test.spring.*</camel.osgi.export.pkg>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
index 9416e9f..3d88020 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
@@ -16,8 +16,7 @@
*/
package org.apache.camel.test.spring;
-import java.util.LinkedHashSet;
-import java.util.Set;
+import java.util.List;
import org.junit.runners.model.InitializationError;
import org.springframework.test.context.TestContextManager;
@@ -44,18 +43,7 @@ public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
*/
@Override
protected TestContextManager createTestContextManager(Class<?> clazz) {
- return new CamelTestContextManager(clazz, getDefaultContextLoaderClassName(clazz));
- }
-
- /**
- * Returns the specialized loader for tight integration between Camel testing features
- * and the application context initialization.
- *
- * @return Returns the class name for {@link org.apache.camel.test.spring.CamelSpringTestContextLoader}
- */
- @Override
- protected String getDefaultContextLoaderClassName(Class<?> clazz) {
- return CamelSpringTestContextLoader.class.getName();
+ return new CamelTestContextManager(clazz);
}
/**
@@ -64,25 +52,17 @@ public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
*/
public static final class CamelTestContextManager extends TestContextManager {
- public CamelTestContextManager(Class<?> testClass, String defaultContextLoaderClassName) {
- super(testClass, defaultContextLoaderClassName);
- }
-
- /**
- * Augments the default listeners with additional listeners to provide support
- * for the Camel testing features.
- */
- @Override
- protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
- Set<Class<? extends TestExecutionListener>> classes = new LinkedHashSet<Class<? extends TestExecutionListener>>();
+ public CamelTestContextManager(Class<?> testClass) {
+ super(testClass);
- classes.add(CamelSpringTestContextLoaderTestExecutionListener.class);
- classes.addAll(super.getDefaultTestExecutionListenerClasses());
- classes.add(DisableJmxTestExecutionListener.class);
- classes.add(StopWatchTestExecutionListener.class);
-
- return classes;
+ // inject Camel first, and then disable jmx and add the stop-watch
+ List<TestExecutionListener> list = getTestExecutionListeners();
+ list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
+ list.add(new DisableJmxTestExecutionListener());
+ list.add(new StopWatchTestExecutionListener());
+ registerTestExecutionListeners(list);
}
+
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java
new file mode 100644
index 0000000..169eed1
--- /dev/null
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelTestContextBootstrapper.java
@@ -0,0 +1,31 @@
+/**
+ * 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.spring;
+
+import org.springframework.test.context.ContextLoader;
+import org.springframework.test.context.support.DefaultTestContextBootstrapper;
+
+/**
+ * To boostrap Camel for testing with Spring 4.1 onwards.
+ */
+public class CamelTestContextBootstrapper extends DefaultTestContextBootstrapper {
+
+ @Override
+ protected Class<? extends ContextLoader> getDefaultContextLoaderClass(Class<?> testClass) {
+ return CamelSpringTestContextLoader.class;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
index d3cc369..8796dfe 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
@@ -41,20 +41,22 @@ public class StopWatchTestExecutionListener extends AbstractTestExecutionListene
public void beforeTestMethod(TestContext testContext) throws Exception {
StopWatch stopWatch = new StopWatch();
threadStopWatch.set(stopWatch);
-
- stopWatch.restart();
}
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
- long time = threadStopWatch.get().stop();
- threadStopWatch.remove();
- Logger log = LoggerFactory.getLogger(testContext.getTestClass());
+ StopWatch watch = threadStopWatch.get();
+ if (watch != null) {
+ long time = watch.stop();
+ Logger log = LoggerFactory.getLogger(testContext.getTestClass());
- log.info("********************************************************************************");
- log.info("Testing done: " + testContext.getTestMethod().getName() + "(" + testContext.getTestClass().getName() + ")");
- log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
- log.info("********************************************************************************");
+ log.info("********************************************************************************");
+ log.info("Testing done: " + testContext.getTestMethod().getName() + "(" + testContext.getTestClass().getName() + ")");
+ log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");
+ log.info("********************************************************************************");
+
+ threadStopWatch.remove();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
index 337d387..8b1504f 100644
--- a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
+++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java
@@ -26,13 +26,12 @@ import org.apache.camel.ServiceStatus;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.management.DefaultManagementStrategy;
import org.apache.camel.util.StopWatch;
-
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
+import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.ContextConfiguration;
import static org.junit.Assert.assertEquals;
@@ -42,8 +41,10 @@ import static org.junit.Assert.assertTrue;
// START SNIPPET: e1
@RunWith(CamelSpringJUnit4ClassRunner.class)
-@ContextConfiguration
-// Put here to prevent Spring context caching across tests and test methods since some tests inherit
+// must tell Spring to bootstrap with Camel
+@BootstrapWith(CamelTestContextBootstrapper.class)
+@ContextConfiguration()
+// Put here to prevent Spring context caching across tests and test methods since some tests inherit
// from this test and therefore use the same Spring context. Also because we want to reset the
// Camel context and mock endpoints between test methods automatically.
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/pom.xml b/components/camel-test-spring40/pom.xml
new file mode 100644
index 0000000..f13e99d
--- /dev/null
+++ b/components/camel-test-spring40/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-test-spring40</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Test :: Spring 4.0</name>
+ <description>Camel Testing Library using JUnit and Spring 4.0</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.test.spring.*</camel.osgi.export.pkg>
+ <spring-version>${spring40-version}</spring-version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <!-- we need to override the other spring version -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring40-version}</version>
+ </dependency>
+
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
new file mode 100644
index 0000000..a3bb4a3
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
@@ -0,0 +1,321 @@
+/**
+ * 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.spring;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.impl.DefaultDebugger;
+import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
+import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.apache.camel.spi.Breakpoint;
+import org.apache.camel.spi.Debugger;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigUtils;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.test.context.MergedContextConfiguration;
+import org.springframework.test.context.support.DelegatingSmartContextLoader;
+
+import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
+
+
+
+/**
+ * CamelSpringDelegatingTestContextLoader which fixes issues in Camel's JavaConfigContextLoader. (adds support for Camel's test annotations)
+ * <br>
+ * <em>This loader can handle either classes or locations for configuring the context.</em>
+ * <br>
+ * NOTE: This TestContextLoader doesn't support the annotation of ExcludeRoutes now.
+ */
+public class CamelSpringDelegatingTestContextLoader extends DelegatingSmartContextLoader {
+
+ protected final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Override
+ public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
+
+ Class<?> testClass = getTestClass();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loading ApplicationContext for merged context configuration [{}].", mergedConfig);
+ }
+
+ // Pre CamelContext(s) instantiation setup
+ handleDisableJmx(null, testClass);
+
+ try {
+ SpringCamelContext.setNoStart(true);
+ ConfigurableApplicationContext context = (ConfigurableApplicationContext) super.loadContext(mergedConfig);
+ SpringCamelContext.setNoStart(false);
+ return loadContext(context, testClass);
+ } finally {
+ cleanup(testClass);
+ }
+ }
+
+ /**
+ * Performs the bulk of the Spring application context loading/customization.
+ *
+ * @param context the partially configured context. The context should have the bean definitions loaded, but nothing else.
+ * @param testClass the test class being executed
+ * @return the initialized (refreshed) Spring application context
+ *
+ * @throws Exception if there is an error during initialization/customization
+ */
+ public ApplicationContext loadContext(ConfigurableApplicationContext context, Class<?> testClass)
+ throws Exception {
+
+ AnnotationConfigUtils.registerAnnotationConfigProcessors((BeanDefinitionRegistry) context);
+
+ // Post CamelContext(s) instantiation but pre CamelContext(s) start setup
+ handleProvidesBreakpoint(context, testClass);
+ handleShutdownTimeout(context, testClass);
+ handleMockEndpoints(context, testClass);
+ handleMockEndpointsAndSkip(context, testClass);
+
+ // CamelContext(s) startup
+ handleCamelContextStartup(context, testClass);
+
+ return context;
+ }
+
+ /**
+ * Cleanup/restore global state to defaults / pre-test values after the test setup
+ * is complete.
+ *
+ * @param testClass the test class being executed
+ */
+ protected void cleanup(Class<?> testClass) {
+ SpringCamelContext.setNoStart(false);
+
+ if (testClass.isAnnotationPresent(DisableJmx.class)) {
+ if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ } else {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED,
+ CamelSpringTestHelper.getOriginalJmxDisabled());
+ }
+ }
+ }
+
+ /**
+ * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleDisableJmx(ConfigurableApplicationContext context, Class<?> testClass) {
+ CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
+
+ if (testClass.isAnnotationPresent(DisableJmx.class)) {
+ if (testClass.getAnnotation(DisableJmx.class).value()) {
+ logger.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+
+ } else {
+ logger.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ }
+ } else {
+ logger.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+ }
+ }
+
+ /**
+ * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
+ * as it is needed in
+ *
+ * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
+ * @param testClass the test class being processed
+ *
+ * @throws Exception if there is an error processing the class
+ */
+ protected void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
+ Collection<Method> methods = getAllMethods(testClass);
+ final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>();
+
+ for (Method method : methods) {
+ if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
+ Class<?>[] argTypes = method.getParameterTypes();
+ if (argTypes.length != 0) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
+ } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
+ } else if (!Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not static.");
+ } else if (!Modifier.isPublic(method.getModifiers())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not public.");
+ }
+
+ try {
+ breakpoints.add((Breakpoint) method.invoke(null));
+ } catch (Exception e) {
+ throw new RuntimeException("Method [" + method.getName()
+ + "] threw exception during evaluation.", e);
+ }
+ }
+ }
+
+ if (breakpoints.size() != 0) {
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ Debugger debugger = camelContext.getDebugger();
+ if (debugger == null) {
+ debugger = new DefaultDebugger();
+ camelContext.setDebugger(debugger);
+ }
+
+ for (Breakpoint breakpoint : breakpoints) {
+ logger.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
+ debugger.addBreakpoint(breakpoint);
+ }
+ }
+ });
+ }
+ }
+
+
+ /**
+ * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleShutdownTimeout(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
+ final int shutdownTimeout;
+ final TimeUnit shutdownTimeUnit;
+ if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
+ shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
+ shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
+ } else {
+ shutdownTimeout = 10;
+ shutdownTimeUnit = TimeUnit.SECONDS;
+ }
+
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ logger.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", new Object[]{shutdownTimeout, shutdownTimeUnit, contextName});
+ camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
+ camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
+ }
+ });
+ }
+
+ /**
+ * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleMockEndpoints(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
+ if (testClass.isAnnotationPresent(MockEndpoints.class)) {
+ final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ logger.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
+ camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
+ }
+ });
+ }
+ }
+
+ /**
+ * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
+ * original endpoint.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleMockEndpointsAndSkip(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
+ if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
+ final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ logger.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
+ camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints, true));
+ }
+ });
+ }
+ }
+
+
+ /**
+ * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleCamelContextStartup(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
+ boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
+ if (skip) {
+ logger.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
+ } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
+ if (testClass.getAnnotation(UseAdviceWith.class).value()) {
+ logger.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
+ skip = true;
+ } else {
+ logger.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
+ skip = false;
+ }
+ }
+
+ if (!skip) {
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+ public void execute(String contextName,
+ SpringCamelContext camelContext) throws Exception {
+ logger.info("Starting CamelContext with name [{}].", contextName);
+ camelContext.start();
+ }
+ });
+ }
+ }
+
+ /**
+ * Returns the class under test in order to enable inspection of annotations while the
+ * Spring context is being created.
+ *
+ * @return the test class that is being executed
+ * @see CamelSpringTestHelper
+ */
+ protected Class<?> getTestClass() {
+ return CamelSpringTestHelper.getTestClass();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
new file mode 100644
index 0000000..9416e9f
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunner.java
@@ -0,0 +1,88 @@
+/**
+ * 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.spring;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.junit.runners.model.InitializationError;
+import org.springframework.test.context.TestContextManager;
+import org.springframework.test.context.TestExecutionListener;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * An implementation bringing the functionality of {@link org.apache.camel.test.spring.CamelSpringTestSupport} to
+ * Spring Test based test cases. This approach allows developers to implement tests
+ * for their Spring based applications/routes using the typical Spring Test conventions
+ * for test development.
+ */
+public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
+
+ public CamelSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError {
+ super(clazz);
+ }
+
+ /**
+ * Returns the specialized manager instance that provides tight integration between Camel testing
+ * features and Spring.
+ *
+ * @return a new instance of {@link CamelTestContextManager}.
+ */
+ @Override
+ protected TestContextManager createTestContextManager(Class<?> clazz) {
+ return new CamelTestContextManager(clazz, getDefaultContextLoaderClassName(clazz));
+ }
+
+ /**
+ * Returns the specialized loader for tight integration between Camel testing features
+ * and the application context initialization.
+ *
+ * @return Returns the class name for {@link org.apache.camel.test.spring.CamelSpringTestContextLoader}
+ */
+ @Override
+ protected String getDefaultContextLoaderClassName(Class<?> clazz) {
+ return CamelSpringTestContextLoader.class.getName();
+ }
+
+ /**
+ * An implementation providing additional integration between Spring Test and Camel
+ * testing features.
+ */
+ public static final class CamelTestContextManager extends TestContextManager {
+
+ public CamelTestContextManager(Class<?> testClass, String defaultContextLoaderClassName) {
+ super(testClass, defaultContextLoaderClassName);
+ }
+
+ /**
+ * Augments the default listeners with additional listeners to provide support
+ * for the Camel testing features.
+ */
+ @Override
+ protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses() {
+ Set<Class<? extends TestExecutionListener>> classes = new LinkedHashSet<Class<? extends TestExecutionListener>>();
+
+ classes.add(CamelSpringTestContextLoaderTestExecutionListener.class);
+ classes.addAll(super.getDefaultTestExecutionListenerClasses());
+ classes.add(DisableJmxTestExecutionListener.class);
+ classes.add(StopWatchTestExecutionListener.class);
+
+ return classes;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
new file mode 100644
index 0000000..e973b44
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
@@ -0,0 +1,473 @@
+/**
+ * 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.spring;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.impl.DefaultDebugger;
+import org.apache.camel.impl.InterceptSendToMockEndpointStrategy;
+import org.apache.camel.management.JmxSystemPropertyKeys;
+import org.apache.camel.spi.Breakpoint;
+import org.apache.camel.spi.Debugger;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.ExcludingPackageScanClassResolver;
+import org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigUtils;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.test.context.MergedContextConfiguration;
+import org.springframework.test.context.support.AbstractContextLoader;
+import org.springframework.test.context.support.AbstractGenericContextLoader;
+import org.springframework.test.context.support.GenericXmlContextLoader;
+import org.springframework.util.StringUtils;
+
+import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
+
+/**
+ * Replacement for the default {@link GenericXmlContextLoader} that provides hooks for
+ * processing some class level Camel related test annotations.
+ */
+public class CamelSpringTestContextLoader extends AbstractContextLoader {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CamelSpringTestContextLoader.class);
+
+ /**
+ * Modeled after the Spring implementation in {@link AbstractGenericContextLoader},
+ * this method creates and refreshes the application context while providing for
+ * processing of additional Camel specific post-refresh actions. We do not provide the
+ * pre-post hooks for customization seen in {@link AbstractGenericContextLoader} because
+ * they probably are unnecessary for 90+% of users.
+ * <p/>
+ * For some functionality, we cannot use {@link org.springframework.test.context.TestExecutionListener} because we need
+ * to both produce the desired outcome during application context loading, and also cleanup
+ * after ourselves even if the test class never executes. Thus the listeners, which
+ * only run if the application context is successfully initialized are insufficient to
+ * provide the behavior described above.
+ */
+ @Override
+ public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
+ Class<?> testClass = getTestClass();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Loading ApplicationContext for merged context configuration [{}].", mergedConfig);
+ }
+
+ try {
+ GenericApplicationContext context = createContext(testClass, mergedConfig);
+ context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles());
+ loadBeanDefinitions(context, mergedConfig);
+ return loadContext(context, testClass);
+ } finally {
+ cleanup(testClass);
+ }
+ }
+
+ /**
+ * Modeled after the Spring implementation in {@link AbstractGenericContextLoader},
+ * this method creates and refreshes the application context while providing for
+ * processing of additional Camel specific post-refresh actions. We do not provide the
+ * pre-post hooks for customization seen in {@link AbstractGenericContextLoader} because
+ * they probably are unnecessary for 90+% of users.
+ * <p/>
+ * For some functionality, we cannot use {@link org.springframework.test.context.TestExecutionListener} because we need
+ * to both produce the desired outcome during application context loading, and also cleanup
+ * after ourselves even if the test class never executes. Thus the listeners, which
+ * only run if the application context is successfully initialized are insufficient to
+ * provide the behavior described above.
+ */
+ @Override
+ public ApplicationContext loadContext(String... locations) throws Exception {
+
+ Class<?> testClass = getTestClass();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Loading ApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "].");
+ }
+
+ try {
+ GenericApplicationContext context = createContext(testClass, null);
+ loadBeanDefinitions(context, locations);
+ return loadContext(context, testClass);
+ } finally {
+ cleanup(testClass);
+ }
+ }
+
+ /**
+ * Returns "<code>-context.xml</code>".
+ */
+ @Override
+ public String getResourceSuffix() {
+ return "-context.xml";
+ }
+
+ /**
+ * Performs the bulk of the Spring application context loading/customization.
+ *
+ * @param context the partially configured context. The context should have the bean definitions loaded, but nothing else.
+ * @param testClass the test class being executed
+ * @return the initialized (refreshed) Spring application context
+ *
+ * @throws Exception if there is an error during initialization/customization
+ */
+ protected ApplicationContext loadContext(GenericApplicationContext context, Class<?> testClass) throws Exception {
+
+ AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
+
+ // Pre CamelContext(s) instantiation setup
+ handleDisableJmx(context, testClass);
+
+ // Temporarily disable CamelContext start while the contexts are instantiated.
+ SpringCamelContext.setNoStart(true);
+ context.refresh();
+ context.registerShutdownHook();
+ // Turn CamelContext startup back on since the context's have now been instantiated.
+ SpringCamelContext.setNoStart(false);
+
+ // Post CamelContext(s) instantiation but pre CamelContext(s) start setup
+ handleProvidesBreakpoint(context, testClass);
+ handleShutdownTimeout(context, testClass);
+ handleMockEndpoints(context, testClass);
+ handleMockEndpointsAndSkip(context, testClass);
+ handleLazyLoadTypeConverters(context, testClass);
+
+ // CamelContext(s) startup
+ handleCamelContextStartup(context, testClass);
+
+ return context;
+ }
+
+ /**
+ * Cleanup/restore global state to defaults / pre-test values after the test setup
+ * is complete.
+ *
+ * @param testClass the test class being executed
+ */
+ protected void cleanup(Class<?> testClass) {
+ SpringCamelContext.setNoStart(false);
+
+ if (testClass.isAnnotationPresent(DisableJmx.class)) {
+ if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ } else {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED,
+ CamelSpringTestHelper.getOriginalJmxDisabled());
+ }
+ }
+ }
+
+ protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
+ (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(mergedConfig.getLocations());
+ }
+
+ protected void loadBeanDefinitions(GenericApplicationContext context, String... locations) {
+ (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(locations);
+ }
+
+ /**
+ * Creates and starts the Spring context while optionally starting any loaded Camel contexts.
+ *
+ * @param testClass the test class that is being executed
+ * @return the loaded Spring context
+ */
+ protected GenericApplicationContext createContext(Class<?> testClass, MergedContextConfiguration mergedConfig) {
+ ApplicationContext parentContext = null;
+ GenericApplicationContext routeExcludingContext = null;
+
+ if (mergedConfig != null) {
+ parentContext = mergedConfig.getParentApplicationContext();
+
+ }
+
+ if (testClass.isAnnotationPresent(ExcludeRoutes.class)) {
+ Class<?>[] excludedClasses = testClass.getAnnotation(ExcludeRoutes.class).value();
+
+ if (excludedClasses.length > 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Setting up package scanning excluded classes as ExcludeRoutes "
+ + "annotation was found. Excluding [" + StringUtils.arrayToCommaDelimitedString(excludedClasses) + "].");
+ }
+
+ if (parentContext == null) {
+ routeExcludingContext = new GenericApplicationContext();
+ } else {
+ routeExcludingContext = new GenericApplicationContext(parentContext);
+ }
+ routeExcludingContext.registerBeanDefinition("excludingResolver", new RootBeanDefinition(ExcludingPackageScanClassResolver.class));
+ routeExcludingContext.refresh();
+
+ ExcludingPackageScanClassResolver excludingResolver = routeExcludingContext.getBean("excludingResolver", ExcludingPackageScanClassResolver.class);
+ List<Class<?>> excluded = Arrays.asList(excludedClasses);
+ excludingResolver.setExcludedClasses(new HashSet<Class<?>>(excluded));
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Not enabling package scanning excluded classes as ExcludeRoutes "
+ + "annotation was found but no classes were excluded.");
+ }
+ }
+ }
+
+ GenericApplicationContext context;
+
+ if (routeExcludingContext != null) {
+ context = new GenericApplicationContext(routeExcludingContext);
+ } else {
+ if (parentContext != null) {
+ context = new GenericApplicationContext(parentContext);
+ } else {
+ context = new GenericApplicationContext();
+ }
+ }
+
+ return context;
+ }
+
+ /**
+ * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleDisableJmx(GenericApplicationContext context, Class<?> testClass) {
+ CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
+
+ if (testClass.isAnnotationPresent(DisableJmx.class)) {
+ if (testClass.getAnnotation(DisableJmx.class).value()) {
+ LOG.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+ } else {
+ LOG.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ }
+ } else {
+ LOG.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+ }
+ }
+
+ /**
+ * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
+ * as it is needed in
+ *
+ * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
+ * @param testClass the test class being processed
+ *
+ * @throws Exception if there is an error processing the class
+ */
+ protected void handleProvidesBreakpoint(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ Collection<Method> methods = getAllMethods(testClass);
+ final List<Breakpoint> breakpoints = new LinkedList<Breakpoint>();
+
+ for (Method method : methods) {
+ if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
+ Class<?>[] argTypes = method.getParameterTypes();
+ if (argTypes.length != 0) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
+ } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
+ } else if (!Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not static.");
+ } else if (!Modifier.isPublic(method.getModifiers())) {
+ throw new IllegalArgumentException("Method [" + method.getName()
+ + "] is annotated with ProvidesBreakpoint but is not public.");
+ }
+
+ try {
+ breakpoints.add((Breakpoint) method.invoke(null));
+ } catch (Exception e) {
+ throw new RuntimeException("Method [" + method.getName()
+ + "] threw exception during evaluation.", e);
+ }
+ }
+ }
+
+ if (breakpoints.size() != 0) {
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ Debugger debugger = camelContext.getDebugger();
+ if (debugger == null) {
+ debugger = new DefaultDebugger();
+ camelContext.setDebugger(debugger);
+ }
+
+ for (Breakpoint breakpoint : breakpoints) {
+ LOG.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
+ debugger.addBreakpoint(breakpoint);
+ }
+ }
+ });
+ }
+ }
+
+
+ /**
+ * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleShutdownTimeout(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ final int shutdownTimeout;
+ final TimeUnit shutdownTimeUnit;
+ if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
+ shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
+ shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
+ } else {
+ shutdownTimeout = 10;
+ shutdownTimeUnit = TimeUnit.SECONDS;
+ }
+
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ LOG.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", new Object[]{shutdownTimeout, shutdownTimeUnit, contextName});
+ camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
+ camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
+ }
+ });
+ }
+
+ /**
+ * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleMockEndpoints(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ if (testClass.isAnnotationPresent(MockEndpoints.class)) {
+ final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ LOG.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
+ camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
+ }
+ });
+ }
+ }
+
+ /**
+ * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
+ * original endpoint.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleMockEndpointsAndSkip(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
+ final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ LOG.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
+ camelContext.addRegisterEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints, true));
+ }
+ });
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ protected void handleLazyLoadTypeConverters(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ final boolean lazy;
+
+ if (testClass.isAnnotationPresent(LazyLoadTypeConverters.class)) {
+ lazy = testClass.getAnnotation(LazyLoadTypeConverters.class).value();
+ } else {
+ lazy = true;
+ }
+
+ if (lazy) {
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName, SpringCamelContext camelContext)
+ throws Exception {
+ LOG.info("Enabling lazy loading of type converters on CamelContext with name [{}].", contextName);
+ camelContext.setLazyLoadTypeConverters(lazy);
+ }
+ });
+ }
+ }
+
+ /**
+ * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
+ *
+ * @param context the initialized Spring context
+ * @param testClass the test class being executed
+ */
+ protected void handleCamelContextStartup(GenericApplicationContext context, Class<?> testClass) throws Exception {
+ boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
+ if (skip) {
+ LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
+ } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
+ if (testClass.getAnnotation(UseAdviceWith.class).value()) {
+ LOG.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
+ skip = true;
+ } else {
+ LOG.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
+ skip = false;
+ }
+ }
+
+ if (!skip) {
+ CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
+
+ @Override
+ public void execute(String contextName,
+ SpringCamelContext camelContext) throws Exception {
+ LOG.info("Starting CamelContext with name [{}].", contextName);
+ camelContext.start();
+ }
+ });
+ }
+ }
+
+ /**
+ * Returns the class under test in order to enable inspection of annotations while the
+ * Spring context is being created.
+ *
+ * @return the test class that is being executed
+ * @see CamelSpringTestHelper
+ */
+ protected Class<?> getTestClass() {
+ return CamelSpringTestHelper.getTestClass();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
new file mode 100644
index 0000000..c96943d
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
@@ -0,0 +1,36 @@
+/**
+ * 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.spring;
+
+import org.springframework.test.context.TestContext;
+import org.springframework.test.context.support.AbstractTestExecutionListener;
+
+/**
+ * Helper for {@link CamelSpringTestContextLoader} that sets the test class state
+ * in {@link CamelSpringTestHelper} almost immediately before the loader initializes
+ * the Spring context.
+ * <p/>
+ * Implemented as a listener as the state can be set on a {@code ThreadLocal} and we are pretty sure
+ * that the same thread will be used to initialize the Spring context.
+ */
+public class CamelSpringTestContextLoaderTestExecutionListener extends AbstractTestExecutionListener {
+
+ @Override
+ public void prepareTestInstance(TestContext testContext) throws Exception {
+ CamelSpringTestHelper.setTestClass(testContext.getTestClass());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
new file mode 100644
index 0000000..aa75c0e
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
@@ -0,0 +1,99 @@
+/**
+ * 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.spring;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.camel.spring.SpringCamelContext;
+
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Helper that provides state information across the levels of Spring Test that do not expose the
+ * necessary context/state for integration of Camel testing features into Spring test. Also
+ * provides utility methods.
+ * <p/>
+ * Note that this class makes use of {@link ThreadLocal}s to maintain some state. It is imperative
+ * that the state setters and getters are accessed within the scope of a single thread in order
+ * for this class to work right.
+ */
+public final class CamelSpringTestHelper {
+
+ private static ThreadLocal<String> originalJmxDisabledValue = new ThreadLocal<String>();
+ private static ThreadLocal<Class<?>> testClazz = new ThreadLocal<Class<?>>();
+
+ private CamelSpringTestHelper() {
+ }
+
+ public static String getOriginalJmxDisabled() {
+ return originalJmxDisabledValue.get();
+ }
+
+ public static void setOriginalJmxDisabledValue(String originalValue) {
+ originalJmxDisabledValue.set(originalValue);
+ }
+
+ public static Class<?> getTestClass() {
+ return testClazz.get();
+ }
+
+ public static void setTestClass(Class<?> testClass) {
+ testClazz.set(testClass);
+ }
+
+ /**
+ * Returns all methods defined in {@code clazz} and its superclasses/interfaces.
+ */
+ public static Collection<Method> getAllMethods(Class<?> clazz) {
+ Set<Method> methods = new LinkedHashSet<Method>();
+ Class<?> currentClass = clazz;
+
+ while (currentClass != null) {
+ methods.addAll(Arrays.asList(clazz.getMethods()));
+ currentClass = currentClass.getSuperclass();
+ }
+
+ return methods;
+ }
+
+ /**
+ * Executes {@code strategy} against all {@link SpringCamelContext}s found in the Spring context.
+ * This method reduces the amount of repeated find and loop code throughout this class.
+ *
+ * @param context the Spring context to search
+ * @param strategy the strategy to execute against the found {@link SpringCamelContext}s
+ *
+ * @throws Exception if there is an error executing any of the strategies
+ */
+ public static void doToSpringCamelContexts(ApplicationContext context, DoToSpringCamelContextsStrategy strategy) throws Exception {
+ Map<String, SpringCamelContext> contexts = context.getBeansOfType(SpringCamelContext.class);
+
+ for (Entry<String, SpringCamelContext> entry : contexts.entrySet()) {
+ strategy.execute(entry.getKey(), entry.getValue());
+ }
+ }
+
+ public interface DoToSpringCamelContextsStrategy {
+ void execute(String contextName, SpringCamelContext camelContext) throws Exception;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
new file mode 100644
index 0000000..b855b40
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/CamelSpringTestSupport.java
@@ -0,0 +1,220 @@
+/**
+ * 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.spring;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.CamelBeanPostProcessor;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.ExcludingPackageScanClassResolver;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ * @version
+ */
+public abstract class CamelSpringTestSupport extends CamelTestSupport {
+ protected static ThreadLocal<AbstractApplicationContext> threadAppContext = new ThreadLocal<AbstractApplicationContext>();
+ protected static Object lock = new Object();
+
+ protected AbstractApplicationContext applicationContext;
+ protected abstract AbstractApplicationContext createApplicationContext();
+
+ /**
+ * Lets post process this test instance to process any Camel annotations.
+ * Note that using Spring Test or Guice is a more powerful approach.
+ */
+ @Override
+ public void postProcessTest() throws Exception {
+ super.postProcessTest();
+ if (isCreateCamelContextPerClass()) {
+ applicationContext = threadAppContext.get();
+ }
+
+ // use the bean post processor from camel-spring
+ CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
+ processor.setApplicationContext(applicationContext);
+ processor.setCamelContext(context);
+ processor.postProcessBeforeInitialization(this, getClass().getName());
+ processor.postProcessAfterInitialization(this, getClass().getName());
+ }
+
+ @Override
+ public void doPreSetup() throws Exception {
+ if (!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
+ // tell camel-spring it should not trigger starting CamelContext, since we do that later
+ // after we are finished setting up the unit test
+ synchronized (lock) {
+ SpringCamelContext.setNoStart(true);
+ if (isCreateCamelContextPerClass()) {
+ applicationContext = threadAppContext.get();
+ if (applicationContext == null) {
+ applicationContext = doCreateApplicationContext();
+ threadAppContext.set(applicationContext);
+ }
+ } else {
+ applicationContext = doCreateApplicationContext();
+ }
+ SpringCamelContext.setNoStart(false);
+ }
+ } else {
+ log.info("Skipping starting CamelContext as system property skipStartingCamelContext is set to be true.");
+ }
+ }
+
+ private AbstractApplicationContext doCreateApplicationContext() {
+ AbstractApplicationContext context = createApplicationContext();
+ assertNotNull("Should have created a valid Spring application context", context);
+
+ String[] profiles = activeProfiles();
+ if (profiles != null && profiles.length > 0) {
+ // the context must not be active
+ if (context.isActive()) {
+ throw new IllegalStateException("Cannot active profiles: " + Arrays.asList(profiles) + " on active Spring application context: " + context
+ + ". The code in your createApplicationContext() method should be adjusted to create the application context with refresh = false as parameter");
+ }
+ log.info("Spring activating profiles: {}", Arrays.asList(profiles));
+ context.getEnvironment().setActiveProfiles(profiles);
+ }
+
+ // ensure the context has been refreshed at least once
+ if (!context.isActive()) {
+ context.refresh();
+ }
+
+ return context;
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (!isCreateCamelContextPerClass()) {
+ IOHelper.close(applicationContext);
+ applicationContext = null;
+ }
+ }
+
+ @AfterClass
+ public static void tearSpringDownAfterClass() throws Exception {
+ if (threadAppContext.get() != null) {
+ IOHelper.close(threadAppContext.get());
+ threadAppContext.remove();
+ }
+ }
+
+ /**
+ * Create a parent context that initializes a
+ * {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given classes from
+ * being resolved. Typically this is used at test time to exclude certain routes,
+ * which might otherwise be just noisy, from being discovered and initialized.
+ * <p/>
+ * To use this filtering mechanism it is necessary to provide the
+ * {@link org.springframework.context.ApplicationContext} returned from here as the parent context to
+ * your test context e.g.
+ *
+ * <pre>
+ * protected AbstractXmlApplicationContext createApplicationContext() {
+ * return new ClassPathXmlApplicationContext(new String[] {"test-context.xml"}, getRouteExcludingApplicationContext());
+ * }
+ * </pre>
+ *
+ * This will, in turn, call the template methods <code>excludedRoutes</code>
+ * and <code>excludedRoute</code> to determine the classes to be excluded from scanning.
+ *
+ * @return ApplicationContext a parent {@link org.springframework.context.ApplicationContext} configured
+ * to exclude certain classes from package scanning
+ */
+ protected ApplicationContext getRouteExcludingApplicationContext() {
+ GenericApplicationContext routeExcludingContext = new GenericApplicationContext();
+ routeExcludingContext.registerBeanDefinition("excludingResolver", new RootBeanDefinition(ExcludingPackageScanClassResolver.class));
+ routeExcludingContext.refresh();
+
+ ExcludingPackageScanClassResolver excludingResolver = routeExcludingContext.getBean("excludingResolver", ExcludingPackageScanClassResolver.class);
+ List<Class<?>> excluded = Arrays.asList(excludeRoutes());
+ excludingResolver.setExcludedClasses(new HashSet<Class<?>>(excluded));
+
+ return routeExcludingContext;
+ }
+
+ /**
+ * Template method used to exclude {@link org.apache.camel.Route} from the test time context
+ * route scanning
+ *
+ * @return Class[] the classes to be excluded from test time context route scanning
+ */
+ protected Class<?>[] excludeRoutes() {
+ Class<?> excludedRoute = excludeRoute();
+ return excludedRoute != null ? new Class[] {excludedRoute} : new Class[0];
+ }
+
+ /**
+ * Template method used to exclude a {@link org.apache.camel.Route} from the test camel context
+ */
+ protected Class<?> excludeRoute() {
+ return null;
+ }
+
+ /**
+ * Looks up the mandatory spring bean of the given name and type, failing if
+ * it is not present or the correct type
+ */
+ public <T> T getMandatoryBean(Class<T> type, String name) {
+ Object value = applicationContext.getBean(name);
+ assertNotNull("No spring bean found for name <" + name + ">", value);
+ if (type.isInstance(value)) {
+ return type.cast(value);
+ } else {
+ fail("Spring bean <" + name + "> is not an instanceof " + type.getName() + " but is of type " + ObjectHelper.className(value));
+ return null;
+ }
+ }
+
+ /**
+ * Which active profiles should be used.
+ * <p/>
+ * <b>Important:</b> When using active profiles, then the code in {@link #createApplicationContext()} should create
+ * the Spring {@link org.springframework.context.support.AbstractApplicationContext} without refreshing. For example creating an
+ * {@link org.springframework.context.support.ClassPathXmlApplicationContext} you would need to pass in
+ * <tt>false</tt> in the refresh parameter, in the constructor.
+ * Camel will thrown an {@link IllegalStateException} if this is not correct stating this problem.
+ * The reason is that we cannot active profiles <b>after</b> a Spring application context has already
+ * been refreshed, and is active.
+ *
+ * @return an array of active profiles to use, use <tt>null</tt> to not use any active profiles.
+ */
+ protected String[] activeProfiles() {
+ return null;
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ // don't start the springCamelContext if we
+ return SpringCamelContext.springCamelContext(applicationContext, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7764c326/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmx.java
----------------------------------------------------------------------
diff --git a/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmx.java b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmx.java
new file mode 100644
index 0000000..1dd0ab1
--- /dev/null
+++ b/components/camel-test-spring40/src/main/java/org/apache/camel/test/spring/DisableJmx.java
@@ -0,0 +1,43 @@
+/**
+ * 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.spring;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates if JMX should be globally disabled in the {@code CamelContext}s that are bootstrapped
+ * during the test through the use of Spring Test loaded application contexts. Note that the
+ * presence of this annotation will result in the manipulation of System Properties that
+ * will affect Camel contexts constructed outside of the Spring Test loaded application contexts.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface DisableJmx {
+
+ /**
+ * Whether the test annotated with this annotation should be run with JMX disabled in Camel.
+ * Defaults to {@code true}.
+ */
+ boolean value() default true;
+}