You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2010/01/27 17:15:06 UTC
svn commit: r903708 - in /cxf/dosgi/trunk/systests2: ./ common/ common/src/
common/src/main/ common/src/main/java/ common/src/main/java/org/
common/src/main/java/org/apache/ common/src/main/java/org/apache/cxf/
common/src/main/java/org/apache/cxf/dosgi...
Author: davidb
Date: Wed Jan 27 16:15:04 2010
New Revision: 903708
URL: http://svn.apache.org/viewvc?rev=903708&view=rev
Log:
More Pax-Exam based system tests.
Added:
cxf/dosgi/trunk/systests2/common/
cxf/dosgi/trunk/systests2/common/pom.xml (with props)
cxf/dosgi/trunk/systests2/common/src/
cxf/dosgi/trunk/systests2/common/src/main/
cxf/dosgi/trunk/systests2/common/src/main/java/
cxf/dosgi/trunk/systests2/common/src/main/java/org/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java (with props)
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java (with props)
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java (with props)
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java (with props)
cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java (with props)
cxf/dosgi/trunk/systests2/common/src/main/resources/
cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml (with props)
cxf/dosgi/trunk/systests2/multi-bundle/
cxf/dosgi/trunk/systests2/multi-bundle/pom.xml (with props)
cxf/dosgi/trunk/systests2/multi-bundle/src/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java (with props)
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java (with props)
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java (with props)
cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/
cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml (with props)
Removed:
cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/Streams.java
cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/test1/
Modified:
cxf/dosgi/trunk/systests2/pom.xml
cxf/dosgi/trunk/systests2/single-bundle/pom.xml
cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestExportService.java
cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestImportService.java
Added: cxf/dosgi/trunk/systests2/common/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/pom.xml?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/pom.xml (added)
+++ cxf/dosgi/trunk/systests2/common/pom.xml Wed Jan 27 16:15:04 2010
@@ -0,0 +1,97 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+ 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.
+-->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-parent</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.cxf.dosgi.systests</groupId>
+ <artifactId>cxf-dosgi-ri-systests2-common</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Distributed OSGi System Tests Common Classes</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>1.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle-minimal</artifactId>
+ <version>${cxf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi.samples</groupId>
+ <artifactId>cxf-dosgi-ri-samples-greeter-impl</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi.samples</groupId>
+ <artifactId>cxf-dosgi-ri-samples-greeter-interface</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>Bundle containing common code for the CX DOSGi system tests</Bundle-Name>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+ <!-- The TinyBundles are only used during the 'configure' stage and are therefore not
+ needed at runtime. -->
+ <Import-Package>
+ !org.ops4j.pax.swissbox.tinybundles.*,
+ *
+ </Import-Package>
+ <Export-Package>*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
Propchange: cxf/dosgi/trunk/systests2/common/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/dosgi/trunk/systests2/common/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,131 @@
+/**
+ * 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.cxf.dosgi.systests2.common;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.URL;
+import java.util.Map;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+import org.apache.cxf.dosgi.samples.greeter.GreeterException;
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.junit.Assert;
+
+public abstract class AbstractTestExportService {
+ // Make sure to explicitly invoke the test from the actual test class
+ // Annotating this method with @Test will not properly report any failures.
+ protected void baseTestAccessEndpoint() throws Exception {
+ waitPort(9090);
+ URL wsdlURL = new URL("http://localhost:9090/greeter?wsdl");
+
+ // Do some basic checking on the WSDL
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(wsdlURL.openStream());
+ Element el = doc.getDocumentElement();
+ Assert.assertEquals("definitions", el.getLocalName());
+ Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/", el.getNamespaceURI());
+ Assert.assertEquals("GreeterService", el.getAttribute("name"));
+
+ // Make an actual invocation on the remote service.
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
+ try {
+ ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+ factory.setServiceClass(GreeterService.class);
+ factory.setAddress("http://localhost:9090/greeter");
+ factory.getServiceFactory().setDataBinding(new AegisDatabinding());
+ GreeterService client = (GreeterService)factory.create();
+ Map<GreetingPhrase, String> greetings = client.greetMe("Fred");
+ Assert.assertEquals("Fred", greetings.get(new GreetingPhrase("Hello")));
+ System.out.println("Invocation result: " + greetings);
+
+ try {
+ class GreeterDataImpl implements GreeterData {
+ private String name;
+ private int age;
+ private boolean exception;
+
+ GreeterDataImpl(String n, int a, boolean ex) {
+ name = n;
+ age = a;
+ exception = ex;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public boolean isException() {
+ return exception;
+ }
+ }
+
+ GreeterData gd = new GreeterDataImpl("Stranger", 11, true);
+ client.greetMe(gd);
+ Assert.fail("GreeterException has to be thrown");
+ } catch (GreeterException ex) {
+ Assert.assertEquals("Wrong exception message",
+ "GreeterService can not greet Stranger",
+ ex.toString());
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ private void waitPort(int port) throws Exception {
+ for (int i = 0; i < 20; i++) {
+ Socket s = null;
+ try {
+ s = new Socket((String) null, port);
+ // yep, its available
+ return;
+ } catch (IOException e) {
+ // wait
+ } finally {
+ if (s != null) {
+ try {
+ s.close();
+ } catch (IOException e) {}
+ }
+ }
+ System.out.println("Waiting for server to appear on port: " + port);
+ Thread.sleep(1000);
+ }
+ throw new TimeoutException();
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestExportService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,127 @@
+/**
+ * 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.cxf.dosgi.systests2.common;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+import org.apache.cxf.dosgi.samples.greeter.GreeterException;
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+import org.apache.cxf.dosgi.systests2.common.test1.MyActivator;
+import org.apache.cxf.dosgi.systests2.common.test1.MyServiceTracker;
+import org.apache.cxf.dosgi.systests2.common.test1.StartServiceTracker;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.junit.Assert;
+import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+public abstract class AbstractTestImportService {
+ protected abstract BundleContext getBundleContext();
+
+ protected static InputStream getTestClientBundle() {
+ // This creates a bundle on the fly, which is basically the service consumer
+ return TinyBundles.newBundle()
+ .add(MyActivator.class)
+ .add(MyServiceTracker.class)
+ .add(StartServiceTracker.class)
+ .add("OSGI-INF/remote-service/remote-services.xml", AbstractTestImportService.class.getResource("/rs-test1.xml"))
+ .set(Constants.BUNDLE_SYMBOLICNAME, "testClientBundle")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.cxf.dosgi.systests2.common.test1")
+ .set(Constants.BUNDLE_ACTIVATOR, MyActivator.class.getName())
+ .build(TinyBundles.withBnd());
+ }
+
+ // Make sure to explicitly invoke the test from the actual test class
+ // Annotating this method with @Test will not properly report any failures.
+ protected void baseTestClientConsumer() throws Exception {
+ // This test tests the consumer side of Distributed OSGi. It works as follows:
+ // 1. It creates a little test bundle on the fly and starts that in the framework
+ // (this happens in the configure() method above). The test bundle waits until its
+ // instructed to start doing stuff. It's give this instruction via a service that is
+ // registered by this test (the service is of type java.lang.Object and has testName=test1).
+ // 2. The test manually creates a CXF server of the appropriate type (using ServerFactoryBean)
+ // 3. It signals the client bundle by registering a service to start doing its work.
+ // This registers a ServiceTracker in the client bundle for the remote service that is created
+ // by the test in step 2. The client bundle knows about the address through the
+ // remote-services.xml file.
+ // 4. The client bundle will invoke the remote service and record the results in a service that it
+ // registers in the Service Registry.
+ // 5. The test waits for this service to appear and then checks the results which are available as
+ // a service property.
+
+ // Set up a Server in the test
+ ServerFactoryBean factory = new ServerFactoryBean();
+ factory.setServiceClass(GreeterService.class);
+ factory.setAddress("http://localhost:9191/grrr");
+ factory.getServiceFactory().setDataBinding(new AegisDatabinding());
+ factory.setServiceBean(new TestGreeter());
+
+ Server server = null;
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
+ server = factory.create();
+
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put("testName", "test1");
+ getBundleContext().registerService(Object.class.getName(), new Object(), props);
+
+ // Wait for the service tracker in the test bundle to register a service with the test result
+ ServiceReference ref = waitService(String.class.getName(), "(testResult=test1)");
+ Assert.assertEquals("HiOSGi", ref.getProperty("result"));
+ } finally {
+ server.stop();
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ private ServiceReference waitService(String cls, String filter) throws Exception {
+ ServiceReference[] refs = null;
+ for (int i=0; i < 20; i++) {
+ refs = getBundleContext().getServiceReferences(cls, filter);
+ if (refs != null && refs.length > 0) {
+ return refs[0];
+ }
+ System.out.println("Waiting for service: " + cls + filter);
+ Thread.sleep(1000);
+ }
+ throw new Exception("Service not found: " + cls + filter);
+ }
+
+ public static class TestGreeter implements GreeterService {
+ public Map<GreetingPhrase, String> greetMe(String name) {
+ Map<GreetingPhrase, String> m = new HashMap<GreetingPhrase, String>();
+ GreetingPhrase gp = new GreetingPhrase("Hi");
+ m.put(gp, name);
+ return m;
+ }
+
+ public GreetingPhrase[] greetMe(GreeterData gd) throws GreeterException {
+ throw new GreeterException("TestGreeter");
+ }
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/AbstractTestImportService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,43 @@
+/**
+ * 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.cxf.dosgi.systests2.common.test1;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class MyActivator implements BundleActivator {
+ private ServiceTracker startTracker, tracker;
+
+ public void start(final BundleContext bc) throws Exception {
+ Filter filter = bc.createFilter("(&(objectClass=java.lang.Object)(testName=test1))");
+ tracker = new MyServiceTracker(bc);
+
+ // The start tracker waits until a service from the test class is set before the
+ // 'MyServiceTracker' is activated.
+ startTracker = new StartServiceTracker(bc, filter, tracker);
+ startTracker.open();
+ }
+
+ public void stop(BundleContext bc) throws Exception {
+ startTracker.close();
+ tracker.close();
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyActivator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,62 @@
+/**
+ * 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.cxf.dosgi.systests2.common.test1;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class MyServiceTracker extends ServiceTracker {
+ private static StringBuffer invocationResult = new StringBuffer();
+
+ public MyServiceTracker(BundleContext context) {
+ super(context, GreeterService.class.getName(), null);
+ }
+
+ public Object addingService(ServiceReference reference) {
+ Object svc = super.addingService(reference);
+ if (svc instanceof GreeterService) {
+ invokeGreeter((GreeterService) svc);
+ }
+ return svc;
+ }
+
+ public static String getResult() {
+ return invocationResult.toString();
+ }
+
+ private void invokeGreeter(GreeterService svc) {
+ Map<GreetingPhrase, String> result = svc.greetMe("OSGi");
+ for (Map.Entry<GreetingPhrase, String> e : result.entrySet()) {
+ GreetingPhrase key = e.getKey();
+ invocationResult.append(key.getPhrase());
+ invocationResult.append(e.getValue());
+ }
+
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put("result", invocationResult.toString());
+ props.put("testResult", "test1");
+ context.registerService(String.class.getName(), "test1", props);
+ }
+}
\ No newline at end of file
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/MyServiceTracker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java Wed Jan 27 16:15:04 2010
@@ -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.cxf.dosgi.systests2.common.test1;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class StartServiceTracker extends ServiceTracker {
+ private ServiceTracker tracker;
+
+ public StartServiceTracker(BundleContext context, Filter filter, ServiceTracker tracker) {
+ super(context, filter, null);
+ this.tracker = tracker;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ tracker.open();
+ return super.addingService(reference);
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/java/org/apache/cxf/dosgi/systests2/common/test1/StartServiceTracker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml (added)
+++ cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml Wed Jan 27 16:15:04 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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.
+ -->
+<rsa:endpoint-descriptions xmlns:rsa="http://www.osgi.org/xmlns/rsa/v1.0.0"
+ xmlns:other="http://www.acme.org/xmlns/other/v1.0.0">
+ <endpoint-description>
+ <property name="objectClass">
+ <array>
+ <value>org.apache.cxf.dosgi.samples.greeter.GreeterService</value>
+ </array>
+ </property>
+ <property name="endpoint.id">http://localhost:9191/grrr</property>
+ <property name="service.imported.configs">org.apache.cxf.ws</property>
+ </endpoint-description>
+</rsa:endpoint-descriptions>
+
Propchange: cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/dosgi/trunk/systests2/common/src/main/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/pom.xml?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/pom.xml (added)
+++ cxf/dosgi/trunk/systests2/multi-bundle/pom.xml Wed Jan 27 16:15:04 2010
@@ -0,0 +1,128 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-parent</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.cxf.dosgi.systests</groupId>
+ <artifactId>cxf-dosgi-ri-systests2-multibundle</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Distributed OSGi System Tests Multi-Bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi.systests</groupId>
+ <artifactId>cxf-dosgi-ri-systests2-common</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle-minimal</artifactId>
+ <version>${cxf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi.samples</groupId>
+ <artifactId>cxf-dosgi-ri-samples-greeter-impl</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi.samples</groupId>
+ <artifactId>cxf-dosgi-ri-samples-greeter-interface</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- use pax exam maven plugin -->
+
+ <!--
+ Note: settings and dependencies for the final osgi runtime (TESTS) are just used in TestCases
+ that annotated with this:
+ @RunWith( MavenConfiguredJUnit4TestRunner.class )
+
+ All other testcases will use their own settings/provisioning inside @Configure Methods.
+ -->
+ <plugin>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>maven-paxexam-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-config</id>
+ <goals>
+ <goal>generate-config</goal>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <options>
+ <platform>equinox</platform>
+ <profiles>log</profiles>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java (added)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,95 @@
+/**
+ * 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.cxf.dosgi.systests2.multi;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class MultiBundleTools {
+ private MultiBundleTools() {}
+
+ static int getDistroBundles(Map<Integer, String> bundles) throws Exception {
+ File root = getRootDirectory();
+ File mdRoot = new File(root, "distribution/multi-bundle");
+ String pomVersion = getPomVersion(mdRoot);
+
+ return getDistroBundles(mdRoot, pomVersion, bundles);
+ }
+
+ private static int getDistroBundles(File mdRoot, String pomVersion, Map<Integer, String> bundles) throws Exception {
+ File distroDir = new File(mdRoot, "target/cxf-dosgi-ri-multibundle-distribution-" + pomVersion + ".dir");
+ Properties p = new Properties();
+ p.load(new FileInputStream(new File(distroDir, "apache-cxf-dosgi-ri-" + pomVersion + "/conf/felix.config.properties.append")));
+
+ int startLevel = Integer.parseInt(p.getProperty("org.osgi.framework.startlevel.beginning"));
+ for (int i = 0; i <= startLevel; i++) {
+ String val = p.getProperty("felix.auto.start." + i);
+ if (val != null) {
+ if (val.startsWith("file:")) {
+ File fullDir = new File(distroDir, val.substring("file:".length()));
+ bundles.put(i, fullDir.toURI().toASCIIString());
+ } else {
+ bundles.put(i, val);
+ }
+ }
+ }
+ return startLevel;
+ }
+
+ private static File getRootDirectory() {
+ String resourceName = "/" + MultiBundleTools.class.getName().replace('.', '/') + ".class";
+ URL curURL = MultiBundleTools.class.getResource(resourceName);
+ File curFile = new File(curURL.getFile());
+ String curString = curFile.getAbsolutePath();
+ File curBase = new File(curString.substring(0, curString.length() - resourceName.length()));
+ File root = curBase.getParentFile().getParentFile().getParentFile().getParentFile();
+ return root;
+ }
+
+ private static String getPomVersion(File mdRoot) throws Exception {
+ File mdPom = new File(mdRoot, "pom.xml");
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(mdPom);
+ Element el = doc.getDocumentElement();
+ String pomVersion = null;
+ NodeList children = el.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if ("version".equals(child.getLocalName())) {
+ pomVersion = child.getTextContent().trim();
+ break;
+ }
+ }
+ return pomVersion;
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/MultiBundleTools.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java (added)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,64 @@
+/**
+ * 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.cxf.dosgi.systests2.multi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+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;
+import org.osgi.framework.BundleContext;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestExportService extends AbstractTestExportService {
+ @Inject
+ BundleContext bundleContext;
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+ Map<Integer, String> bundles = new TreeMap<Integer, String>();
+ int startLevel = MultiBundleTools.getDistroBundles(bundles);
+
+ List<Option> opts = new ArrayList<Option>();
+ opts.add(CoreOptions.systemProperty("org.osgi.framework.startlevel.beginning").value("" + startLevel));
+ for(Map.Entry<Integer, String> entry : bundles.entrySet()) {
+ opts.add(CoreOptions.bundle(entry.getValue()).startLevel(entry.getKey()));
+ }
+ 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());
+
+ return CoreOptions.options(opts.toArray(new Option[opts.size()]));
+ }
+
+
+ @Test
+ public void testAccessEndpoint() throws Exception {
+ // call into base test. Inheriting the test doesn't properly report failures.
+ baseTestAccessEndpoint();
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java (added)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java Wed Jan 27 16:15:04 2010
@@ -0,0 +1,68 @@
+/**
+ * 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.cxf.dosgi.systests2.multi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+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.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.BundleContext;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestImportService extends AbstractTestImportService {
+ @Inject
+ BundleContext bundleContext = null;
+
+ @Configuration
+ public static Option[] configure() throws Exception {
+ Map<Integer, String> bundles = new TreeMap<Integer, String>();
+ int startLevel = MultiBundleTools.getDistroBundles(bundles);
+
+ List<Option> opts = new ArrayList<Option>();
+ opts.add(CoreOptions.systemProperty("org.osgi.framework.startlevel.beginning").value("" + startLevel));
+ for(Map.Entry<Integer, String> entry : bundles.entrySet()) {
+ opts.add(CoreOptions.bundle(entry.getValue()).startLevel(entry.getKey()));
+ }
+ opts.add(CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").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(getTestClientBundle()));
+
+ return CoreOptions.options(opts.toArray(new Option[opts.size()]));
+ }
+
+ protected BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ @Test
+ public void testClientConsumer() throws Exception {
+ baseTestClientConsumer();
+ }
+}
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml?rev=903708&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml (added)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml Wed Jan 27 16:15:04 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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.
+ -->
+<rsa:endpoint-descriptions xmlns:rsa="http://www.osgi.org/xmlns/rsa/v1.0.0"
+ xmlns:other="http://www.acme.org/xmlns/other/v1.0.0">
+ <endpoint-description>
+ <property name="objectClass">
+ <array>
+ <value>org.apache.cxf.dosgi.samples.greeter.GreeterService</value>
+ </array>
+ </property>
+ <property name="endpoint.id">http://localhost:9191/grrr</property>
+ <property name="service.imported.configs">org.apache.cxf.ws</property>
+ </endpoint-description>
+</rsa:endpoint-descriptions>
+
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/dosgi/trunk/systests2/multi-bundle/src/test/resources/rs-test1.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: cxf/dosgi/trunk/systests2/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/pom.xml?rev=903708&r1=903707&r2=903708&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/pom.xml (original)
+++ cxf/dosgi/trunk/systests2/pom.xml Wed Jan 27 16:15:04 2010
@@ -18,10 +18,12 @@
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>
- <name>Distributed OSGi System Tests 2</name>
+ <name>Distributed OSGi System Tests</name>
<modules>
+ <module>common</module>
<module>single-bundle</module>
+ <module>multi-bundle</module>
</modules>
</project>
Modified: cxf/dosgi/trunk/systests2/single-bundle/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/single-bundle/pom.xml?rev=903708&r1=903707&r2=903708&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/single-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/systests2/single-bundle/pom.xml Wed Jan 27 16:15:04 2010
@@ -54,10 +54,23 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.cxf.dosgi.systests</groupId>
+ <artifactId>cxf-dosgi-ri-systests2-common</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-singlebundle-distribution</artifactId>
<version>${pom.version}</version>
- <scope>test</scope>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.foundation</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf.dosgi.samples</groupId>
Modified: cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestExportService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestExportService.java?rev=903708&r1=903707&r2=903708&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestExportService.java (original)
+++ cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestExportService.java Wed Jan 27 16:15:04 2010
@@ -18,25 +18,7 @@
*/
package org.apache.cxf.dosgi.systests2.basic;
-import java.io.IOException;
-import java.net.Socket;
-import java.net.URL;
-import java.util.Map;
-import java.util.concurrent.TimeoutException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.dosgi.samples.greeter.GreeterData;
-import org.apache.cxf.dosgi.samples.greeter.GreeterException;
-import org.apache.cxf.dosgi.samples.greeter.GreeterService;
-import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.junit.Assert;
+import org.apache.cxf.dosgi.systests2.common.AbstractTestExportService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
@@ -45,7 +27,7 @@
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
@RunWith( JUnit4TestRunner.class )
-public class TestExportService {
+public class TestExportService extends AbstractTestExportService {
@Configuration
public static Option[] configure() {
return CoreOptions.options(
@@ -57,93 +39,19 @@
CoreOptions.mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").versionAsInProject(),
CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi").artifactId("cxf-dosgi-ri-singlebundle-distribution").versionAsInProject(),
+
+ // The following two bundles start the greeter demo which registers a remote service
CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
- CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject()
+ CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject(),
+
+ // This bundle contains the common system testing code
+ CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject()
);
}
@Test
- public void testCreateEndpoint() throws Exception {
- waitPort(9090);
- URL wsdlURL = new URL("http://localhost:9090/greeter?wsdl");
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- dbf.setValidating(false);
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(wsdlURL.openStream());
- Element el = doc.getDocumentElement();
- Assert.assertEquals("definitions", el.getLocalName());
- Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/", el.getNamespaceURI());
- Assert.assertEquals("GreeterService", el.getAttribute("name"));
-
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
- try {
- ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
- factory.setServiceClass(GreeterService.class);
- factory.setAddress("http://localhost:9090/greeter");
- factory.getServiceFactory().setDataBinding(new AegisDatabinding());
- GreeterService client = (GreeterService)factory.create();
- Map<GreetingPhrase, String> greetings = client.greetMe("Fred");
- Assert.assertEquals("Fred", greetings.get(new GreetingPhrase("Hello")));
-
- try {
- class GreeterDataImpl implements GreeterData {
- private String name;
- private int age;
- private boolean exception;
-
- GreeterDataImpl(String n, int a, boolean ex) {
- name = n;
- age = a;
- exception = ex;
- }
-
- public String getName() {
- return name;
- }
-
- public int getAge() {
- return age;
- }
-
- public boolean isException() {
- return exception;
- }
- }
-
- GreeterData gd = new GreeterDataImpl("Stranger", 11, true);
- client.greetMe(gd);
- Assert.fail("GreeterException has to be thrown");
- } catch (GreeterException ex) {
- Assert.assertEquals("Wrong exception message",
- "GreeterService can not greet Stranger",
- ex.toString());
- }
- } finally {
- Thread.currentThread().setContextClassLoader(contextLoader);
- }
- }
-
- private void waitPort(int port) throws Exception {
- for (int i = 0; i < 20; i++) {
- Socket s = null;
- try {
- s = new Socket((String) null, port);
- // yep, its available
- return;
- } catch (IOException e) {
- // wait
- } finally {
- if (s != null) {
- try {
- s.close();
- } catch (IOException e) {}
- }
- }
- Thread.sleep(1000);
- }
- throw new TimeoutException();
+ public void testAccessEndpoint() throws Exception {
+ // call into base test. Inheriting the test doesn't properly report failures.
+ baseTestAccessEndpoint();
}
}
Modified: cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestImportService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestImportService.java?rev=903708&r1=903707&r2=903708&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestImportService.java (original)
+++ cxf/dosgi/trunk/systests2/single-bundle/src/test/java/org/apache/cxf/dosgi/systests2/basic/TestImportService.java Wed Jan 27 16:15:04 2010
@@ -1,21 +1,24 @@
+/**
+ * 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.cxf.dosgi.systests2.basic;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.dosgi.samples.greeter.GreeterData;
-import org.apache.cxf.dosgi.samples.greeter.GreeterException;
-import org.apache.cxf.dosgi.samples.greeter.GreeterService;
-import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
-import org.apache.cxf.dosgi.systests2.basic.test1.MyActivator;
-import org.apache.cxf.dosgi.systests2.basic.test1.MyServiceTracker;
-import org.apache.cxf.dosgi.systests2.basic.test1.StartServiceTracker;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.junit.Assert;
+import org.apache.cxf.dosgi.systests2.common.AbstractTestImportService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
@@ -23,87 +26,33 @@
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
@RunWith( JUnit4TestRunner.class )
-public class TestImportService {
+public class TestImportService extends AbstractTestImportService {
@Inject
BundleContext bundleContext = null;
@Configuration
public static Option[] configure() {
- InputStream testClientBundle = TinyBundles.newBundle()
- .add(MyActivator.class)
- .add(MyServiceTracker.class)
- .add(StartServiceTracker.class)
- .add("OSGI-INF/remote-service/remote-services.xml", TestImportService.class.getResource("/rs-test1.xml"))
- .set(Constants.BUNDLE_SYMBOLICNAME, "testClientBundle")
- .set(Constants.EXPORT_PACKAGE, "org.apache.cxf.dosgi.systests2.common.test1")
- .set(Constants.BUNDLE_ACTIVATOR, MyActivator.class.getName())
- .build(TinyBundles.withBnd());
-
return CoreOptions.options(
CoreOptions.mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").versionAsInProject(),
CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi").artifactId("cxf-dosgi-ri-singlebundle-distribution").versionAsInProject(),
CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
- CoreOptions.provision(testClientBundle)
+
+ // This bundle contains the common system testing code
+ CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.systests").artifactId("cxf-dosgi-ri-systests2-common").versionAsInProject(),
+
+ CoreOptions.provision(getTestClientBundle())
);
}
+ protected BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
@Test
public void testClientConsumer() throws Exception {
- // Set up a Server in the test
- ServerFactoryBean factory = new ServerFactoryBean();
- factory.setServiceClass(GreeterService.class);
- factory.setAddress("http://localhost:9191/grrr");
- factory.getServiceFactory().setDataBinding(new AegisDatabinding());
- factory.setServiceBean(new TestGreeter());
-
- Server server = null;
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
- server = factory.create();
-
- Hashtable<String, Object> props = new Hashtable<String, Object>();
- props.put("testName", "test1");
- bundleContext.registerService(Object.class.getName(), new Object(), props);
-
- // Wait for the service tracker in the test bundle to register a service with the test result
- ServiceReference ref = waitService(String.class.getName(), "(testResult=test1)");
- Assert.assertEquals("HiOSGi", ref.getProperty("result"));
- } finally {
- server.stop();
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-
- private ServiceReference waitService(String cls, String filter) throws Exception {
- ServiceReference[] refs = null;
- for (int i=0; i < 20; i++) {
- refs = bundleContext.getServiceReferences(cls, filter);
- if (refs != null && refs.length > 0) {
- return refs[0];
- }
- System.out.println("Waiting for service: " + cls + filter);
- Thread.sleep(1000);
- }
- throw new Exception("Service not found: " + cls + filter);
- }
-
- public static class TestGreeter implements GreeterService {
- public Map<GreetingPhrase, String> greetMe(String name) {
- Map<GreetingPhrase, String> m = new HashMap<GreetingPhrase, String>();
- GreetingPhrase gp = new GreetingPhrase("Hi");
- m.put(gp, name);
- return m;
- }
-
- public GreetingPhrase[] greetMe(GreeterData gd) throws GreeterException {
- throw new GreeterException("TestGreeter");
- }
- }
+ baseTestClientConsumer();
+ }
}