Author: davsclaus
Date: Wed Oct 31 08:29:54 2012
New Revision: 1404024

URL: http://svn.apache.org/viewvc?rev=1404024&view=rev
Log:
Polished and fixed test on slow CI server.

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
    
camel/branches/camel-2.10.x/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1404020

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunner.java
 Wed Oct 31 08:29:54 2012
@@ -34,12 +34,9 @@ import org.springframework.test.context.
  * for their Spring based applications/routes using the typical Spring Test 
conventions
  * for test development.
  */
-public class CamelSpringJUnit4ClassRunner extends
-        SpringJUnit4ClassRunner {
+public class CamelSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
 
-    public CamelSpringJUnit4ClassRunner(Class<?> clazz)
-        throws InitializationError {
-        
+    public CamelSpringJUnit4ClassRunner(Class<?> clazz) throws 
InitializationError {
         super(clazz);
     }
 
@@ -71,8 +68,7 @@ public class CamelSpringJUnit4ClassRunne
      */
     public static final class CamelTestContextManager extends 
TestContextManager {
 
-        public CamelTestContextManager(Class<?> testClass,
-                String defaultContextLoaderClassName) {
+        public CamelTestContextManager(Class<?> testClass, String 
defaultContextLoaderClassName) {
             super(testClass, defaultContextLoaderClassName);
         }
 
@@ -81,19 +77,16 @@ public class CamelSpringJUnit4ClassRunne
          * for the Camel testing features.
          */
         @Override
-        protected Set<Class<? extends TestExecutionListener>> 
-        getDefaultTestExecutionListenerClasses() {
-            
-            Set<Class<? extends TestExecutionListener>> classes = 
-                    new LinkedHashSet<Class<? extends 
TestExecutionListener>>();
-            
+        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/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
 Wed Oct 31 08:29:54 2012
@@ -36,12 +36,10 @@ import org.springframework.context.suppo
  * @version 
  */
 public abstract class CamelSpringTestSupport extends CamelTestSupport {
-    protected static ThreadLocal<AbstractApplicationContext> threadAppContext 
-        = new ThreadLocal<AbstractApplicationContext>();
+    protected static ThreadLocal<AbstractApplicationContext> threadAppContext 
= new ThreadLocal<AbstractApplicationContext>();
     protected static Object lock = new Object();
     
     protected AbstractApplicationContext applicationContext;
-    
     protected abstract AbstractApplicationContext createApplicationContext();
 
     /**

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
 Wed Oct 31 08:29:54 2012
@@ -49,6 +49,8 @@ import org.springframework.test.context.
 import org.springframework.test.context.support.GenericXmlContextLoader;
 import org.springframework.util.StringUtils;
 
+import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
+
 /**
  * Replacement for the default {@link GenericXmlContextLoader} that provides 
hooks for
  * processing some class level Camel related test annotations.
@@ -64,7 +66,7 @@ public class CamelSpringTestContextLoade
      *  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
+     *  For some functionality, we cannot use {@link 
org.springframework.test.context.TestExecutionListener} because we need
      *  to both produce the desired outcome during application context 
loading, and also cleanup
      *  after ourselves even if the test class never executes.  Thus the 
listeners, which
      *  only run if the application context is successfully initialized are 
insufficient to
@@ -72,12 +74,10 @@ public class CamelSpringTestContextLoade
      */
     @Override
     public ApplicationContext loadContext(MergedContextConfiguration 
mergedConfig) throws Exception {
-        
         Class<?> testClass = getTestClass();
         
         if (LOG.isDebugEnabled()) {
-            LOG.debug(String.format("Loading ApplicationContext for merged 
context configuration [%s].",
-                mergedConfig));
+            LOG.debug("Loading ApplicationContext for merged context 
configuration [{}].", mergedConfig);
         }
         
         try {            
@@ -97,7 +97,7 @@ public class CamelSpringTestContextLoade
      *  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
+     *  For some functionality, we cannot use {@link 
org.springframework.test.context.TestExecutionListener} because we need
      *  to both produce the desired outcome during application context 
loading, and also cleanup
      *  after ourselves even if the test class never executes.  Thus the 
listeners, which
      *  only run if the application context is successfully initialized are 
insufficient to
@@ -109,8 +109,7 @@ public class CamelSpringTestContextLoade
         Class<?> testClass = getTestClass();
         
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Loading ApplicationContext for locations ["
-                    + StringUtils.arrayToCommaDelimitedString(locations) + 
"].");
+            LOG.debug("Loading ApplicationContext for locations [" + 
StringUtils.arrayToCommaDelimitedString(locations) + "].");
         }
         
         try {
@@ -135,13 +134,11 @@ public class CamelSpringTestContextLoade
      *
      * @param context the partially configured context.  The context should 
have the bean definitions loaded, but nothing else.
      * @param testClass the test class being executed
-     *
      * @return the initialized (refreshed) Spring application context
      *
      * @throws Exception if there is an error during 
initialization/customization
      */
-    protected ApplicationContext loadContext(GenericApplicationContext 
context, Class<?> testClass)
-        throws Exception {
+    protected ApplicationContext loadContext(GenericApplicationContext 
context, Class<?> testClass) throws Exception {
             
         AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
         
@@ -196,48 +193,25 @@ public class CamelSpringTestContextLoade
     }
     
     /**
-     * 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();
+            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) + "].");
+                            + "annotation was found. Excluding [" + 
StringUtils.arrayToCommaDelimitedString(excludedClasses) + "].");
                 }
                 
                 routeExcludingContext = new GenericApplicationContext();
-                routeExcludingContext.registerBeanDefinition(
-                        "excludingResolver", new RootBeanDefinition(
-                                ExcludingPackageScanClassResolver.class));
+                
routeExcludingContext.registerBeanDefinition("excludingResolver", new 
RootBeanDefinition(ExcludingPackageScanClassResolver.class));
                 routeExcludingContext.refresh();
                 
                 ExcludingPackageScanClassResolver excludingResolver = 
routeExcludingContext.getBean("excludingResolver", 
ExcludingPackageScanClassResolver.class);
@@ -252,7 +226,7 @@ public class CamelSpringTestContextLoade
         }
         
         GenericApplicationContext context;
-        
+
         if (routeExcludingContext != null) {
             context = new GenericApplicationContext(routeExcludingContext);
         } else {
@@ -269,26 +243,18 @@ public class CamelSpringTestContextLoade
      * @param testClass the test class being executed
      */
     protected void handleDisableJmx(GenericApplicationContext context, 
Class<?> testClass) {
-        CamelSpringTestHelper.setOriginalJmxDisabledValue(
-                System.getProperty(JmxSystemPropertyKeys.DISABLED));
+        
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.");
-                
+                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.");
-                
+                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.");
-            
+            LOG.info("Disabling Camel JMX globally for tests by default.  Use 
the DisableJMX annotation to override the default setting.");
             System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
         }
     }
@@ -299,18 +265,14 @@ public class CamelSpringTestContextLoade
      *
      * @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) {
@@ -328,7 +290,7 @@ public class CamelSpringTestContextLoade
                 }
                 
                 try {
-                    breakpoints.add((Breakpoint) method.invoke(null, new 
Object[] {}));
+                    breakpoints.add((Breakpoint) method.invoke(null));
                 } catch (Exception e) {
                     throw new RuntimeException("Method [" + method.getName()
                            + "] threw exception during evaluation.", e);
@@ -337,13 +299,11 @@ public class CamelSpringTestContextLoade
         }
         
         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();
@@ -351,10 +311,7 @@ public class CamelSpringTestContextLoade
                     }
                     
                     for (Breakpoint breakpoint : breakpoints) {
-                        LOG.info(
-                                 "Adding Breakpoint [{}] to CamelContext with 
name [{}].",
-                                 breakpoint, contextName);
-                        
+                        LOG.info("Adding Breakpoint [{}] to CamelContext with 
name [{}].", breakpoint, contextName);
                         debugger.addBreakpoint(breakpoint);
                     }
                 }
@@ -370,7 +327,6 @@ public class CamelSpringTestContextLoade
      * @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)) {
@@ -386,10 +342,7 @@ public class CamelSpringTestContextLoade
             @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});
+                LOG.info("Setting shutdown timeout to [{} {}] on CamelContext 
with name [{}].", new Object[]{shutdownTimeout, shutdownTimeUnit, contextName});
                 camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
                 
camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
             }
@@ -404,19 +357,14 @@ public class CamelSpringTestContextLoade
      */
     protected void handleMockEndpoints(GenericApplicationContext context, 
Class<?> testClass) throws Exception {
         if (testClass.isAnnotationPresent(MockEndpoints.class)) {
-            
-            final String mockEndpoints = testClass.getAnnotation(
-                    MockEndpoints.class).value();
+            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));
+                    LOG.info("Enabling auto mocking of endpoints matching 
pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
+                    camelContext.addRegisterEndpointCallback(new 
InterceptSendToMockEndpointStrategy(mockEndpoints));
                 }
             });
         }
@@ -431,19 +379,14 @@ public class CamelSpringTestContextLoade
      */
     protected void handleMockEndpointsAndSkip(GenericApplicationContext 
context, Class<?> testClass) throws Exception {
         if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
-            
-            final String mockEndpoints = testClass.getAnnotation(
-                    MockEndpointsAndSkip.class).value();
+            final String mockEndpoints = 
testClass.getAnnotation(MockEndpointsAndSkip.class).value();
             CamelSpringTestHelper.doToSpringCamelContexts(context, new 
DoToSpringCamelContextsStrategy() {
                 
                 @Override
                 public void execute(String contextName, SpringCamelContext 
camelContext)
                     throws Exception {
-                    
-                    LOG.info("Enabling auto mocking and skipping of endpoints 
matching pattern [{}] on "
-                            + "CamelContext with name [{}].", mockEndpoints, 
contextName);
-                    camelContext.addRegisterEndpointCallback(
-                            new 
InterceptSendToMockEndpointStrategy(mockEndpoints, true));
+                    LOG.info("Enabling auto mocking and skipping of endpoints 
matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, 
contextName);
+                    camelContext.addRegisterEndpointCallback(new 
InterceptSendToMockEndpointStrategy(mockEndpoints, true));
                 }
             });
         }
@@ -465,9 +408,7 @@ public class CamelSpringTestContextLoade
                 @Override
                 public void execute(String contextName, SpringCamelContext 
camelContext)
                     throws Exception {
-                    
-                    LOG.info("Enabling lazy loading of type converters on "
-                            + "CamelContext with name [{}].", contextName);
+                    LOG.info("Enabling lazy loading of type converters on 
CamelContext with name [{}].", contextName);
                     camelContext.setLazyLoadTypeConverters(lazy);
                 }
             });
@@ -483,16 +424,13 @@ public class CamelSpringTestContextLoade
     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.");
+            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.");
+                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.");
+                LOG.info("Starting CamelContext(s) as UseAdviceWith annotation 
was found, but isUseAdviceWith is set to false.");
                 skip = false;
             }
         }

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoaderTestExecutionListener.java
 Wed Oct 31 08:29:54 2012
@@ -27,8 +27,7 @@ import org.springframework.test.context.
  * 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 {
+public class CamelSpringTestContextLoaderTestExecutionListener extends 
AbstractTestExecutionListener {
 
     @Override
     public void prepareTestInstance(TestContext testContext) throws Exception {

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
 Wed Oct 31 08:29:54 2012
@@ -19,7 +19,7 @@ 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.LinkedHashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -40,7 +40,6 @@ import org.springframework.context.Appli
 public final class CamelSpringTestHelper {
     
     private static ThreadLocal<String> originalJmxDisabledValue = new 
ThreadLocal<String>();
-    
     private static ThreadLocal<Class<?>> testClazz = new 
ThreadLocal<Class<?>>();
     
     private CamelSpringTestHelper() {
@@ -66,8 +65,7 @@ public final class CamelSpringTestHelper
      * Returns all methods defined in {@code clazz} and its 
superclasses/interfaces.
      */
     public static Collection<Method> getAllMethods(Class<?> clazz)  {
-        
-        Set<Method> methods = new HashSet<Method>();
+        Set<Method> methods = new LinkedHashSet<Method>();
         Class<?> currentClass = clazz;
         
         while (currentClass != null) {
@@ -87,10 +85,8 @@ public final class CamelSpringTestHelper
      *
      * @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);
+    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());

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
 Wed Oct 31 08:29:54 2012
@@ -22,19 +22,18 @@ import org.springframework.test.context.
 
 /**
  * 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.
+ * support in Camel through the use of {@link DisableJmx}.
+ * Tries to ensure that the pre-test value is restored.
  */
-public class DisableJmxTestExecutionListener extends
-        AbstractTestExecutionListener {
+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());
+            System.setProperty(JmxSystemPropertyKeys.DISABLED, 
CamelSpringTestHelper.getOriginalJmxDisabled());
         }
     }
+
 }

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ExcludeRoutes.java
 Wed Oct 31 08:29:54 2012
@@ -34,8 +34,9 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE})
 public @interface ExcludeRoutes {
+
     /**
-     * The classes to exlcude from resolution when using package scanning. 
+     * The classes to exclude from resolution when using package scanning.
      */
     Class<?>[] value() default {};
 }

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/ShutdownTimeout.java
 Wed Oct 31 08:29:54 2012
@@ -35,8 +35,10 @@ import java.util.concurrent.TimeUnit;
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.TYPE})
 public @interface ShutdownTimeout {
+
     /**
-     * The shutdown timeout to set on the {@code CamelContext}(s).   Defaults 
to {@code 10} seconds. 
+     * The shutdown timeout to set on the {@code CamelContext}(s).
+     * Defaults to {@code 10} seconds.
      */
     int value() default 10;
     

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/StopWatchTestExecutionListener.java
 Wed Oct 31 08:29:54 2012
@@ -24,16 +24,14 @@ import org.springframework.test.context.
 import org.springframework.test.context.support.AbstractTestExecutionListener;
 
 /**
- * An execution listener that simulates the timing output built in to {@link 
CamelTestSupport}.
+ * An execution listener that simulates the timing output built in to {@link 
org.apache.camel.test.junit4.CamelTestSupport}.
  */
-public class StopWatchTestExecutionListener extends
-        AbstractTestExecutionListener {
+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.
+     * 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();
@@ -58,4 +56,5 @@ public class StopWatchTestExecutionListe
         log.info("Took: " + TimeUtils.printDuration(time) + " ("  + time + " 
millis)");
         
log.info("********************************************************************************");
     }
+
 }

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/UseAdviceWith.java
 Wed Oct 31 08:29:54 2012
@@ -42,7 +42,8 @@ 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}. 
+     * automatically.
+     * Defaults to {@code true}.
      */
     boolean value() default true;
 }

Modified: 
camel/branches/camel-2.10.x/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java?rev=1404024&r1=1404023&r2=1404024&view=diff
==============================================================================
--- 
camel/branches/camel-2.10.x/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-test-spring/src/test/java/org/apache/camel/test/junit4/CamelSpringJUnit4ClassRunnerUseAdviceWithTest.java
 Wed Oct 31 08:29:54 2012
@@ -20,9 +20,9 @@ import org.apache.camel.ServiceStatus;
 import org.apache.camel.test.spring.StopWatchTestExecutionListener;
 import org.apache.camel.test.spring.UseAdviceWith;
 import org.apache.camel.util.StopWatch;
-
 import org.junit.Before;
 import org.junit.Test;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -37,8 +37,9 @@ public class CamelSpringJUnit4ClassRunne
         assertEquals(ServiceStatus.Stopped, camelContext2.getStatus());
         camelContext.start();
         camelContext2.start();
-        
-        Thread.sleep(4000);
+
+        // just sleep a little to simulate testing take a bit time
+        Thread.sleep(1000);
     }
     
     @Test
@@ -46,6 +47,8 @@ public class CamelSpringJUnit4ClassRunne
         StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
         
         assertNotNull(stopWatch);
-        assertTrue(stopWatch.taken() < 4100);
+        long taken = stopWatch.taken();
+        assertTrue(taken + " > 0, but was: " + taken, taken > 0);
+        assertTrue(taken + " < 3000, but was: " + taken, taken < 3000);
     }
 }


Reply via email to