You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dv...@apache.org on 2012/02/06 21:10:42 UTC
svn commit: r1241143 [1/2] - in /camel/trunk/components/camel-test-spring:
./ src/main/java/org/apache/camel/test/
src/main/java/org/apache/camel/test/junit4/
src/main/java/org/apache/camel/test/spring/
src/test/java/org/apache/camel/test/junit4/ src/t...
Author: dvaleri
Date: Mon Feb 6 20:10:40 2012
New Revision: 1241143
URL: http://svn.apache.org/viewvc?rev=1241143&view=rev
Log:
[CAMEL-4987] Push of initial Spring Test integration code.
Added:
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java (with props)
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerPlainTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerProvidesBreakpointInherritedTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerProvidesBreakpointTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedOverrideTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutInheritedTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerShutdownTimeoutTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java (with props)
camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/TestRouteBuilder.java (with props)
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/
camel/trunk/components/camel-test-spring/src/test/resources/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerPlainTest-context.xml (with props)
Modified:
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
Modified: camel/trunk/components/camel-test-spring/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/pom.xml?rev=1241143&r1=1241142&r2=1241143&view=diff
==============================================================================
--- camel/trunk/components/camel-test-spring/pom.xml (original)
+++ camel/trunk/components/camel-test-spring/pom.xml Mon Feb 6 20:10:40 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=1241143&r1=1241142&r2=1241143&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 Mon Feb 6 20:10:40 2012
@@ -17,16 +17,11 @@
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.Route;
-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;
@@ -75,15 +70,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
Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java Mon Feb 6 20:10:40 2012
@@ -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;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.camel.impl.DefaultPackageScanClassResolver;
+import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
+import org.apache.camel.impl.scan.InvertingPackageScanFilter;
+
+public class ExcludingPackageScanClassResolver extends DefaultPackageScanClassResolver {
+
+ public void setExcludedClasses(Set<Class<?>> excludedClasses) {
+ Set<Class<?>> parents = excludedClasses == null ? Collections.<Class<?>>emptySet() : excludedClasses;
+ addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(parents)));
+ }
+
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/ExcludingPackageScanClassResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 2012
@@ -0,0 +1,100 @@
+/**
+ * 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.CamelSpringTestSupport;
+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;
+ }
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&r1=1241142&r2=1241143&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 Mon Feb 6 20:10:40 2012
@@ -17,17 +17,13 @@
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.Route;
-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;
@@ -112,16 +108,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=1241143&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 Mon Feb 6 20:10:40 2012
@@ -0,0 +1,428 @@
+/**
+ * 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 "<code>-context.xml</code>".
+ */
+ @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));
+ }
+ });
+ }
+ }
+
+ 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();
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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());
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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;
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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;
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmx.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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());
+ }
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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 just 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 {};
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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 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.
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface LazyLoadTypeConverters {
+
+ /**
+ * Whether the test annotated with this annotation should be run with lazy type converter loading in Camel.
+ * Defaults to {@code true}.
+ */
+ boolean value() default true;
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/LazyLoadTypeConverters.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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 "*";
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/MockEndpoints.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java (added)
+++ camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java Mon Feb 6 20:10:40 2012
@@ -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 java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * TODO
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD})
+public @interface ProvidesBreakpoint {
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ProvidesBreakpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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;
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 2012
@@ -0,0 +1,62 @@
+/**
+ * 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.test.CamelTestSupport;
+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("********************************************************************************");
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1241143&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 Mon Feb 6 20:10:40 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 CamelContexts} 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;
+}
Propchange: camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java Mon Feb 6 20:10:40 2012
@@ -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.junit4;
+
+import org.apache.camel.management.DefaultManagementStrategy;
+import org.apache.camel.test.spring.DisableJmx;
+
+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());
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedOverrideTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java Mon Feb 6 20:10:40 2012
@@ -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.junit4;
+
+public class CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest
+ extends CamelSpringJUnit4ClassRunnerDisableJmxTest {
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxInheritedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java Mon Feb 6 20:10:40 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.junit4;
+
+import org.apache.camel.management.ManagedManagementStrategy;
+import org.apache.camel.test.spring.DisableJmx;
+
+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());
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerDisableJmxTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java Mon Feb 6 20:10:40 2012
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.junit4;
+
+import org.apache.camel.test.spring.ExcludeRoutes;
+
+import static org.junit.Assert.assertNull;
+
+@ExcludeRoutes(TestRouteBuilder.class)
+public class CamelSpringJUnit4ClassRunnerExcludeRoutesTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Override
+ public void testExcludedRoute() {
+ assertNull(camelContext.getRoute("excludedRoute"));
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerExcludeRoutesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java Mon Feb 6 20:10:40 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.junit4;
+
+import org.apache.camel.test.spring.LazyLoadTypeConverters;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+@LazyLoadTypeConverters(true)
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest
+ extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest {
+
+ @Test
+ @Override
+ public void testLazyLoadTypeConverters() {
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedOverrideTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java Mon Feb 6 20:10:40 2012
@@ -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.junit4;
+
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest
+ extends CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest {
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersInheritedTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java Mon Feb 6 20:10:40 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.test.junit4;
+
+import org.apache.camel.test.spring.LazyLoadTypeConverters;
+
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+
+@LazyLoadTypeConverters(false)
+public class CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Test
+ @Override
+ public void testLazyLoadTypeConverters() {
+ assertFalse(camelContext.isLazyLoadTypeConverters());
+ assertFalse(camelContext2.isLazyLoadTypeConverters());
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerLazyLoadTypeConvertersTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java?rev=1241143&view=auto
==============================================================================
--- camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java (added)
+++ camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java Mon Feb 6 20:10:40 2012
@@ -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.junit4;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.MockEndpoints;
+import org.junit.Test;
+
+@MockEndpoints("log:*")
+public class CamelSpringJUnit4ClassRunnerMockEndpointsTest
+ extends CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @EndpointInject(uri = "mock:log:org.apache.camel.test.junit4.spring", context = "camelContext2")
+ protected MockEndpoint mockLog;
+
+ @Test
+ @Override
+ public void testPositive() throws Exception {
+ mockLog.expectedBodiesReceived("Hell David");
+
+ super.testPositive();
+ }
+}
Propchange: camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerMockEndpointsTest.java
------------------------------------------------------------------------------
svn:eol-style = native