Author: davidb
Date: Tue Dec 22 13:56:28 2009
New Revision: 893169
URL: http://svn.apache.org/viewvc?rev=893169&view=rev
Log:
Applying patch rsa_testCasesAndFixes.patch for DOSGI-13 on behalf or Marc
Schaaf.
Added:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
(with props)
Removed:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.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/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.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/OsgiUtils.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=893169&r1=893168&r2=893169&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
Tue Dec 22 13:56:28 2009
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -591,4 +592,16 @@
return "0.0.0";
}
+
+ public static String getUUID(BundleContext bc) {
+ synchronized ("org.osgi.framework.uuid") {
+ String uuid = bc.getProperty("org.osgi.framework.uuid");
+ if (uuid == null) {
+ uuid = UUID.randomUUID().toString();
+ System.setProperty("org.osgi.framework.uuid", uuid);
+ }
+ return uuid;
+ }
+ }
+
}
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=893169&r1=893168&r2=893169&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
Tue Dec 22 13:56:28 2009
@@ -58,7 +58,7 @@
return null;
}
- LOG.info("Creating a " + sd.getInterfaces().toArray()[0] + " client,
endpoint address is " + address);
+ LOG.info("Creating a " + iClass.getName() + " client, endpoint address
is " + address);
ClassLoader oldClassLoader =
Thread.currentThread().getContextClassLoader();
try {
@@ -80,7 +80,6 @@
Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
Object proxy = getProxy(factory.create(), iClass);
- // MARC: FIXME !!!!
getDistributionProvider().addRemoteService(serviceReference);
return proxy;
} catch (Exception e) {
LOG.log(Level.WARNING, "proxy creation failed", e);
@@ -117,8 +116,8 @@
// FIXME: This key is not defined in the spec but is required by the
EndpointDescription !!!!!
endpointProps.put(RemoteConstants.ENDPOINT_ID, 123L);
- endpointProps.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, getUUID());
- endpointProps.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS,
Constants.WS_CONFIG_TYPE);
+ endpointProps.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
OsgiUtils.getUUID(getBundleContext()));
+ endpointProps.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS,
Constants.WS_CONFIG_TYPE);
endpointProps.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + sa[0],
OsgiUtils.getVersion(iClass, dswContext));
DataBinding databinding;
@@ -144,16 +143,11 @@
Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
Server server = factory.create();
- // MARC: FIXME !!!!
getDistributionProvider().addExposedService(serviceReference,
- // registerPublication(server, intents));
- // TODO: registerPublication(server, intents);
endpointProps.put(RemoteConstants.ENDPOINT_URI, address);
exportRegistration.setServer(server);
} catch (IntentUnsatifiedException iue) {
- // MARC: FIXME !!!!
getDistributionProvider().intentsUnsatisfied(serviceReference);
- // throw iue;
exportRegistration.setException(iue);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
@@ -177,25 +171,16 @@
}
- private String getUUID() {
- synchronized ("org.osgi.framework.uuid") {
- String uuid =
getBundleContext().getProperty("org.osgi.framework.uuid");
- if (uuid == null) {
- uuid = UUID.randomUUID().toString();
- System.setProperty("org.osgi.framework.uuid", uuid);
- }
- return uuid;
- }
- }
- @Override
- Map<String, String> registerPublication(Server server, String[] intents) {
- Map<String, String> publicationProperties =
super.registerPublication(server, intents);
- publicationProperties.put(Constants.WS_ADDRESS_PROPERTY,
server.getDestination().getAddress()
- .getAddress().getValue());
- return publicationProperties;
- }
+// @Override
+// Map<String, String> registerPublication(Server server, String[] intents)
{
+// Map<String, String> publicationProperties =
super.registerPublication(server, intents);
+// publicationProperties.put(Constants.WS_ADDRESS_PROPERTY,
server.getDestination().getAddress()
+// .getAddress().getValue());
+//
+// return publicationProperties;
+// }
protected String getPojoAddress(Map sd, Class<?> iClass) {
String address = OsgiUtils.getProperty(sd,
RemoteConstants.ENDPOINT_URI);
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java?rev=893169&r1=893168&r2=893169&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
Tue Dec 22 13:56:28 2009
@@ -105,7 +105,7 @@
private synchronized void instanceClosed(ImportRegistrationImpl i) {
childs.remove(i);
- if (childs.isEmpty() & !detatched) {
+ if (childs.isEmpty() && !detatched && closed) {
detatched = true;
LOG.fine("really closing ImportRegistartion now! ");
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=893169&r1=893168&r2=893169&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
Tue Dec 22 13:56:28 2009
@@ -36,20 +36,13 @@
import org.apache.cxf.dosgi.dsw.handlers.ClientServiceFactory;
import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.handlers.IntentUnsatifiedException;
-import org.apache.cxf.dosgi.dsw.hooks.ServiceHookUtils;
-import org.apache.cxf.endpoint.Server;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.ExportRegistration;
import org.osgi.service.remoteserviceadmin.ImportRegistration;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
public class RemoteServiceAdminCore implements RemoteServiceAdmin {
@@ -62,6 +55,11 @@
private EventProducer eventProducer;
+ private volatile boolean useMasterMap = true;
+ private volatile String defaultPort;
+ private volatile String defaultHost;
+
+
private static List<String> supportedConfigurationTypes = new
ArrayList<String>();
static {
supportedConfigurationTypes.add(Constants.WSDL_CONFIG_TYPE);
@@ -263,10 +261,7 @@
}
}
- private volatile boolean useMasterMap = true;
- // MARC: FIXME !!!!
- private volatile String defaultPort;
- private volatile String defaultHost;
+
private ConfigurationTypeHandler getHandler(List<String>
configurationTypes, Map serviceProperties,
Map<String, Object> props) {
@@ -306,16 +301,7 @@
return ir;
}
- // FIXME:
- List remoteConfigurationTypes = endpoint.getConfigurationTypes();
// not yet implemented
- {
- Object ecs_o =
endpoint.getProperties().get(RemoteConstants.SERVICE_EXPORTED_CONFIGS);
-
- if (ecs_o instanceof String) {
- remoteConfigurationTypes = new ArrayList(1);
- remoteConfigurationTypes.add((String)ecs_o);
- }
- }
+ List remoteConfigurationTypes = endpoint.getConfigurationTypes();
if (remoteConfigurationTypes == null) {
LOG.severe("the supplied endpoint has no configuration type");
@@ -332,7 +318,7 @@
if (usableConfigurationTypes.size() == 0) {
LOG
.severe("the supplied endpoint has no compatible
configuration type. Supported types are: "
- + supportedConfigurationTypes);
+ + supportedConfigurationTypes + " Types
needed by the endpoint: " +remoteConfigurationTypes);
return null;
}
@@ -360,6 +346,7 @@
proxifyMatchingInterface(matchingInterfaces.get(0), imReg,
handler, bctx);
importedServices.put(endpoint, imReg);
+ eventProducer.publishNotifcation(imReg);
return imReg;
} else {
return null;
@@ -368,7 +355,7 @@
}
- private void proxifyMatchingInterface(String interfaceName,
ImportRegistrationImpl imReg,
+ protected void proxifyMatchingInterface(String interfaceName,
ImportRegistrationImpl imReg,
ConfigurationTypeHandler handler,
BundleContext requestingContext) {
try {
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java?rev=893169&r1=893168&r2=893169&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
Tue Dec 22 13:56:28 2009
@@ -18,12 +18,16 @@
*/
package org.apache.cxf.dosgi.dsw.service;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.logging.Logger;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
public class Utils {
+ private static final Logger LOG = Logger.getLogger(Utils.class.getName());
+
public static String[] normalizeStringPlus(Object object) {
if (object instanceof String) {
@@ -36,12 +40,18 @@
if (object instanceof String[]) {
return (String[])object;
}
- // FIXME: This needs to be tested !!!!!
if (object instanceof Collection) {
Collection col = (Collection)object;
- if (col.toArray() instanceof String[]) {
- return (String[])col.toArray();
+ ArrayList<String> ar = new ArrayList<String>(col.size());
+ for (Object o : col) {
+ if (o instanceof String) {
+ String s = (String)o;
+ ar.add(s);
+ }else{
+ LOG.warning("stringPlus contained non string element in
list ! Element was skipped");
+ }
}
+ return ar.toArray(new String[ar.size()]);
}
return null;
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java?rev=893169&r1=893168&r2=893169&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
Tue Dec 22 13:56:28 2009
@@ -33,12 +33,18 @@
import org.apache.cxf.dosgi.dsw.decorator.ServiceDecorator;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
+import org.easymock.IMocksControl;
import org.jdom.Element;
import org.jdom.Namespace;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
public class OsgiUtilsTest extends TestCase {
@@ -337,4 +343,104 @@
public void testMultiValuePropertyNull() {
assertNull(OsgiUtils.getMultiValueProperty(null));
}
+
+
+ public void testGetUUID(){
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+
EasyMock.expect(bc.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn(null).atLeastOnce();
+ EasyMock.replay(bc);
+ String uuid = OsgiUtils.getUUID(bc);
+ assertNotNull(uuid);
+
+ assertEquals(System.getProperty("org.osgi.framework.uuid"),uuid );
+
+ EasyMock.verify(bc);
+ }
+
+
+
+ public void testGetVersion(){
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext bc = c.createMock(BundleContext.class);
+ ServiceReference sref = c.createMock(ServiceReference.class);
+ PackageAdmin pa = c.createMock(PackageAdmin.class);
+ Bundle b = c.createMock(Bundle.class);
+
+
EasyMock.expect(bc.getServiceReference(EasyMock.eq(PackageAdmin.class.getName()))).andReturn(sref);
+ EasyMock.expect(bc.getService(EasyMock.eq(sref))).andReturn(pa);
+
+ Class<?> iClass = CharSequence.class;
+
+ c.replay();
+ // version 0.0.0 because of missing bundle
+
+ assertEquals("0.0.0", OsgiUtils.getVersion(iClass, bc));
+
+ c.verify();
+ c.reset();
+ // version 1.2.3 ...
+
+
EasyMock.expect(bc.getServiceReference(EasyMock.eq(PackageAdmin.class.getName()))).andReturn(sref);
+ EasyMock.expect(bc.getService(EasyMock.eq(sref))).andReturn(pa);
+ EasyMock.expect(pa.getBundle(EasyMock.eq(iClass))).andReturn(b);
+
+ ExportedPackage[] exP = new ExportedPackage[] { new
MyExportedPackage(iClass.getPackage(),"1.2.3"), new
MyExportedPackage(String.class.getPackage(),"4.5.6") };
+
+
EasyMock.expect(pa.getExportedPackages(EasyMock.eq(b))).andReturn(exP).atLeastOnce();
+
+ c.replay();
+ assertEquals("1.2.3", OsgiUtils.getVersion(iClass, bc));
+ c.verify();
+ }
+
+
+ private static class MyExportedPackage implements ExportedPackage{
+
+ Package package1;
+ String version;
+
+ public MyExportedPackage(Package package1, String version) {
+ this.package1 = package1;
+ this.version = version;
+ }
+
+ public Bundle getExportingBundle() {
+ return null;
+ }
+
+ public Bundle[] getImportingBundles() {
+ return null;
+ }
+
+ public String getName() {
+ return package1.getName();
+ }
+
+ public String getSpecificationVersion() {
+ return null;
+ }
+
+ public Version getVersion() {
+ return new Version(version);
+ }
+
+ public boolean isRemovalPending() {
+ return false;
+ }
+
+ }
+
+
+ public void testGetProperty(){
+
+ Map<String, Object> p = new HashMap<String, Object>();
+ p.put(RemoteConstants.ENDPOINT_URI, "http://google.de");
+ p.put("notAString",new Object());
+
+ EndpointDescription ep = new EndpointDescription(p);
+
+ assertNull(OsgiUtils.getProperty(ep, "unkownProp"));
+
assertEquals(p.get(RemoteConstants.ENDPOINT_URI),OsgiUtils.getProperty(ep,
RemoteConstants.ENDPOINT_URI));
+ assertEquals(null, OsgiUtils.getProperty(ep, "notAString"));
+ }
}
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=893169&r1=893168&r2=893169&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
Tue Dec 22 13:56:28 2009
@@ -52,6 +52,7 @@
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventConstants;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
@@ -90,17 +91,78 @@
assertEquals("http://localhost:9000/java/lang/String",
handler.getPojoAddress(sd, String.class));
}
-// 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");
-// }
-//
+ 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");
+ }
+
+ // todo: add test for data bindings
+ public void testCreateProxy(){
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext bc1 = c.createMock(BundleContext.class);
+ BundleContext bc2 = c.createMock(BundleContext.class);
+
+ ServiceReference sref = c.createMock(ServiceReference.class);
+
+ final ClientProxyFactoryBean cpfb =
c.createMock(ClientProxyFactoryBean.class);
+ ReflectionServiceFactoryBean sf =
c.createMock(ReflectionServiceFactoryBean.class);
+ EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
+
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
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];
+ }
+ };
+
+ Map props = new HashMap();
+
+ props.put(RemoteConstants.ENDPOINT_URI, "http://google.de/");
+
+ EndpointDescription endpoint = new EndpointDescription(props);
+
+
+
cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_URI)));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ cpfb.setServiceClass(EasyMock.eq(CharSequence.class));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ c.replay();
+
+
+
+
+
+ Object proxy = p.createProxy(sref, bc1, bc2, CharSequence.class,
endpoint);
+
+ assertNotNull(proxy);
+
+ if (proxy instanceof CharSequence) {
+ CharSequence cs = (CharSequence)proxy;
+
+ }else{
+ assertTrue("Proxy is not of the requested type! ", false);
+ }
+
+
+
+ c.verify();
+
+ }
+
// public void testCreateProxyPopulatesDistributionProvider() {
// BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
// EasyMock.replay(bc);
@@ -112,7 +174,7 @@
// EasyMock.replay(cpfb);
//
// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(bc);
-// PojoConfigurationTypeHandler p = new
PojoConfigurationTypeHandler(bc, dp, handlerProps) {
+// PojoConfigurationTypeHandler p = new
PojoConfigurationTypeHandler(bc, handlerProps) {
// @Override
// ClientProxyFactoryBean createClientProxyFactoryBean(String
frontend) {
// return cpfb;
@@ -120,7 +182,7 @@
//
// @Override
// String[] applyIntents(BundleContext dswContext, BundleContext
callingContext,
-// List<AbstractFeature> features, AbstractEndpointFactory
factory, ServiceEndpointDescription sd) {
+// List<AbstractFeature> features, AbstractEndpointFactory
factory, Map sd) {
// return new String[0];
// }
// };
@@ -221,56 +283,56 @@
// assertEquals(expected, dp.getExposedProperties(sr));
// }
//
-// private ServerFactoryBean createMockServerFactoryBean() {
-// ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
-// EasyMock.replay(sf);
-//
-// final StringBuilder serverURI = new StringBuilder();
-//
-// ServerFactoryBean sfb =
EasyMock.createNiceMock(ServerFactoryBean.class);
-// Server server = createMockServer(sfb);
-//
-// EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
-// EasyMock.expect(sfb.create()).andReturn(server);
-// sfb.setAddress((String) EasyMock.anyObject());
-// EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-// public Object answer() throws Throwable {
-// serverURI.setLength(0);
-// serverURI.append(EasyMock.getCurrentArguments()[0]);
-// return null;
-// }
-// });
-// EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
-// public String answer() throws Throwable {
-// return serverURI.toString();
-// }
-// });
-// EasyMock.replay(sfb);
-// return sfb;
-// }
-//
-// private Server createMockServer(final ServerFactoryBean sfb) {
-// AttributedURIType addr =
EasyMock.createMock(AttributedURIType.class);
-// EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
-// public String answer() throws Throwable {
-// return sfb.getAddress();
-// }
-// });
-// EasyMock.replay(addr);
-//
-// EndpointReferenceType er =
EasyMock.createMock(EndpointReferenceType.class);
-// EasyMock.expect(er.getAddress()).andReturn(addr);
-// EasyMock.replay(er);
-//
-// Destination destination = EasyMock.createMock(Destination.class);
-// EasyMock.expect(destination.getAddress()).andReturn(er);
-// EasyMock.replay(destination);
-//
-// Server server = EasyMock.createNiceMock(Server.class);
-// EasyMock.expect(server.getDestination()).andReturn(destination);
-// EasyMock.replay(server);
-// return server;
-// }
+ private ServerFactoryBean createMockServerFactoryBean() {
+ ReflectionServiceFactoryBean sf =
EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
+ EasyMock.replay(sf);
+
+ final StringBuilder serverURI = new StringBuilder();
+
+ ServerFactoryBean sfb =
EasyMock.createNiceMock(ServerFactoryBean.class);
+ Server server = createMockServer(sfb);
+
+ EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
+ EasyMock.expect(sfb.create()).andReturn(server);
+ sfb.setAddress((String) EasyMock.anyObject());
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ serverURI.setLength(0);
+ serverURI.append(EasyMock.getCurrentArguments()[0]);
+ return null;
+ }
+ });
+ EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return serverURI.toString();
+ }
+ });
+ EasyMock.replay(sfb);
+ return sfb;
+ }
+
+ private Server createMockServer(final ServerFactoryBean sfb) {
+ AttributedURIType addr = EasyMock.createMock(AttributedURIType.class);
+ EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return sfb.getAddress();
+ }
+ });
+ EasyMock.replay(addr);
+
+ EndpointReferenceType er =
EasyMock.createMock(EndpointReferenceType.class);
+ EasyMock.expect(er.getAddress()).andReturn(addr);
+ EasyMock.replay(er);
+
+ Destination destination = EasyMock.createMock(Destination.class);
+ EasyMock.expect(destination.getAddress()).andReturn(er);
+ EasyMock.replay(destination);
+
+ Server server = EasyMock.createNiceMock(Server.class);
+ EasyMock.expect(server.getDestination()).andReturn(destination);
+ EasyMock.replay(server);
+ return server;
+ }
//
// public void testIntents() throws Exception {
// Map<String, Object> intents = new HashMap<String, Object>();
@@ -749,18 +811,18 @@
// }
// EasyMock.verify(ea);
// }
-//
-// private static class TestFeature extends AbstractFeature {
-// private final String name;
-//
-// private TestFeature(String n) {
-// name = n;
-// }
-//
-// @Override
-// public String toString() {
-// return name;
-// }
-// }
+
+ private static class TestFeature extends AbstractFeature {
+ private final String name;
+
+ private TestFeature(String n) {
+ name = n;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
}
Added:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java?rev=893169&view=auto
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
(added)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
Tue Dec 22 13:56:28 2009
@@ -0,0 +1,58 @@
+/**
+ * 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.service;
+
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
+
+import org.junit.Test;
+
+
+public class UtilsTest {
+
+ @Test
+ public void testNormalizeStringPlus(){
+
+ String s1 = "s1";
+ String s2 = "s2";
+ String s3 = "s3";
+
+ String[] sa = new String[] {s1,s2,s3};
+
+ Collection<Object> sl = new ArrayList<Object>(4);
+ sl.add(s1);
+ sl.add(s2);
+ sl.add(s3);
+ sl.add(new Object()); // must be skipped
+
+ assertEquals(null,Utils.normalizeStringPlus(new Object()));
+ assertEquals(new String[] {s1},Utils.normalizeStringPlus(s1));
+ assertEquals(sa,Utils.normalizeStringPlus(sa));
+ assertEquals(sa,Utils.normalizeStringPlus(sl));
+
+ }
+
+
+}
Propchange:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date