Copied: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java (from r1409458, cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryRountrip.java) URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java?p2=cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java&p1=cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryRountrip.java&r1=1409458&r2=1410456&rev=1410456&view=diff ============================================================================== --- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryRountrip.java (original) +++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java Fri Nov 16 16:48:21 2012 @@ -18,65 +18,84 @@ */ package org.apache.cxf.dosgi.systests2.multi; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + +import java.io.IOException; +import java.net.ServerSocket; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import javax.inject.Inject; + +import junit.framework.Assert; + import org.apache.cxf.dosgi.systests2.common.AbstractTestDiscoveryRoundtrip; +import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.data.Stat; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Inject; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.Configuration; import org.ops4j.pax.exam.junit.JUnit4TestRunner; import org.osgi.framework.BundleContext; +import org.osgi.service.cm.ConfigurationAdmin; + +@RunWith(JUnit4TestRunner.class) +public class TestDiscoveryExport extends AbstractTestDiscoveryRoundtrip { -@RunWith( JUnit4TestRunner.class ) -public class TestDiscoveryRountrip extends AbstractTestDiscoveryRoundtrip { @Inject BundleContext bundleContext = null; + @Inject + ConfigurationAdmin configAdmin; + @Configuration public static Option[] configure() throws Exception { Map<Integer, String> bundles = new TreeMap<Integer, String>(); - int startLevel = MultiBundleTools.getDistroBundles(bundles, true); - + MultiBundleTools.getDistroBundles(bundles, true); + List<Option> opts = new ArrayList<Option>(); - - // Run this test under Equinox. - opts.add(CoreOptions.frameworks(CoreOptions.equinox())); - - // This property sets the start level for felix - opts.add(CoreOptions.systemProperty("org.osgi.framework.startlevel.beginning").value("" + startLevel)); - - // This property sets the start level for equinox - opts.add(CoreOptions.systemProperty("osgi.startLevel").value("" + startLevel)); - for(Map.Entry<Integer, String> entry : bundles.entrySet()) { - opts.add(CoreOptions.bundle(entry.getValue()).startLevel(entry.getKey())); + for (Map.Entry<Integer, String> entry : bundles.entrySet()) { + String bundleUri = entry.getValue(); + if (!bundleUri.contains("pax-logging")) { + opts.add(CoreOptions.bundle(bundleUri)); + } } - - opts.add(CoreOptions.mavenBundle().groupId("org.apache.log4j").artifactId("com.springsource.org.apache.log4j").versionAsInProject()); - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi").artifactId("cxf-dosgi-ri-discovery-distributed-zookeeper-server").versionAsInProject()); - - // This bundle contains the common system testing code - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject()); - - opts.add(CoreOptions.provision(getClientBundle())); - opts.add(CoreOptions.provision(getServerBundle())); - - return CoreOptions.options(opts.toArray(new Option[opts.size()])); - } - - protected BundleContext getBundleContext() { - return bundleContext; + opts.add(CoreOptions.mavenBundle().groupId("org.apache.servicemix.bundles") + .artifactId("org.apache.servicemix.bundles.junit").version("4.9_2")); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples") + .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject()); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples") + .artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject()); + opts.add(mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common") + .versionAsInProject()); + + return CoreOptions.options(opts.toArray(new Option[opts.size()])); } @Test - public void testDiscoveryRoundtrip() throws Exception { - // Disabled temporarily - // baseTestDiscoveryRoundtrip(); + public void testDiscoveryExport() throws Exception { + final int zkPort = getFreePort(); + configureZookeeper(configAdmin, zkPort); + Thread.sleep(3000); + ZooKeeper zk = new ZooKeeper("localhost:" + zkPort, 1000, null); + Stat stat = zk.exists( + "/osgi/service_registry/org/apache/cxf/dosgi/samples/greeter/GreeterService/localhost#9090##greeter", + null); + Assert.assertNotNull("Node for GreeterService endpoint not found in zookeeper", stat); + zk.close(); + } + + private int getFreePort() throws IOException { + ServerSocket socket = new ServerSocket(0); + try { + return socket.getLocalPort(); + } finally { + socket.close(); + } } }
Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java?rev=1410456&r1=1410455&r2=1410456&view=diff ============================================================================== --- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java (original) +++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java Fri Nov 16 16:48:21 2012 @@ -23,11 +23,12 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import javax.inject.Inject; + import org.apache.cxf.dosgi.systests2.common.AbstractTestExportService; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Inject; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.Configuration; import org.ops4j.pax.exam.junit.JUnit4TestRunner; @@ -45,15 +46,16 @@ public class TestExportService extends A List<Option> opts = new ArrayList<Option>(); - // Run this test under Felix. - opts.add(CoreOptions.frameworks(CoreOptions.felix())); - for(Map.Entry<Integer, String> entry : bundles.entrySet()) { - opts.add(CoreOptions.bundle(entry.getValue()).startLevel(entry.getKey())); + String bundleUri = entry.getValue(); + if (!bundleUri.contains("pax-logging")) { + opts.add(CoreOptions.bundle(bundleUri)); + } } - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject().startLevel(++startLevel)); - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject().startLevel(++startLevel)); - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject().startLevel(++startLevel)); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.servicemix.bundles" ).artifactId("org.apache.servicemix.bundles.junit").version("4.9_2")); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject()); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject()); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject()); opts.add(CoreOptions.systemProperty("org.osgi.framework.startlevel.beginning").value("" + startLevel)); // For debugging... Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java?rev=1410456&r1=1410455&r2=1410456&view=diff ============================================================================== --- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java (original) +++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java Fri Nov 16 16:48:21 2012 @@ -23,13 +23,13 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import javax.inject.Inject; + import org.apache.cxf.dosgi.systests2.common.AbstractTestImportService; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Inject; import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.container.def.PaxRunnerOptions; import org.ops4j.pax.exam.junit.Configuration; import org.ops4j.pax.exam.junit.JUnit4TestRunner; import org.osgi.framework.BundleContext; @@ -42,36 +42,19 @@ public class TestImportService extends A @Configuration public static Option[] configure() throws Exception { Map<Integer, String> bundles = new TreeMap<Integer, String>(); - int startLevel = MultiBundleTools.getDistroBundles(bundles, false); + MultiBundleTools.getDistroBundles(bundles, false); List<Option> opts = new ArrayList<Option>(); - - // Run this test under Felix. - opts.add(CoreOptions.frameworks(CoreOptions.felix())); - for(Map.Entry<Integer, String> entry : bundles.entrySet()) { - opts.add(CoreOptions.bundle(entry.getValue()).startLevel(entry.getKey())); + String bundleUri = entry.getValue(); + if (!bundleUri.contains("pax-logging")) { + opts.add(CoreOptions.bundle(bundleUri)); + } } - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject().startLevel(++startLevel)); - - // This bundle contains the common system testing code - opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject().startLevel(++startLevel)); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject()); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.servicemix.bundles" ).artifactId("org.apache.servicemix.bundles.junit").version("4.9_2")); + opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject()); opts.add(CoreOptions.provision(getTestClientBundle())); - opts.add(CoreOptions.systemProperty("org.osgi.framework.startlevel.beginning").value("" + startLevel)); - - String loggingConfigFile = System.getProperty("java.util.logging.config.file"); - if (loggingConfigFile != null) { - // When running from eclipse junit the loggingConfigFile will not be set - opts.add(CoreOptions.systemProperty("java.util.logging.config.file").value(loggingConfigFile)); - } - - // For debugging... - final String debugPort = System.getProperty("org.apache.cxf.dosgi.test.debug.port"); - if(debugPort != null) { - opts.add(PaxRunnerOptions.vmOption( "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + debugPort )); - opts.add(CoreOptions.waitForFrameworkStartup()); - } - // end debugging section. // service wait timeout (this should also be increased for debugging)... opts.add(CoreOptions.systemProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout").value(System.getProperty("org.apache.cxf.dosgi.test.serviceWaitTimeout", "20"))); @@ -85,6 +68,9 @@ public class TestImportService extends A @Test public void testClientConsumer() throws Exception { +// for( Bundle b : bundleContext.getBundles() ) { +// System.out.println( "*** Bundle " + b.getBundleId() + " : " + b.getSymbolicName() + "/" + b.getState()); +// } baseTestClientConsumer(); } } Added: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/log4j.properties URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/log4j.properties?rev=1410456&view=auto ============================================================================== --- cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/log4j.properties (added) +++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/log4j.properties Fri Nov 16 16:48:21 2012 @@ -0,0 +1,13 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=INFO, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n + +log4j.logger.org.ops4j.pax.scanner=WARN +log4j.logger.org.ops4j.pax.runner=WARN +log4j.logger.org.ops4j.pax.url=WARN \ No newline at end of file Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/log4j.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Propchange: cxf/dosgi/trunk/systests2/single-bundle/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Fri Nov 16 16:48:21 2012 @@ -3,3 +3,7 @@ bin target .project + +.classpath + +.settings
