Author: eglynn
Date: Thu Oct 2 04:21:09 2008
New Revision: 701084
URL: http://svn.apache.org/viewvc?rev=701084&view=rev
Log:
Applied further patch for CXF-1836 on behalf of David Bosschaert.
Added:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
(with props)
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
(with props)
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
Thu Oct 2 04:21:09 2008
@@ -45,13 +45,13 @@
this.handler = handler;
}
- public Object getService(Bundle requestingBundle, ServiceRegistration
sreg) {
-
+ public Object getService(Bundle requestingBundle, ServiceRegistration
sreg) {
try {
- return handler.createProxy(dswContext,
-
requestingBundle.getBundleContext(),
- iClass,
- sd);
+ return handler.createProxy(sreg.getReference(),
+ dswContext,
+ requestingBundle.getBundleContext(),
+ iClass,
+ sd);
} catch (Exception ex) {
LOG.log(Level.WARNING,
"Problem creating a remote proxy for "
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
Thu Oct 2 04:21:09 2008
@@ -31,7 +31,8 @@
Class<?> iClass,
Object serviceBean);
- Object createProxy(BundleContext dswContext,
+ Object createProxy(ServiceReference serviceReference,
+ BundleContext dswContext,
BundleContext callingContext,
Class<?> iClass, ServiceDescription sd);
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
Thu Oct 2 04:21:09 2008
@@ -59,7 +59,8 @@
return new ServerFactoryBean();
}
- public Object createProxy(BundleContext dswContext,
+ public Object createProxy(ServiceReference serviceReference,
+ BundleContext dswContext,
BundleContext callingContext,
Class<?> iClass, ServiceDescription sd) {
@@ -86,7 +87,9 @@
factory.getClientFactoryBean(),
sd);
- return getProxy(factory.create(), iClass);
+ Object proxy = getProxy(factory.create(), iClass);
+ getDistributionProvider().addRemoteService(serviceReference);
+ return proxy;
} catch (Exception e) {
LOG.log(Level.WARNING, "proxy creation failed", e);
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
Thu Oct 2 04:21:09 2008
@@ -44,7 +44,8 @@
super(dp, handlerProps);
}
- public Object createProxy(BundleContext dswContext,
+ public Object createProxy(ServiceReference serviceReference,
+ BundleContext dswContext,
BundleContext callingContext,
Class<?> iClass,
ServiceDescription sd) {
@@ -72,11 +73,18 @@
PackageUtils.getPackageName(iClass));
}
QName serviceQname = new QName(serviceNs, iClass.getSimpleName());
- Service service = Service.create(wsdlAddress, serviceQname);
- return getProxy(service.getPort(iClass), iClass);
+ Service service = createWebService(wsdlAddress, serviceQname);
+ Object proxy = getProxy(service.getPort(iClass), iClass);
+ getDistributionProvider().addRemoteService(serviceReference);
+ return proxy;
}
+ // Isolated so that it can be overridden for test purposes.
+ Service createWebService(URL wsdlAddress, QName serviceQname) {
+ return Service.create(wsdlAddress, serviceQname);
+ }
+
public Server createServer(ServiceReference sr,
BundleContext dswContext,
BundleContext callingContext,
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
Thu Oct 2 04:21:09 2008
@@ -22,5 +22,6 @@
import org.osgi.service.dsw.DistributionProvider;
public interface CxfDistributionProvider extends DistributionProvider {
- void addExposedService(ServiceReference serviceReference);
+ void addExposedService(ServiceReference serviceReference);
+ void addRemoteService(ServiceReference serviceReference);
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
Thu Oct 2 04:21:09 2008
@@ -29,6 +29,7 @@
public class DistributionProviderImpl implements DistributionProvider,
CxfDistributionProvider {
private Set<ServiceReference> exposedServices = new
HashSet<ServiceReference>();
+ private Set<ServiceReference> remoteServices = new
HashSet<ServiceReference>();
public Map getPublicationProperties(ServiceReference sr) {
return Collections.EMPTY_MAP;
@@ -45,7 +46,9 @@
}
public ServiceReference[] getRemoteServices() {
- return new ServiceReference[]{};
+ synchronized (remoteServices) {
+ return remoteServices.toArray(new
ServiceReference[remoteServices.size()]);
+ }
}
public void addExposedService(ServiceReference sr) {
@@ -54,5 +57,9 @@
}
}
-
+ public void addRemoteService(ServiceReference sr) {
+ synchronized (remoteServices) {
+ remoteServices.add(sr);
+ }
+ }
}
Added:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java?rev=701084&view=auto
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
(added)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
Thu Oct 2 04:21:09 2008
@@ -0,0 +1,37 @@
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.discovery.ServiceDescription;
+
+public class ClientServiceFactoryTest extends TestCase {
+ public void testGetService() {
+ Object myTestProxyObject = new Object();
+
+ IMocksControl control = EasyMock.createNiceControl();
+ BundleContext dswContext = control.createMock(BundleContext.class);
+ ServiceDescription sd = control.createMock(ServiceDescription.class);
+ ConfigurationTypeHandler handler =
control.createMock(ConfigurationTypeHandler.class);
+
+ BundleContext requestingContext =
control.createMock(BundleContext.class);
+ Bundle requestingBundle = control.createMock(Bundle.class);
+
EasyMock.expect(requestingBundle.getBundleContext()).andReturn(requestingContext);
+
+ ServiceReference sr = control.createMock(ServiceReference.class);
+ ServiceRegistration sreg =
control.createMock(ServiceRegistration.class);
+ EasyMock.expect(sreg.getReference()).andReturn(sr);
+
+ handler.createProxy(sr, dswContext, requestingContext, String.class,
sd);
+ EasyMock.expectLastCall().andReturn(myTestProxyObject);
+ control.replay();
+
+ ClientServiceFactory csf = new ClientServiceFactory(dswContext,
String.class, sd, handler);
+ assertSame(myTestProxyObject, csf.getService(requestingBundle, sreg));
+ }
+}
Propchange:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Thu Oct 2 04:21:09 2008
@@ -28,6 +28,7 @@
import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.easymock.classextension.EasyMock;
@@ -48,6 +49,41 @@
handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321");
}
+ public void testCreateProxyPopulatesDistributionProvider() {
+ ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
+ EasyMock.replay(sf);
+
+ final ClientProxyFactoryBean cpfb =
EasyMock.createNiceMock(ClientProxyFactoryBean.class);
+ EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
+ EasyMock.replay(cpfb);
+
+ DistributionProviderImpl dp = new DistributionProviderImpl();
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
+ @Override
+ ClientProxyFactoryBean createClientProxyFactoryBean() {
+ return cpfb;
+ }
+
+ @Override
+ void applyIntents(BundleContext dswContext, BundleContext
callingContext,
+ List<AbstractFeature> features, AbstractEndpointFactory
factory, ServiceDescription sd) {}
+ };
+
+ ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
+ ServiceDescription sd =
EasyMock.createNiceMock(ServiceDescription.class);
+ EasyMock.replay(sr);
+ EasyMock.replay(dswContext);
+ EasyMock.replay(callingContext);
+ EasyMock.replay(sd);
+
+ assertEquals("Precondition failed", 0, dp.getRemoteServices().length);
+ p.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
+ assertEquals(1, dp.getRemoteServices().length);
+ assertSame(sr, dp.getRemoteServices()[0]);
+ }
+
public void testCreateServerPopulatesDistributionProvider() {
String myService = "Hi";
Added:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java?rev=701084&view=auto
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
(added)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
Thu Oct 2 04:21:09 2008
@@ -0,0 +1,58 @@
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.discovery.ServiceDescription;
+
+public class WsdlConfigurationTypeHandlerTest extends TestCase {
+ private Map<String, Object> handlerProps;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ handlerProps = new HashMap<String, Object>();
+ handlerProps.put(Constants.DEFAULT_HOST_CONFIG, "somehost");
+ handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321");
+ }
+
+ public void testCreateProxyPopulatesDistributionProvider() {
+ DistributionProviderImpl dp = new DistributionProviderImpl();
+ WsdlConfigurationTypeHandler w = new WsdlConfigurationTypeHandler(dp,
handlerProps) {
+ @Override
+ Service createWebService(URL wsdlAddress, QName serviceQname) {
+ Service svc = EasyMock.createMock(Service.class);
+
EasyMock.expect(svc.getPort(CharSequence.class)).andReturn("Hi").anyTimes();
+ EasyMock.replay(svc);
+ return svc;
+ }
+ };
+
+ ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
+ ServiceDescription sd =
EasyMock.createNiceMock(ServiceDescription.class);
+ EasyMock.replay(sr);
+ EasyMock.replay(dswContext);
+ EasyMock.replay(callingContext);
+ EasyMock.replay(sd);
+
+ assertEquals("Precondition failed", 0, dp.getRemoteServices().length);
+ w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
+ assertEquals(1, dp.getRemoteServices().length);
+ assertSame(sr, dp.getRemoteServices()[0]);
+
+ }
+}
Propchange:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
Thu Oct 2 04:21:09 2008
@@ -110,7 +110,8 @@
Map<String, Object>
props) {
return new ConfigurationTypeHandler() {
- public Object createProxy(BundleContext dswContext,
BundleContext callingContext,
+ public Object createProxy(ServiceReference sr,
+ BundleContext dswContext,
BundleContext callingContext,
Class<?> iClass, ServiceDescription
sd) {
throw new UnsupportedOperationException();
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java?rev=701084&r1=701083&r2=701084&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
Thu Oct 2 04:21:09 2008
@@ -28,22 +28,56 @@
DistributionProviderImpl dp = new DistributionProviderImpl();
assertEquals(0, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(0, dp.getRemoteServices().length);
ServiceReference sr = new TestServiceReference();
ServiceReference sr2 = new TestServiceReference();
dp.addExposedService(sr);
assertEquals(1, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(0, dp.getRemoteServices().length);
assertSame(sr, dp.getExposedServices()[0]);
dp.addExposedService(sr);
assertEquals(1, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(0, dp.getRemoteServices().length);
assertSame(sr, dp.getExposedServices()[0]);
dp.addExposedService(sr2);
- assertEquals(2, dp.getExposedServices().length);
-
+ assertEquals(2, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(0, dp.getRemoteServices().length);
}
+ public void testRemoteServices() {
+ DistributionProviderImpl dp = new DistributionProviderImpl();
+
+ assertEquals(0, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(0, dp.getRemoteServices().length);
+ ServiceReference sr = new TestServiceReference();
+ ServiceReference sr2 = new TestServiceReference();
+
+ dp.addRemoteService(sr);
+ assertEquals(0, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(1, dp.getRemoteServices().length);
+ assertSame(sr, dp.getRemoteServices()[0]);
+
+ dp.addRemoteService(sr);
+ assertEquals(0, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(1, dp.getRemoteServices().length);
+ assertSame(sr, dp.getRemoteServices()[0]);
+
+ dp.addRemoteService(sr2);
+ assertEquals(0, dp.getExposedServices().length);
+ assertEquals(0, dp.getPublishedServices().length);
+ assertEquals(2, dp.getRemoteServices().length);
+ }
+
private static class TestServiceReference implements ServiceReference {
public Bundle getBundle() {
return null;