Repository: camel
Updated Branches:
  refs/heads/master b70c4189c -> 9863ac9e4


Fixed the mvn test error of camel-itest-karaf


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9863ac9e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9863ac9e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9863ac9e

Branch: refs/heads/master
Commit: 9863ac9e42640bbc6448ab9763643093a7ffb4ee
Parents: e65f67e
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Tue Aug 26 14:07:50 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Tue Aug 26 14:08:13 2014 +0800

----------------------------------------------------------------------
 tests/camel-itest-karaf/pom.xml                 |   2 -
 .../camel/itest/karaf/AbstractFeatureTest.java  |  77 +++++++++-----
 .../camel/itest/karaf/org.ops4j.pax.url.mvn.cfg | 103 +++++++++++++++++++
 3 files changed, 154 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9863ac9e/tests/camel-itest-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-karaf/pom.xml b/tests/camel-itest-karaf/pom.xml
index 9e5e6b4..219ac8c 100644
--- a/tests/camel-itest-karaf/pom.xml
+++ b/tests/camel-itest-karaf/pom.xml
@@ -163,8 +163,6 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <forkMode>pertest</forkMode>
-                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
-                    <argLine>-Xmx256m</argLine>
                     <systemPropertyVariables>
                         <karafVersion>${karaf-version}</karafVersion>
                     </systemPropertyVariables>

http://git-wip-us.apache.org/repos/asf/camel/blob/9863ac9e/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/AbstractFeatureTest.java
----------------------------------------------------------------------
diff --git 
a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/AbstractFeatureTest.java
 
b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/AbstractFeatureTest.java
index 9cd900c..c164b9a 100644
--- 
a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/AbstractFeatureTest.java
+++ 
b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/AbstractFeatureTest.java
@@ -18,12 +18,15 @@ package org.apache.camel.itest.karaf;
 
 import java.io.File;
 
+import java.lang.reflect.Field;
+import java.nio.charset.Charset;
 import javax.inject.Inject;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultRouteContext;
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.osgi.CamelContextFactory;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
 import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption;
 import org.junit.After;
@@ -49,10 +52,14 @@ public abstract class AbstractFeatureTest {
 
     @Before
     public void setUp() throws Exception {
+        LOG.info("Calling the setUp method ");
+        LOG.info("The BundleContext is " + bundleContext);
+        Thread.sleep(3000);
     }
 
     @After
     public void tearDown() throws Exception {
+        LOG.info("Calling the tearDown method ");
     }
 
     protected void testComponent(String component) throws Exception {
@@ -114,12 +121,19 @@ public abstract class AbstractFeatureTest {
     }
 
     protected CamelContext createCamelContext() throws Exception {
+        LOG.info("Creating the CamelContext ...");
+        setThreadContextClassLoader();
         CamelContextFactory factory = new CamelContextFactory();
         factory.setBundleContext(bundleContext);
         LOG.info("Get the bundleContext is " + bundleContext);
         return factory.createContext();
     }
 
+    protected void setThreadContextClassLoader() {
+        // set the thread context classloader current bundle classloader
+        
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+    }
+
     public static String extractName(Class<?> clazz) {
         String name = clazz.getName();
         int id0 = name.indexOf("Camel") + "Camel".length();
@@ -139,7 +153,7 @@ public abstract class AbstractFeatureTest {
         return mavenBundle().
                 groupId("org.apache.camel.karaf").
                 artifactId("apache-camel").
-                classifier("features").type("xml").versionAsInProject();
+                versionAsInProject().type("xml/features");
     }
     
     public static UrlReference getKarafFeatureUrl() {
@@ -151,32 +165,43 @@ public abstract class AbstractFeatureTest {
             artifactId("standard").version(karafVersion).type(type);
     }
 
+    private static void switchPlatformEncodingToUTF8() {
+        try {
+            System.setProperty("file.encoding","UTF-8");
+            Field charset = Charset.class.getDeclaredField("defaultCharset");
+            charset.setAccessible(true);
+            charset.set(null,null);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     public static Option[] configure(String feature) {
-        Option[] options = 
-            new Option[]{
-                    
KarafDistributionOption.karafDistributionConfiguration().frameworkUrl(
-                    
maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject())
-                    .karafVersion("2.3.6").name("Apache Karaf")
-                    .unpackDirectory(new File("target/paxexam/unpack/")),
-                
-                KarafDistributionOption.keepRuntimeFolder(),
-                // override the config.properties (to fix pax-exam bug)
-                
KarafDistributionOption.replaceConfigurationFile("etc/config.properties", new 
File("src/test/resources/org/apache/camel/itest/karaf/config.properties")),
-                
KarafDistributionOption.replaceConfigurationFile("etc/custom.properties", new 
File("src/test/resources/org/apache/camel/itest/karaf/custom.properties")),
-                
KarafDistributionOption.replaceConfigurationFile("etc/jre.properties", new 
File("../../platforms/karaf/features/src/main/resources/config.properties")),
-                // Add apache-snapshots repository
-                
KarafDistributionOption.editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
 "org.ops4j.pax.url.mvn.repositories",
-                    "http://repo1.maven.org/maven2@id=central, "
-                        + 
"http://svn.apache.org/repos/asf/servicemix/m2-repo@id=servicemix, "
-                        + 
"http://repository.springsource.com/maven/bundles/release@id=springsource.release,
 "
-                        + 
"http://repository.springsource.com/maven/bundles/external@id=springsource.external,
 "
-                        + 
"http://oss.sonatype.org/content/repositories/releases/@id=sonatype, "
-                        + 
"http://repository.apache.org/content/groups/snapshots-group@snapshots@noreleases@id=apache";),
-
-                    // we need INFO logging otherwise we cannot see what 
happens
-                KarafDistributionOption.logLevel(LogLevelOption.LogLevel.INFO),
-                 // install the cxf jaxb spec as the karaf doesn't provide it 
by default
-                KarafDistributionOption.features(getCamelKarafFeatureUrl(), 
"cxf-jaxb", "camel-core", "camel-spring", "camel-" + feature)};
+        switchPlatformEncodingToUTF8();
+
+        Option[] options =
+                new Option[]{
+                        
KarafDistributionOption.karafDistributionConfiguration()
+                                
.frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject())
+                                .karafVersion("2.3.6")
+                                .name("Apache Karaf")
+                                .useDeployFolder(false).unpackDirectory(new 
File("target/paxexam/unpack/")),
+
+                        vmOption("-Dfile.encoding=UTF-8"),
+
+                        KarafDistributionOption.keepRuntimeFolder(),
+                        // override the config.properties (to fix pax-exam bug)
+                        
KarafDistributionOption.replaceConfigurationFile("etc/config.properties", new 
File("src/test/resources/org/apache/camel/itest/karaf/config.properties")),
+                        
KarafDistributionOption.replaceConfigurationFile("etc/custom.properties", new 
File("src/test/resources/org/apache/camel/itest/karaf/custom.properties")),
+                        
KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.url.mvn.cfg",
 new 
File("src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg")),
+
+
+                        // we need INFO logging otherwise we cannot see what 
happens
+                        new LogLevelOption(LogLevelOption.LogLevel.INFO),
+
+
+                        // install the cxf jaxb spec as the karaf doesn't 
provide it by default
+                        
KarafDistributionOption.features(getCamelKarafFeatureUrl(), "cxf-jaxb", 
"camel-core", "camel-spring", "camel-" + feature)};
 
         return options;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9863ac9e/tests/camel-itest-karaf/src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg
----------------------------------------------------------------------
diff --git 
a/tests/camel-itest-karaf/src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg
 
b/tests/camel-itest-karaf/src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg
new file mode 100644
index 0000000..18fed15
--- /dev/null
+++ 
b/tests/camel-itest-karaf/src/test/resources/org/apache/camel/itest/karaf/org.ops4j.pax.url.mvn.cfg
@@ -0,0 +1,103 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+#
+# If set to true, the following property will not allow any certificate to be 
used
+# when accessing Maven repositories through SSL
+#
+#org.ops4j.pax.url.mvn.certificateCheck=
+
+#
+# Path to the local Maven settings file.
+# The repositories defined in this file will be automatically added to the list
+# of default repositories if the 'org.ops4j.pax.url.mvn.repositories' property
+# below is not set.
+# The following locations are checked for the existence of the settings.xml 
file
+#   * 1. looks for the specified url
+#   * 2. if not found looks for ${user.home}/.m2/settings.xml
+#   * 3. if not found looks for ${maven.home}/conf/settings.xml
+#   * 4. if not found looks for ${M2_HOME}/conf/settings.xml
+#
+#org.ops4j.pax.url.mvn.settings=
+
+#
+# Path to the local Maven repository which is used to avoid downloading
+# artifacts when they already exist locally.
+# The value of this property will be extracted from the settings.xml file
+# above, or defaulted to:
+#     System.getProperty( "user.home" ) + "/.m2/repository"
+#
+#org.ops4j.pax.url.mvn.localRepository=
+
+#
+# Default this to false. It's just weird to use undocumented repos
+#
+org.ops4j.pax.url.mvn.useFallbackRepositories=false
+
+#
+# Uncomment if you don't wanna use the proxy settings
+# from the Maven conf/settings.xml file
+#
+# org.ops4j.pax.url.mvn.proxySupport=false
+
+#
+# Disable aether support by default.  This ensure that the defaultRepositories
+# below will be used
+#
+org.ops4j.pax.url.mvn.disableAether=true
+
+#
+# Comma separated list of repositories scanned when resolving an artifact.
+# Those repositories will be checked before iterating through the
+#    below list of repositories and even before the local repository
+# A repository url can be appended with zero or more of the following flags:
+#    @snapshots  : the repository contains snaphots
+#    @noreleases : the repository does not contain any released artifacts
+#    @id=reponid : the id for the repository, just like in the settings.xml 
this is optional but recomendet
+#
+# The following property value will add the system folder as a repo.
+#
+org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots@id=karaf.${karaf.default.repository}
+
+#
+# Comma separated list of repositories scanned when resolving an artifact.
+# The default list includes the following repositories containing releases:
+#    http://repo1.maven.org/maven2@id=central
+#    http://svn.apache.org/repos/asf/servicemix/m2-repo@id=servicemix
+#    
http://repository.springsource.com/maven/bundles/release@id=springsource.release
+#    
http://repository.springsource.com/maven/bundles/external@id=springsource.external
+# To add repositories to the default ones, prepend '+' to the list of 
repositories
+# to add.
+# A repository url can be appended with zero or more of the following flags:
+#    @snapshots  : the repository contains snapshots
+#    @noreleases : the repository does not contain any released artifacts
+#
+# The default list doesn't contain any repository containing snapshots as it 
can impact the artifacts resolution.
+# You may want to add the following repositories containing snapshots:
+#    
http://oss.sonatype.org/content/repositories/snapshots@snapshots@noreleases@id=sonatype.snapshot
+#    
http://oss.sonatype.org/content/repositories/ops4j-snapshots@snapshots@noreleases@id=ops4j.snapshot
+#    
http://repository.apache.org/content/groups/snapshots-group@snapshots@noreleases@id=apache
+#
+org.ops4j.pax.url.mvn.repositories= \
+    http://repo1.maven.org/maven2@id=central, \
+    http://svn.apache.org/repos/asf/servicemix/m2-repo@id=servicemix, \
+    
http://repository.springsource.com/maven/bundles/release@id=springsource.release,
 \
+    
http://repository.springsource.com/maven/bundles/external@id=springsource.external,
 \
+    http://oss.sonatype.org/content/repositories/releases/@id=sonatype
+

Reply via email to