camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1305069 [1/2] - in /camel/trunk: camel-core/src/test/java/org/apache/camel/component/stub/ components/camel-spring/src/test/java/org/apache/camel/spring/management/ components/camel-test-spring/ components/camel-test-spring/src/main/java/o...
Date Sun, 25 Mar 2012 16:14:47 GMT
Author: cmueller
Date: Sun Mar 25 16:14:46 2012
New Revision: 1305069

URL: http://svn.apache.org/viewvc?rev=1305069&view=rev
Log:
Revert "Revert "[CAMEL-4987] Minor documentation tweaks and fix of a false positive unit test in Spring Test support.""

This reverts commit ad7e43430927bfa41f22405a10c6c8e647331897.

Added:
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerPlainTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
    camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/TestRouteBuilder.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerPlainTest-context.xml
    camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTests.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsDisableJmxInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsDisableJmxInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsDisableJmxTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsExcludeRoutesTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsLazyLoadTypeConvertersInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsLazyLoadTypeConvertersInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsLazyLoadTypeConvertersTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsMockEndpointsTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsPlainTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsProvidesBreakpointInherritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsProvidesBreakpointTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsShutdownTimeoutInheritedOverrideTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsShutdownTimeoutInheritedTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsShutdownTimeoutTest.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsUseAdviceWithTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/TestRouteBuilder.java
      - copied, changed from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-testng/src/test/resources/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsPlainTest-context.xml
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
    camel/trunk/components/camel-test-spring/pom.xml
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/CamelSpringTestSupport.java
    camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
    camel/trunk/components/camel-testng/pom.xml
    camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelSpringTestSupport.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java?rev=1305069&r1=1305068&r2=1305069&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/stub/StubInOnlyTest.java Sun Mar 25 16:14:46 2012
@@ -49,4 +49,4 @@ public class StubInOnlyTest extends Abst
             }
         };
     }
-}
+}
\ No newline at end of file

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java?rev=1305069&r1=1305068&r2=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java Sun Mar 25 16:14:46 2012
@@ -21,6 +21,9 @@ import org.apache.camel.management.Manag
 
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
+/**
+ * @version 
+ */
 public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
 
     protected CamelContext createCamelContext() throws Exception {

Modified: camel/trunk/components/camel-test-spring/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/pom.xml?rev=1305069&r1=1305068&r2=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-test-spring/pom.xml (original)
+++ camel/trunk/components/camel-test-spring/pom.xml Sun Mar 25 16:14:46 2012
@@ -52,6 +52,11 @@
             <artifactId>slf4j-log4j12</artifactId>
             <scope>test</scope>
         </dependency>
+        
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
 
     </dependencies>
 

Modified: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/CamelSpringTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/CamelSpringTestSupport.java?rev=1305069&r1=1305068&r2=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/CamelSpringTestSupport.java (original)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/CamelSpringTestSupport.java Sun Mar 25 16:14:46 2012
@@ -17,15 +17,10 @@
 package org.apache.camel.test;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultPackageScanClassResolver;
-import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
-import org.apache.camel.impl.scan.InvertingPackageScanFilter;
 import org.apache.camel.spring.CamelBeanPostProcessor;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.CastUtils;
@@ -77,15 +72,6 @@ public abstract class CamelSpringTestSup
         processor.postProcessAfterInitialization(this, getClass().getName());
     }
 
-    private static class ExcludingPackageScanClassResolver extends DefaultPackageScanClassResolver {
-
-        public void setExcludedClasses(Set<Class<?>> excludedClasses) {
-            Set<Class<?>> parents = excludedClasses == null ? Collections.<Class<?>>emptySet() : excludedClasses;
-            addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(parents)));
-        }
-
-    }
-
     /**
      * Create a parent context that initializes a
      * {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given classes from

Copied: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java?p2=camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+import java.util.Collections;
+import java.util.Set;
 
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import org.apache.camel.impl.DefaultPackageScanClassResolver;
+import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
+import org.apache.camel.impl.scan.InvertingPackageScanFilter;
 
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
+public class ExcludingPackageScanClassResolver extends DefaultPackageScanClassResolver {
 
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
+    public void setExcludedClasses(Set<Class<?>> excludedClasses) {
+        Set<Class<?>> parents = excludedClasses == null ? Collections.<Class<?>>emptySet() : excludedClasses;
+        addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(parents)));
     }
 
 }

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java Sun Mar 25 16:14:46 2012
@@ -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.junit4;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.camel.test.spring.CamelSpringTestContextLoader;
+import org.apache.camel.test.spring.CamelSpringTestContextLoaderTestExecutionListener;
+import org.apache.camel.test.spring.DisableJmxTestExecutionListener;
+import org.apache.camel.test.spring.StopWatchTestExecutionListener;
+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 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 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;
+        }
+    }
+}

Modified: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java?rev=1305069&r1=1305068&r2=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java (original)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java Sun Mar 25 16:14:46 2012
@@ -17,16 +17,12 @@
 package org.apache.camel.test.junit4;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 import org.apache.camel.CamelContext;
-import org.apache.camel.impl.DefaultPackageScanClassResolver;
-import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
-import org.apache.camel.impl.scan.InvertingPackageScanFilter;
 import org.apache.camel.spring.CamelBeanPostProcessor;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.ExcludingPackageScanClassResolver;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.ObjectHelper;
 import org.junit.After;
@@ -111,16 +107,7 @@ public abstract class CamelSpringTestSup
             threadAppContext.remove();
         }
     }
-
-    private static class ExcludingPackageScanClassResolver extends DefaultPackageScanClassResolver {
-
-        public void setExcludedClasses(Set<Class<?>> excludedClasses) {
-            Set<Class<?>> parents = excludedClasses == null ? Collections.<Class<?>>emptySet() : excludedClasses;
-            addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(parents)));
-        }
-
-    }
-
+    
     /**
      * Create a parent context that initializes a
      * {@link org.apache.camel.spi.PackageScanClassResolver} to exclude a set of given classes from

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java Sun Mar 25 16:14:46 2012
@@ -0,0 +1,429 @@
+/**
+ * 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.Set;
+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.apache.camel.util.CastUtils;
+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.support.AbstractContextLoader;
+import org.springframework.test.context.support.AbstractGenericContextLoader;
+import org.springframework.test.context.support.GenericXmlContextLoader;
+import org.springframework.util.StringUtils;
+
+/**
+ * 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 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();
+        
+        try {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Loading ApplicationContext for locations ["
+                        + StringUtils.arrayToCommaDelimitedString(locations) + "].");
+            }
+            
+            GenericApplicationContext context = createContext(testClass);
+            (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(locations);
+            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);
+            handleLazyLoadTypeConverters(context, testClass);
+            
+            // CamelContext(s) startup
+            handleCamelContextStartup(context, testClass);
+            
+            return context;
+        } finally {
+            SpringCamelContext.setNoStart(false);
+            
+            if (testClass.isAnnotationPresent(DisableJmx.class)) {
+                if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+                    System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+                } else {
+                    System.setProperty(JmxSystemPropertyKeys.DISABLED,
+                        CamelSpringTestHelper.getOriginalJmxDisabled());
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns &quot;<code>-context.xml</code>&quot;.
+     */
+    @Override
+    public String getResourceSuffix() {
+        return "-context.xml";
+    }
+    
+    /**
+     * Returns all methods defined in {@code clazz} and its superclasses/interfaces.
+     */
+    protected Collection<Method> getAllMethods(Class<?> clazz)  {
+        
+        Set<Method> methods = new HashSet<Method>();
+        Class<?> currentClass = clazz;
+        
+        while (currentClass != null) {
+            methods.addAll(Arrays.asList(clazz.getMethods()));
+            currentClass = currentClass.getSuperclass(); 
+        }
+                
+        return methods;
+    }
+    
+    /**
+     * 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) {
+
+        GenericApplicationContext routeExcludingContext = null;
+        
+        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) + "].");
+                }
+                
+                routeExcludingContext = new GenericApplicationContext();
+                routeExcludingContext.registerBeanDefinition(
+                        "excludingResolver", new RootBeanDefinition(
+                                ExcludingPackageScanClassResolver.class));
+                routeExcludingContext.refresh();
+                
+                ExcludingPackageScanClassResolver excludingResolver = routeExcludingContext.getBean("excludingResolver", ExcludingPackageScanClassResolver.class);
+                List<Class<?>> excluded = CastUtils.cast(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 {
+            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
+     * @param log the logger to use
+     * @param statics if static methods or instance methods should be 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, new Object[] {}));
+                } 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));
+                }
+            });
+        }
+    }
+    
+    @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();
+    }
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java Sun Mar 25 16:14:46 2012
@@ -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.
+ */
+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());
+    }    
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java Sun Mar 25 16:14:46 2012
@@ -0,0 +1,103 @@
+/**
+ * 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.HashSet;
+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 HashSet<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;
+    }
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java Sun Mar 25 16:14:46 2012
@@ -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;
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java Sun Mar 25 16:14:46 2012
@@ -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.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());
+        }
+    }
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java Sun Mar 25 16:14:46 2012
@@ -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.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 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 exlcude from resolution when using package scanning. 
+     */
+    Class<?>[] value() default {};
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java Sun Mar 25 16:14:46 2012
@@ -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;
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java Sun Mar 25 16:14:46 2012
@@ -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 "*";
+}

Copied: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java?p2=camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test.spring;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+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 static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
-
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
-
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
-    }
+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 {
 }

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java Sun Mar 25 16:14:46 2012
@@ -0,0 +1,47 @@
+/**
+ * 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;
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java Sun Mar 25 16:14:46 2012
@@ -0,0 +1,61 @@
+/**
+ * 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 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("********************************************************************************");
+    }
+}

Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java?rev=1305069&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java Sun Mar 25 16:14:46 2012
@@ -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.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;
+}

Copied: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java?p2=camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test.junit4;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+import org.apache.camel.management.DefaultManagementStrategy;
+import org.apache.camel.test.spring.DisableJmx;
 
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
+@DisableJmx
+public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest
+        extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
 
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
+    @Test
+    public void testJmx() throws Exception {
+        assertEquals(DefaultManagementStrategy.class, camelContext.getManagementStrategy().getClass());
     }
-
 }

Copied: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java?p2=camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
-
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
-
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
-
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
-    }
+package org.apache.camel.test.junit4;
 
+public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest 
+        extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
 }

Copied: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java?p2=camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test.junit4;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+import org.apache.camel.management.ManagedManagementStrategy;
+import org.apache.camel.test.spring.DisableJmx;
 
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
+@DisableJmx(false)
+public class CamelSpringJUnit4ClassRunnerDisableJmxTest 
+        extends CamelSpringJUnit4ClassRunnerPlainTest {
 
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
+    @Test
+    @Override
+    public void testJmx() throws Exception {
+        assertEquals(ManagedManagementStrategy.class, camelContext.getManagementStrategy().getClass());
     }
-
 }

Copied: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java?p2=camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test.junit4;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+import org.apache.camel.test.spring.ExcludeRoutes;
 
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import static org.junit.Assert.assertNull;
 
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
+@ExcludeRoutes(TestRouteBuilder.class)
+public class CamelSpringJUnit4ClassRunnerExcludeRoutesTest
+        extends CamelSpringJUnit4ClassRunnerPlainTest {
 
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
+    @Override
+    public void testExcludedRoute() {
+        assertNull(camelContext.getRoute("excludedRoute"));
     }
-
 }

Copied: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java (from r1305042, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java?p2=camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java&r1=1305042&r2=1305069&rev=1305069&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.java (original)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java Sun Mar 25 16:14:46 2012
@@ -14,17 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.management;
+package org.apache.camel.test.junit4;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.management.ManagedRouteRemoveRouteScopedErrorHandlerTest;
+import org.apache.camel.test.spring.LazyLoadTypeConverters;
 
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
 
-public class SpringManagedRouteRemoveRouteScopedErrorHandlerTest extends ManagedRouteRemoveRouteScopedErrorHandlerTest {
+@SuppressWarnings("deprecation")
+@LazyLoadTypeConverters(true)
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest 
+        extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest {
 
-    protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedRouteRemoveRouteScopedErrorHandlerTest.xml");
+    @Test
+    @Override
+    public void testLazyLoadTypeConverters() {
+        assertTrue(camelContext.isLazyLoadTypeConverters());
+        assertTrue(camelContext2.isLazyLoadTypeConverters());
     }
-
 }



Mime
View raw message