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 { + +}
