You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2009/03/10 17:35:55 UTC
svn commit: r752159 - in /cxf/dosgi/trunk/systests:
common/src/main/java/org/apache/cxf/dosgi/systests/common/
multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/
single_bundle_distro/src/test/resources/OSGI-INF/remote-service/
Author: eglynn
Date: Tue Mar 10 16:35:54 2009
New Revision: 752159
URL: http://svn.apache.org/viewvc?rev=752159&view=rev
Log:
Added test cases for multiple instances of the same service type described in the remote-services.xml
Modified:
cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java
cxf/dosgi/trunk/systests/multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml
cxf/dosgi/trunk/systests/single_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml
Modified: cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java?rev=752159&r1=752158&r2=752159&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java (original)
+++ cxf/dosgi/trunk/systests/common/src/main/java/org/apache/cxf/dosgi/systests/common/AbstractListenerHookServiceListenerTest.java Tue Mar 10 16:35:54 2009
@@ -39,7 +39,13 @@
import org.springframework.core.io.Resource;
public abstract class AbstractListenerHookServiceListenerTest extends AbstractDosgiSystemTest {
- private FutureTask<Map<GreetingPhrase, String>> task;
+
+ private final static String ADDRESS1 = "http://localhost:9090/greeter";
+ private final static String ADDRESS2 = "http://localhost:9089/greeter";
+ private FutureTask<Map<GreetingPhrase, String>> task1;
+ private Object mutex1 = new Object();
+ private FutureTask<Map<GreetingPhrase, String>> task2;
+ private Object mutex2 = new Object();
@Override
protected String[] getTestBundlesNames() {
@@ -66,12 +72,15 @@
Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
- Server server = null;
+ Server server1 = null;
+ Server server2 = null;
ServiceTracker tracker = null;
try {
- server = startServer("http://localhost:9090/greeter",
- GreeterService.class, new GreeterServiceImpl());
+ server1 = startServer(ADDRESS1,
+ GreeterService.class, new GreeterServiceImpl());
+ server2 = startServer(ADDRESS2,
+ GreeterService.class, new GreeterServiceImpl());
tracker = new ServiceTracker(bundleContext,
GreeterService.class.getName(), null) {
@Override
@@ -84,7 +93,17 @@
return useService(reference);
}});
future.run();
- setFuture(future);
+ synchronized (mutex1) {
+ synchronized (mutex2) {
+ if (task1 == null) {
+ task1 = future;
+ mutex1.notify();
+ } else if (task2 == null) {
+ task2 = future;
+ mutex2.notify();
+ }
+ }
+ }
return result;
}
};
@@ -92,26 +111,62 @@
// sleep for a bit
Thread.sleep(2000);
- if (!usingIntegralDsw()) {
- // now install dsw
- installBundle("org.apache.cxf.dosgi", "cxf-dosgi-ri-dsw-cxf", null, "jar");
- }
- verifyGreeterResponse();
+ installDswIfNeeded();
+
+ verifyGreeterResponse(task1, mutex1);
+ verifyGreeterResponse(task2, mutex2);
} finally {
if (tracker != null) {
tracker.close();
}
- if (server != null) {
- server.getDestination().shutdown();
- server.stop();
+ if (server1 != null) {
+ server1.getDestination().shutdown();
+ server1.stop();
+ }
+
+ if (server2 != null) {
+ server2.getDestination().shutdown();
+ server2.stop();
}
}
}
+ public void testMultiServiceProxification() throws Exception {
+
+ Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
+
+ installDswIfNeeded();
+
+ // sleep for a bit
+ Thread.sleep(2000);
+
+ ServiceReference[] srefs =
+ bundleContext.getAllServiceReferences(GreeterService.class.getName(), null);
+ assertNotNull(srefs);
+ assertEquals(2, srefs.length);
+ String addr1 = (String)
+ srefs[0].getProperty("osgi.remote.configuration.pojo.address");
+ String addr2 = (String)
+ srefs[1].getProperty("osgi.remote.configuration.pojo.address");
+ assertNotNull(addr1);
+ assertNotNull(addr2);
+ assertTrue("unexpected address property: " + addr1,
+ ADDRESS1.equals(addr1) ^ ADDRESS2.equals(addr1));
+ assertTrue("unexpected address property: " + addr2,
+ ADDRESS1.equals(addr2) ^ ADDRESS2.equals(addr2));
+ }
+
protected abstract boolean usingIntegralDsw();
-
+
+ private void installDswIfNeeded() throws Exception {
+ if (!usingIntegralDsw()) {
+ // now install dsw
+ installBundle("org.apache.cxf.dosgi", "cxf-dosgi-ri-dsw-cxf", null, "jar");
+ }
+ }
+
private Map<GreetingPhrase, String> useService(ServiceReference sref) {
GreeterService hs = (GreeterService)bundleContext.getService(sref);
assertNotNull(hs);
@@ -123,11 +178,11 @@
return null;
}
- private void verifyGreeterResponse() throws Exception {
+ private void verifyGreeterResponse(FutureTask<Map<GreetingPhrase, String>> task, Object mutex) throws Exception {
Map<GreetingPhrase, String> greetings = null;
- synchronized (this) {
+ synchronized (mutex) {
while (task == null) {
- wait(500);
+ mutex.wait(500);
}
greetings = task.get();
}
@@ -135,14 +190,6 @@
assertEquals("Fred", greetings.get(new GreetingPhrase("Hello")));
}
- private void setFuture(FutureTask<Map<GreetingPhrase, String>> future) {
- synchronized (this) {
- task = future;
- notify();
- }
- }
-
-
private class GreeterServiceImpl implements GreeterService {
private final static String STRANGER_NAME = "Stranger";
Modified: cxf/dosgi/trunk/systests/multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests/multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml?rev=752159&r1=752158&r2=752159&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests/multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml (original)
+++ cxf/dosgi/trunk/systests/multi_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml Tue Mar 10 16:35:54 2009
@@ -21,4 +21,11 @@
<property name="osgi.remote.configuration.type" value="pojo" />
<property name="osgi.remote.configuration.pojo.address" value="http://localhost:9090/greeter" />
</service-description>
+ <service-description>
+ <provide interface="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
+ <property name="osgi.remote.interfaces" value="*" />
+ <property name="osgi.remote.requires.intents" value="SOAP HTTP" />
+ <property name="osgi.remote.configuration.type" value="pojo" />
+ <property name="osgi.remote.configuration.pojo.address" value="http://localhost:9089/greeter" />
+ </service-description>
</service-descriptions>
Modified: cxf/dosgi/trunk/systests/single_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests/single_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml?rev=752159&r1=752158&r2=752159&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests/single_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml (original)
+++ cxf/dosgi/trunk/systests/single_bundle_distro/src/test/resources/OSGI-INF/remote-service/remote-services.xml Tue Mar 10 16:35:54 2009
@@ -21,4 +21,11 @@
<property name="osgi.remote.configuration.type">pojo</property>
<property name="osgi.remote.configuration.pojo.address">http://localhost:9090/greeter</property>
</service-description>
+ <service-description>
+ <provide interface="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
+ <property name="osgi.remote.interfaces">*</property>
+ <property name="osgi.remote.requires.intents">SOAP HTTP</property>
+ <property name="osgi.remote.configuration.type">pojo</property>
+ <property name="osgi.remote.configuration.pojo.address">http://localhost:9089/greeter</property>
+ </service-description>
</service-descriptions>