camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1100508 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/converter/ camel-core/src/main/java/org/apache/camel/impl/converter/ camel-core/src/main/java/org/apache/camel/impl/osgi/ camel-core/src/main/resources/META-INF/ser...
Date Sat, 07 May 2011 10:43:55 GMT
Author: davsclaus
Date: Sat May  7 10:43:52 2011
New Revision: 1100508

URL: http://svn.apache.org/viewvc?rev=1100508&view=rev
Log:
CAMEL-3953, CAMEL-3954, CAMEL-3260: camel-core now loads type converter without classpath scanning. This speeup starting CamelContext and unit testing. CAMEL-3032: Do not use camel-test JAR in pomx.xml.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CorePackageScanClassResolver.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceDummyFallbackConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceMethodWithExchangeTestConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/MyFallbackPromoteConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/PurchaseOrderConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticDummyFallbackConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java   (contents, props changed)
      - copied, changed from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticMethodWithExchangeTestConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockNoLazyTypeConverterTest.java
      - copied, changed from r1100321, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java
    camel/trunk/camel-core/src/test/resources/META-INF/services/
    camel/trunk/camel-core/src/test/resources/META-INF/services/org/
    camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/
    camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/
    camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/XPathFilterTest.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/LanguageTestSupport.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/LanguageTestSupport.java
    camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugNoLazyTypeConverterTest.java
      - copied, changed from r1100247, camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugTest.java
    camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/LanguageTestSupport.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/DebugNoLazyTypeConverterTest.java
      - copied, changed from r1100247, camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/DebugTest.java
Removed:
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceDummyFallbackConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceMethodWithExchangeTestConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/MyFallbackPromoteConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/PurchaseOrderConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticDummyFallbackConverter.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticMethodWithExchangeTestConverter.java
    camel/trunk/components/camel-core-osgi/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
    camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
    camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/PredicateBinaryCoerceRouteTest.java
    camel/trunk/camel-core/src/test/resources/log4j.properties
    camel/trunk/components/camel-blueprint/pom.xml
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java
    camel/trunk/components/camel-groovy/pom.xml
    camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyInvokeMethodTest.java
    camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
    camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetFixedHeaderTest.java
    camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetHeaderTest.java
    camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/processor/groovy/GroovyFilterTest.java
    camel/trunk/components/camel-groovy/src/test/resources/org/apache/camel/processor/groovy/groovyFilter.xml
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMinMaxThreadPoolTest.java
    camel/trunk/components/camel-juel/pom.xml
    camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelLanguageTest.java
    camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelTest.java
    camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/NullBodyTest.java
    camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/issues/XsltLosesHeaderTest.java
    camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java
    camel/trunk/components/camel-msv/pom.xml
    camel/trunk/components/camel-msv/src/test/java/org/apache/camel/component/validator/msv/RelaxNGRouteTest.java
    camel/trunk/components/camel-mvel/pom.xml
    camel/trunk/components/camel-mvel/src/test/java/org/apache/camel/language/mvel/MvelTest.java
    camel/trunk/components/camel-ognl/pom.xml
    camel/trunk/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlInvokeMethodTest.java
    camel/trunk/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
    camel/trunk/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/patterns/FilterTest.java
    camel/trunk/components/camel-script/pom.xml
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/AnyLanguageFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/BeanShellFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/GroovyFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/JavaScriptFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/PythonFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/example/RubyFilterTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java
    camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/osgi/OsgiSpringCamelContext.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelTestSupport.java
    camel/trunk/components/camel-testng/src/main/java/org/apache/camel/testng/CamelTestSupport.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/DebugTest.java
    camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/FilterTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/ObjectConverter.java Sat May  7 10:43:52 2011
@@ -214,6 +214,8 @@ public final class ObjectConverter {
         }
     }
 
+    // add fast type converters from most common used
+
     @Converter
     public static String toString(Integer value) {
         return value.toString();
@@ -239,4 +241,29 @@ public final class ObjectConverter {
         return value.toString();
     }
 
+    @Converter
+    public static Integer toInteger(String value) {
+        return Integer.valueOf(value);
+    }
+
+    @Converter
+    public static Long toLong(String value) {
+        return Long.valueOf(value);
+    }
+
+    @Converter
+    public static Float toFloat(String value) {
+        return Float.valueOf(value);
+    }
+
+    @Converter
+    public static Double toDouble(String value) {
+        return Double.valueOf(value);
+    }
+
+    @Converter
+    public static Boolean toBoolean(String value) {
+        return "true".equalsIgnoreCase(value.toString()) ? Boolean.TRUE : Boolean.FALSE;
+    }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/AnnotationTypeConverterLoader.java Sat May  7 10:43:52 2011
@@ -74,6 +74,16 @@ public class AnnotationTypeConverterLoad
             throw new TypeConverterLoaderException("Cannot find package names to be used for classpath scanning for annotated type converters.", e);
         }
 
+        // if we only have camel-core on the classpath then we have already pre-loaded all its type converters
+        // but we exposed the "org.apache.camel.core" package in camel-core. This ensures there is at least one
+        // packageName to scan, which triggers the scanning process. That allows us to ensure that we look for
+        // type converters in all the JARs.
+        if (packageNames.length == 1 && "org.apache.camel.core".equals(packageNames[0])) {
+            LOG.debug("No additional package names found in classpath for annotated type converters.");
+            // no additional package names found to load type converters so break out
+            return;
+        }
+
         Set<Class<?>> classes = resolver.findAnnotated(Converter.class, packageNames);
         if (classes == null || classes.isEmpty()) {
             throw new TypeConverterLoaderException("Cannot find any type converter classes from the following packages: " + Arrays.asList(packageNames));

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java Sat May  7 10:43:52 2011
@@ -57,11 +57,13 @@ public abstract class BaseTypeConverterR
     protected final Map<TypeMapping, TypeMapping> misses = new ConcurrentHashMap<TypeMapping, TypeMapping>();
     protected final List<TypeConverterLoader> typeConverterLoaders = new ArrayList<TypeConverterLoader>();
     protected final List<FallbackTypeConverter> fallbackConverters = new ArrayList<FallbackTypeConverter>();
+    protected final PackageScanClassResolver resolver;
     protected Injector injector;
     protected final FactoryFinder factoryFinder;
     protected final PropertyEditorTypeConverter propertyEditorTypeConverter = new PropertyEditorTypeConverter();
 
     public BaseTypeConverterRegistry(PackageScanClassResolver resolver, Injector injector, FactoryFinder factoryFinder) {
+        this.resolver = resolver;
         this.injector = injector;
         this.factoryFinder = factoryFinder;
         this.typeConverterLoaders.add(new AnnotationTypeConverterLoader(resolver));
@@ -379,12 +381,27 @@ public abstract class BaseTypeConverterR
     }
 
     /**
+     * Loads the core type converters which is mandatory to use Camel
+     */
+    protected void loadCoreTypeConverters() throws Exception {
+        int before = typeMappings.size();
+
+        // load all the type converters from camel-core
+        CoreTypeConverterLoader core = new CoreTypeConverterLoader();
+        core.load(this);
+
+        int delta = typeMappings.size() - before;
+        log.info("Loaded {} core type converters (total {} type converters)" , delta, typeMappings.size());
+    }
+
+    /**
      * Checks if the registry is loaded and if not lazily load it
      */
     protected void loadTypeConverters() throws Exception {
         StopWatch watch = new StopWatch();
+        int before = typeMappings.size();
 
-        log.debug("Loading type converters ...");
+        log.debug("Loading additional type converters ...");
         for (TypeConverterLoader typeConverterLoader : getTypeConverterLoaders()) {
             typeConverterLoader.load(this);
         }
@@ -395,11 +412,13 @@ public abstract class BaseTypeConverterR
         } catch (NoFactoryAvailableException e) {
             // ignore its fine to have none
         }
-        log.debug("Loading type converters done");
+        log.debug("Loading additional type converters done");
 
         // report how long time it took to load
+        int delta = typeMappings.size() - before;
         if (log.isInfoEnabled()) {
-            log.info("Loaded " + typeMappings.size() + " type converters in " + TimeUtils.printDuration(watch.stop()));
+            log.info("Loaded additional " + delta + " type converters (total " + typeMappings.size()
+                    + " type converters) in " + TimeUtils.printDuration(watch.stop()));
         }
     }
 

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CorePackageScanClassResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CorePackageScanClassResolver.java?rev=1100508&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CorePackageScanClassResolver.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CorePackageScanClassResolver.java Sat May  7 10:43:52 2011
@@ -0,0 +1,122 @@
+/**
+ * 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.impl.converter;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.camel.component.bean.BeanConverter;
+import org.apache.camel.component.file.GenericFileConverter;
+import org.apache.camel.converter.CamelConverter;
+import org.apache.camel.converter.CollectionConverter;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.converter.NIOConverter;
+import org.apache.camel.converter.ObjectConverter;
+import org.apache.camel.converter.TimePatternConverter;
+import org.apache.camel.converter.jaxp.DomConverter;
+import org.apache.camel.converter.jaxp.StaxConverter;
+import org.apache.camel.converter.jaxp.StreamSourceConverter;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.converter.stream.StreamCacheConverter;
+import org.apache.camel.spi.PackageScanClassResolver;
+import org.apache.camel.spi.PackageScanFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A {@link org.apache.camel.spi.ClassResolver} which loads type converters
+ * from a hardcoded list of classes.
+ * <p/>
+ * <b>Important:</b> Whenever a new type converter class is added to camel-core
+ * then the class should be added to the list in this class.
+ *
+ * @see CoreTypeConverterLoader
+ */
+public class CorePackageScanClassResolver implements PackageScanClassResolver {
+
+    protected final transient Logger log = LoggerFactory.getLogger(getClass());
+    private final Set<ClassLoader> classLoaders = new LinkedHashSet<ClassLoader>();
+    private final Set<Class<?>> converters = new LinkedHashSet<Class<?>>();
+
+    public CorePackageScanClassResolver() {
+        converters.add(ObjectConverter.class);
+        converters.add(CollectionConverter.class);
+        converters.add(IOConverter.class);
+        converters.add(NIOConverter.class);
+        converters.add(StaxConverter.class);
+        converters.add(DomConverter.class);
+        converters.add(StreamSourceConverter.class);
+        converters.add(XmlConverter.class);
+        converters.add(CamelConverter.class);
+        converters.add(StreamCacheConverter.class);
+        converters.add(TimePatternConverter.class);
+        converters.add(FutureTypeConverter.class);
+        converters.add(BeanConverter.class);
+        converters.add(GenericFileConverter.class);
+    }
+
+    @Override
+    public void setClassLoaders(Set<ClassLoader> classLoaders) {
+        // add all the class loaders
+        this.classLoaders.addAll(classLoaders);
+    }
+
+    @Override
+    public Set<ClassLoader> getClassLoaders() {
+        // return a new set to avoid any concurrency issues in other runtimes such as OSGi
+        return Collections.unmodifiableSet(new LinkedHashSet<ClassLoader>(classLoaders));
+    }
+
+    @Override
+    public void addClassLoader(ClassLoader classLoader) {
+        classLoaders.add(classLoader);
+    }
+
+    @Override
+    public Set<Class<?>> findAnnotated(Class<? extends Annotation> annotation, String... packageNames) {
+        return converters;
+    }
+
+    @Override
+    public Set<Class<?>> findAnnotated(Set<Class<? extends Annotation>> annotations, String... packageNames) {
+        return converters;
+    }
+
+    @Override
+    public Set<Class<?>> findImplementations(Class<?> parent, String... packageNames) {
+        // noop
+        return null;
+    }
+
+    @Override
+    public Set<Class<?>> findByFilter(PackageScanFilter filter, String... packageNames) {
+        // noop
+        return null;
+    }
+
+    @Override
+    public void addFilter(PackageScanFilter filter) {
+        // noop
+    }
+
+    @Override
+    public void removeFilter(PackageScanFilter filter) {
+        // noop
+    }
+}

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java?rev=1100508&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterLoader.java Sat May  7 10:43:52 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.converter;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+/**
+ * Will load all type converters from camel-core without classpath scanning, which makes
+ * it much faster.
+ * <p/>
+ * The {@link CorePackageScanClassResolver} contains a hardcoded list of the type converter classes to load.
+ */
+public class CoreTypeConverterLoader extends AnnotationTypeConverterLoader {
+
+    public CoreTypeConverterLoader() {
+        super(new CorePackageScanClassResolver());
+    }
+
+    @Override
+    protected String[] findPackageNames() throws IOException, URISyntaxException {
+        return new String[]{"org.apache.camel.converter", "org.apache.camel.component.bean", "org.apache.camel.component.file"};
+    }
+
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java Sat May  7 10:43:52 2011
@@ -38,6 +38,7 @@ public class DefaultTypeConverter extend
     protected void doStart() throws Exception {
         super.doStart();
         // load type converters up front
+        loadCoreTypeConverters();
         loadTypeConverters();
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java Sat May  7 10:43:52 2011
@@ -36,7 +36,7 @@ public class EnumTypeConverter implement
     public <T> T convertTo(Class<T> type, Object value) {
         if (type.isEnum() && value != null) {
             String text = value.toString();
-            Method method = null;
+            Method method;
             try {
                 method = type.getMethod("valueOf", String.class);
             } catch (NoSuchMethodException e) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java Sat May  7 10:43:52 2011
@@ -44,38 +44,59 @@ public class LazyLoadingTypeConverter ex
 
     @Override
     protected Object doConvertTo(final Class type, final Exchange exchange, final Object value) {
-        ensureLoaded();
-        return super.doConvertTo(type, exchange, value);
+        Object answer = super.doConvertTo(type, exchange, value);
+        if (answer == null && !loaded.get()) {
+            // okay we could not convert, so try again, but load the converters up front
+            ensureLoaded();
+            answer = super.doConvertTo(type, exchange, value);
+        }
+        return answer;
     }
 
     @Override
     public TypeConverter getTypeConverter(Class<?> toType, Class<?> fromType) {
-        ensureLoaded();
-        return super.getTypeConverter(toType, fromType);
+        TypeConverter answer = super.getTypeConverter(toType, fromType);
+        if (answer == null && !loaded.get()) {
+            // okay we could not convert, so try again, but load the converters up front
+            ensureLoaded();
+            answer = super.getTypeConverter(toType, fromType);
+        }
+        return answer;
     }
 
     @Override
     public Set<Class<?>> getFromClassMappings() {
-        ensureLoaded();
+        if (!loaded.get()) {
+            ensureLoaded();
+        }
         return super.getFromClassMappings();
     }
 
     @Override
     public Map<Class<?>, TypeConverter> getToClassMappings(Class<?> fromClass) {
-        ensureLoaded();
+        if (!loaded.get()) {
+            ensureLoaded();
+        }
         return super.getToClassMappings(fromClass);
     }
 
     @Override
     public Map<TypeMapping, TypeConverter> getTypeMappings() {
-        ensureLoaded();
+        if (!loaded.get()) {
+            ensureLoaded();
+        }
         return super.getTypeMappings();
     }
 
     @Override
     protected TypeConverter doLookup(Class<?> toType, Class<?> fromType, boolean isSuper) {
-        ensureLoaded();
-        return super.doLookup(toType, fromType, isSuper);
+        TypeConverter answer = super.doLookup(toType, fromType, isSuper);
+        if (answer == null && !loaded.get()) {
+            // okay we could not convert, so try again, but load the converters up front
+            ensureLoaded();
+            answer = super.doLookup(toType, fromType, isSuper);
+        }
+        return answer;
     }
 
     private synchronized void ensureLoaded() {
@@ -89,9 +110,17 @@ public class LazyLoadingTypeConverter ex
     }
 
     @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        // must load core type converters
+        loadCoreTypeConverters();
+    }
+
+    @Override
     protected void doStop() throws Exception {
         super.doStop();
         // reset loaded flag
         loaded.set(false);
     }
 }
+

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java Sat May  7 10:43:52 2011
@@ -26,7 +26,6 @@ import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -368,7 +367,7 @@ public class Activator implements Bundle
                 Set<String> packages = getConverterPackages(bundle.getEntry(META_INF_TYPE_CONVERTER));
                 for (String pkg : packages) {
                     Enumeration<URL> e = bundle.findEntries("/" + pkg.replace('.', '/'), "*.class", true);
-                    while (e.hasMoreElements()) {
+                    while (e != null && e.hasMoreElements()) {
                         String path = e.nextElement().getPath();
                         String externalName = path.substring(path.charAt(0) == '/' ? 1 : 0, path.indexOf('.')).replace('/', '.');
                         try {
@@ -497,7 +496,7 @@ public class Activator implements Bundle
     }
 
     protected static Set<String> getConverterPackages(URL resource) {
-        Set<String> packages = new HashSet<String>();
+        Set<String> packages = new LinkedHashSet<String>();
         if (resource != null) {
             BufferedReader reader = null;
             try {

Modified: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (original)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Sat May  7 10:43:52 2011
@@ -15,6 +15,9 @@
 # limitations under the License.
 #
 
-org.apache.camel.converter
-org.apache.camel.component.bean
-org.apache.camel.component.file
\ No newline at end of file
+# keep at least one package in camel-core so the annotation type converter
+# should at least be able to discover one package to scan
+# notice that there are no @Converter classes in util. As all camel-core
+# type converters have been pre-loaded without package scanning, as that is
+# faster
+org.apache.camel.core

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java Sat May  7 10:43:52 2011
@@ -134,6 +134,17 @@ public abstract class ContextTestSupport
         return false;
     }
 
+    /**
+     * Whether or not type converters should be lazy loaded (notice core converters is always loaded)
+     * <p/>
+     * We enabled lazy by default as it would speedup unit testing.
+     *
+     * @return <tt>true</tt> by default.
+     */
+    protected boolean isLazyLoadingTypeConverter() {
+        return true;
+    }
+
     protected void stopCamelContext() throws Exception {
         if (camelContextService != null) {
             camelContextService.stop();
@@ -160,7 +171,9 @@ public abstract class ContextTestSupport
     }
 
     protected CamelContext createCamelContext() throws Exception {
-        return new DefaultCamelContext(createRegistry());
+        CamelContext context = new DefaultCamelContext(createRegistry());
+        context.setLazyLoadTypeConverters(isLazyLoadingTypeConverter());
+        return context;
     }
 
     protected JndiRegistry createRegistry() throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/PredicateBinaryCoerceRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/PredicateBinaryCoerceRouteTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/PredicateBinaryCoerceRouteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/PredicateBinaryCoerceRouteTest.java Sat May  7 10:43:52 2011
@@ -24,7 +24,7 @@ import org.apache.camel.WaitForTaskToCom
  */
 public class PredicateBinaryCoerceRouteTest extends ContextTestSupport {
 
-    public void testNoHeder() throws Exception {
+    public void testNoHeader() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(0);
         getMockEndpoint("mock:456").expectedMessageCount(0);
         getMockEndpoint("mock:other").expectedMessageCount(1);
@@ -34,7 +34,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsNumber123() throws Exception {
+    public void testHeaderAsNumber123() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(1);
         getMockEndpoint("mock:456").expectedMessageCount(0);
         getMockEndpoint("mock:other").expectedMessageCount(0);
@@ -44,7 +44,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsNumber456() throws Exception {
+    public void testHeaderAsNumber456() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(0);
         getMockEndpoint("mock:456").expectedMessageCount(1);
         getMockEndpoint("mock:other").expectedMessageCount(0);
@@ -54,7 +54,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsNumber999() throws Exception {
+    public void testHeaderAsNumber999() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(0);
         getMockEndpoint("mock:456").expectedMessageCount(0);
         getMockEndpoint("mock:other").expectedMessageCount(1);
@@ -64,7 +64,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsString123() throws Exception {
+    public void testHeaderAsString123() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(1);
         getMockEndpoint("mock:456").expectedMessageCount(0);
         getMockEndpoint("mock:other").expectedMessageCount(0);
@@ -74,7 +74,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsString456() throws Exception {
+    public void testHeaderAsString456() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(0);
         getMockEndpoint("mock:456").expectedMessageCount(1);
         getMockEndpoint("mock:other").expectedMessageCount(0);
@@ -84,7 +84,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsString999() throws Exception {
+    public void testHeaderAsString999() throws Exception {
         getMockEndpoint("mock:123").expectedMessageCount(0);
         getMockEndpoint("mock:456").expectedMessageCount(0);
         getMockEndpoint("mock:other").expectedMessageCount(1);
@@ -94,7 +94,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsEnum() throws Exception {
+    public void testHeaderAsEnum() throws Exception {
         getMockEndpoint("mock:enum").expectedMessageCount(1);
 
         template.sendBodyAndHeader("direct:start", "Hello World", "foo", WaitForTaskToComplete.Always);
@@ -102,7 +102,7 @@ public class PredicateBinaryCoerceRouteT
         assertMockEndpointsSatisfied();
     }
 
-    public void testHederAsEnumString() throws Exception {
+    public void testHeaderAsEnumString() throws Exception {
         getMockEndpoint("mock:enum").expectedMessageCount(1);
 
         template.sendBodyAndHeader("direct:start", "Hello World", "foo", "Always");

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceDummyFallbackConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceDummyFallbackConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceDummyFallbackConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java Sat May  7 10:43:52 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import java.util.Currency;
 

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceDummyFallbackConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceMethodWithExchangeTestConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceMethodWithExchangeTestConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/InstanceMethodWithExchangeTestConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java Sat May  7 10:43:52 2011
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
+import org.apache.camel.converter.MyBean;
 
 @Converter
 public class InstanceMethodWithExchangeTestConverter {

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/InstanceMethodWithExchangeTestConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/MyFallbackPromoteConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/MyFallbackPromoteConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/MyFallbackPromoteConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java Sat May  7 10:43:52 2011
@@ -14,11 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
 import org.apache.camel.FallbackConverter;
+import org.apache.camel.converter.MyCoolBean;
 import org.apache.camel.spi.TypeConverterRegistry;
 
 /**

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/MyFallbackPromoteConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/PurchaseOrderConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/PurchaseOrderConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/PurchaseOrderConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java Sat May  7 10:43:52 2011
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import java.math.BigDecimal;
 
 import org.apache.camel.Converter;
 import org.apache.camel.TypeConverter;
+import org.apache.camel.converter.PurchaseOrder;
 import org.apache.camel.spi.TypeConverterAware;
 
 /**

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticDummyFallbackConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticDummyFallbackConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticDummyFallbackConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java Sat May  7 10:43:52 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import java.util.TimeZone;
 

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticDummyFallbackConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java (from r1100165, camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticMethodWithExchangeTestConverter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticMethodWithExchangeTestConverter.java&r1=1100165&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/StaticMethodWithExchangeTestConverter.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java Sat May  7 10:43:52 2011
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.converter;
+package org.apache.camel.converter.myconverter;
 
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
+import org.apache.camel.converter.MyBean;
 import org.apache.camel.util.ObjectHelper;
 
 @Converter

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/myconverter/StaticMethodWithExchangeTestConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockNoLazyTypeConverterTest.java (from r1100321, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockNoLazyTypeConverterTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockNoLazyTypeConverterTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java&r1=1100321&r2=1100508&rev=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SimpleMockNoLazyTypeConverterTest.java Sat May  7 10:43:52 2011
@@ -16,41 +16,14 @@
  */
 package org.apache.camel.processor;
 
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-
 /**
  * @version 
  */
-public class SimpleMockTest extends ContextTestSupport {
-
-    public void testSimple() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Hello World");
-
-        template.sendBody("direct:start", "Hello World");
-
-        assertMockEndpointsSatisfied();
-    }
-
-    public void testSimpleTwoMessages() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Hello World", "Bye World");
-
-        template.sendBody("direct:start", "Hello World");
-        template.sendBody("direct:start", "Bye World");
-
-        assertMockEndpointsSatisfied();
-    }
+public class SimpleMockNoLazyTypeConverterTest extends SimpleMockTest {
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("direct:start").to("log:foo").to("log:bar").to("mock:result");
-            }
-        };
+    protected boolean isLazyLoadingTypeConverter() {
+        return false;
     }
+
 }

Added: camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/TypeConverter?rev=1100508&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/TypeConverter (added)
+++ camel/trunk/camel-core/src/test/resources/META-INF/services/org/apache/camel/TypeConverter Sat May  7 10:43:52 2011
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.camel.converter.myconverter

Modified: camel/trunk/camel-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/resources/log4j.properties?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/resources/log4j.properties (original)
+++ camel/trunk/camel-core/src/test/resources/log4j.properties Sat May  7 10:43:52 2011
@@ -25,6 +25,7 @@ log4j.logger.org.apache.camel.management
 log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
 #log4j.logger.org.apache.camel.impl.converter.DefaultTypeConverter=TRACE
 #log4j.logger.org.apache.camel.impl.converter.PropertyEditorTypeConverter=TRACE
+#log4j.logger.org.apache.camel.impl.converter=DEBUG
 
 #log4j.logger.org.apache.camel=DEBUG
 #log4j.logger.org.apache.camel.language.simple=TRACE

Modified: camel/trunk/components/camel-blueprint/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/pom.xml?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/pom.xml (original)
+++ camel/trunk/components/camel-blueprint/pom.xml Sat May  7 10:43:52 2011
@@ -86,12 +86,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-log4j12</artifactId>
           <scope>test</scope>
@@ -123,22 +117,6 @@
         <plugins>
 
             <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <childDelegation>false</childDelegation>
-                    <useFile>true</useFile>
-                    <forkMode>pertest</forkMode>
-                    <includes>
-                        <include>**/*Test.java</include>
-                    </includes>
-                    <excludes>
-                        <!-- TODO FIXME ASAP -->
-                        <exclude>**/XXXTest.*</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-
-            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
@@ -187,26 +165,6 @@
               </executions>
             </plugin>
 
-
-            <!-- generate the attached tests jar -->
-            <plugin>
-                <artifactId>maven-jar-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>test-jar</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <!-- TODO: this doesn't work - if ever we can figure out the maven ninja to get it working -->
-                    <!-- TODO: we can zap the Ant package phase stuff above -->
-                    <excludes>
-                        <exclude>**/*/log4j.properties</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-
         </plugins>
 
         <pluginManagement>

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java (original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java Sat May  7 10:43:52 2011
@@ -25,6 +25,7 @@ import org.apache.camel.core.osgi.OsgiPa
 import org.apache.camel.core.osgi.OsgiTypeConverter;
 import org.apache.camel.core.osgi.utils.BundleContextUtils;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.Registry;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -93,7 +94,8 @@ public class BlueprintCamelContext exten
         if (ctx == null) {
             ctx = bundleContext;
         }
-        return new OsgiTypeConverter(ctx, getInjector());
+        FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
+        return new OsgiTypeConverter(ctx, getInjector(), finder);
     }
 
     @Override

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java (original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java Sat May  7 10:43:52 2011
@@ -46,14 +46,17 @@ public class OsgiComponentResolver imple
         } catch (Exception e) {
             LOG.debug("Ignored error looking up bean: " + name + ". Error: " + e);
         }
-        if (bean instanceof Component) {
-            return (Component)bean;
-        } else {
-            // lets use Camel's type conversion mechanism to convert things like CamelContext
-            // and other types into a valid Component
-            Component component = CamelContextHelper.convertTo(context, Component.class, bean);
-            if (component != null) {
-                return component;
+
+        if (bean != null) {
+            if (bean instanceof Component) {
+                return (Component)bean;
+            } else {
+                // lets use Camel's type conversion mechanism to convert things like CamelContext
+                // and other types into a valid Component
+                Component component = CamelContextHelper.convertTo(context, Component.class, bean);
+                if (component != null) {
+                    return component;
+                }
             }
         }
 

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java (original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java Sat May  7 10:43:52 2011
@@ -19,6 +19,7 @@ package org.apache.camel.core.osgi;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.core.osgi.utils.BundleContextUtils;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.Registry;
 import org.osgi.framework.BundleContext;
 
@@ -54,7 +55,8 @@ public class OsgiDefaultCamelContext ext
         if (ctx == null) {
             ctx = bundleContext;
         }
-        return new OsgiTypeConverter(ctx, getInjector());
+        FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
+        return new OsgiTypeConverter(ctx, getInjector(), finder);
     }
 
     @Override

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java (original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java Sat May  7 10:43:52 2011
@@ -21,14 +21,17 @@ import java.util.Set;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.impl.DefaultPackageScanClassResolver;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.impl.converter.DefaultTypeConverter;
+import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.Injector;
 import org.apache.camel.spi.TypeConverterLoader;
 import org.apache.camel.spi.TypeConverterRegistry;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ServiceHelper;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
@@ -41,12 +44,14 @@ public class OsgiTypeConverter extends S
 
     private final BundleContext bundleContext;
     private final Injector injector;
+    private final FactoryFinder factoryFinder;
     private final ServiceTracker tracker;
     private volatile DefaultTypeConverter delegate;
 
-    public OsgiTypeConverter(BundleContext bundleContext, Injector injector) {
+    public OsgiTypeConverter(BundleContext bundleContext, Injector injector, FactoryFinder factoryFinder) {
         this.bundleContext = bundleContext;
         this.injector = injector;
+        this.factoryFinder = factoryFinder;
         this.tracker = new ServiceTracker(bundleContext, TypeConverterLoader.class.getName(), this);
     }
 
@@ -68,6 +73,12 @@ public class OsgiTypeConverter extends S
 
     public void removedService(ServiceReference serviceReference, Object o) {
         LOG.trace("RemovedService: {}", serviceReference);
+        try {
+            ServiceHelper.stopService(this.delegate);
+        } catch (Exception e) {
+            // ignore
+            LOG.debug("Error stopping service due: " + e.getMessage() + ". This exception will be ignored.", e);
+        }
         this.delegate = null;
     }
 
@@ -79,6 +90,7 @@ public class OsgiTypeConverter extends S
     @Override
     protected void doStop() throws Exception {
         this.tracker.close();
+        ServiceHelper.stopService(this.delegate);
         this.delegate = null;
     }
 
@@ -118,40 +130,42 @@ public class OsgiTypeConverter extends S
         return getDelegate().getInjector();
     }
 
-    public DefaultTypeConverter getDelegate() {
+    public synchronized DefaultTypeConverter getDelegate() {
         if (delegate == null) {
-            synchronized (this) {
-                if (delegate != null) {
-                    return delegate;
-                } else {
-                    delegate = createRegistry();
-                }
-            }
+            delegate = createRegistry();
         }
         return delegate;
     }
 
     protected DefaultTypeConverter createRegistry() {
         // base the osgi type converter on the default type converter
-        // TODO: Why is it based on the DefaultPackageScanClassResolver and not OsgiPackageScanClassResolver?
-        DefaultTypeConverter reg = new DefaultTypeConverter(new DefaultPackageScanClassResolver() {
+        DefaultTypeConverter answer = new DefaultTypeConverter(new DefaultPackageScanClassResolver() {
             @Override
             public Set<ClassLoader> getClassLoaders() {
+                // we don't need any classloaders as we use osgi service tracker instead
                 return Collections.emptySet();
             }
-        }, injector, null);
+        }, injector, factoryFinder);
+
+        // load the type converters the tracker has been tracking
         Object[] services = this.tracker.getServices();
         if (services != null) {
             for (Object o : services) {
                 try {
-                    ((TypeConverterLoader) o).load(reg);
+                    ((TypeConverterLoader) o).load(answer);
                 } catch (Throwable t) {
-                    throw ObjectHelper.wrapRuntimeCamelException(t);
+                    throw new RuntimeCamelException("Error loading type converters from service: " + o + " due: " + t.getMessage(), t);
                 }
             }
         }
 
-        LOG.trace("Created TypeConverter: {}", reg);
-        return reg;
+        try {
+            ServiceHelper.startService(answer);
+        } catch (Exception e) {
+            throw new RuntimeCamelException("Error staring OSGiTypeConverter due: " + e.getMessage(), e);
+        }
+
+        LOG.trace("Created TypeConverter: {}", answer);
+        return answer;
     }
 }

Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDirectoriesNotMatchedTest.java Sat May  7 10:43:52 2011
@@ -28,7 +28,7 @@ public class FtpConsumerDirectoriesNotMa
 
     private String getFtpUrl() {
         return "ftp://admin@localhost:" + getPort() + "/dirnotmatched/?password=admin"
-                + "&recursive=true&include=.*txt$";
+                + "&recursive=true&include=^.*txt$";
     }
 
     @Override

Modified: camel/trunk/components/camel-groovy/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/pom.xml?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/pom.xml (original)
+++ camel/trunk/components/camel-groovy/pom.xml Sat May  7 10:43:52 2011
@@ -57,12 +57,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-	  <groupId>org.apache.camel</groupId>
-	  <artifactId>camel-core</artifactId>
-	  <type>test-jar</type>
-	  <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>

Modified: camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyInvokeMethodTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyInvokeMethodTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyInvokeMethodTest.java (original)
+++ camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyInvokeMethodTest.java Sat May  7 10:43:52 2011
@@ -16,15 +16,17 @@
  */
 package org.apache.camel.language.groovy;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version 
  */
-public class GroovyInvokeMethodTest extends ContextTestSupport {
+public class GroovyInvokeMethodTest extends CamelTestSupport {
 
+    @Test
     public void testInvokeMethod() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);

Modified: camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java (original)
+++ camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyLanguageTest.java Sat May  7 10:43:52 2011
@@ -16,13 +16,15 @@
  */
 package org.apache.camel.language.groovy;
 
-import org.apache.camel.LanguageTestSupport;
+import org.apache.camel.test.junit4.LanguageTestSupport;
+import org.junit.Test;
 
 /**
  * @version 
  */
 public class GroovyLanguageTest extends LanguageTestSupport {
 
+    @Test
     public void testGroovyExpressions() throws Exception {
         assertExpression("exchange.in.headers.foo", "abc");
         assertExpression("request.headers.foo", "abc");

Modified: camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetFixedHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetFixedHeaderTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetFixedHeaderTest.java (original)
+++ camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetFixedHeaderTest.java Sat May  7 10:43:52 2011
@@ -16,17 +16,19 @@
  */
 package org.apache.camel.language.groovy;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 import static org.apache.camel.language.groovy.GroovyLanguage.groovy;
 
 /**
  * @version 
  */
-public class GroovySetFixedHeaderTest extends ContextTestSupport {
+public class GroovySetFixedHeaderTest extends CamelTestSupport {
 
+    @Test
     public void testSetHeader() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");

Modified: camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetHeaderTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetHeaderTest.java (original)
+++ camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovySetHeaderTest.java Sat May  7 10:43:52 2011
@@ -19,15 +19,17 @@ package org.apache.camel.language.groovy
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version 
  */
-public class GroovySetHeaderTest extends ContextTestSupport {
+public class GroovySetHeaderTest extends CamelTestSupport {
 
+    @Test
     public void testSetHeader() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
@@ -36,7 +38,7 @@ public class GroovySetHeaderTest extends
         mock.expectedHeaderReceived("two", "twei");
         mock.expectedHeaderReceived("beer", "Carlsberg");
         mock.expectedHeaderReceived("drink", "Carlsberg");
-        mock.expectedHeaderReceived("camelId", "camel-1");
+        mock.expectedHeaderReceived("camelId", context.getName());
 
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put("one", "einz");
@@ -53,14 +55,11 @@ public class GroovySetHeaderTest extends
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                
                 from("direct:start")
                     .setHeader("drink").groovy("request.headers.beer")
                     // shows how to access the camelContext value
                     .setHeader("camelId").groovy("camelContext.name")
                     .to("mock:result");
-                
-                
             }
         };
     }

Modified: camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/processor/groovy/GroovyFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/processor/groovy/GroovyFilterTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/processor/groovy/GroovyFilterTest.java (original)
+++ camel/trunk/components/camel-groovy/src/test/java/org/apache/camel/processor/groovy/GroovyFilterTest.java Sat May  7 10:43:52 2011
@@ -16,24 +16,37 @@
  */
 package org.apache.camel.processor.groovy;
 
-import org.apache.camel.CamelContext;
-import org.apache.camel.processor.XPathFilterTest;
-import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version 
  */
-public class GroovyFilterTest extends XPathFilterTest {
+public class GroovyFilterTest extends CamelSpringTestSupport {
 
     @Override
-    public boolean isUseRouteBuilder() {
-        return false;
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/processor/groovy/groovyFilter.xml");
     }
 
-    @Override
-    protected CamelContext createCamelContext() throws Exception {
-        return SpringCamelContext.springCamelContext(new ClassPathXmlApplicationContext("org/apache/camel/processor/groovy/groovyFilter.xml"));
+    @Test
+    public void testSendMatchingMessage() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBodyAndHeader("direct:start", "Hello World", "foo", 123);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testSendNotMatchingMessage() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
     }
 
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-groovy/src/test/resources/org/apache/camel/processor/groovy/groovyFilter.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-groovy/src/test/resources/org/apache/camel/processor/groovy/groovyFilter.xml?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-groovy/src/test/resources/org/apache/camel/processor/groovy/groovyFilter.xml (original)
+++ camel/trunk/components/camel-groovy/src/test/resources/org/apache/camel/processor/groovy/groovyFilter.xml Sat May  7 10:43:52 2011
@@ -27,7 +27,7 @@
     <route>
       <from uri="direct:start"/>
       <filter>
-        <groovy>exchange.in.headers.testCase == 'testSendMatchingMessage'</groovy>
+        <groovy>exchange.in.headers.foo == 123</groovy>
         <to uri="mock:result"/>
       </filter>
     </route>

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMinMaxThreadPoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMinMaxThreadPoolTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMinMaxThreadPoolTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMinMaxThreadPoolTest.java Sat May  7 10:43:52 2011
@@ -64,6 +64,8 @@ public class JettyMinMaxThreadPoolTest e
         latch.await(30, TimeUnit.SECONDS);
         log.info("All messages done");
 
+        assertEquals(10, replies.size());
+
         // sort replies
         Collections.sort(replies);
 

Modified: camel/trunk/components/camel-juel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/pom.xml?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/pom.xml (original)
+++ camel/trunk/components/camel-juel/pom.xml Sat May  7 10:43:52 2011
@@ -55,8 +55,7 @@
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-      <type>test-jar</type>
+      <artifactId>camel-test</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelLanguageTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelLanguageTest.java (original)
+++ camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelLanguageTest.java Sat May  7 10:43:52 2011
@@ -16,18 +16,22 @@
  */
 package org.apache.camel.language.juel;
 
-import org.apache.camel.LanguageTestSupport;
+import org.apache.camel.test.junit4.LanguageTestSupport;
+import org.junit.Test;
 
 /**
  * @version 
  */
 public class JuelLanguageTest extends LanguageTestSupport {
+
+    @Test
     public void testElExpressions() throws Exception {
         assertExpression("${exchange}", exchange);
         assertExpression("${in.headers.foo}", "abc");
         assertExpression("${in.body}", "<hello id='m123'>world!</hello>");
     }
 
+    @Test
     public void testElPredicates() throws Exception {
         assertPredicate("${in.headers.foo.startsWith('a')}");
         assertPredicate("${in.headers.foo == 'abc'}");

Modified: camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelTest.java (original)
+++ camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/JuelTest.java Sat May  7 10:43:52 2011
@@ -20,16 +20,17 @@ import javax.el.ELContext;
 import javax.el.ExpressionFactory;
 import javax.el.ValueExpression;
 
-import junit.framework.TestCase;
-
 import de.odysseus.el.ExpressionFactoryImpl;
 import de.odysseus.el.util.SimpleContext;
+import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * @version 
  */
 public class JuelTest extends TestCase {
 
+    @Test
     public void testJuel() throws Exception {
         ExpressionFactory factory = new ExpressionFactoryImpl();
         ELContext context  = new SimpleContext();

Modified: camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/NullBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/NullBodyTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/NullBodyTest.java (original)
+++ camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/NullBodyTest.java Sat May  7 10:43:52 2011
@@ -16,15 +16,19 @@
  */
 package org.apache.camel.language.juel;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
 import static org.apache.camel.language.juel.JuelExpression.el;
 
 /**
  * @version 
  */
-public class NullBodyTest extends ContextTestSupport {
+public class NullBodyTest extends CamelTestSupport {
+
+    @Test
     public void testNullBody() throws Exception {
         MockEndpoint resultEndpoint = getMockEndpoint("mock:After");
 

Modified: camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/issues/XsltLosesHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/issues/XsltLosesHeaderTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/issues/XsltLosesHeaderTest.java (original)
+++ camel/trunk/components/camel-juel/src/test/java/org/apache/camel/language/juel/issues/XsltLosesHeaderTest.java Sat May  7 10:43:52 2011
@@ -18,7 +18,6 @@ package org.apache.camel.language.juel.i
 
 import javax.xml.transform.TransformerConfigurationException;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
@@ -26,12 +25,15 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.builder.xml.XsltBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxp.StringSource;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
 import static org.apache.camel.language.juel.JuelExpression.el;
 
 /**
  * @version 
  */
-public class XsltLosesHeaderTest extends ContextTestSupport {
+public class XsltLosesHeaderTest extends CamelTestSupport {
     protected String xslt = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
             + "<xsl:stylesheet version=\"2.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
             + "<xsl:template match=\"/cats\">"
@@ -39,6 +41,7 @@ public class XsltLosesHeaderTest extends
             + "</xsl:template>"
             + "</xsl:stylesheet>";
 
+    @Test
     public void testXsltLosesHeader() throws Exception {
 
         MockEndpoint endpointAfter = getMockEndpoint("mock:After");

Modified: camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java (original)
+++ camel/trunk/components/camel-juel/src/test/java/org/apache/camel/processor/juel/SimulatorTest.java Sat May  7 10:43:52 2011
@@ -18,21 +18,22 @@ package org.apache.camel.processor.juel;
 
 import javax.naming.Context;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.jndi.JndiContext;
+import org.junit.Test;
 
 import static org.apache.camel.language.juel.JuelExpression.el;
 
 /**
  * @version 
  */
-public class SimulatorTest extends ContextTestSupport {
+public class SimulatorTest extends CamelTestSupport {
 
     protected Context createJndiContext() throws Exception {
         JndiContext answer = new JndiContext();
@@ -41,10 +42,12 @@ public class SimulatorTest extends Conte
         return answer;
     }
 
+    @Test
     public void testReceivesFooResponse() throws Exception {
         assertRespondsWith("foo", "Bye said foo");
     }
 
+    @Test
     public void testReceivesBarResponse() throws Exception {
         assertRespondsWith("bar", "Bye said bar");
     }

Modified: camel/trunk/components/camel-msv/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-msv/pom.xml?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-msv/pom.xml (original)
+++ camel/trunk/components/camel-msv/pom.xml Sat May  7 10:43:52 2011
@@ -84,14 +84,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-spring</artifactId>
-      <type>test-jar</type>
+      <artifactId>camel-test</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: camel/trunk/components/camel-msv/src/test/java/org/apache/camel/component/validator/msv/RelaxNGRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-msv/src/test/java/org/apache/camel/component/validator/msv/RelaxNGRouteTest.java?rev=1100508&r1=1100507&r2=1100508&view=diff
==============================================================================
--- camel/trunk/components/camel-msv/src/test/java/org/apache/camel/component/validator/msv/RelaxNGRouteTest.java (original)
+++ camel/trunk/components/camel-msv/src/test/java/org/apache/camel/component/validator/msv/RelaxNGRouteTest.java Sat May  7 10:43:52 2011
@@ -16,16 +16,42 @@
  */
 package org.apache.camel.component.validator.msv;
 
-import org.apache.camel.component.validator.ValidatorRouteTest;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version 
  */
-public class RelaxNGRouteTest extends ValidatorRouteTest {
+public class RelaxNGRouteTest extends CamelSpringTestSupport {
 
     protected ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/validator/msv/camelContext.xml");
     }
+
+    @Test
+    public void testValidMessage() throws Exception {
+        getMockEndpoint("mock:valid").expectedMessageCount(1);
+        getMockEndpoint("mock:invalid").expectedMessageCount(0);
+        getMockEndpoint("mock:finally").expectedMessageCount(1);
+
+        template.sendBody("direct:start",
+                "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testInvalidMessage() throws Exception {
+        getMockEndpoint("mock:valid").expectedMessageCount(0);
+        getMockEndpoint("mock:invalid").expectedMessageCount(1);
+        getMockEndpoint("mock:finally").expectedMessageCount(1);
+
+        template.sendBody("direct:start",
+                "<mail xmlns='http://foo.com/bar'><body>Hello world!</body></mail>");
+
+        assertMockEndpointsSatisfied();
+    }
+
 }
 



Mime
View raw message