Author: eglynn
Date: Thu Oct 16 09:12:12 2008
New Revision: 705271
URL: http://svn.apache.org/viewvc?rev=705271&view=rev
Log:
Applying patch for CXF-1876 on behalf of David Bosschaert
Modified:
cxf/sandbox/dosgi/distribution/single-bundle/pom.xml
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.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/hooks/AbstractClientHook.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/ConfigTypeHandlerFactoryTest.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/handlers/WsdlConfigurationTypeHandlerTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
Modified: cxf/sandbox/dosgi/distribution/single-bundle/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/distribution/single-bundle/pom.xml?rev=705271&r1=705270&r2=705271&view=diff
==============================================================================
--- cxf/sandbox/dosgi/distribution/single-bundle/pom.xml (original)
+++ cxf/sandbox/dosgi/distribution/single-bundle/pom.xml Thu Oct 16 09:12:12
2008
@@ -219,7 +219,11 @@
org.osgi.*,
*;resolution:=optional
</Import-Package>
- <Export-Package>org.apache.cxf.dosgi</Export-Package>
+ <Export-Package>
+ org.apache.cxf.dosgi,
+ org.osgi.service.distribution;version="1.0",
+ org.osgi.service.discovery;version="1.0"
+ </Export-Package>
<Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency>
<Embed-Directory>lib</Embed-Directory>
<_exportcontents>*</_exportcontents>
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=705271&r1=705270&r2=705271&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
Thu Oct 16 09:12:12 2008
@@ -19,10 +19,8 @@
package org.apache.cxf.dosgi.dsw;
-import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -54,6 +52,7 @@
private ExecutorService execService =
new ThreadPoolExecutor(5, 10, 50, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
+ private CxfDistributionProvider dpService;
public void start(BundleContext context) {
bc = context;
@@ -61,7 +60,7 @@
context.registerService(ManagedService.class.getName(),
this, getDefaults());
- CxfDistributionProvider dpService =
registerDistributionProviderService();
+ dpService = registerDistributionProviderService();
pHook = new CxfPublishHook(context, dpService);
lHook = new CxfListenerHook(context, dpService);
@@ -71,7 +70,7 @@
}
private CxfDistributionProvider registerDistributionProviderService() {
- DistributionProviderImpl dpService = new DistributionProviderImpl();
+ DistributionProviderImpl dpService = new DistributionProviderImpl(bc);
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put(DistributionProvider.PROP_KEY_PRODUCT_NAME,
getHeader("Bundle-Name"));
@@ -100,6 +99,7 @@
}
public void stop(BundleContext context) {
+ dpService.shutdown();
execService.shutdown();
pHook.removeEndpoints();
}
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=705271&r1=705270&r2=705271&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 16 09:12:12 2008
@@ -119,14 +119,20 @@
factory.getServiceFactory().setDataBinding(new AegisDatabinding());
factory.setServiceBean(serviceBean);
- String [] intents = applyIntents(
- dswContext, callingContext, factory.getFeatures(), factory, sd);
-
- Server server = factory.create();
- getDistributionProvider().addExposedService(serviceReference,
registerPublication(server, intents));
- return server;
+ try {
+ String [] intents = applyIntents(
+ dswContext, callingContext, factory.getFeatures(), factory,
sd);
+
+ Server server = factory.create();
+ getDistributionProvider().addExposedService(serviceReference,
registerPublication(server, intents));
+ return server;
+ } catch (IntentUnsatifiedException iue) {
+ getDistributionProvider().intentsUnsatisfied(serviceReference);
+ throw iue;
+ }
}
+
private Map<String, String> registerPublication(Server server, String[]
intents) {
Map<String, String> publicationProperties = new HashMap<String,
String>();
publicationProperties.put(Constants.CONFIG_TYPE_PROPERTY,
Constants.POJO_CONFIG_TYPE);
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java?rev=705271&r1=705270&r2=705271&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
Thu Oct 16 09:12:12 2008
@@ -110,6 +110,7 @@
Map<String, Object> props = new HashMap<String, Object>();
props.putAll(sd.getProperties());
props.put(Constants.DSW_CLIENT_ID, getIdentificationProperty());
+ props.put(Constants.REMOTE_PROPERTY_PREFIX, "true");
return props;
}
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=705271&r1=705270&r2=705271&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 16 09:12:12 2008
@@ -25,5 +25,8 @@
public interface CxfDistributionProvider extends DistributionProvider {
void addExposedService(ServiceReference serviceReference, Map<String,
String> publicationProperties);
- void addRemoteService(ServiceReference serviceReference);
+ void addRemoteService(ServiceReference serviceReference);
+ void intentsUnsatisfied(ServiceReference serviceReference);
+
+ void shutdown();
}
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=705271&r1=705270&r2=705271&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 16 09:12:12 2008
@@ -19,21 +19,41 @@
package org.apache.cxf.dosgi.dsw.service;
import java.util.Collections;
+import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.distribution.DistributionProvider;
-
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class DistributionProviderImpl implements DistributionProvider,
CxfDistributionProvider {
+ private EventAdmin eventAdmin;
+
private Map<ServiceReference, Map<String, String>> publicationProperties =
new HashMap<ServiceReference, Map<String,String>>();
private Set<ServiceReference> exposedServices = new
HashSet<ServiceReference>();
- private Set<ServiceReference> remoteServices = new
HashSet<ServiceReference>();
+ private Set<ServiceReference> remoteServices = new
HashSet<ServiceReference>();
+
+ private final ServiceTracker tracker;
+
+ public DistributionProviderImpl(BundleContext bc) {
+ tracker = new ServiceTracker(bc, EventAdmin.class.getName(), new
MyTrackerCustomizer());
+ tracker.open();
+ }
+ public void shutdown() {
+ tracker.close();
+ }
+
public Map<String, String> getPublicationProperties(ServiceReference sr) {
synchronized (publicationProperties) {
return publicationProperties.get(sr);
@@ -66,11 +86,50 @@
}
publicationProperties.put(sr, pp);
}
+ postAdminEvent(DistributionProvider.class.getName().replace('.', '/')
+ "/service/exposed", sr);
+ }
+
+ public void intentsUnsatisfied(ServiceReference sr) {
+ postAdminEvent(DistributionProvider.class.getName().replace('.', '/')
+ "/service/unsatisfied", sr);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void postAdminEvent(String topic, ServiceReference
serviceReference) {
+ if (eventAdmin != null) {
+ Dictionary ht = new Hashtable();
+ addEventEntry(ht, EventConstants.SERVICE, serviceReference);
+ addEventEntry(ht, EventConstants.SERVICE_ID,
serviceReference.getProperty(org.osgi.framework.Constants.SERVICE_ID));
+ addEventEntry(ht, EventConstants.SERVICE_OBJECTCLASS,
serviceReference.getProperty(org.osgi.framework.Constants.OBJECTCLASS));
+ addEventEntry(ht, EventConstants.SERVICE_PID,
serviceReference.getProperty(org.osgi.framework.Constants.SERVICE_PID));
+ eventAdmin.postEvent(new Event(topic, ht));
+ }
}
+ @SuppressWarnings("unchecked")
+ private void addEventEntry(Dictionary ht, String key, Object value) {
+ if (value != null) {
+ ht.put(key, value);
+ }
+ }
+
public void addRemoteService(ServiceReference sr) {
synchronized (remoteServices) {
remoteServices.add(sr);
}
}
+
+ private class MyTrackerCustomizer implements ServiceTrackerCustomizer {
+ public Object addingService(ServiceReference sr) {
+ Object svc = sr.getBundle().getBundleContext().getService(sr);
+ if (svc instanceof EventAdmin) {
+ eventAdmin = (EventAdmin) svc;
+ }
+ return svc;
+ }
+
+ public void modifiedService(ServiceReference sr, Object arg1) {}
+ public void removedService(ServiceReference sr, Object arg1) {
+ eventAdmin = null;
+ }
+ }
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java?rev=705271&r1=705270&r2=705271&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
Thu Oct 16 09:12:12 2008
@@ -28,21 +28,29 @@
import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
import org.apache.cxf.dosgi.dsw.service.ServiceEndpointDescriptionImpl;
+import org.easymock.EasyMock;
+import org.osgi.framework.BundleContext;
import org.osgi.service.discovery.ServiceEndpointDescription;
public class ConfigTypeHandlerFactoryTest extends TestCase {
public void testGetDefaultHandler() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+
ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl("MyInterface");
- CxfDistributionProvider dp = new DistributionProviderImpl();
+ CxfDistributionProvider dp = new DistributionProviderImpl(bc);
ConfigurationTypeHandler handler = f.getHandler(sd, dp, new
HashMap<String, Object>());
assertTrue(handler instanceof PojoConfigurationTypeHandler);
assertSame(dp, ((PojoConfigurationTypeHandler)
handler).getDistributionProvider());
}
public void testGetPojoHandler() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+
ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
Map<String, Object> sdProps = new HashMap<String, Object>();
@@ -50,13 +58,16 @@
ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
Collections.singletonList("MyInterface"), sdProps);
- CxfDistributionProvider dp = new DistributionProviderImpl();
+ CxfDistributionProvider dp = new DistributionProviderImpl(bc);
ConfigurationTypeHandler handler = f.getHandler(sd, dp, new
HashMap<String, Object>());
assertTrue(handler instanceof PojoConfigurationTypeHandler);
assertSame(dp, ((PojoConfigurationTypeHandler)
handler).getDistributionProvider());
}
public void testGetWSDLHandler() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+
ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
Map<String, Object> sdProps = new HashMap<String, Object>();
@@ -64,7 +75,7 @@
ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
Collections.singletonList("MyInterface"), sdProps);
- CxfDistributionProvider dp = new DistributionProviderImpl();
+ CxfDistributionProvider dp = new DistributionProviderImpl(bc);
ConfigurationTypeHandler handler = f.getHandler(sd, dp, new
HashMap<String, Object>());
assertTrue(handler instanceof WsdlConfigurationTypeHandler);
assertSame(dp, ((WsdlConfigurationTypeHandler)
handler).getDistributionProvider());
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=705271&r1=705270&r2=705271&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 16 09:12:12 2008
@@ -63,6 +63,8 @@
}
public void testCreateProxyPopulatesDistributionProvider() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
EasyMock.replay(sf);
@@ -70,7 +72,7 @@
EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
EasyMock.replay(cpfb);
- DistributionProviderImpl dp = new DistributionProviderImpl();
+ DistributionProviderImpl dp = new DistributionProviderImpl(bc);
PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
@Override
ClientProxyFactoryBean createClientProxyFactoryBean() {
@@ -100,10 +102,13 @@
}
public void testCreateServerPopulatesDistributionProvider() {
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
String myService = "Hi";
final ServerFactoryBean sfb = createMockServerFactoryBean();
- DistributionProviderImpl dp = new DistributionProviderImpl();
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
@Override
ServerFactoryBean createServerFactoryBean() {
@@ -118,11 +123,9 @@
};
ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
ServiceEndpointDescription sd =
TestUtils.mockServiceDescription("Foo");
EasyMock.replay(sr);
- EasyMock.replay(dswContext);
EasyMock.replay(callingContext);
EasyMock.replay(sd);
@@ -195,14 +198,6 @@
final IntentMap intentMap = new IntentMap();
intentMap.setIntents(intents);
- DistributionProviderImpl dp = new DistributionProviderImpl();
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
- @Override
- IntentMap getIntentMap(BundleContext callingContext) {
- return intentMap;
- }
- };
-
IMocksControl control = EasyMock.createNiceControl();
BundleContext dswContext = control.createMock(BundleContext.class);
BundleContext callingContext =
control.createMock(BundleContext.class);
@@ -210,6 +205,14 @@
AbstractEndpointFactory factory =
control.createMock(AbstractEndpointFactory.class);
control.replay();
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
+ @Override
+ IntentMap getIntentMap(BundleContext callingContext) {
+ return intentMap;
+ }
+ };
+
Map<String, Object> props = new HashMap<String, Object>();
props.put(Constants.REQUIRES_INTENTS_PROPERTY, "A");
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
@@ -226,14 +229,6 @@
final IntentMap intentMap = new IntentMap();
intentMap.setIntents(intents);
- DistributionProviderImpl dp = new DistributionProviderImpl();
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
- @Override
- IntentMap getIntentMap(BundleContext callingContext) {
- return intentMap;
- }
- };
-
IMocksControl control = EasyMock.createNiceControl();
BundleContext dswContext = control.createMock(BundleContext.class);
BundleContext callingContext =
control.createMock(BundleContext.class);
@@ -241,6 +236,14 @@
AbstractEndpointFactory factory =
control.createMock(AbstractEndpointFactory.class);
control.replay();
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
+ @Override
+ IntentMap getIntentMap(BundleContext callingContext) {
+ return intentMap;
+ }
+ };
+
Map<String, Object> props = new HashMap<String, Object>();
props.put(Constants.REQUIRES_INTENTS_PROPERTY, "transactionality
confidentiality.message");
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
@@ -256,15 +259,7 @@
intents.put("A", new AbstractFeature() {});
final IntentMap intentMap = new IntentMap();
intentMap.setIntents(intents);
-
- DistributionProviderImpl dp = new DistributionProviderImpl();
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
- @Override
- IntentMap getIntentMap(BundleContext callingContext) {
- return intentMap;
- }
- };
-
+
IMocksControl control = EasyMock.createNiceControl();
BundleContext dswContext = control.createMock(BundleContext.class);
BundleContext callingContext =
control.createMock(BundleContext.class);
@@ -272,6 +267,14 @@
AbstractEndpointFactory factory =
control.createMock(AbstractEndpointFactory.class);
control.replay();
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp,
handlerProps) {
+ @Override
+ IntentMap getIntentMap(BundleContext callingContext) {
+ return intentMap;
+ }
+ };
+
Map<String, Object> props = new HashMap<String, Object>();
props.put(Constants.REQUIRES_INTENTS_PROPERTY, "A B");
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
@@ -331,13 +334,15 @@
final IntentMap appIntentMap = new IntentMap();
appIntentMap.setIntents(appIntents);
- DistributionProviderImpl dp = new DistributionProviderImpl();
IMocksControl control = EasyMock.createNiceControl();
final BundleContext dswContext =
control.createMock(BundleContext.class);
final BundleContext callingContext =
control.createMock(BundleContext.class);
List<AbstractFeature> features = new ArrayList<AbstractFeature>();
AbstractEndpointFactory factory =
control.createMock(AbstractEndpointFactory.class);
control.replay();
+
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+
Map<String, Object> props = new HashMap<String, Object>();
props.put(Constants.REQUIRES_INTENTS_PROPERTY, requestedIntents);
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
@@ -373,13 +378,15 @@
final IntentMap appIntentMap = new IntentMap();
appIntentMap.setIntents(new HashMap<String, Object>());
- DistributionProviderImpl dp = new DistributionProviderImpl();
IMocksControl control = EasyMock.createNiceControl();
final BundleContext dswContext =
control.createMock(BundleContext.class);
final BundleContext callingContext =
control.createMock(BundleContext.class);
List<AbstractFeature> features = new ArrayList<AbstractFeature>();
AbstractEndpointFactory factory =
control.createMock(AbstractEndpointFactory.class);
control.replay();
+
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+
Map<String, Object> props = new HashMap<String, Object>();
props.put(Constants.REQUIRES_INTENTS_PROPERTY, "B A");
ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
Modified:
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=705271&r1=705270&r2=705271&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
Thu Oct 16 09:12:12 2008
@@ -47,18 +47,7 @@
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;
- }
- };
-
+ public void testCreateProxyPopulatesDistributionProvider() {
ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
@@ -68,6 +57,17 @@
EasyMock.replay(callingContext);
EasyMock.replay(sd);
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+ 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;
+ }
+ };
+
assertEquals("Precondition failed", 0, dp.getRemoteServices().length);
w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
assertEquals(1, dp.getRemoteServices().length);
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=705271&r1=705270&r2=705271&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 16 09:12:12 2008
@@ -23,12 +23,16 @@
import junit.framework.TestCase;
+import org.easymock.EasyMock;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class DistributionProviderImplTest extends TestCase {
public void testExposedServices() {
- DistributionProviderImpl dp = new DistributionProviderImpl();
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+ DistributionProviderImpl dp = new DistributionProviderImpl(bc);
assertEquals(0, dp.getExposedServices().length);
assertEquals(0, dp.getPublishedServices().length);
@@ -55,7 +59,9 @@
}
public void testRemoteServices() {
- DistributionProviderImpl dp = new DistributionProviderImpl();
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+ DistributionProviderImpl dp = new DistributionProviderImpl(bc);
assertEquals(0, dp.getExposedServices().length);
assertEquals(0, dp.getPublishedServices().length);
@@ -82,7 +88,10 @@
}
public void testPublicationProperties() {
- DistributionProviderImpl dp = new DistributionProviderImpl();
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bc);
+
+ DistributionProviderImpl dp = new DistributionProviderImpl(bc);
ServiceReference sr = new TestServiceReference();
ServiceReference sr2 = new TestServiceReference();