http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java new file mode 100644 index 0000000..64beeac --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java @@ -0,0 +1,75 @@ +/** + * 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; + +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +public class ServiceInvocationHandlerTest extends TestCase { + + private static final Map<String, Method> OBJECT_METHODS = new HashMap<String, Method>(); { + for (Method m : Object.class.getMethods()) { + OBJECT_METHODS.put(m.getName(), m); + } + } + + public void testInvoke() throws Throwable { + ServiceInvocationHandler sih = new ServiceInvocationHandler("hello", String.class); + Method m = String.class.getMethod("length", new Class[] {}); + assertEquals(5, sih.invoke(null, m, new Object[] {})); + } + + public void testInvokeObjectMethod() throws Throwable { + final List<String> called = new ArrayList<String>(); + ServiceInvocationHandler sih = new ServiceInvocationHandler("hi", String.class) { + public boolean equals(Object obj) { + called.add("equals"); + return super.equals(obj); + } + + public int hashCode() { + called.add("hashCode"); + return super.hashCode(); + } + + public String toString() { + called.add("toString"); + return "somestring"; + } + }; + + Object proxy = Proxy.newProxyInstance( + getClass().getClassLoader(), new Class[] {Runnable.class}, sih); + + assertEquals(true, + sih.invoke(null, OBJECT_METHODS.get("equals"), new Object[] {proxy})); + assertEquals(System.identityHashCode(sih), + sih.invoke(null, OBJECT_METHODS.get("hashCode"), new Object[] {})); + assertEquals("somestring", + sih.invoke(null, OBJECT_METHODS.get("toString"), new Object[] {})); + assertEquals(Arrays.asList("equals", "hashCode", "toString"), called); + } +}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java new file mode 100644 index 0000000..df90758 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java @@ -0,0 +1,67 @@ +/** + * 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; + +import junit.framework.TestCase; + +public class WsdlConfigurationTypeHandlerTest extends TestCase { + + public void testDUMMY() { + assertTrue(true); + } + +// private Map<String, Object> handlerProps; +// +// @Override +// protected void setUp() throws Exception { +// super.setUp(); +// +// handlerProps = new HashMap<String, Object>(); +// handlerProps.put(Constants.DEFAULT_HOST_CONFIG, "somehost"); +// handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321"); +// } +// +// public void testCreateProxyPopulatesDistributionProvider() { +// 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); +// +// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext); +// WsdlConfigurationTypeHandler w = new WsdlConfigurationTypeHandler(dswContext, 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().size()); +// w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd); +// assertEquals(1, dp.getRemoteServices().size()); +// assertSame(sr, dp.getRemoteServices().iterator().next()); +// +// } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java new file mode 100644 index 0000000..7814267 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java @@ -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 { + String echo(String message); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java new file mode 100644 index 0000000..699c9ae --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java @@ -0,0 +1,27 @@ +/** + * 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 http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java new file mode 100644 index 0000000..7d574ca --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java @@ -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 { + String echo(String message); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java new file mode 100644 index 0000000..19dda4b --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java @@ -0,0 +1,27 @@ +/** + * 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 http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java new file mode 100644 index 0000000..fde48d2 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java @@ -0,0 +1,341 @@ +/** + * 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.hooks; + +import org.junit.Assert; +import org.junit.Test; + +public class CxfFindListenerHookTest extends Assert { + + @Test + public void testDUMMY() throws Exception { + } + +// private IMocksControl control; +// +// @Before +// public void setUp() { +// control = EasyMock.createNiceControl(); +// } + + /* Todo this test doesn't apply at the moment since the ListenerHook doesn't + * have a serviceReferencesRequested() API (yet). + @Test + public void testSyncListenerHook() throws Exception { + Bundle bundle = control.createMock(Bundle.class); + bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"), + EasyMock.eq("*.xml"), EasyMock.anyBoolean()); + EasyMock.expectLastCall().andReturn(Collections.enumeration( + Arrays.asList(getClass().getResource("/OSGI-INF/remote-service/remote-services.xml")))); + Dictionary<String, String> bundleHeaders = new Hashtable<String, String>(); + bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, + "Test Bundle"); + bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, + "1.0.0"); + bundle.getHeaders(); + EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes(); + bundle.loadClass(TestService.class.getName()); + EasyMock.expectLastCall().andReturn(TestService.class).anyTimes(); + final BundleContext requestingContext = control.createMock(BundleContext.class); + requestingContext.getBundle(); + EasyMock.expectLastCall().andReturn(bundle).anyTimes(); + + BundleTestContext dswContext = new BundleTestContext(bundle); + dswContext.addServiceReference(TestService.class.getName(), + control.createMock(ServiceReference.class)); + control.replay(); + + CxfListenerHook hook = new CxfListenerHook(dswContext, null); + + // TODO : if the next call ends up being executed in a thread of its own then + // update the test accordingly, use Futures for ex + + hook.serviceReferencesRequested(requestingContext, + TestService.class.getName(), null, true); + + List<ServiceReference> registeredRefs = dswContext.getRegisteredReferences(); + assertNotNull(registeredRefs); + assertEquals(1, registeredRefs.size()); + } */ + +// @Test +// public void testTrackerPropertiesOnlyClassInFilterWithMatchingInterface() throws Exception { +// String filter = "(objectClass=" + TestService.class.getName() + ")"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.interfaces", +// TestService.class.getName(), +// asList(TestService.class.getName()), +// Collections.EMPTY_SET); +// } +// +// @Test +// public void testTrackerPropertiesGenericFilterWithMatchingInterface() throws Exception { +// String filter = "(&(objectClass=" + TestService.class.getName() +// + ")(colour=blue))"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.filters", +// replacePredicate(filter), +// asList(TestService.class.getName()), +// Collections.EMPTY_SET); +// } +// +// @Test +// public void testTrackerPropertiesOnlyClassInFilterWithMatchingFilter() throws Exception { +// String filter = "(objectClass=" + TestService.class.getName() + ")"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.interfaces", +// TestService.class.getName(), +// Collections.EMPTY_SET, +// asList(replacePredicate(filter))); +// } +// +// @Test +// public void testTrackerPropertiesGenericFilterWithMatchingFilter() throws Exception { +// String filter = "(&(objectClass=" + TestService.class.getName() +// + ")(colour=blue))"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.filters", +// replacePredicate(filter), +// Collections.EMPTY_SET, +// asList(replacePredicate(filter))); +// } +// +// @Test +// public void testTrackerPropertiesOnlyClassInFilterWithMatchingBoth() throws Exception { +// String filter = "(objectClass=" + TestService.class.getName() + ")"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.interfaces", +// TestService.class.getName(), +// asList(TestService.class.getName()), +// asList(replacePredicate(filter))); +// } +// +// @Test +// public void testTrackerPropertiesGenericFilterWithMatchingBoth() throws Exception { +// String filter = "(&(objectClass=" + TestService.class.getName() +// + ")(colour=blue))"; +// doTestTrackerPropertiesSet(filter, +// "osgi.remote.discovery.interest.filters", +// replacePredicate(filter), +// Collections.EMPTY_SET, +// asList(replacePredicate(filter))); +// } +// +// private void doTestTrackerPropertiesSet(final String filter, +// String propKey, +// String propValue, +// Collection matchingInterfaces, +// Collection matchingFilters) throws Exception { +// Bundle bundle = control.createMock(Bundle.class); +// Dictionary<String, String> bundleHeaders = new Hashtable<String, String>(); +// bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, +// "Test Bundle"); +// bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, +// "1.0.0"); +// bundle.getHeaders(); +// EasyMock.expectLastCall().andReturn(bundleHeaders).times(2); +// final String serviceClass = TestService.class.getName(); +// bundle.loadClass(serviceClass); +// EasyMock.expectLastCall().andReturn(TestService.class).times(2); +// final BundleContext requestingContext = control.createMock(BundleContext.class); +// +// BundleTestContext dswContext = new BundleTestContext(bundle); +// ServiceRegistration serviceRegistration = control.createMock(ServiceRegistration.class); +// dswContext.addServiceRegistration(serviceClass, serviceRegistration); +// serviceRegistration.unregister(); +// EasyMock.expectLastCall().times(1); +// ServiceReference serviceReference = control.createMock(ServiceReference.class); +// dswContext.addServiceReference(serviceClass, serviceReference); +// +// final String trackerClass = DiscoveredServiceTracker.class.getName(); +// ServiceRegistration trackerRegistration = control.createMock(ServiceRegistration.class); +// dswContext.addServiceRegistration(trackerClass, trackerRegistration); +// ServiceReference trackerReference = control.createMock(ServiceReference.class); +// dswContext.addServiceReference(trackerClass, trackerReference); +// +// List property = asList(propValue); +// Dictionary properties = new Hashtable(); +// properties.put(propKey, property); +// trackerRegistration.setProperties(properties); +// EasyMock.expectLastCall(); +// +// if (matchingInterfaces.size() == 0 && matchingFilters.size() > 0) { +// Iterator filters = matchingFilters.iterator(); +// while (filters.hasNext()) { +// Filter f = control.createMock(Filter.class); +// dswContext.addFilter((String)filters.next(), f); +// f.match(EasyMock.isA(Dictionary.class)); +// EasyMock.expectLastCall().andReturn(true); +// } +// } +// +// control.replay(); +// +// CxfFindListenerHook hook = new CxfFindListenerHook(dswContext, null); +// +// ListenerHook.ListenerInfo info = new ListenerHook.ListenerInfo() { +// public BundleContext getBundleContext() { +// return requestingContext; +// } +// +// public String getFilter() { +// return filter; +// } +// +// public boolean isRemoved() { +// return false; +// } +// }; +// hook.added(Collections.singleton(info)); +// +// DiscoveredServiceTracker tracker = (DiscoveredServiceTracker) +// dswContext.getService(trackerReference); +// assertNotNull(tracker); +// +// Collection interfaces = asList(serviceClass); +// +// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "1234"); +// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "5678"); +// notifyAvailable(tracker, matchingInterfaces, matchingFilters, "1234"); +// +// notifyUnAvailable(tracker, "1234"); +// notifyUnAvailable(tracker, "5678"); +// +// notifyAvailable(tracker, matchingInterfaces, matchingFilters , "1234"); +// +// control.verify(); +// +// Map<String, ServiceReference> registeredRefs = dswContext.getRegisteredReferences(); +// assertNotNull(registeredRefs); +// assertEquals(2, registeredRefs.size()); +// assertNotNull(registeredRefs.get(serviceClass)); +// assertSame(serviceReference, registeredRefs.get(serviceClass)); +// +// Map<String, ServiceRegistration> registeredRegs = dswContext.getRegisteredRegistrations(); +// assertNotNull(registeredRegs); +// assertEquals(2, registeredRegs.size()); +// assertNotNull(registeredRegs.get(trackerClass)); +// assertSame(trackerRegistration, registeredRegs.get(trackerClass)); +// +// List<Object> registeredServices = dswContext.getRegisteredServices(); +// assertNotNull(registeredServices); +// assertEquals(2, registeredServices.size()); +// } +// +// @Test +// public void testConstructorAndGetters() { +// BundleContext bc = control.createMock(BundleContext.class); +// CxfRemoteServiceAdmin dp = control.createMock(CxfRemoteServiceAdmin.class); +// control.replay(); +// +// CxfFindListenerHook clh = new CxfFindListenerHook(bc, dp); +// assertSame(bc, clh.getContext()); +// assertSame(dp, clh.getDistributionProvider()); +// } +// +// @Test +// public void testFindHook() { +// BundleContext bc = EasyMock.createNiceMock(BundleContext.class); +// +// final List<String> lookupCalls = new ArrayList<String>(); +// CxfFindListenerHook fh = new CxfFindListenerHook(bc, null) { +// @Override +// protected synchronized void lookupDiscoveryService( +// String interfaceName, String filterValue) { +// lookupCalls.add(interfaceName); +// lookupCalls.add(filterValue); +// } +// }; +// +// String clazz = "my.app.Class"; +// String filter = "&(A=B)(C=D)"; +// fh.find(null, clazz, filter, true, null); +// +// assertEquals(Arrays.asList(clazz, filter), lookupCalls); +// } +// +// private void notifyAvailable(DiscoveredServiceTracker tracker, +// Collection interfaces, +// Collection filters, +// String endpointId) { +// Map<String, Object> props = new Hashtable<String, Object>(); +// props.put("osgi.remote.interfaces", "*"); +// props.put("osgi.remote.endpoint.id", endpointId); +// tracker.serviceChanged(new Notification(AVAILABLE, +// TestService.class.getName(), +// interfaces, +// filters, +// props)); +// } +// +// private void notifyUnAvailable(DiscoveredServiceTracker tracker, +// String endpointId) { +// Map<String, Object> props = new Hashtable<String, Object>(); +// props.put("osgi.remote.endpoint.id", endpointId); +// tracker.serviceChanged(new Notification(UNAVAILABLE, +// TestService.class.getName(), +// Collections.EMPTY_SET, +// Collections.EMPTY_SET, +// props)); +// } +// +// private List<String> asList(String s) { +// List l = new ArrayList<String>(); +// l.add(s); +// return l; +// } +// +// private String replacePredicate(String filter) { +// return filter.replace("objectClass", ServicePublication.SERVICE_INTERFACE_NAME); +// } +// +// private class Notification implements DiscoveredServiceNotification { +// private int type; +// private ServiceEndpointDescription sed; +// private Collection interfaces; +// private Collection filters; +// +// Notification(int type, +// String interfaceName, +// Collection interfaces, +// Collection filters, +// Map<String, Object> props) { +// this.type = type; +// this.sed = new ServiceEndpointDescriptionImpl(interfaceName, props); +// this.interfaces = interfaces; +// this.filters = filters; +// } +// +// public int getType() { +// return type; +// } +// +// public ServiceEndpointDescription getServiceEndpointDescription() { +// return sed; +// } +// +// public Collection getInterfaces() { +// return interfaces; +// } +// +// public Collection getFilters() { +// return filters; +// } +// } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java new file mode 100644 index 0000000..40b40c5 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java @@ -0,0 +1,299 @@ +/** + * 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.hooks; + +import org.junit.Assert; +import org.junit.Test; + +public class CxfPublishHookTest extends Assert { + + @Test + public void testDUMMY() throws Exception { + } + + // + // private IMocksControl control; + // + // @Before + // public void setUp() { + // control = EasyMock.createNiceControl(); + // } + // + // @Test + // public void testPublishSingleInterface() throws Exception { + // String[] serviceNames = new String[]{TestService.class.getName()}; + // String[] addresses = new String[]{"http://localhost:9000/hello"}; + // doTestPublishHook("remote-services.xml", serviceNames, addresses); + // } + // + // @Test + // public void testPublishSingleInterfaceAltFormat() throws Exception { + // String[] serviceNames = new String[]{TestService.class.getName()}; + // String[] addresses = new String[]{"http://localhost:9000/hello"}; + // doTestPublishHook("alt-remote-services.xml", serviceNames, addresses); + // } + // + // @Test + // public void testPublishMultiInterface() throws Exception { + // String[] serviceNames = new String[]{TestService.class.getName(), + // AdditionalInterface.class.getName()}; + // String[] addresses = new String[]{"http://localhost:9001/hello", + // "http://localhost:9002/hello"}; + // doTestPublishHook("multi-services.xml", serviceNames, addresses); + // } + // + // @SuppressWarnings("unchecked") + // private void doTestPublishHook(String remoteServices, + // String[] serviceNames, + // String[] addresses) throws Exception { + // + // Bundle bundle = control.createMock(Bundle.class); + // bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"), + // EasyMock.eq("*.xml"), EasyMock.anyBoolean()); + // EasyMock.expectLastCall().andReturn(Collections.enumeration( + // Arrays.asList(getClass().getResource("/OSGI-INF/remote-service/" + remoteServices)))); + // Dictionary<String, String> bundleHeaders = new Hashtable<String, String>(); + // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, + // "Test Bundle"); + // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, + // "1.0.0"); + // bundle.getHeaders(); + // EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes(); + // BundleContext requestingContext = control.createMock(BundleContext.class); + // bundle.getBundleContext(); + // EasyMock.expectLastCall().andReturn(requestingContext).anyTimes(); + // + // TestService serviceObject = new TestServiceImpl(); + // Dictionary serviceProps = new Hashtable(); + // + // ServiceReference sref = control.createMock(ServiceReference.class); + // sref.getBundle(); + // EasyMock.expectLastCall().andReturn(bundle).anyTimes(); + // sref.getProperty(Constants.OBJECTCLASS); + // EasyMock.expectLastCall().andReturn(serviceNames).anyTimes(); + // sref.getPropertyKeys(); + // EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes(); + // + // BundleTestContext dswContext = new BundleTestContext(bundle); + // + // ServiceRegistration[] serviceRegistrations = + // new ServiceRegistration[serviceNames.length]; + // + // for (int i = 0; i < serviceNames.length ; i++) { + // serviceRegistrations[i] = + // control.createMock(ServiceRegistration.class); + // dswContext.addServiceRegistration(serviceNames[i], + // serviceRegistrations[i]); + // dswContext.addServiceReference(serviceNames[i], sref); + // } + // dswContext.registerService(serviceNames, serviceObject, serviceProps); + // + // Server server = control.createMock(Server.class); + // + // String publicationClass = ServicePublication.class.getName(); + // ServiceRegistration publicationRegistration = + // control.createMock(ServiceRegistration.class); + // publicationRegistration.unregister(); + // EasyMock.expectLastCall().times(serviceNames.length); + // dswContext.addServiceRegistration(publicationClass, publicationRegistration); + // ServiceReference publicationReference = + // control.createMock(ServiceReference.class); + // dswContext.addServiceReference(publicationClass, publicationReference); + // control.replay(); + // + // TestPublishHook hook = new TestPublishHook(dswContext, + // serviceObject, + // server); + // hook.publishEndpoint(sref); + // hook.verify(); + // + // assertEquals(1, hook.getEndpoints().size()); + // List<EndpointInfo> list = hook.getEndpoints().get(sref); + // assertNotNull(list); + // assertEquals(serviceNames.length, list.size()); + // for (int i = 0; i < serviceNames.length; i++) { + // assertNotNull(list.get(i)); + // ServiceEndpointDescription sd = list.get(i).getServiceDescription(); + // assertNotNull(sd); + // assertNotNull(sd.getProvidedInterfaces()); + // assertEquals(1, sd.getProvidedInterfaces().size()); + // Collection names = sd.getProvidedInterfaces(); + // assertEquals(1, names.size()); + // assertEquals(serviceNames[i], names.toArray()[0]); + // String excludeProp = "osgi.remote.interfaces"; + // assertNull(sd.getProperties().get(excludeProp)); + // String addrProp = + // org.apache.cxf.dosgi.dsw.Constants.WS_ADDRESS_PROPERTY_OLD; + // assertEquals(addresses[i], sd.getProperties().get(addrProp)); + // } + // + // Map<String, ServiceRegistration> registeredRegs = + // dswContext.getRegisteredRegistrations(); + // assertNotNull(registeredRegs); + // assertEquals(serviceNames.length + 1, registeredRegs.size()); + // assertNotNull(registeredRegs.get(publicationClass)); + // assertSame(publicationRegistration, registeredRegs.get(publicationClass)); + // + // Map<String, List<Dictionary>> registeredProps = + // dswContext.getRegisteredProperties(); + // assertNotNull(registeredProps); + // assertEquals(serviceNames.length + 1, registeredProps.size()); + // assertNotNull(registeredProps.get(publicationClass)); + // List<Dictionary> propsList = registeredProps.get(publicationClass); + // assertEquals(serviceNames.length, propsList.size()); + // for (Dictionary props : propsList) { + // Collection interfaces = + // (Collection)props.get(SERVICE_INTERFACE_NAME); + // assertNotNull(interfaces); + // assertTrue(interfaces.contains(TestService.class.getName()) + // || interfaces.contains(AdditionalInterface.class.getName())); + // } + // + // hook.removeEndpoints(); + // + // control.verify(); + // } + // + // @SuppressWarnings("unchecked") + // @Test + // public void testPublishMultipleTimes() { + // Bundle bundle = control.createMock(Bundle.class); + // bundle.findEntries(EasyMock.eq("OSGI-INF/remote-service"), + // EasyMock.eq("*.xml"), EasyMock.anyBoolean()); + // EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + // public Object answer() throws Throwable { + // return Collections.enumeration(Arrays.asList( + // getClass().getResource("/OSGI-INF/remote-service/remote-services.xml"))); + // } + // }).anyTimes(); + // Dictionary<String, String> bundleHeaders = new Hashtable<String, String>(); + // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, + // "org.apache.cxf.example.bundle"); + // bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_VERSION, + // "1.0.0"); + // bundle.getHeaders(); + // EasyMock.expectLastCall().andReturn(bundleHeaders).anyTimes(); + // BundleContext requestingContext = control.createMock(BundleContext.class); + // bundle.getBundleContext(); + // EasyMock.expectLastCall().andReturn(requestingContext).anyTimes(); + // + // TestService serviceObject = new TestServiceImpl(); + // Dictionary serviceProps = new Hashtable(); + // + // ServiceReference sref = control.createMock(ServiceReference.class); + // sref.getBundle(); + // EasyMock.expectLastCall().andReturn(bundle).anyTimes(); + // sref.getProperty(Constants.OBJECTCLASS); + // String[] serviceNames = {TestService.class.getName()}; + // EasyMock.expectLastCall().andReturn(serviceNames).anyTimes(); + // sref.getPropertyKeys(); + // EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes(); + // + // BundleTestContext dswContext = new BundleTestContext(bundle); + // ServiceRegistration[] serviceRegistrations = + // new ServiceRegistration[serviceNames.length]; + // for (int i = 0; i < serviceNames.length ; i++) { + // serviceRegistrations[i] = + // control.createMock(ServiceRegistration.class); + // dswContext.addServiceRegistration(serviceNames[i], + // serviceRegistrations[i]); + // dswContext.addServiceReference(serviceNames[i], sref); + // } + // dswContext.registerService(serviceNames, serviceObject, serviceProps); + // + // final Server server = control.createMock(Server.class); + // control.replay(); + // + // CxfPublishHook hook = new CxfPublishHook(dswContext, null) { + // @Override + // Server createServer(ServiceReference sref, ServiceEndpointDescription sd) { + // return server; + // } + // }; + // assertNull("Precondition not met", hook.getEndpoints().get(sref)); + // hook.publishEndpoint(sref); + // assertEquals(1, hook.getEndpoints().get(sref).size()); + // + // hook.endpoints.put(sref, new ArrayList<EndpointInfo>()); + // assertEquals("Precondition failed", 0, hook.getEndpoints().get(sref).size()); + // hook.publishEndpoint(sref); + // assertEquals(0, hook.getEndpoints().get(sref).size()); + // + // control.verify(); + // } + // + // private static class TestPublishHook extends CxfPublishHook { + // + // private boolean called; + // private TestService serviceObject; + // private Server server; + // + // public TestPublishHook(BundleContext bc, TestService serviceObject, + // Server s) { + // super(bc, null); + // this.serviceObject = serviceObject; + // this.server = s; + // } + // + // @Override + // protected ConfigurationTypeHandler getHandler(ServiceEndpointDescription sd, + // Map<String, Object> props) { + // return new ConfigurationTypeHandler() { + // public String getType() { + // return "test"; + // } + // + // public Object createProxy(ServiceReference sr, + // BundleContext dswContext, BundleContext callingContext, + // Class<?> iClass, ServiceEndpointDescription sd) { + // throw new UnsupportedOperationException(); + // } + // + // public Server createServer(ServiceReference sr, + // BundleContext dswContext, BundleContext callingContext, + // ServiceEndpointDescription sd, Class<?> iClass, Object serviceBean) { + // Assert.assertSame(serviceBean, serviceObject); + // TestPublishHook.this.setCalled(); + // Map props = sd.getProperties(); + // String address = (String)props.get(WS_ADDRESS_PROPERTY); + // if (address != null) { + // props.put(ENDPOINT_LOCATION, address); + // } + // return server; + // } + // + // }; + // } + // + // public void setCalled() { + // called = true; + // } + // + // public void verify() { + // Assert.assertTrue(called); + // } + // } + // + // public interface AdditionalInterface { + // } + // + // private static class TestServiceImpl implements TestService, AdditionalInterface { + // + // } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java new file mode 100644 index 0000000..c004702 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java @@ -0,0 +1,116 @@ +/** + * 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.hooks; + +import junit.framework.TestCase; + +public class ServiceHookUtilsTest extends TestCase { + + public void testDUMMY() { + assertTrue(true); + } + +/* + public void testCreateServer() { + IMocksControl control = EasyMock.createNiceControl(); + + Server srvr = control.createMock(Server.class); + ServiceReference serviceReference = control.createMock(ServiceReference.class); + BundleContext dswContext = control.createMock(BundleContext.class); + BundleContext callingContext = control.createMock(BundleContext.class); + ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("java.lang.String"); + Object service = "hi"; + + ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class); + handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service); + EasyMock.expectLastCall().andReturn(srvr); + control.replay(); + + assertSame(srvr, + ServiceHookUtils.createServer(handler, serviceReference, dswContext, callingContext, sd, service)); + } + + public void testNoServerWhenNoInterfaceSpecified() { + IMocksControl control = EasyMock.createNiceControl(); + + Server srvr = control.createMock(Server.class); + ServiceReference serviceReference = control.createMock(ServiceReference.class); + BundleContext dswContext = control.createMock(BundleContext.class); + BundleContext callingContext = control.createMock(BundleContext.class); + ServiceEndpointDescription sd = mockServiceDescription(control, "Foo"); + Object service = "hi"; + + ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class); + handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service); + EasyMock.expectLastCall().andReturn(srvr); + control.replay(); + + assertNull(ServiceHookUtils.createServer(handler, serviceReference, dswContext, + callingContext, sd, service)); + } + + public void testPublish() throws Exception { + Map<String, Object> props = new HashMap<String, Object>(); + props.put("foo", "bar"); + props.put(ServicePublication.ENDPOINT_LOCATION, "http:localhost/xyz"); + ServiceEndpointDescriptionImpl sed = new ServiceEndpointDescriptionImpl(String.class.getName(), props); + assertEquals(new URI("http:localhost/xyz"), sed.getLocation()); + + final Dictionary<String, Object> expectedProps = new Hashtable<String, Object>(); + expectedProps.put(ServicePublication.SERVICE_PROPERTIES, props); + expectedProps.put(ServicePublication.SERVICE_INTERFACE_NAME, Collections.singleton(String.class.getName())); + expectedProps.put(ServicePublication.ENDPOINT_LOCATION, new URI("http:localhost/xyz")); + + BundleContext bc = EasyMock.createMock(BundleContext.class); + EasyMock.expect(bc.registerService( + EasyMock.eq(ServicePublication.class.getName()), + EasyMock.anyObject(), + (Dictionary<?, ?>) EasyMock.anyObject())) + .andAnswer(new IAnswer<ServiceRegistration>() { + public ServiceRegistration answer() throws Throwable { + assertTrue(EasyMock.getCurrentArguments()[1] instanceof ServicePublication); + Dictionary<?, ?> actualProps = + (Dictionary<?, ?>) EasyMock.getCurrentArguments()[2]; + UUID uuid = UUID.fromString(actualProps.get(ServicePublication.ENDPOINT_SERVICE_ID) + .toString()); + expectedProps.put(ServicePublication.ENDPOINT_SERVICE_ID, uuid.toString()); + assertEquals(expectedProps, actualProps); + return EasyMock.createMock(ServiceRegistration.class); + } + }); + EasyMock.replay(bc); + + ServiceHookUtils.publish(bc, null, sed); + EasyMock.verify(bc); + } + + private ServiceEndpointDescription mockServiceDescription(IMocksControl control, + String... interfaceNames) { + List<String> iList = new ArrayList<String>(); + for (String iName : interfaceNames) { + iList.add(iName); + } + ServiceEndpointDescription sd = control.createMock(ServiceEndpointDescription.class); + sd.getProvidedInterfaces(); + EasyMock.expectLastCall().andReturn(iList); + return sd; + } +*/ +} + http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java new file mode 100644 index 0000000..07b5088 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/TestService.java @@ -0,0 +1,22 @@ +/** + * 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.hooks; + +public interface TestService { +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java new file mode 100644 index 0000000..d90136c --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java @@ -0,0 +1,278 @@ +/** + * 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.qos; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.aries.rsa.spi.IntentUnsatisfiedException; +import org.apache.cxf.binding.BindingConfiguration; +import org.apache.cxf.endpoint.AbstractEndpointFactory; +import org.apache.cxf.feature.AbstractFeature; +import org.apache.cxf.feature.Feature; +import org.easymock.EasyMock; +import org.easymock.IMocksControl; +import org.junit.Assert; +import org.junit.Test; + +public class IntentManagerImplTest extends Assert { + + @Test + public void testIntents() throws Exception { + Map<String, Object> intents = new HashMap<String, Object>(); + intents.put("A", new TestFeature("A")); + intents.put("SOAP", new TestFeature("SOAP")); + final IntentMap intentMap = new IntentMap(intents); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + IntentManager intentManager = new IntentManagerImpl(intentMap, 10000); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "A"); + + List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props)); + assertEquals(Arrays.asList("A", "SOAP"), effectiveIntents); + } + + @Test + public void testMultiIntents() { + final IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create()); + intentMap.put("confidentiality.message", new TestFeature("confidentiality.message")); + intentMap.put("transactionality", new TestFeature("transactionality")); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "transactionality confidentiality.message"); + + List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props)); + assertTrue(effectiveIntents.contains("transactionality")); + assertTrue(effectiveIntents.contains("confidentiality.message")); + } + + @Test + public void testFailedIntent() { + Map<String, Object> intents = new HashMap<String, Object>(); + intents.put("A", new TestFeature("A")); + final IntentMap intentMap = new IntentMap(intents); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "A B"); + // ServiceEndpointDescription sd = + // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props); + + try { + intentManager.applyIntents(features, factory, props); + Assert.fail("applyIntents() should have thrown an exception as there was an unsatisfiable intent"); + } catch (IntentUnsatisfiedException iue) { + assertEquals("B", iue.getIntent()); + } + } + + @Test + public void testInferIntents() { + Map<String, Object> intents = new HashMap<String, Object>(); + intents.put("SOAP", new TestFeature("SOAP")); + intents.put("Prov", "PROVIDED"); + AbstractFeature feat1 = new TestFeature("feat1"); + intents.put("A", feat1); + intents.put("A_alt", feat1); + intents.put("B", new TestFeature("B")); + final IntentMap intentMap = new IntentMap(intents); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "A"); + // ServiceEndpointDescription sd = + // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props); + + List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props)); + assertEquals(4, effectiveIntents.size()); + assertTrue(effectiveIntents.contains("Prov")); + assertTrue(effectiveIntents.contains("A")); + assertTrue(effectiveIntents.contains("A_alt")); + } + + @Test + public void testDefaultBindingIntent() { + IMocksControl control = EasyMock.createNiceControl(); + + Map<String, Object> intents = new HashMap<String, Object>(); + BindingConfiguration feat1 = control.createMock(BindingConfiguration.class); + intents.put("A", new AbstractFeature() { + }); + intents.put("SOAP", feat1); + intents.put("SOAP.1_1", feat1); + intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class)); + final IntentMap intentMap = new IntentMap(intents); + + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "A"); + // ServiceEndpointDescription sd = + // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props); + + List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props)); + assertEquals(3, effectiveIntents.size()); + assertTrue(effectiveIntents.contains("A")); + assertTrue(effectiveIntents.contains("SOAP")); + assertTrue(effectiveIntents.contains("SOAP.1_1")); + } + + @Test + public void testExplicitBindingIntent() { + IMocksControl control = EasyMock.createNiceControl(); + + Map<String, Object> intents = new HashMap<String, Object>(); + BindingConfiguration feat1 = control.createMock(BindingConfiguration.class); + intents.put("A", new AbstractFeature() { + }); + intents.put("SOAP", feat1); + intents.put("SOAP.1_1", feat1); + intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class)); + final IntentMap intentMap = new IntentMap(intents); + + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "A SOAP.1_2"); + // ServiceEndpointDescription sd = + // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props); + + List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props)); + assertEquals(2, effectiveIntents.size()); + assertTrue(effectiveIntents.contains("A")); + assertTrue(effectiveIntents.contains("SOAP.1_2")); + } + + public void testInheritMasterIntentMapDefault() { + List<String> features = runTestInheritMasterIntentMap("A B"); + + assertEquals(2, features.size()); + assertTrue(features.contains("appFeatureA")); + assertTrue(features.contains("masterFeatureB")); + } + + public void testInheritMasterIntentMap() { + List<String> features = runTestInheritMasterIntentMap("A B"); + + assertEquals(2, features.size()); + assertTrue(features.contains("appFeatureA")); + assertTrue(features.contains("masterFeatureB")); + } + + private List<String> runTestInheritMasterIntentMap(String requestedIntents) { + Map<String, Object> masterIntents = new HashMap<String, Object>(); + masterIntents.put("A", new TestFeature("masterFeatureA")); + masterIntents.put("B", new TestFeature("masterFeatureB")); + final IntentMap intentMap = new IntentMap(masterIntents); + intentMap.put("A", new TestFeature("appFeatureA")); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", requestedIntents); + + IntentManagerImpl intentManager = new IntentManagerImpl(intentMap); + intentManager.applyIntents(features, factory, props); + + List<String> featureNames = new ArrayList<String>(); + for (Feature f : features) { + featureNames.add(f.toString()); + } + return featureNames; + } + + @Test + public void testProvidedIntents() { + Map<String, Object> masterIntents = new HashMap<String, Object>(); + masterIntents.put("SOAP", "SOAP"); + masterIntents.put("A", "Provided"); + masterIntents.put("B", "PROVIDED"); + final IntentMap intentMap = new IntentMap(masterIntents); + + IMocksControl control = EasyMock.createNiceControl(); + List<Feature> features = new ArrayList<Feature>(); + AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class); + control.replay(); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("osgi.remote.requires.intents", "B A"); + + IntentManager intentManager = new IntentManagerImpl(intentMap); + + Set<String> effectiveIntents = new HashSet<String>(Arrays.asList(intentManager.applyIntents(features, + factory, + props))); + Set<String> expectedIntents = new HashSet<String>(Arrays.asList(new String[] {"A", "B", "SOAP"})); + assertEquals(expectedIntents, effectiveIntents); + } + + private static final class TestFeature extends AbstractFeature { + + private final String name; + + private TestFeature(String n) { + name = n; + } + + @Override + public String toString() { + return name; + } + } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentMapTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentMapTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentMapTest.java new file mode 100644 index 0000000..748da85 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentMapTest.java @@ -0,0 +1,41 @@ +/** + * 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.qos; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + +public class IntentMapTest { + + @Test + public void inheritanceTest() { + Map<String, Object> defaultMap = new HashMap<String, Object>(); + defaultMap.put("key1", "defaultValue"); + IntentMap intentMap = new IntentMap(defaultMap); + Assert.assertEquals("defaultValue", intentMap.get("key1")); + intentMap.put("key1", "overridden"); + Assert.assertEquals("overridden", intentMap.get("key1")); + Object curValue = intentMap.remove("key1"); + Assert.assertEquals("overridden", curValue); + Assert.assertEquals("defaultValue", intentMap.get("key1")); + } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java new file mode 100644 index 0000000..b68cf61 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentTrackerTest.java @@ -0,0 +1,80 @@ +/** + * 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.qos; + +import org.apache.cxf.dosgi.dsw.Constants; +import org.apache.cxf.feature.AbstractFeature; +import org.easymock.Capture; +import org.easymock.EasyMock; +import org.easymock.IMocksControl; +import org.junit.Assert; +import org.junit.Test; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; + +import static org.easymock.EasyMock.expect; + +public class IntentTrackerTest { + + private static final String MY_INTENT_NAME = "myIntent"; + + @Test + public void testIntentAsService() throws InvalidSyntaxException { + IMocksControl c = EasyMock.createControl(); + BundleContext bc = c.createMock(BundleContext.class); + Filter filter = c.createMock(Filter.class); + expect(bc.createFilter(EasyMock.<String>anyObject())).andReturn(filter); + final Capture<ServiceListener> capturedListener = EasyMock.newCapture(); + bc.addServiceListener(EasyMock.capture(capturedListener), EasyMock.<String>anyObject()); + EasyMock.expectLastCall().atLeastOnce(); + expect(bc.getServiceReferences(EasyMock.<String>anyObject(), + EasyMock.<String>anyObject())).andReturn(new ServiceReference[]{}); + IntentMap intentMap = new IntentMap(); + + // Create a custom intent + @SuppressWarnings("unchecked") + ServiceReference<AbstractFeature> reference = c.createMock(ServiceReference.class); + expect(reference.getProperty(Constants.INTENT_NAME_PROP)).andReturn(MY_INTENT_NAME); + AbstractFeature testIntent = new AbstractFeature() { + }; + expect(bc.getService(reference)).andReturn(testIntent).atLeastOnce(); + + c.replay(); + + IntentTracker tracker = new IntentTracker(bc, intentMap); + tracker.open(); + + Assert.assertFalse("IntentMap should not contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME)); + ServiceListener listener = capturedListener.getValue(); + + // Simulate adding custom intent service + ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, reference); + listener.serviceChanged(event); + + // our custom intent should now be available + Assert.assertTrue("IntentMap should contain " + MY_INTENT_NAME, intentMap.containsKey(MY_INTENT_NAME)); + Assert.assertEquals(testIntent, intentMap.get(MY_INTENT_NAME)); + + c.verify(); + } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java new file mode 100644 index 0000000..f7fe844 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java @@ -0,0 +1,70 @@ +/** + * 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.qos; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.cxf.dosgi.dsw.Constants; +import org.junit.Assert; +import org.junit.Test; +import org.osgi.service.remoteserviceadmin.RemoteConstants; + +public class IntentUtilsTest { + + @Test + public void testMergeArrays() { + Assert.assertNull(IntentUtils.mergeArrays(null, null)); + + String[] sa1 = {}; + Assert.assertEquals(0, IntentUtils.mergeArrays(sa1, null).length); + + String[] sa2 = {"X"}; + Assert.assertEquals(1, IntentUtils.mergeArrays(null, sa2).length); + Assert.assertEquals("X", IntentUtils.mergeArrays(null, sa2)[0]); + + String[] sa3 = {"Y", "Z"}; + String[] sa4 = {"A", "Z"}; + Assert.assertEquals(3, IntentUtils.mergeArrays(sa3, sa4).length); + Assert.assertEquals(new HashSet<String>(Arrays.asList("A", "Y", "Z")), + new HashSet<String>(Arrays.asList(IntentUtils.mergeArrays(sa3, sa4)))); + } + + @SuppressWarnings("deprecation") + @Test + public void testRequestedIntents() { + Map<String, Object> props = new HashMap<String, Object>(); + Assert.assertEquals(0, IntentUtils.getRequestedIntents(props).size()); + + props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "one"); + Assert.assertEquals(Collections.singleton("one"), IntentUtils.getRequestedIntents(props)); + + props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, new String[] {"two", "three"}); + Set<String> expected1 = new HashSet<String>(Arrays.asList("one", "two", "three")); + Assert.assertEquals(expected1, IntentUtils.getRequestedIntents(props)); + + props.put(Constants.EXPORTED_INTENTS_OLD, "A B C"); + Set<String> expected2 = new HashSet<String>(Arrays.asList("one", "two", "three", "A", "B", "C")); + Assert.assertEquals(expected2, IntentUtils.getRequestedIntents(props)); + } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java new file mode 100644 index 0000000..cc15ea6 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/OsgiUtilsTest.java @@ -0,0 +1,152 @@ +/** + * 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.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +import org.easymock.EasyMock; +import org.easymock.IMocksControl; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.Version; +import org.osgi.service.packageadmin.ExportedPackage; +import org.osgi.service.packageadmin.PackageAdmin; +import org.osgi.service.remoteserviceadmin.EndpointDescription; +import org.osgi.service.remoteserviceadmin.RemoteConstants; + +@SuppressWarnings("deprecation") +public class OsgiUtilsTest extends TestCase { + + public void testMultiValuePropertyAsString() { + assertEquals(Collections.singleton("hi"), + OsgiUtils.getMultiValueProperty("hi")); + } + + public void testMultiValuePropertyAsArray() { + assertEquals(Arrays.asList("a", "b"), + OsgiUtils.getMultiValueProperty(new String[] {"a", "b"})); + } + + public void testMultiValuePropertyAsCollection() { + List<String> list = new ArrayList<String>(); + list.add("1"); + list.add("2"); + list.add("3"); + assertEquals(list, OsgiUtils.getMultiValueProperty(list)); + } + + public void testMultiValuePropertyNull() { + assertNull(OsgiUtils.getMultiValueProperty(null)); + } + + @SuppressWarnings({ + "rawtypes", "unchecked" + }) + 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))).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))).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; + + 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_ID, "http://google.de"); + p.put("notAString", new Object()); + p.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{"my.class"}); + p.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"}); + + EndpointDescription endpoint = new EndpointDescription(p); + + assertNull(OsgiUtils.getProperty(endpoint, "unknownProp")); + assertEquals(p.get(RemoteConstants.ENDPOINT_ID), OsgiUtils.getProperty(endpoint, RemoteConstants.ENDPOINT_ID)); + assertEquals(null, OsgiUtils.getProperty(endpoint, "notAString")); + } +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/Provider.java ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/Provider.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/Provider.java new file mode 100644 index 0000000..ecd7c78 --- /dev/null +++ b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/util/Provider.java @@ -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.util; + + +public class Provider { +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml new file mode 100644 index 0000000..36409ce --- /dev/null +++ b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/alt-remote-services.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> + <service-description> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" /> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" /> + + <property name="osgi.remote.interfaces" value="*" /> + <property name="osgi.remote.requires.intents" value="SOAP HTTP" /> + <property name="osgi.remote.configuration.type" value="pojo" /> + <property name="osgi.remote.configuration.pojo.address" value="http://localhost:9000/hello" /> + </service-description> +</service-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml new file mode 100644 index 0000000..3d20c08 --- /dev/null +++ b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/multi-services.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> + <service-description> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" /> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" /> + <property name="osgi.remote.interfaces">org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface</property> + <property name="osgi.remote.requires.intents">SOAP HTTP</property> + <property name="osgi.remote.configuration.type">pojo</property> + <property name="osgi.remote.configuration.pojo.address" + interface="org.apache.cxf.dosgi.dsw.hooks.TestService"> + http://localhost:9001/hello + </property> + <property name="osgi.remote.configuration.pojo.address" + interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface"> + http://localhost:9002/hello + </property> + </service-description> +</service-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml new file mode 100644 index 0000000..45b2a20 --- /dev/null +++ b/cxf-dsw/src/test/resources/OSGI-INF/remote-service/remote-services.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> + <service-description> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.TestService" /> + <provide interface="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface" /> + + <property name="osgi.remote.interfaces">*</property> + <property name="osgi.remote.requires.intents">SOAP HTTP</property> + <property name="osgi.remote.configuration.type">pojo</property> + <property name="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property> + </service-description> +</service-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/test-resources/rs1.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/test-resources/rs1.xml b/cxf-dsw/src/test/resources/test-resources/rs1.xml new file mode 100644 index 0000000..f67a833 --- /dev/null +++ b/cxf-dsw/src/test/resources/test-resources/rs1.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> + <service-description> + <provide interface="SomeService" /> + <property name="osgi.remote.requires.intents">confidentiality</property> + </service-description> + <service-description> + <provide interface="SomeOtherService" /> + <provide interface="WithSomeSecondInterface" /> + </service-description> +</service-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/test-resources/rs2.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/test-resources/rs2.xml b/cxf-dsw/src/test/resources/test-resources/rs2.xml new file mode 100644 index 0000000..098aa21 --- /dev/null +++ b/cxf-dsw/src/test/resources/test-resources/rs2.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"> + <service-description> + <provide interface="org.example.Service" /> + <property name="deployment.intents">confidentiality.message integrity</property> + <property name="osgi.remote.interfaces">*</property> + </service-description> +</service-descriptions> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/cxf-dsw/src/test/resources/test-resources/sd-1.xml ---------------------------------------------------------------------- diff --git a/cxf-dsw/src/test/resources/test-resources/sd-1.xml b/cxf-dsw/src/test/resources/test-resources/sd-1.xml new file mode 100644 index 0000000..483b196 --- /dev/null +++ b/cxf-dsw/src/test/resources/test-resources/sd-1.xml @@ -0,0 +1,3 @@ +<test> + <some-other-tag/> +</test> \ No newline at end of file
