You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2014/12/01 16:43:37 UTC

cxf git commit: Some refactorings in OSGi tests

Repository: cxf
Updated Branches:
  refs/heads/master 10b043faa -> f51fb3327


Some refactorings in OSGi tests


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

Branch: refs/heads/master
Commit: f51fb332753e9600a6b6e6dd17b42c1a1494395a
Parents: 10b043f
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Dec 1 16:43:12 2014 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Dec 1 16:43:31 2014 +0100

----------------------------------------------------------------------
 osgi/itests/pom.xml                             |  2 +-
 .../osgi/itests/BundlesAndNamespacesTest.java   |  3 +-
 .../cxf/osgi/itests/CXFOSGiTestSupport.java     | 44 +++++++++-----------
 .../cxf/osgi/itests/jaxrs/JaxRsServiceTest.java |  5 ++-
 .../cxf/osgi/itests/soap/HttpServiceTest.java   | 10 +++--
 .../cxf/osgi/itests/soap/JmsServiceTest.java    |  9 ++--
 6 files changed, 37 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/itests/pom.xml b/osgi/itests/pom.xml
index e8072eb..17607d7 100644
--- a/osgi/itests/pom.xml
+++ b/osgi/itests/pom.xml
@@ -76,7 +76,7 @@
         	<groupId>org.apache.activemq</groupId>
         	<artifactId>activemq-karaf</artifactId>
         	<type>xml</type>
-                <version>${cxf.activemq.version}</version>
+            <version>${cxf.activemq.version}</version>
         	<classifier>features</classifier>
         </dependency>
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
index d4dc925..c6e90b1 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/BundlesAndNamespacesTest.java
@@ -28,7 +28,7 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
-
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
 
 
@@ -53,6 +53,7 @@ public class BundlesAndNamespacesTest extends CXFOSGiTestSupport {
     public Option[] config() {
         return new Option[]{
                 cxfBaseConfig(),
+                features(cxfUrl, "cxf-core", "cxf-jaxws"),
                 logLevel(LogLevel.INFO)};
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
index 85f2b7d..2cc3710 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
@@ -58,23 +58,21 @@ import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
-
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 
 /**
  * 
  */
 public class CXFOSGiTestSupport {
-    static final Long COMMAND_TIMEOUT = 10000L;
-    static final Long DEFAULT_TIMEOUT = 20000L;
-    static final Long SERVICE_TIMEOUT = 30000L;
+    private static final String MAVEN_DEPENDENCIES_PROPERTIES = "/META-INF/maven/dependencies.properties";
+    private static final Long COMMAND_TIMEOUT = 10000L;
+    private static final Long SERVICE_TIMEOUT = 30000L;
 
     @Inject
     protected BundleContext bundleContext;
@@ -98,14 +96,7 @@ public class CXFOSGiTestSupport {
     }
 
     private static String getKarafVersion() {
-        InputStream ins = CXFOSGiTestSupport.class.getResourceAsStream("/META-INF/maven/dependencies.properties");
-        Properties p = new Properties();
-        try {
-            p.load(ins);
-        } catch (Throwable t) {
-            //
-        }
-        String karafVersion = p.getProperty("org.apache.karaf/apache-karaf/version");
+        String karafVersion = getVersionFromPom("org.apache.karaf/apache-karaf/version");
         if (karafVersion == null) {
             karafVersion = System.getProperty("cxf.karaf.version");
         }
@@ -117,13 +108,24 @@ public class CXFOSGiTestSupport {
             karafVersion = "2.3.6";
         }
         return karafVersion;
+    }
+
+    private static String getVersionFromPom(String key) {
+        try {
+            InputStream ins = CXFOSGiTestSupport.class.getResourceAsStream(MAVEN_DEPENDENCIES_PROPERTIES);
+            Properties p = new Properties();
+            p.load(ins);
+            return p.getProperty(key);
+        } catch (Throwable t) {
+            throw new IllegalStateException(MAVEN_DEPENDENCIES_PROPERTIES + " can not be found", t);
+        }
     }    
     /**
      * Create an {@link org.ops4j.pax.exam.Option} for using a .
      * 
      * @return
      */
-    protected Option cxfBaseConfig(boolean testUtils) {
+    protected Option cxfBaseConfig() {
         karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
             .type("tar.gz");
         cxfUrl = maven().groupId("org.apache.cxf.karaf").artifactId("apache-cxf").versionAsInProject()
@@ -137,24 +139,16 @@ public class CXFOSGiTestSupport {
                              .useDeployFolder(false)
                              .unpackDirectory(new File("target/paxexam/")),
                          //DO NOT COMMIT WITH THIS LINE ENABLED!!!    
-                         //org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder(),
-                         features(cxfUrl, "cxf-core", "cxf-jaxws", "cxf-jaxrs"),                         
+                         //KarafDistributionOption.keepRuntimeFolder(),                         
                          systemProperty("java.awt.headless").value("true"),
-                         when(testUtils).useOptions(mavenBundle()
-                                                    .groupId("org.apache.cxf")
-                                                    .artifactId("cxf-testutils")
-                                                    .versionAsInProject()),
                          when(localRepo != null)
                              .useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
                                                                   "org.ops4j.pax.url.mvn.localRepository",
                                                                   localRepo)),
                          when(urp != null).useOptions(systemProperty("cxf.useRandomFirstPort").value("true")));
     }
-    protected Option cxfBaseConfig() {
-        return cxfBaseConfig(false);
-    }
-    protected Option cxfBaseConfigWithTestUtils() {
-        return cxfBaseConfig(true);
+    protected Option testUtils() {
+        return mavenBundle().groupId("org.apache.cxf").artifactId("cxf-testutils").versionAsInProject();
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
index 0a62845..2b08262 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
@@ -93,9 +93,10 @@ public class JaxRsServiceTest extends CXFOSGiTestSupport {
     @Configuration
     public Option[] config() {
         return new Option[] {
-            cxfBaseConfigWithTestUtils(),
+            cxfBaseConfig(),
+            testUtils(),
+            features(cxfUrl, "cxf-core", "cxf-jaxrs"),
             logLevel(LogLevel.INFO),
-            features(cxfUrl, "cxf-http"),
             provision(serviceBundle())
         };
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
index 731a40d..34279e3 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
@@ -46,18 +46,18 @@ public class HttpServiceTest extends CXFOSGiTestSupport {
 
     @Test
     public void testHttpEndpoint() throws Exception {
-        Greeter greeter = greeterHttp("8181");
+        Greeter greeter = greeterHttpProxy("8181");
         String res = greeter.greetMe("Chris");
         Assert.assertEquals("Hi Chris", res);
     }
     @Test
     public void testHttpEndpointJetty() throws Exception {
-        Greeter greeter = greeterHttp(HttpTestActivator.PORT);
+        Greeter greeter = greeterHttpProxy(HttpTestActivator.PORT);
         String res = greeter.greetMe("Chris");
         Assert.assertEquals("Hi Chris", res);
     }
     
-    private Greeter greeterHttp(String port) {
+    private Greeter greeterHttpProxy(String port) {
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
         factory.setServiceClass(Greeter.class);
         factory.setAddress("http://localhost:" + port + "/cxf/greeter");
@@ -67,7 +67,9 @@ public class HttpServiceTest extends CXFOSGiTestSupport {
     @Configuration
     public Option[] config() {
         return new Option[] {
-            cxfBaseConfigWithTestUtils(),
+            cxfBaseConfig(),
+            features(cxfUrl, "cxf-core", "cxf-jaxws"),
+            testUtils(),
             logLevel(LogLevel.INFO),
             features(cxfUrl, "cxf-http", "cxf-http-jetty"),
             provision(serviceBundle())

http://git-wip-us.apache.org/repos/asf/cxf/blob/f51fb332/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
index 0916b1c..7a797e8 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
@@ -33,6 +33,7 @@ import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
@@ -77,10 +78,12 @@ public class JmsServiceTest extends CXFOSGiTestSupport {
         MavenUrlReference activeMQFeature = maven().groupId("org.apache.activemq")
             .artifactId("activemq-karaf").type("xml").classifier("features").versionAsInProject();
         return new Option[] {
-            cxfBaseConfigWithTestUtils(),
-            logLevel(LogLevel.WARN),
+            cxfBaseConfig(),
+            testUtils(),
+            features(cxfUrl, "cxf-core", "cxf-jaxws", "cxf-transports-jms"),
+            KarafDistributionOption.keepRuntimeFolder(),
+            logLevel(LogLevel.INFO),
             features(activeMQFeature, "activemq-broker-noweb"),
-            features(cxfUrl, "cxf-transports-jms"),
             provision(serviceBundle())
         };
     }