Repository: cxf
Updated Branches:
  refs/heads/master 7fb37afad -> 9cc3f37d1


Cleanup on OSGi tests


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

Branch: refs/heads/master
Commit: 108dcd6099e86cd2070b5f9bae2b0feb7d5a7524
Parents: 20b73a7
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Apr 25 14:08:35 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Apr 25 16:10:47 2017 +0200

----------------------------------------------------------------------
 osgi/itests/pom.xml                             | 97 +++++++-------------
 .../osgi/itests/BundlesAndNamespacesTest.java   |  1 +
 .../cxf/osgi/itests/CXFOSGiTestSupport.java     | 86 +----------------
 osgi/itests/src/test/resources/log4j.properties |  5 +
 4 files changed, 41 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/108dcd60/osgi/itests/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/itests/pom.xml b/osgi/itests/pom.xml
index d4c64db..2349136 100644
--- a/osgi/itests/pom.xml
+++ b/osgi/itests/pom.xml
@@ -29,10 +29,8 @@
     <name>Apache CXF :: OSGi :: Integration Tests</name>
     <packaging>jar</packaging>
     <properties>
-        <cxf.surefire.fork.mode>once</cxf.surefire.fork.mode>
     </properties>
     <dependencies>
-
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-core</artifactId>
@@ -63,7 +61,11 @@
             <artifactId>cxf-rt-transports-jms</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>activemq-client</artifactId>
+        </dependency>
+
         <!-- Karaf features -->
         <dependency>
             <groupId>org.apache.cxf.karaf</groupId>
@@ -71,6 +73,12 @@
             <version>${project.version}</version>
             <type>xml</type>
             <classifier>features</classifier>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+               </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.activemq</groupId>
@@ -78,6 +86,12 @@
             <type>xml</type>
             <version>${cxf.activemq.version}</version>
             <classifier>features</classifier>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+               </exclusion>
+            </exclusions>
         </dependency>
         
         <dependency>
@@ -87,7 +101,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
             <version>${cxf.karaf.version}</version>
         </dependency>
         <dependency>
@@ -105,10 +119,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <version>4.3.1</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <version>4.3.1</version>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -122,7 +138,6 @@
             <scope>test</scope>
         </dependency>
 
-        
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam-junit4</artifactId>
@@ -155,6 +170,10 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+        </dependency>
         
         <dependency>
             <groupId>org.apache.karaf</groupId>
@@ -162,28 +181,12 @@
             <version>${cxf.karaf.version}</version>
             <type>tar.gz</type>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.karaf.shell</groupId>
-                    <artifactId>org.apache.karaf.shell.dev</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.eclipse</groupId>
-                    <artifactId>osgi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.eclipse</groupId>
-                    <artifactId>org.eclipse.osgi</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.karaf</groupId>
-                    <artifactId>org.apache.karaf.client</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>org.apache.felix.framework</artifactId>
-                </exclusion>
-            </exclusions>
+               <exclusions>
+                       <exclusion>
+               <groupId>*</groupId>
+               <artifactId>*</artifactId>
+                       </exclusion>
+               </exclusions>
         </dependency>
     </dependencies>
     <build>
@@ -192,6 +195,7 @@
             <plugin>
                 <groupId>org.apache.servicemix.tooling</groupId>
                 <artifactId>depends-maven-plugin</artifactId>
+                <version>1.4.0</version>
                 <executions>
                     <execution>
                         <id>generate-depends-file</id>
@@ -210,46 +214,9 @@
                         <karaf.version>${cxf.karaf.version}</karaf.version>
                         <localRepository>${maven.repo.local}</localRepository>
                     </systemPropertyVariables>
-                    <reuseForks>false</reuseForks>
+                    <reuseForks>true</reuseForks>
                 </configuration>
             </plugin>
         </plugins>
-        <pluginManagement>
-            <plugins>
-                <!--This plugin's configuration is used to store Eclipse m2e 
settings only. It has no influence on the Maven build itself.-->
-                <plugin>
-                    <groupId>org.eclipse.m2e</groupId>
-                    <artifactId>lifecycle-mapping</artifactId>
-                    <version>1.0.0</version>
-                    <configuration>
-                        <lifecycleMappingMetadata>
-                            <pluginExecutions>
-                                <pluginExecution>
-                                    <pluginExecutionFilter>
-                                        <groupId>
-                                            org.apache.servicemix.tooling
-                                        </groupId>
-                                        <artifactId>
-                                            depends-maven-plugin
-                                        </artifactId>
-                                        <versionRange>
-                                            [1.2,)
-                                        </versionRange>
-                                        <goals>
-                                            <goal>
-                                                generate-depends-file
-                                            </goal>
-                                        </goals>
-                                    </pluginExecutionFilter>
-                                    <action>
-                                        <ignore />
-                                    </action>
-                                </pluginExecution>
-                            </pluginExecutions>
-                        </lifecycleMappingMetadata>
-                    </configuration>
-                </plugin>
-            </plugins>
-        </pluginManagement>
     </build>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/108dcd60/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 74d7d33..a93f745 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
@@ -36,6 +36,7 @@ import static 
org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceCo
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class BundlesAndNamespacesTest extends CXFOSGiTestSupport {
+
     @Test
     public void test() throws Exception {
         assertBundleStarted("org.apache.cxf.cxf-core");

http://git-wip-us.apache.org/repos/asf/cxf/blob/108dcd60/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 3ca758a..94ae560 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
@@ -29,11 +29,6 @@ import java.io.PrintStream;
 import java.net.DatagramSocket;
 import java.net.ServerSocket;
 import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
 import java.util.Properties;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -55,9 +50,6 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
-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;
@@ -73,9 +65,11 @@ import static 
org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDist
 public class CXFOSGiTestSupport {
     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 CommandProcessor commandProcessor;
+    
+    @Inject
     protected BundleContext bundleContext;
 
     @Inject
@@ -183,7 +177,6 @@ public class CXFOSGiTestSupport {
         String response;
         final ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();
         final PrintStream printStream = new PrintStream(byteArrayOutputStream);
-        final CommandProcessor commandProcessor = 
getOsgiService(CommandProcessor.class);
         final CommandSession commandSession = 
commandProcessor.createSession(System.in, printStream,
                                                                              
System.err);
         FutureTask<String> commandFuture = new FutureTask<String>(new 
Callable<String>() {
@@ -222,7 +215,6 @@ public class CXFOSGiTestSupport {
         String response;
         final ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();
         final PrintStream printStream = new PrintStream(byteArrayOutputStream);
-        final CommandProcessor commandProcessor = 
getOsgiService(CommandProcessor.class);
         final CommandSession commandSession = 
commandProcessor.createSession(System.in, printStream,
                                                                              
System.err);
         FutureTask<String> commandFuture = new FutureTask<String>(new 
Callable<String>() {
@@ -262,71 +254,6 @@ public class CXFOSGiTestSupport {
         throw new RuntimeException("Bundle " + symbolicName + " does not 
exist");
     }
 
-    /*
-     * Explode the dictionary into a ,-delimited list of key=value pairs
-     */
-    private static String explode(Dictionary<String, String> dictionary) {
-        Enumeration<String> keys = dictionary.keys();
-        StringBuilder result = new StringBuilder();
-        while (keys.hasMoreElements()) {
-            Object key = keys.nextElement();
-            result.append(String.format("%s=%s", key, dictionary.get(key)));
-            if (keys.hasMoreElements()) {
-                result.append(", ");
-            }
-        }
-        return result.toString();
-    }
-
-    protected <T> T getOsgiService(Class<T> type, long timeout) {
-        return getOsgiService(type, null, timeout);
-    }
-
-    protected <T> T getOsgiService(Class<T> type) {
-        return getOsgiService(type, null, SERVICE_TIMEOUT);
-    }
-
-    protected <T> T getOsgiService(Class<T> type, String filter, long timeout) 
{
-        ServiceTracker<T, ?> tracker = null;
-        try {
-            String flt;
-            if (filter != null) {
-                if (filter.startsWith("(")) {
-                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() 
+ ")" + filter + ")";
-                } else {
-                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() 
+ ")(" + filter + "))";
-                }
-            } else {
-                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
-            }
-            Filter osgiFilter = FrameworkUtil.createFilter(flt);
-            tracker = new ServiceTracker<T, Object>(bundleContext, osgiFilter, 
null);
-            tracker.open(true);
-            // Note that the tracker is not closed to keep the reference
-            // This is buggy, as the service reference may change i think
-            Object svc = type.cast(tracker.waitForService(timeout));
-            if (svc == null) {
-                Dictionary<String, String> dic = 
bundleContext.getBundle().getHeaders();
-                System.err.println("Test bundle headers: " + explode(dic));
-
-                for (ServiceReference<?> ref : 
asCollection(bundleContext.getAllServiceReferences(null, null))) {
-                    System.err.println("ServiceReference: " + ref);
-                }
-
-                for (ServiceReference<?> ref : 
asCollection(bundleContext.getAllServiceReferences(null, flt))) {
-                    System.err.println("Filtered ServiceReference: " + ref);
-                }
-
-                throw new RuntimeException("Gave up waiting for service " + 
flt);
-            }
-            return type.cast(svc);
-        } catch (InvalidSyntaxException e) {
-            throw new IllegalArgumentException("Invalid filter", e);
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
     /**
      * Finds a free port starting from the give port numner.
      *
@@ -367,13 +294,6 @@ public class CXFOSGiTestSupport {
         return false;
     }
 
-    /**
-     * Provides an iterable collection of references, even if the original 
array is null
-     */
-    private static Collection<ServiceReference<?>> 
asCollection(ServiceReference<?>[] references) {
-        return references != null ? Arrays.asList(references) : 
Collections.<ServiceReference<?>> emptyList();
-    }
-
     protected void assertBundleStarted(String name) {
         Bundle bundle = findBundleByName(name);
         Assert.assertNotNull("Bundle " + name + " should be installed", 
bundle);

http://git-wip-us.apache.org/repos/asf/cxf/blob/108dcd60/osgi/itests/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/osgi/itests/src/test/resources/log4j.properties 
b/osgi/itests/src/test/resources/log4j.properties
new file mode 100644
index 0000000..5b083ba
--- /dev/null
+++ b/osgi/itests/src/test/resources/log4j.properties
@@ -0,0 +1,5 @@
+log4j.rootLogger=INFO,stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c - 
%X{address} - %m%n

Reply via email to