Author: davidb
Date: Thu Jan 22 05:08:40 2009
New Revision: 736631
URL: http://svn.apache.org/viewvc?rev=736631&view=rev
Log:
Made the publication of the osgi.remote.configuration.pojo.address property
contain correct port number when using OSGi HttpService.
When using the HttpService (triggered by the
osgi.remote.configuration.pojo.httpservice.context property) the publication of
the service uses osgi.remote.configuration.pojo.address property to declare the
location of the service when publishing to Discovery. This is because the
client side would still need this property to look up the service.
The new code looks up the port number used by the HttpService using the
standard osgi "org.osgi.service.http.port" and/or
"org.osgi.service.http.port.secure" properties.
This way it fabricates the value of the osgi.remote.configuration.pojo.address
property as follows:
http[s]://{machine-name}:{port property}/{context}
Also added new unit tests.
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.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/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=736631&r1=736630&r2=736631&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
Thu Jan 22 05:08:40 2009
@@ -42,10 +42,13 @@
protected String getDefaultAddress(Class<?> type) {
String host =
handlerProps.get(Constants.DEFAULT_HOST_CONFIG).toString();
String port =
handlerProps.get(Constants.DEFAULT_PORT_CONFIG).toString();
+ return getAddress("http", host, port, "/" +
type.getName().replace('.', '/'));
+ }
+
+ protected String getAddress(String scheme, String host, String port,
String context) {
StringBuilder buf = new StringBuilder();
- buf.append("http://").append(host).append(':').append(port).append('/')
- .append(type.getName().replace('.', '/'));
- return buf.toString();
+
buf.append(scheme).append("://").append(host).append(':').append(port).append(context);
+ return buf.toString();
}
protected boolean useMasterMap() {
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=736631&r1=736630&r2=736631&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
Thu Jan 22 05:08:40 2009
@@ -68,8 +68,6 @@
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);
- publicationProperties.put(Constants.POJO_ADDRESS_PROPERTY,
- server.getDestination().getAddress().getAddress().getValue());
String intentsValue = OsgiUtils.formatIntents(intents);
if (intentsValue.length() > 0) {
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java?rev=736631&r1=736630&r2=736631&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandler.java
Thu Jan 22 05:08:40 2009
@@ -18,6 +18,8 @@
*/
package org.apache.cxf.dosgi.dsw.handlers;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
@@ -78,8 +80,8 @@
ServiceEndpointDescription sd,
Class<?> iClass,
Object serviceBean) {
- String context = getServletContext(sd, iClass);
- if (context == null) {
+ String contextRoot = getServletContextRoot(sd, iClass);
+ if (contextRoot == null) {
LOG.warning("Remote address is unavailable");
return null;
}
@@ -87,8 +89,8 @@
CXFNonSpringServlet cxf = new CXFNonSpringServlet();
HttpService httpService = getHttpService();
try {
- httpService.registerServlet(context, cxf, new Hashtable<String,
String>(), null);
- LOG.info("Successfully registered CXF DOSGi servlet at " +
context);
+ httpService.registerServlet(contextRoot, cxf, new
Hashtable<String, String>(), null);
+ LOG.info("Successfully registered CXF DOSGi servlet at " +
contextRoot);
} catch (Exception e) {
throw new ServiceException("CXF DOSGi: problem registering CXF
HTTP Servlet", e);
}
@@ -106,13 +108,41 @@
applyIntents(dswContext, callingContext,
factory.getFeatures(), factory, sd);
Server server = factory.create();
- getDistributionProvider().addExposedService(serviceReference,
registerPublication(server, intents));
+ getDistributionProvider().addExposedService(serviceReference,
registerPublication(server, intents, contextRoot));
return server;
} catch (IntentUnsatifiedException iue) {
getDistributionProvider().intentsUnsatisfied(serviceReference);
throw iue;
}
}
+
+ private Map<String, String> registerPublication(Server server, String[]
intents, String contextRoot) {
+ Map<String, String> publicationProperties =
super.registerPublication(server, intents);
+
+ String port = null;
+ boolean https = false;
+ if
("true".equalsIgnoreCase(System.getProperty("org.osgi.service.http.secure.enabled")))
{
+ https = true;
+ port = System.getProperty("org.osgi.service.http.port.secure");
+ } else {
+ port = System.getProperty("org.osgi.service.http.port");
+ }
+ if (port == null) {
+ port = "80";
+ }
+
+ String hostName = null;
+ try {
+ hostName = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ hostName = "localhost";
+ }
+
+ publicationProperties.put(Constants.POJO_ADDRESS_PROPERTY,
+ getAddress(https ? "https" : "http", hostName, port, contextRoot));
+
+ return publicationProperties;
+ }
private HttpService getHttpService() {
for (ServiceReference sr : httpServiceReferences) {
@@ -124,10 +154,10 @@
throw new ServiceException("CXF DOSGi: No HTTP Service could be found
to publish CXF endpoint in.");
}
- private String getServletContext(ServiceEndpointDescription sd, Class<?>
iClass) {
+ private String getServletContextRoot(ServiceEndpointDescription sd,
Class<?> iClass) {
String context = OsgiUtils.getProperty(sd,
Constants.POJO_HTTP_SERVICE_CONTEXT);
if (context == null) {
- context = iClass.getName().replace('.', '/');
+ context = "/" + iClass.getName().replace('.', '/');
LOG.info("Using a default address : " + context);
}
return context;
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=736631&r1=736630&r2=736631&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 Jan 22 05:08:40 2009
@@ -85,35 +85,43 @@
ServiceEndpointDescription sd,
Class<?> iClass,
Object serviceBean) throws
IntentUnsatifiedException {
- String address = getPojoAddress(sd, iClass);
- if (address == null) {
- LOG.warning("Remote address is unavailable");
- return null;
- }
-
- LOG.info("Creating a " + sd.getInterfaceNames().toArray()[0]
- + " endpoint from CXF PublishHook, address is " + address);
-
- ServerFactoryBean factory = createServerFactoryBean();
- factory.setServiceClass(iClass);
- factory.setAddress(address);
- factory.getServiceFactory().setDataBinding(new AegisDatabinding());
- factory.setServiceBean(serviceBean);
-
- try {
- String [] intents = applyIntents(
- dswContext, callingContext, factory.getFeatures(), factory, sd);
+ String address = getPojoAddress(sd, iClass);
+ if (address == null) {
+ LOG.warning("Remote address is unavailable");
+ return null;
+ }
+
+ LOG.info("Creating a " + sd.getInterfaceNames().toArray()[0]
+ + " endpoint from CXF PublishHook, address is " + address);
+
+ ServerFactoryBean factory = createServerFactoryBean();
+ factory.setServiceClass(iClass);
+ factory.setAddress(address);
+ factory.getServiceFactory().setDataBinding(new AegisDatabinding());
+ factory.setServiceBean(serviceBean);
+
+ 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;
+ }
+ }
- Server server = factory.create();
- getDistributionProvider().addExposedService(serviceReference,
registerPublication(server, intents));
- return server;
- } catch (IntentUnsatifiedException iue) {
- getDistributionProvider().intentsUnsatisfied(serviceReference);
- throw iue;
+ @Override
+ Map<String, String> registerPublication(Server server, String[] intents) {
+ Map<String, String> publicationProperties =
super.registerPublication(server, intents);
+ publicationProperties.put(Constants.POJO_ADDRESS_PROPERTY,
+ server.getDestination().getAddress().getAddress().getValue());
+
+ return publicationProperties;
}
-}
-
-
+
private String getPojoAddress(ServiceEndpointDescription sd, Class<?>
iClass) {
String address = OsgiUtils.getProperty(sd,
Constants.POJO_ADDRESS_PROPERTY);
if (address == null) {
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java?rev=736631&r1=736630&r2=736631&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceConfigurationTypeHandlerTest.java
Thu Jan 22 05:08:40 2009
@@ -1,13 +1,17 @@
package org.apache.cxf.dosgi.dsw.handlers;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import junit.framework.TestCase;
-import org.apache.cxf.dosgi.dsw.TestUtils;
+import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.apache.cxf.dosgi.dsw.service.ServiceEndpointDescriptionImpl;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.AbstractFeature;
@@ -24,7 +28,74 @@
import org.osgi.service.http.HttpService;
public class HttpServiceConfigurationTypeHandlerTest extends TestCase {
- public void testServer() {
+ public void testServer() throws Exception {
+ Properties savedProps = new Properties();
+ savedProps.putAll(System.getProperties());
+ try {
+ System.setProperty("org.osgi.service.http.port", "327");
+
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ HttpService httpService =
EasyMock.createNiceMock(HttpService.class);
+ // expect that the cxf servlet is registered
+ EasyMock.replay(httpService);
+
+ ServiceReference httpSvcSR =
EasyMock.createNiceMock(ServiceReference.class);
+ EasyMock.replay(httpSvcSR);
+
EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
+ EasyMock.replay(dswContext);
+
+ final ServerFactoryBean sfb = createMockServerFactoryBean();
+
+ DistributionProviderImpl dp = new
DistributionProviderImpl(dswContext);
+ Map<String, Object> handlerProps = new HashMap<String, Object>();
+ HttpServiceConfigurationTypeHandler h =
+ new HttpServiceConfigurationTypeHandler(dswContext, dp,
handlerProps) {
+ @Override
+ ServerFactoryBean createServerFactoryBean() {
+ return sfb;
+ }
+
+ @Override
+ String[] applyIntents(BundleContext dswContext,
BundleContext callingContext,
+ List<AbstractFeature> features,
AbstractEndpointFactory factory,
+ ServiceEndpointDescription sd) {
+ return new String [] {"a.b.c"};
+ }
+ };
+ h.httpServiceReferences.add(httpSvcSR);
+
+ Runnable myService = new Runnable() {
+ public void run() {
+ System.out.println("blah");
+ }
+ };
+
+ ServiceReference sr =
EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(sr);
+ EasyMock.replay(callingContext);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.POJO_HTTP_SERVICE_CONTEXT, "/myRunnable");
+ ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
+
+ assertEquals("Precondition failed", 0,
dp.getExposedServices().size());
+ h.createServer(sr, dswContext, callingContext, sd, Runnable.class,
myService);
+ assertEquals(1, dp.getExposedServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
+
+ String hostName = InetAddress.getLocalHost().getHostName();
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("osgi.remote.configuration.type", "pojo");
+ expected.put("osgi.remote.configuration.pojo.address", "http://" +
hostName + ":327/myRunnable");
+ expected.put("osgi.intents", "a.b.c");
+ assertEquals(expected, dp.getExposedProperties(sr));
+ } finally {
+ System.setProperties(savedProps);
+ }
+ }
+
+ public void testServerUsingDefaultAddress() throws Exception {
BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
HttpService httpService = EasyMock.createNiceMock(HttpService.class);
// expect that the cxf servlet is registered
@@ -50,7 +121,7 @@
String[] applyIntents(BundleContext dswContext, BundleContext
callingContext,
List<AbstractFeature> features,
AbstractEndpointFactory factory,
ServiceEndpointDescription sd) {
- return new String [] {"a.b.c"};
+ return new String [] {};
}
};
h.httpServiceReferences.add(httpSvcSR);
@@ -63,25 +134,92 @@
ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
- ServiceEndpointDescription sd =
TestUtils.mockServiceDescription(Runnable.class.getName());
EasyMock.replay(sr);
EasyMock.replay(callingContext);
- EasyMock.replay(sd);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
assertEquals("Precondition failed", 0, dp.getExposedServices().size());
h.createServer(sr, dswContext, callingContext, sd, Runnable.class,
myService);
assertEquals(1, dp.getExposedServices().size());
assertSame(sr, dp.getExposedServices().iterator().next());
+ String hostname = InetAddress.getLocalHost().getHostName();
Map<String, String> expected = new HashMap<String, String>();
expected.put("osgi.remote.configuration.type", "pojo");
- // The following doesn't work yet.
- // expected.put("osgi.remote.configuration.pojo.address",
"http://somehost:54321/myRunnable");
- expected.put("osgi.remote.configuration.pojo.address", "/"); //
temporary
- expected.put("osgi.intents", "a.b.c");
+ expected.put("osgi.remote.configuration.pojo.address", "http://" +
hostname + ":80/java/lang/Runnable");
assertEquals(expected, dp.getExposedProperties(sr));
}
+
+ public void testServerConfiguredUsingHttps() throws Exception {
+ Properties savedProps = new Properties();
+ savedProps.putAll(System.getProperties());
+ try {
+ System.setProperty("org.osgi.service.http.secure.enabled", "true");
+ System.setProperty("org.osgi.service.http.port.secure", "8443");
+
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ HttpService httpService =
EasyMock.createNiceMock(HttpService.class);
+ // expect that the cxf servlet is registered
+ EasyMock.replay(httpService);
+
+ ServiceReference httpSvcSR =
EasyMock.createNiceMock(ServiceReference.class);
+ EasyMock.replay(httpSvcSR);
+
EasyMock.expect(dswContext.getService(httpSvcSR)).andReturn(httpService).anyTimes();
+ EasyMock.replay(dswContext);
+
+ final ServerFactoryBean sfb = createMockServerFactoryBean();
+
+ DistributionProviderImpl dp = new
DistributionProviderImpl(dswContext);
+ Map<String, Object> handlerProps = new HashMap<String, Object>();
+ HttpServiceConfigurationTypeHandler h =
+ new HttpServiceConfigurationTypeHandler(dswContext, dp,
handlerProps) {
+ @Override
+ ServerFactoryBean createServerFactoryBean() {
+ return sfb;
+ }
+
+ @Override
+ String[] applyIntents(BundleContext dswContext,
BundleContext callingContext,
+ List<AbstractFeature> features,
AbstractEndpointFactory factory,
+ ServiceEndpointDescription sd) {
+ return new String [] {};
+ }
+ };
+ h.httpServiceReferences.add(httpSvcSR);
+
+ Runnable myService = new Runnable() {
+ public void run() {
+ System.out.println("blah");
+ }
+ };
+
+ ServiceReference sr =
EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(sr);
+ EasyMock.replay(callingContext);
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.CONFIG_TYPE_PROPERTY,
Constants.POJO_CONFIG_TYPE);
+ props.put(Constants.POJO_HTTP_SERVICE_CONTEXT, "/myRunnable");
+ ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
+
+ assertEquals("Precondition failed", 0,
dp.getExposedServices().size());
+ h.createServer(sr, dswContext, callingContext, sd, Runnable.class,
myService);
+ assertEquals(1, dp.getExposedServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
+
+ String hostName = InetAddress.getLocalHost().getHostName();
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("osgi.remote.configuration.type", "pojo");
+ expected.put("osgi.remote.configuration.pojo.address", "https://"
+ hostName + ":8443/myRunnable");
+ assertEquals(expected, dp.getExposedProperties(sr));
+ } finally {
+ System.setProperties(savedProps);
+ }
+ }
+
private ServerFactoryBean createMockServerFactoryBean() {
ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
EasyMock.replay(sf);
@@ -133,6 +271,8 @@
return server;
}
+ // TODO these tests still need to be written...
+ /*
public void testNoHttpService() {
}
@@ -143,4 +283,5 @@
public void testServletUnregistration() {
}
+ */
}
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=736631&r1=736630&r2=736631&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 Jan 22 05:08:40 2009
@@ -144,6 +144,47 @@
expected.put("osgi.intents", "A B");
assertEquals(expected, dp.getExposedProperties(sr));
}
+
+ public void testCreateServerWithAddressProprety() {
+ BundleContext dswContext =
EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
+ String myService = "Hi";
+ final ServerFactoryBean sfb = createMockServerFactoryBean();
+
+ DistributionProviderImpl dp = new DistributionProviderImpl(dswContext);
+ PojoConfigurationTypeHandler p = new
PojoConfigurationTypeHandler(dswContext, dp, handlerProps) {
+ @Override
+ ServerFactoryBean createServerFactoryBean() {
+ return sfb;
+ }
+
+ @Override
+ String[] applyIntents(BundleContext dswContext, BundleContext
callingContext,
+ List<AbstractFeature> features, AbstractEndpointFactory
factory, ServiceEndpointDescription sd) {
+ return new String []{};
+ }
+ };
+
+ ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
+ BundleContext callingContext =
EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(sr);
+ EasyMock.replay(callingContext);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(Constants.POJO_ADDRESS_PROPERTY,
"http://alternate_host:80/myString");
+ ServiceEndpointDescription sd = new
ServiceEndpointDescriptionImpl(Runnable.class.getName(), props);
+
+ assertEquals("Precondition failed", 0, dp.getExposedServices().size());
+ p.createServer(sr, dswContext, callingContext, sd, String.class,
myService);
+ assertEquals(1, dp.getExposedServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
+
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("osgi.remote.configuration.type", "pojo");
+ expected.put("osgi.remote.configuration.pojo.address",
"http://alternate_host:80/myString");
+ assertEquals(expected, dp.getExposedProperties(sr));
+ }
private ServerFactoryBean createMockServerFactoryBean() {
ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);