You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2012/12/07 11:14:39 UTC
svn commit: r1418247 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src:
main/java/org/apache/cxf/dosgi/dsw/
main/java/org/apache/cxf/dosgi/dsw/handlers/
test/java/org/apache/cxf/dosgi/dsw/handlers/
test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/ test/java/org/a...
Author: cschneider
Date: Fri Dec 7 10:14:30 2012
New Revision: 1418247
URL: http://svn.apache.org/viewvc?rev=1418247&view=rev
Log:
DOSGI-128 Allow to use JAXWS/JAXB service without frontend and databinding properties
Added:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java (with props)
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java (with props)
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java (with props)
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java (with props)
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=1418247&r1=1418246&r2=1418247&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java Fri Dec 7 10:14:30 2012
@@ -63,14 +63,22 @@ public class Constants {
public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
+
public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
+ public static final String WS_FRONTEND_JAXWS = "jaxws";
+ public static final String WS_FRONTEND_SIMPLE = "simple";
+
public static final String WS_IN_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.interceptors";
public static final String WS_OUT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.interceptors";
public static final String WS_OUT_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.fault.interceptors";
public static final String WS_IN_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.fault.interceptors";
public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + ".context.properties";
public static final String WS_FEATURES_PROP_KEY = WS_CONFIG_TYPE + ".features";
+
public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";
+ public static final String WS_DATA_BINDING_JAXB = "jaxb";
+ public static final String WS_DATA_BINDING_AEGIS = "aegis";
+
public static final String WS_WSDL_SERVICE_NAMESPACE = WS_CONFIG_TYPE + ".service.ns";
public static final String WS_WSDL_SERVICE_NAME = WS_CONFIG_TYPE + ".service.name";
public static final String WS_WSDL_PORT_NAME = WS_CONFIG_TYPE + ".port.name";
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=1418247&r1=1418246&r2=1418247&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java Fri Dec 7 10:14:30 2012
@@ -27,9 +27,7 @@ import java.util.Set;
import javax.xml.namespace.QName;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.qos.IntentManager;
import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
@@ -39,15 +37,10 @@ import org.apache.cxf.endpoint.AbstractE
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.AbstractFeature;
import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -124,26 +117,6 @@ public abstract class AbstractPojoConfig
}
}
- // Isolated so that it can be substituted for testing
- ClientProxyFactoryBean createClientProxyFactoryBean(ServiceReference sref, Class<?> iClass) {
- String frontEnd = (String)sref.getProperty(Constants.WS_FRONTEND_PROP_KEY);
- ClientProxyFactoryBean factory = "jaxws".equals(frontEnd) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
- String dataBindingName = (String)sref.getProperty(Constants.WS_DATABINDING_PROP_KEY);
- DataBinding databinding = "jaxb".equals(dataBindingName) ? new JAXBDataBinding() : new AegisDatabinding();
- factory.getServiceFactory().setDataBinding(databinding);
- return factory;
- }
-
- // Isolated so that it can be substituted for testing
- ServerFactoryBean createServerFactoryBean(ServiceReference sref, Class<?> iClass) {
- String frontEnd = (String)sref.getProperty(Constants.WS_FRONTEND_PROP_KEY);
- ServerFactoryBean factory = "jaxws".equals(frontEnd) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
- String dataBindingName = (String)sref.getProperty(Constants.WS_DATABINDING_PROP_KEY);
- DataBinding databinding = "jaxb".equals(dataBindingName) ? new JAXBDataBinding() : new AegisDatabinding();
- factory.getServiceFactory().setDataBinding(databinding);
- return factory;
- }
-
protected void setWsdlProperties(ServerFactoryBean factory,
BundleContext callingContext,
Map<String, Object> sd, boolean wsdlType) {
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=1418247&r1=1418246&r2=1418247&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java Fri Dec 7 10:14:30 2012
@@ -20,12 +20,19 @@ package org.apache.cxf.dosgi.dsw.handler
import java.util.Map;
+import javax.jws.WebService;
+
import org.apache.cxf.Bus;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.qos.IntentManager;
import org.apache.cxf.dosgi.dsw.qos.IntentUnsatifiedException;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -43,9 +50,10 @@ public class PojoConfigurationTypeHandle
return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
}
- public Object createProxy(ServiceReference serviceReference, BundleContext dswContext,
- BundleContext callingContext, Class<?> iClass, EndpointDescription sd) throws IntentUnsatifiedException {
- String address = getClientAddress(sd.getProperties(), iClass);
+ public Object createProxy(ServiceReference sref, BundleContext dswContext,
+ BundleContext callingContext, Class<?> iClass, EndpointDescription epd) throws IntentUnsatifiedException {
+ Map<String, Object> sd = epd.getProperties();
+ String address = getClientAddress(sd, iClass);
if (address == null) {
LOG.warn("Remote address is unavailable");
// TODO: fire Event
@@ -56,13 +64,14 @@ public class PojoConfigurationTypeHandle
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
try {
- ClientProxyFactoryBean factory = createClientProxyFactoryBean(serviceReference, iClass);
+ ClientProxyFactoryBean factory = createClientProxyFactoryBean(sd, iClass);
+ factory.getServiceFactory().setDataBinding(getDataBinding(sd, iClass));
factory.setServiceClass(iClass);
factory.setAddress(address);
- addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd.getProperties());
- setClientWsdlProperties(factory.getClientFactoryBean(), dswContext, sd.getProperties(), false);
+ addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd);
+ setClientWsdlProperties(factory.getClientFactoryBean(), dswContext, sd, false);
- intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd.getProperties());
+ intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
Object proxy = getProxy(factory.create(), iClass);
@@ -80,7 +89,8 @@ public class PojoConfigurationTypeHandle
String address = getServerAddress(sd, iClass);
String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
- ServerFactoryBean factory = createServerFactoryBean(sref, iClass);
+ ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
+ factory.setDataBinding(getDataBinding(sd, iClass));
if (contextRoot != null) {
Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref);
factory.setBus(bus);
@@ -95,9 +105,33 @@ public class PojoConfigurationTypeHandle
String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(dswContext, contextRoot, address);
// The properties for the EndpointDescription
- Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[]{Constants.WS_CONFIG_TYPE}, completeEndpointAddress,intents);
+ Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[]{Constants.WS_CONFIG_TYPE}, completeEndpointAddress, intents);
return createServerFromFactory(factory, endpointProps);
}
+ private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXB(sd, iClass) ? new JAXBDataBinding() : new AegisDatabinding();
+ }
+
+ private boolean isJAXB(Map<String, Object> sd, Class<?> iClass) {
+ String dataBindingName = (String)sd.get(Constants.WS_DATABINDING_PROP_KEY);
+ return (iClass.getAnnotation(WebService.class) != null || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName)) && !Constants.WS_DATA_BINDING_AEGIS.equals(dataBindingName);
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
+ }
+
+ private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
+ String frontEnd = (String)sd.get(Constants.WS_FRONTEND_PROP_KEY);
+ return (iClass.getAnnotation(WebService.class) != null || Constants.WS_FRONTEND_JAXWS.equals(frontEnd)) && !Constants.WS_FRONTEND_SIMPLE.equals(frontEnd);
+ }
+
}
Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=1418247&r1=1418246&r2=1418247&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java Fri Dec 7 10:14:30 2012
@@ -23,17 +23,27 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
+import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoServiceImpl;
+import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
+import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoServiceImpl;
import org.apache.cxf.dosgi.dsw.qos.IntentManager;
import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
import org.apache.cxf.dosgi.dsw.qos.IntentMap;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.Feature;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.transport.Destination;
import org.apache.cxf.ws.addressing.AttributedURIType;
@@ -105,7 +115,7 @@ public class PojoConfigurationTypeHandle
};
PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1, intentManager, dummyHttpServiceManager()) {
@Override
- ClientProxyFactoryBean createClientProxyFactoryBean(ServiceReference sRef, Class<?> iClass) {
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
return cpfb;
}
};
@@ -131,85 +141,6 @@ public class PojoConfigurationTypeHandle
c.verify();
}
-// public void testCreateProxyPopulatesDistributionProvider() {
-// BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-// EasyMock.replay(bc);
-// 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);
-//
-// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(bc);
-// PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc, handlerProps) {
-// @Override
-// ClientProxyFactoryBean createClientProxyFactoryBean(String frontend) {
-// return cpfb;
-// }
-//
-// @Override
-// String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-// List<AbstractFeature> features, AbstractEndpointFactory factory, Map sd) {
-// return new String[0];
-// }
-// };
-//
-// 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);
-//
-// assertEquals("Precondition failed", 0, dp.getRemoteServices().size());
-// p.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
-// assertEquals(1, dp.getRemoteServices().size());
-// assertSame(sr, dp.getRemoteServices().iterator().next());
-// }
-//
-// public void testCreateServerPopulatesDistributionProvider() {
-// BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
-// EasyMock.replay(dswContext);
-//
-// String myService = "Hi";
-// final ServerFactoryBean sfb = createMockServerFactoryBean();
-//
-// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
-// PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, dp, handlerProps) {
-// @Override
-// ServerFactoryBean createServerFactoryBean(String frontend) {
-// return sfb;
-// }
-//
-// @Override
-// String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-// List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceEndpointDescription sd) {
-// return new String []{"A", "B"};
-// }
-// };
-//
-// ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-// BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
-// ServiceEndpointDescription sd = TestUtils.mockServiceDescription("Foo");
-// EasyMock.replay(sr);
-// EasyMock.replay(callingContext);
-// EasyMock.replay(sd);
-//
-// 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("service.exported.configs", "org.apache.cxf.ws");
-// expected.put("org.apache.cxf.ws.address", "http://somehost:54321/java/lang/String");
-// expected.put("service.intents", "A B");
-// assertEquals(expected, dp.getExposedProperties(sr));
-// }
-//
public void testCreateServerWithAddressProprety() {
BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.replay(dswContext);
@@ -226,7 +157,7 @@ public class PojoConfigurationTypeHandle
};
PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager, dummyHttpServiceManager()) {
@Override
- ServerFactoryBean createServerFactoryBean(ServiceReference sRef, Class<?> iClass) {
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
return sfb;
}
};
@@ -302,8 +233,6 @@ public class PojoConfigurationTypeHandle
return server;
}
-
-
public void testCreateEndpointProps() {
BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
@@ -326,123 +255,60 @@ public class PojoConfigurationTypeHandle
assertEquals(Arrays.asList("my_intent", "your_intent"), Arrays.asList((Object []) props.get(RemoteConstants.SERVICE_INTENTS)));
assertEquals("0.0.0", props.get("endpoint.package.version.java.lang"));
}
-//
-// public void testServiceExposedAdminEvent() throws Exception {
-// EventAdmin ea = EasyMock.createMock(EventAdmin.class);
-// ea.postEvent((Event) EasyMock.anyObject());
-// EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-// public Object answer() throws Throwable {
-// Event e = (Event) EasyMock.getCurrentArguments()[0];
-// assertEquals("org/osgi/service/distribution/DistributionProvider/service/exposed", e.getTopic());
-// List<String> keys = Arrays.asList(e.getPropertyNames());
-// assertTrue(keys.contains(EventConstants.SERVICE));
-// assertNotNull(e.getProperty(EventConstants.SERVICE));
-// assertTrue(keys.contains(EventConstants.SERVICE_ID));
-// assertEquals(17L, e.getProperty(EventConstants.SERVICE_ID));
-// assertTrue(keys.contains(EventConstants.SERVICE_OBJECTCLASS));
-// assertEquals(Arrays.asList(String.class.getName()),
-// Arrays.asList((Object []) e.getProperty(EventConstants.SERVICE_OBJECTCLASS)));
-// return null;
-// }
-// });
-// EasyMock.replay(ea);
-//
-// BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
-// EasyMock.replay(dswContext);
-//
-// String myService = "Hi";
-// final ServerFactoryBean sfb = createMockServerFactoryBean();
-// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
-// dp.addEventAdmin(ea);
-//
-// PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, dp, handlerProps) {
-// @Override
-// ServerFactoryBean createServerFactoryBean(String frontend) {
-// return sfb;
-// }
-//
-// @Override
-// String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-// List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceEndpointDescription sd) {
-// return new String []{};
-// }
-// };
-//
-// final Map<String, Object> props = new HashMap<String, Object>();
-// props.put(org.osgi.framework.Constants.SERVICE_ID, 17L);
-// props.put(org.osgi.framework.Constants.OBJECTCLASS, new String [] {String.class.getName()});
-// props.put("boo", "baa");
-// ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-// EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
-// EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-// public Object answer() throws Throwable {
-// return props.get(EasyMock.getCurrentArguments()[0]);
-// }
-// }).anyTimes();
-// BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
-// ServiceEndpointDescription sd = TestUtils.mockServiceDescription("Foo");
-// EasyMock.replay(sr);
-// EasyMock.replay(callingContext);
-// EasyMock.replay(sd);
-//
-// p.createServer(sr, dswContext, callingContext, sd, String.class, myService);
-// EasyMock.verify(ea);
-// }
-//
-// public void testServiceUnsatisfiedAdminEvent() throws Exception {
-// EventAdmin ea = EasyMock.createMock(EventAdmin.class);
-// ea.postEvent((Event) EasyMock.anyObject());
-// EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-// public Object answer() throws Throwable {
-// Event e = (Event) EasyMock.getCurrentArguments()[0];
-// assertEquals("org/osgi/service/distribution/DistributionProvider/service/unsatisfied", e.getTopic());
-// return null;
-// }
-// });
-// EasyMock.replay(ea);
-//
-// BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
-// EasyMock.replay(dswContext);
-//
-// String myService = "Hi";
-// final ServerFactoryBean sfb = createMockServerFactoryBean();
-// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
-// dp.addEventAdmin(ea);
-//
-// PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, dp, handlerProps) {
-// @Override
-// ServerFactoryBean createServerFactoryBean(String frontend) {
-// return sfb;
-// }
-//
-// @Override
-// String[] applyIntents(BundleContext dswContext, BundleContext callingContext,
-// List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceEndpointDescription sd) {
-// throw new IntentUnsatifiedException("XYZ");
-// }
-// };
-//
-// final Map<String, Object> props = new HashMap<String, Object>();
-// ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-// EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
-// EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-// public Object answer() throws Throwable {
-// return props.get(EasyMock.getCurrentArguments()[0]);
-// }
-// }).anyTimes();
-// BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
-// ServiceEndpointDescription sd = TestUtils.mockServiceDescription("Foo");
-// EasyMock.replay(sr);
-// EasyMock.replay(callingContext);
-// EasyMock.replay(sd);
-//
-// try {
-// p.createServer(sr, dswContext, callingContext, sd, String.class, myService);
-// fail("Should have thrown an IntentUnsatifiedException");
-// } catch (IntentUnsatifiedException iue) {
-// // good
-// }
-// EasyMock.verify(ea);
-// }
+ public void testCreateJaxWsEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+ IntentManager intentManager = new DummyIntentManager();
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
+ Object serviceBean = new MyJaxWsEchoServiceImpl();
+ ServiceReference sref = c.createMock(ServiceReference.class);
+
+ Map<String, Object> sd = new HashMap<String, Object>();
+
+ c.replay();
+ ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MyJaxWsEchoService.class, serviceBean);
+ c.verify();
+
+ Server server = exportResult.getServer();
+ Endpoint ep = server.getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/", "MyJaxWsEchoServiceServiceSoapBinding"), bindingName);
+
+ }
+
+ public void testCreateSimpleEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+ IntentManager intentManager = new DummyIntentManager();
+ PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
+ Object serviceBean = new MySimpleEchoServiceImpl();
+ ServiceReference sref = c.createMock(ServiceReference.class);
+ Map<String, Object> sd = new HashMap<String, Object>();
+
+ c.replay();
+ ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MySimpleEchoService.class, serviceBean);
+ Server server = exportResult.getServer();
+ c.verify();
+
+ Endpoint ep = server.getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(EndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/", "MySimpleEchoServiceSoapBinding"), bindingName);
+ }
+
+ public static class DummyIntentManager implements IntentManager {
+
+ @Override
+ public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props) {
+ return new String[]{};
+ }
+
+ @Override
+ public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
+
+ }
+
+ }
}
Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java?rev=1418247&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java Fri Dec 7 10:14:30 2012
@@ -0,0 +1,26 @@
+/**
+ * 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.dsw.handlers.jaxws;
+
+import javax.jws.WebService;
+
+@WebService
+public interface MyJaxWsEchoService {
+ public String echo(String message);
+}
\ No newline at end of file
Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java?rev=1418247&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java Fri Dec 7 10:14:30 2012
@@ -0,0 +1,26 @@
+/**
+ * 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.dsw.handlers.jaxws;
+
+public class MyJaxWsEchoServiceImpl implements MyJaxWsEchoService {
+ @Override
+ public String echo(String message) {
+ return message;
+ }
+}
\ No newline at end of file
Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java?rev=1418247&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java Fri Dec 7 10:14:30 2012
@@ -0,0 +1,23 @@
+/**
+ * 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.dsw.handlers.simple;
+
+public interface MySimpleEchoService {
+ public String echo(String message);
+}
\ No newline at end of file
Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java?rev=1418247&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java Fri Dec 7 10:14:30 2012
@@ -0,0 +1,26 @@
+/**
+ * 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.dsw.handlers.simple;
+
+public class MySimpleEchoServiceImpl implements MySimpleEchoService {
+ @Override
+ public String echo(String message) {
+ return message;
+ }
+}
\ No newline at end of file
Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain