http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java deleted file mode 100644 index fbe2c02..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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 java.util.HashMap; -import java.util.Map; - -import junit.framework.TestCase; - -import org.apache.cxf.dosgi.dsw.api.DistributionProvider; -import org.easymock.EasyMock; -import org.easymock.IMocksControl; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceRegistration; -import org.osgi.framework.wiring.BundleWiring; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.RemoteConstants; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.isA; - - -public class ClientServiceFactoryTest extends TestCase { - - @SuppressWarnings({ - "rawtypes" - }) - public void testGetService() throws ClassNotFoundException { - final Object myTestProxyObject = new Object(); - - IMocksControl control = EasyMock.createControl(); - EndpointDescription endpoint = createTestEndpointDesc(); - ImportRegistrationImpl iri = new ImportRegistrationImpl(endpoint, null); - - BundleContext consumerContext = control.createMock(BundleContext.class); - Bundle consumerBundle = control.createMock(Bundle.class); - BundleWiring bundleWiring = control.createMock(BundleWiring.class); - EasyMock.expect(bundleWiring.getClassLoader()).andReturn(this.getClass().getClassLoader()); - EasyMock.expect(consumerBundle.adapt(BundleWiring.class)).andReturn(bundleWiring); - EasyMock.expect(consumerBundle.getBundleContext()).andReturn(consumerContext); - ServiceRegistration sreg = control.createMock(ServiceRegistration.class); - - - DistributionProvider handler = mockDistributionProvider(myTestProxyObject); - control.replay(); - - ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri); - assertSame(myTestProxyObject, csf.getService(consumerBundle, sreg)); - } - - /** - * Creating dummy class as I was not able to really mock it - * @param myTestProxyObject - * @return - */ - private DistributionProvider mockDistributionProvider(final Object proxy) { - DistributionProvider handler = EasyMock.createMock(DistributionProvider.class); - EasyMock.expect(handler.importEndpoint(anyObject(ClassLoader.class), - anyObject(BundleContext.class), - isA(Class[].class), - anyObject(EndpointDescription.class))).andReturn(proxy); - EasyMock.replay(handler); - return handler; - } - - private EndpointDescription createTestEndpointDesc() { - Map<String, Object> map = new HashMap<String, Object>(); - map.put(RemoteConstants.ENDPOINT_ID, "http://google.de"); - map.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration"); - map.put(Constants.OBJECTCLASS, new String[]{String.class.getName()}); - EndpointDescription endpoint = new EndpointDescription(map); - return endpoint; - } -}
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderTrackerTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderTrackerTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderTrackerTest.java deleted file mode 100644 index 6ae7004..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderTrackerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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 java.util.Dictionary; - -import org.apache.cxf.dosgi.dsw.api.DistributionProvider; -import org.easymock.EasyMock; -import org.easymock.IMocksControl; -import org.junit.Test; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceFactory; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.remoteserviceadmin.RemoteConstants; - -public class DistributionProviderTrackerTest { - - @SuppressWarnings({ - "unchecked", "rawtypes" - }) - @Test - public void testAddingRemoved() throws InvalidSyntaxException { - IMocksControl c = EasyMock.createControl(); - DistributionProvider provider = c.createMock(DistributionProvider.class); - - ServiceReference<DistributionProvider> providerRef = c.createMock(ServiceReference.class); - EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_INTENTS_SUPPORTED)).andReturn(""); - EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_CONFIGS_SUPPORTED)).andReturn(""); - - BundleContext context = c.createMock(BundleContext.class); - Filter filter = FrameworkUtil.createFilter("(objectClass=org.apache.cxf.dosgi.dsw.api.DistributionProvider)"); - EasyMock.expect(context.createFilter("(objectClass=org.apache.cxf.dosgi.dsw.api.DistributionProvider)")) - .andReturn(filter); - EasyMock.expect(context.getService(providerRef)).andReturn(provider); - ServiceRegistration rsaReg = c.createMock(ServiceRegistration.class); - EasyMock.expect(context.registerService(EasyMock.isA(String.class), EasyMock.isA(ServiceFactory.class), - EasyMock.isA(Dictionary.class))) - .andReturn(rsaReg).atLeastOnce(); - - context.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.isA(String.class)); - EasyMock.expectLastCall(); - - final BundleContext apiContext = c.createMock(BundleContext.class); - c.replay(); - DistributionProviderTracker tracker = new DistributionProviderTracker(context) { - protected BundleContext getAPIContext() { - return apiContext; - }; - }; - tracker.addingService(providerRef); - c.verify(); - - c.reset(); - rsaReg.unregister(); - EasyMock.expectLastCall(); - EasyMock.expect(context.ungetService(providerRef)).andReturn(true); - c.replay(); - tracker.removedService(providerRef, rsaReg); - c.verify(); - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java deleted file mode 100644 index 71d3ed7..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * 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 java.util.Arrays; -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.List; -import java.util.UUID; - -import org.apache.cxf.dosgi.dsw.api.Endpoint; -import org.easymock.EasyMock; -import org.easymock.IAnswer; -import org.junit.Assert; -import org.junit.Test; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.Version; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventAdmin; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.ExportReference; -import org.osgi.service.remoteserviceadmin.ExportRegistration; -import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent; - -@SuppressWarnings({"rawtypes", "unchecked"}) -public class EventProducerTest { - - - @Test - public void testPublishNotification() throws Exception { - RemoteServiceAdminCore remoteServiceAdminCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class); - EasyMock.replay(remoteServiceAdminCore); - - final EndpointDescription epd = EasyMock.createNiceMock(EndpointDescription.class); - EasyMock.expect(epd.getServiceId()).andReturn(Long.MAX_VALUE).anyTimes(); - final String uuid = UUID.randomUUID().toString(); - EasyMock.expect(epd.getFrameworkUUID()).andReturn(uuid).anyTimes(); - EasyMock.expect(epd.getId()).andReturn("foo://bar").anyTimes(); - final List<String> interfaces = Arrays.asList("org.foo.Bar", "org.boo.Far"); - EasyMock.expect(epd.getInterfaces()).andReturn(interfaces).anyTimes(); - EasyMock.expect(epd.getConfigurationTypes()).andReturn(Arrays.asList("org.apache.cxf.ws")).anyTimes(); - EasyMock.replay(epd); - final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class); - EasyMock.replay(sref); - - final Bundle bundle = EasyMock.createNiceMock(Bundle.class); - EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes(); - EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes(); - Dictionary<String, String> headers = new Hashtable<String, String>(); - headers.put("Bundle-Version", "1.2.3.test"); - EasyMock.expect(bundle.getHeaders()).andReturn(headers).anyTimes(); - EasyMock.replay(bundle); - - EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class); - ea.postEvent((Event) EasyMock.anyObject()); - EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { - @Override - public Object answer() throws Throwable { - Event event = (Event) EasyMock.getCurrentArguments()[0]; - - Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_REGISTRATION", event.getTopic()); - Assert.assertSame(bundle, event.getProperty("bundle")); - Assert.assertEquals(42L, event.getProperty("bundle.id")); - Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname")); - Assert.assertEquals(new Version(1, 2, 3, "test"), event.getProperty("bundle.version")); - Assert.assertNull(event.getProperty("cause")); - Assert.assertEquals(epd, event.getProperty("export.registration")); - - Assert.assertEquals(Long.MAX_VALUE, event.getProperty("service.remote.id")); - Assert.assertEquals(uuid, event.getProperty("service.remote.uuid")); - Assert.assertEquals("foo://bar", event.getProperty("service.remote.uri")); - Assert.assertTrue(Arrays.equals(interfaces.toArray(new String[] {}), - (String[]) event.getProperty("objectClass"))); - - Assert.assertNotNull(event.getProperty("timestamp")); - - RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event"); - Assert.assertNull(rsae.getException()); - Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_REGISTRATION, rsae.getType()); - Assert.assertSame(bundle, rsae.getSource()); - ExportReference er = rsae.getExportReference(); - Assert.assertSame(epd, er.getExportedEndpoint()); - Assert.assertSame(sref, er.getExportedService()); - - return null; - } - }); - EasyMock.replay(ea); - - ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class); - EasyMock.replay(eaSref); - - BundleContext bc = EasyMock.createNiceMock(BundleContext.class); - EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes(); - EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null)) - .andReturn(new ServiceReference[] {eaSref}).anyTimes(); - EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes(); - Endpoint endpoint = EasyMock.mock(Endpoint.class); - EasyMock.expect(endpoint.description()).andReturn(epd); - EasyMock.replay(endpoint); - EasyMock.replay(bc); - EventProducer eventProducer = new EventProducer(bc); - - ExportRegistrationImpl ereg = new ExportRegistrationImpl(sref, endpoint, remoteServiceAdminCore); - eventProducer.publishNotification(ereg); - } - - @Test - public void testPublishErrorNotification() throws Exception { - RemoteServiceAdminCore rsaCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class); - EasyMock.replay(rsaCore); - - final EndpointDescription endpoint = EasyMock.createNiceMock(EndpointDescription.class); - EasyMock.expect(endpoint.getInterfaces()).andReturn(Arrays.asList("org.foo.Bar")).anyTimes(); - EasyMock.replay(endpoint); - final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class); - EasyMock.replay(sref); - - final Bundle bundle = EasyMock.createNiceMock(Bundle.class); - EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes(); - EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes(); - EasyMock.expect(bundle.getHeaders()).andReturn(new Hashtable<String, String>()).anyTimes(); - EasyMock.replay(bundle); - - final Exception exportException = new Exception(); - - EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class); - ea.postEvent((Event) EasyMock.anyObject()); - EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { - @Override - public Object answer() throws Throwable { - Event event = (Event) EasyMock.getCurrentArguments()[0]; - - Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_ERROR", event.getTopic()); - Assert.assertSame(bundle, event.getProperty("bundle")); - Assert.assertEquals(42L, event.getProperty("bundle.id")); - Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname")); - Assert.assertEquals(new Version("0"), event.getProperty("bundle.version")); - Assert.assertSame(exportException, event.getProperty("cause")); - Assert.assertEquals(endpoint, event.getProperty("export.registration")); - Assert.assertTrue(Arrays.equals(new String[] {"org.foo.Bar"}, - (String[]) event.getProperty("objectClass"))); - - RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event"); - Assert.assertSame(exportException, rsae.getException()); - Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_ERROR, rsae.getType()); - Assert.assertSame(bundle, rsae.getSource()); - ExportReference er = rsae.getExportReference(); - Assert.assertSame(endpoint, er.getExportedEndpoint()); - Assert.assertSame(sref, er.getExportedService()); - - return null; - } - }); - EasyMock.replay(ea); - - ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class); - EasyMock.replay(eaSref); - - BundleContext bc = EasyMock.createNiceMock(BundleContext.class); - EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes(); - EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null)) - .andReturn(new ServiceReference[] {eaSref}).anyTimes(); - EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes(); - EasyMock.replay(bc); - EventProducer eventProducer = new EventProducer(bc); - - ExportRegistrationImpl ereg = new ExportRegistrationImpl(rsaCore, exportException); - eventProducer.publishNotification(Arrays.<ExportRegistration>asList(ereg)); - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java deleted file mode 100644 index 23902a5..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * 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 org.easymock.EasyMock; -import org.easymock.IMocksControl; -import org.junit.Test; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.remoteserviceadmin.EndpointDescription; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -public class ImportRegistrationImplTest { - - @Test - public void testException() { - IMocksControl c = EasyMock.createNiceControl(); - Exception e = c.createMock(Exception.class); - c.replay(); - - ImportRegistrationImpl i = new ImportRegistrationImpl(e); - - assertEquals(e, i.getException()); - assertNull(i.getImportedEndpointDescription()); - assertNull(i.getImportedService()); - assertEquals(i, i.getParent()); - } - - @Test - public void testDefaultCtor() { - IMocksControl c = EasyMock.createNiceControl(); - EndpointDescription endpoint = c.createMock(EndpointDescription.class); - RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class); - - c.replay(); - - ImportRegistrationImpl i = new ImportRegistrationImpl(endpoint, rsac); - - assertNull(i.getException()); - assertEquals(i, i.getParent()); - assertEquals(endpoint, i.getImportedEndpointDescription()); - } - - @SuppressWarnings("rawtypes") - @Test - public void testCloneAndClose() { - IMocksControl c = EasyMock.createControl(); - EndpointDescription endpoint = c.createMock(EndpointDescription.class); - RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class); - - ServiceRegistration sr = c.createMock(ServiceRegistration.class); - ServiceReference sref = c.createMock(ServiceReference.class); - EasyMock.expect(sr.getReference()).andReturn(sref).anyTimes(); - - c.replay(); - - ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac); - - ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1); - - ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2); - - try { - i2.setImportedServiceRegistration(sr); - assertTrue("An exception should be thrown here !", false); - } catch (IllegalStateException e) { - // must be thrown here - } - - i1.setImportedServiceRegistration(sr); - - assertEquals(i1, i1.getParent()); - assertEquals(i1, i2.getParent()); - assertEquals(i1, i3.getParent()); - - assertEquals(endpoint, i1.getImportedEndpointDescription()); - assertEquals(endpoint, i2.getImportedEndpointDescription()); - assertEquals(endpoint, i3.getImportedEndpointDescription()); - - c.verify(); - c.reset(); - - rsac.removeImportRegistration(EasyMock.eq(i3)); - EasyMock.expectLastCall().once(); - - c.replay(); - - i3.close(); - i3.close(); // shouldn't change anything - - assertNull(i3.getImportedEndpointDescription()); - - c.verify(); - c.reset(); - - rsac.removeImportRegistration(EasyMock.eq(i1)); - EasyMock.expectLastCall().once(); - - c.replay(); - - i1.close(); - - c.verify(); - c.reset(); - - rsac.removeImportRegistration(EasyMock.eq(i2)); - EasyMock.expectLastCall().once(); - - sr.unregister(); - EasyMock.expectLastCall().once(); - - c.replay(); - - i2.close(); - - c.verify(); - } - - @Test - public void testCloseAll() { - IMocksControl c = EasyMock.createControl(); - EndpointDescription endpoint = c.createMock(EndpointDescription.class); - RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class); - - c.replay(); - - ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac); - - ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1); - - ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2); - - assertEquals(i1, i1.getParent()); - assertEquals(i1, i2.getParent()); - assertEquals(i1, i3.getParent()); - - c.verify(); - c.reset(); - - rsac.removeImportRegistration(EasyMock.eq(i2)); - EasyMock.expectLastCall().once(); - - c.replay(); - - i2.close(); - - c.verify(); - c.reset(); - - rsac.removeImportRegistration(EasyMock.eq(i1)); - EasyMock.expectLastCall().once(); - rsac.removeImportRegistration(EasyMock.eq(i3)); - EasyMock.expectLastCall().once(); - - c.replay(); - i3.closeAll(); - c.verify(); - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java deleted file mode 100644 index b0f58eb..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java +++ /dev/null @@ -1,517 +0,0 @@ -/** - * 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 java.io.IOException; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collection; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import org.apache.cxf.dosgi.dsw.api.DistributionProvider; -import org.apache.cxf.dosgi.dsw.api.Endpoint; -import org.easymock.EasyMock; -import org.easymock.IAnswer; -import org.easymock.IMocksControl; -import org.junit.Assert; -import org.junit.Test; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.service.packageadmin.PackageAdmin; -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 static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.isA; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -@SuppressWarnings({ - "rawtypes", "unchecked", "deprecation" - }) -public class RemoteServiceAdminCoreTest { - - private static final String MYCONFIG = "myconfig"; - - @Test - public void testDontExportOwnServiceProxies() throws InvalidSyntaxException { - IMocksControl c = EasyMock.createControl(); - Bundle b = c.createMock(Bundle.class); - BundleContext bc = c.createMock(BundleContext.class); - - EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes(); - bc.addServiceListener(EasyMock.<ServiceListener>anyObject(), EasyMock.<String>anyObject()); - EasyMock.expectLastCall().anyTimes(); - bc.removeServiceListener(EasyMock.<ServiceListener>anyObject()); - EasyMock.expectLastCall().anyTimes(); - - Dictionary<String, String> d = new Hashtable<String, String>(); - EasyMock.expect(b.getHeaders()).andReturn(d).anyTimes(); - - ServiceReference sref = c.createMock(ServiceReference.class); - EasyMock.expect(sref.getBundle()).andReturn(b).anyTimes(); - EasyMock.expect(sref.getPropertyKeys()) - .andReturn(new String[]{"objectClass", "service.exported.interfaces"}).anyTimes(); - EasyMock.expect(sref.getProperty("objectClass")).andReturn(new String[] {"a.b.C"}).anyTimes(); - EasyMock.expect(sref.getProperty(RemoteConstants.SERVICE_IMPORTED)).andReturn(true).anyTimes(); - EasyMock.expect(sref.getProperty("service.exported.interfaces")).andReturn("*").anyTimes(); - - DistributionProvider provider = c.createMock(DistributionProvider.class); - - c.replay(); - - RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, bc, provider); - - // must return an empty List as sref if from the same bundle - List<ExportRegistration> exRefs = rsaCore.exportService(sref, null); - - assertNotNull(exRefs); - assertEquals(0, exRefs.size()); - - // must be empty - assertEquals(rsaCore.getExportedServices().size(), 0); - - c.verify(); - } - - @Test - public void testImport() { - IMocksControl c = EasyMock.createNiceControl(); - Bundle b = c.createMock(Bundle.class); - BundleContext bc = c.createMock(BundleContext.class); - - Dictionary<String, String> d = new Hashtable<String, String>(); - EasyMock.expect(b.getHeaders()).andReturn(d).anyTimes(); - - EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes(); - EasyMock.expect(b.getSymbolicName()).andReturn("BundleName").anyTimes(); - - EndpointDescription endpoint = creatEndpointDesc("unsupportedConfiguration"); - - DistributionProvider provider = c.createMock(DistributionProvider.class); - EasyMock.expect(provider.getSupportedTypes()) - .andReturn(new String[]{MYCONFIG}).atLeastOnce(); - c.replay(); - - RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, bc, provider); - - // must be null as the endpoint doesn't contain any usable configurations - assertNull(rsaCore.importService(endpoint)); - // must be empty - assertEquals(0, rsaCore.getImportedEndpoints().size()); - - EndpointDescription endpoint2 = creatEndpointDesc(MYCONFIG); - - ImportRegistration ireg = rsaCore.importService(endpoint2); - assertNotNull(ireg); - - assertEquals(1, rsaCore.getImportedEndpoints().size()); - - // lets import the same endpoint once more -> should get a copy of the ImportRegistration - ImportRegistration ireg2 = rsaCore.importService(endpoint2); - assertNotNull(ireg2); - assertEquals(2, rsaCore.getImportedEndpoints().size()); - - assertEquals(ireg.getImportReference(), (rsaCore.getImportedEndpoints().toArray())[0]); - - assertEquals(ireg.getImportReference().getImportedEndpoint(), ireg2.getImportReference() - .getImportedEndpoint()); - - // remove the registration - - // first call shouldn't remove the import - ireg2.close(); - assertEquals(1, rsaCore.getImportedEndpoints().size()); - - // second call should really close and remove the import - ireg.close(); - assertEquals(0, rsaCore.getImportedEndpoints().size()); - - c.verify(); - } - - private EndpointDescription creatEndpointDesc(String configType) { - Map<String, Object> p = new HashMap<String, Object>(); - p.put(RemoteConstants.ENDPOINT_ID, "http://google.de"); - p.put(Constants.OBJECTCLASS, new String[] { - "es.schaaf.my.class" - }); - p.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, configType); - EndpointDescription endpoint = new EndpointDescription(p); - return endpoint; - } - - @Test - public void testExport() throws Exception { - BundleContext bc = EasyMock.createMock(BundleContext.class); - EasyMock.expect(bc.getProperty(Constants.FRAMEWORK_VERSION)).andReturn(null).anyTimes(); - bc.addServiceListener(EasyMock.<ServiceListener>anyObject(), EasyMock.<String>anyObject()); - EasyMock.expectLastCall().anyTimes(); - bc.removeServiceListener(EasyMock.<ServiceListener>anyObject()); - EasyMock.expectLastCall().anyTimes(); - EasyMock.expect(bc.getServiceReferences(EasyMock.<String>anyObject(), - EasyMock.<String>anyObject())).andReturn(null).anyTimes(); - EasyMock.expect(bc.getAllServiceReferences(EasyMock.<String>anyObject(), - EasyMock.<String>anyObject())).andReturn(null).anyTimes(); - - Bundle b = createDummyRsaBundle(bc); - - final Map<String, Object> sProps = new HashMap<String, Object>(); - sProps.put("objectClass", new String[] {"java.lang.Runnable"}); - sProps.put("service.id", 51L); - sProps.put("myProp", "myVal"); - sProps.put("service.exported.interfaces", "*"); - ServiceReference sref = mockServiceReference(sProps); - - Runnable svcObject = EasyMock.createNiceMock(Runnable.class); - EasyMock.replay(svcObject); - - EasyMock.expect(bc.getService(sref)).andReturn(svcObject).anyTimes(); - EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes(); - EasyMock.expect(bc.createFilter("(service.id=51)")) - .andReturn(FrameworkUtil.createFilter("(service.id=51)")).anyTimes(); - EasyMock.expect(bc.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn("1111"); - EasyMock.expect(bc.getServiceReference(PackageAdmin.class)).andReturn(null); - EasyMock.replay(bc); - - Map<String, Object> eProps = new HashMap<String, Object>(sProps); - eProps.put("endpoint.id", "http://something"); - eProps.put("service.imported.configs", new String[] {"org.apache.cxf.ws"}); - final EndpointDescription epd = new EndpointDescription(eProps); - Endpoint er = new Endpoint() { - - @Override - public void close() throws IOException { - } - - @Override - public EndpointDescription description() { - return epd; - } - }; - - DistributionProvider handler = EasyMock.createMock(DistributionProvider.class); - EasyMock.expect(handler.exportService(anyObject(), - anyObject(BundleContext.class), - anyObject(Map.class), isA(Class[].class))).andReturn(er); - EasyMock.replay(handler); - - RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, bc, handler); - - // Export the service for the first time - List<ExportRegistration> ereg = rsaCore.exportService(sref, null); - assertEquals(1, ereg.size()); - assertNull(ereg.get(0).getException()); - assertSame(sref, ereg.get(0).getExportReference().getExportedService()); - EndpointDescription endpoint = ereg.get(0).getExportReference().getExportedEndpoint(); - - Map<String, Object> edProps = endpoint.getProperties(); - assertEquals("http://something", edProps.get("endpoint.id")); - assertNotNull(edProps.get("service.imported")); - assertTrue(Arrays.equals(new String[] {"java.lang.Runnable"}, - (Object[]) edProps.get("objectClass"))); - assertTrue(Arrays.equals(new String[] {"org.apache.cxf.ws"}, - (Object[]) edProps.get("service.imported.configs"))); - - // Ask to export the same service again, this should not go through the whole process again but simply return - // a copy of the first instance. - final Map<String, Object> sProps2 = new HashMap<String, Object>(); - sProps2.put("objectClass", new String[] {"java.lang.Runnable"}); - sProps2.put("service.id", 51L); - sProps2.put("service.exported.interfaces", "*"); - ServiceReference sref2 = mockServiceReference(sProps2); - Map<String, Object> props2 = new HashMap<String, Object>(); - props2.put("myProp", "myVal"); - List<ExportRegistration> ereg2 = rsaCore.exportService(sref2, props2); - - assertEquals(1, ereg2.size()); - assertNull(ereg2.get(0).getException()); - assertEquals(ereg.get(0).getExportReference().getExportedEndpoint().getProperties(), - ereg2.get(0).getExportReference().getExportedEndpoint().getProperties()); - - // Look at the exportedServices data structure - Field field = RemoteServiceAdminCore.class.getDeclaredField("exportedServices"); - field.setAccessible(true); - Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices = - (Map<Map<String, Object>, Collection<ExportRegistration>>) field.get(rsaCore); - - assertEquals("One service was exported", 1, exportedServices.size()); - assertEquals("There are 2 export registrations (identical copies)", - 2, exportedServices.values().iterator().next().size()); - - // Unregister one of the exports - rsaCore.removeExportRegistration((ExportRegistrationImpl) ereg.get(0)); - assertEquals("One service was exported", 1, exportedServices.size()); - assertEquals("There 1 export registrations left", - 1, exportedServices.values().iterator().next().size()); - - // Unregister the other export - rsaCore.removeExportRegistration((ExportRegistrationImpl) ereg2.get(0)); - assertEquals("No more exported services", 0, exportedServices.size()); - } - - private Bundle createDummyRsaBundle(BundleContext bc) { - Bundle b = EasyMock.createNiceMock(Bundle.class); - EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes(); - EasyMock.expect(b.getSymbolicName()).andReturn("rsabundle").anyTimes(); - EasyMock.expect(b.getHeaders()).andReturn(new Hashtable<String, String>()).anyTimes(); - EasyMock.replay(b); - return b; - } - - @Test - public void testExportException() throws Exception { - BundleContext bc = EasyMock.createNiceMock(BundleContext.class); - - Bundle b = createDummyRsaBundle(bc); - - final Map<String, Object> sProps = new HashMap<String, Object>(); - sProps.put("objectClass", new String[] {"java.lang.Runnable"}); - sProps.put("service.id", 51L); - sProps.put("service.exported.interfaces", "*"); - ServiceReference sref = mockServiceReference(sProps); - - Runnable svcObject = EasyMock.createNiceMock(Runnable.class); - EasyMock.replay(svcObject); - - EasyMock.expect(bc.getService(sref)).andReturn(svcObject).anyTimes(); - EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes(); - EasyMock.replay(bc); - - Map<String, Object> eProps = new HashMap<String, Object>(sProps); - eProps.put("endpoint.id", "http://something"); - eProps.put("service.imported.configs", new String[] {"org.apache.cxf.ws"}); - - DistributionProvider handler = EasyMock.createMock(DistributionProvider.class); - EasyMock.expect(handler.exportService(anyObject(), - anyObject(BundleContext.class), - anyObject(Map.class), isA(Class[].class))).andThrow(new TestException()); - EasyMock.replay(handler); - - RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, bc, handler); - - List<ExportRegistration> ereg = rsaCore.exportService(sref, sProps); - assertEquals(1, ereg.size()); - assertTrue(ereg.get(0).getException() instanceof TestException); - - // Look at the exportedServices data structure - Field field = RemoteServiceAdminCore.class.getDeclaredField("exportedServices"); - field.setAccessible(true); - Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices = - (Map<Map<String, Object>, Collection<ExportRegistration>>) field.get(rsaCore); - - assertEquals("One service was exported", 1, exportedServices.size()); - assertEquals("There is 1 export registration", - 1, exportedServices.values().iterator().next().size()); - - } - - private ServiceReference mockServiceReference(final Map<String, Object> sProps) throws ClassNotFoundException { - BundleContext bc = EasyMock.createNiceMock(BundleContext.class); - - Bundle b = EasyMock.createNiceMock(Bundle.class); - EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes(); - EasyMock.expect((Class)b.loadClass(Runnable.class.getName())).andReturn(Runnable.class); - EasyMock.replay(b); - - EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes(); - EasyMock.replay(bc); - - ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class); - EasyMock.expect(sref.getBundle()).andReturn(b).anyTimes(); - EasyMock.expect(sref.getPropertyKeys()).andReturn(sProps.keySet().toArray(new String[] {})).anyTimes(); - EasyMock.expect(sref.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() { - @Override - public Object answer() throws Throwable { - return sProps.get(EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - EasyMock.replay(sref); - return sref; - } - - @SuppressWarnings("serial") - private static class TestException extends RuntimeException { - } - - @Test - public void testOverlayProperties() { - Map<String, Object> sProps = new HashMap<String, Object>(); - Map<String, Object> aProps = new HashMap<String, Object>(); - - RemoteServiceAdminCore.overlayProperties(sProps, aProps); - assertEquals(0, sProps.size()); - - sProps.put("aaa", "aval"); - sProps.put("bbb", "bval"); - sProps.put(Constants.OBJECTCLASS, new String[] {"X"}); - sProps.put(Constants.SERVICE_ID, 17L); - - aProps.put("AAA", "achanged"); - aProps.put("CCC", "CVAL"); - aProps.put(Constants.OBJECTCLASS, new String[] {"Y"}); - aProps.put(Constants.SERVICE_ID.toUpperCase(), 51L); - - Map<String, Object> aPropsOrg = new HashMap<String, Object>(aProps); - RemoteServiceAdminCore.overlayProperties(sProps, aProps); - assertEquals("The additional properties should not be modified", aPropsOrg, aProps); - - assertEquals(5, sProps.size()); - assertEquals("achanged", sProps.get("aaa")); - assertEquals("bval", sProps.get("bbb")); - assertEquals("CVAL", sProps.get("CCC")); - assertTrue("Should not be possible to override the objectClass property", - Arrays.equals(new String[] {"X"}, (Object[]) sProps.get(Constants.OBJECTCLASS))); - assertEquals("Should not be possible to override the service.id property", - 17L, sProps.get(Constants.SERVICE_ID)); - } - - @Test - public void testOverlayProperties2() { - Map<String, Object> original = new HashMap<String, Object>(); - - original.put("MyProp", "my value"); - original.put(Constants.OBJECTCLASS, "myClass"); - - Map<String, Object> copy = new HashMap<String, Object>(); - copy.putAll(original); - - // nothing should change here - Map<String, Object> overload = new HashMap<String, Object>(); - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size(), copy.size()); - for (Object key : original.keySet()) { - assertEquals(original.get(key), copy.get(key)); - } - - copy.clear(); - copy.putAll(original); - - // a property should be added - overload = new HashMap<String, Object>(); - overload.put("new", "prop"); - - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size() + 1, copy.size()); - for (Object key : original.keySet()) { - assertEquals(original.get(key), copy.get(key)); - } - assertNotNull(overload.get("new")); - assertEquals("prop", overload.get("new")); - - copy.clear(); - copy.putAll(original); - - // only one property should be added - overload = new HashMap<String, Object>(); - overload.put("new", "prop"); - overload.put("NEW", "prop"); - - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size() + 1, copy.size()); - for (Object key : original.keySet()) { - assertEquals(original.get(key), copy.get(key)); - } - assertNotNull(overload.get("new")); - assertEquals("prop", overload.get("new")); - - copy.clear(); - copy.putAll(original); - - // nothing should change here - overload = new HashMap<String, Object>(); - overload.put(Constants.OBJECTCLASS, "assd"); - overload.put(Constants.SERVICE_ID, "asasdasd"); - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size(), copy.size()); - for (Object key : original.keySet()) { - assertEquals(original.get(key), copy.get(key)); - } - - copy.clear(); - copy.putAll(original); - - // overwrite own prop - overload = new HashMap<String, Object>(); - overload.put("MyProp", "newValue"); - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size(), copy.size()); - for (Object key : original.keySet()) { - if (!"MyProp".equals(key)) { - assertEquals(original.get(key), copy.get(key)); - } - } - assertEquals("newValue", copy.get("MyProp")); - - copy.clear(); - copy.putAll(original); - - // overwrite own prop in different case - overload = new HashMap<String, Object>(); - overload.put("MYPROP", "newValue"); - RemoteServiceAdminCore.overlayProperties(copy, overload); - - assertEquals(original.size(), copy.size()); - for (Object key : original.keySet()) { - if (!"MyProp".equals(key)) { - assertEquals(original.get(key), copy.get(key)); - } - } - assertEquals("newValue", copy.get("MyProp")); - } - - @Test - public void testCreateEndpointProps() { - BundleContext bc = EasyMock.createNiceMock(BundleContext.class); - EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1"); - EasyMock.replay(bc); - - Map<String, Object> sd = new HashMap<String, Object>(); - sd.put(org.osgi.framework.Constants.SERVICE_ID, 42); - DistributionProvider provider = null; - RemoteServiceAdminCore rsa = new RemoteServiceAdminCore(bc, bc, provider); - Map<String, Object> props = rsa.createEndpointProps(sd, new Class[]{String.class}); - - Assert.assertFalse(props.containsKey(org.osgi.framework.Constants.SERVICE_ID)); - assertEquals(42, props.get(RemoteConstants.ENDPOINT_SERVICE_ID)); - assertEquals("some_uuid1", props.get(RemoteConstants.ENDPOINT_FRAMEWORK_UUID)); - assertEquals(Arrays.asList("java.lang.String"), - Arrays.asList((Object[]) props.get(org.osgi.framework.Constants.OBJECTCLASS))); - assertEquals("0.0.0", props.get("endpoint.package.version.java.lang")); - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/StringPlusTest.java ---------------------------------------------------------------------- diff --git a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/StringPlusTest.java b/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/StringPlusTest.java deleted file mode 100644 index 5447966..0000000 --- a/rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/StringPlusTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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 java.util.ArrayList; -import java.util.Collection; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - -public class StringPlusTest { - - @Test - public void testSplitString() { - String[] values = StringPlus.normalize("1, 2"); - assertEquals(2, values.length); - assertEquals(values[0], "1"); - assertEquals(values[1], "2"); - } - - @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 - - assertArrayEquals(null, StringPlus.normalize(new Object())); - assertArrayEquals(new String[] { - s1 - }, StringPlus.normalize(s1)); - assertArrayEquals(sa, StringPlus.normalize(sa)); - assertArrayEquals(sa, StringPlus.normalize(sl)); - } - -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/bnd.bnd ---------------------------------------------------------------------- diff --git a/spi/bnd.bnd b/spi/bnd.bnd new file mode 100644 index 0000000..7ec5bf1 --- /dev/null +++ b/spi/bnd.bnd @@ -0,0 +1,3 @@ +Export-Package: \ + org.apache.aries.rsa.spi,\ + org.apache.aries.rsa.util \ No newline at end of file http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/pom.xml ---------------------------------------------------------------------- diff --git a/spi/pom.xml b/spi/pom.xml index 427383b..da2a348 100644 --- a/spi/pom.xml +++ b/spi/pom.xml @@ -50,18 +50,4 @@ </dependency> </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - </instructions> - </configuration> - </plugin> - </plugins> - </build> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/spi/DistributionProvider.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/DistributionProvider.java b/spi/src/main/java/org/apache/aries/rsa/spi/DistributionProvider.java new file mode 100644 index 0000000..8f78f14 --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/DistributionProvider.java @@ -0,0 +1,56 @@ +/** + * 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.aries.rsa.spi; + +import java.util.Map; + +import org.osgi.framework.BundleContext; +import org.osgi.service.remoteserviceadmin.EndpointDescription; + +@SuppressWarnings("rawtypes") +public interface DistributionProvider { + + String[] getSupportedTypes(); + + /** + * @param serviceO service instance to be exported + * @param serviceContext bundle context of the bundle exporting the sevice + * @param effectiveProperties combined properties of the service and additional properties from rsa + * @param exportedInterfaces name of the interface to be exported + * @return Endpoint that represents the service that is exposed to the outside world + */ + Endpoint exportService(Object serviceO, + BundleContext serviceContext, + Map<String, Object> effectiveProperties, + Class[] exportedInterfaces); + + /** + * @param cl classloader of the consumer bundle + * @param consumerContext bundle context of the consumer bundle + * @param interfaces interfaces of the service to proxy + * @param endpoint description of the remote endpoint + * @return service proxy to be given to the requesting bundle + * @throws IntentUnsatisfiedException + */ + Object importEndpoint(ClassLoader cl, + BundleContext consumerContext, + Class[] interfaces, + EndpointDescription endpoint) + throws IntentUnsatisfiedException; +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/spi/Endpoint.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/Endpoint.java b/spi/src/main/java/org/apache/aries/rsa/spi/Endpoint.java new file mode 100644 index 0000000..ca8e356 --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/Endpoint.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.aries.rsa.spi; + +import java.io.Closeable; + +import org.osgi.service.remoteserviceadmin.EndpointDescription; + +public interface Endpoint extends Closeable { + EndpointDescription description(); +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java b/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java new file mode 100644 index 0000000..ace717f --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java @@ -0,0 +1,46 @@ +/** + * 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.aries.rsa.spi; + +import java.util.Map; + +import org.osgi.framework.ServiceReference; + + +/** + * SPI for TopologyManagerExport. Allows to export services that are + * not marked for export as well customize the way services are exported. + * + * Use cases: + * - Mandate SSL and basic authoriziation by adding the respective intents and configs + * - Add logging interceptor as intent + * - Remove exported interfaces to filter out services + */ +public interface ExportPolicy { + /** + * Allows to supply additional properties for a service that are then + * given to RemoteServiceAdmin. The service will be exported + * if the original service or the additional properties contain the + * non empty property service.exported.interfaces. + * + * @param service to export + * @return additional properties for exported Service (must not be null) + */ + Map<String, ?> additionalParameters(ServiceReference<?> sref); +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/spi/IntentUnsatisfiedException.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/IntentUnsatisfiedException.java b/spi/src/main/java/org/apache/aries/rsa/spi/IntentUnsatisfiedException.java new file mode 100644 index 0000000..5718d58 --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/IntentUnsatisfiedException.java @@ -0,0 +1,35 @@ +/** + * 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.aries.rsa.spi; + +public class IntentUnsatisfiedException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + private final String intent; + + public IntentUnsatisfiedException(String intent) { + super(intent); + this.intent = intent; + } + + public String getIntent() { + return intent; + } +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/spi/packageinfo ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/packageinfo b/spi/src/main/java/org/apache/aries/rsa/spi/packageinfo new file mode 100644 index 0000000..c72722a --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/packageinfo @@ -0,0 +1,19 @@ +# +# 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. +# +version 1.0.0 http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java b/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java new file mode 100644 index 0000000..c57e656 --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.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.aries.rsa.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public final class EndpointHelper { + + private EndpointHelper() { + } + + public static void addObjectClass(Map<String, Object> props, Class<?>[] interfaces) { + props.put(org.osgi.framework.Constants.OBJECTCLASS, getClassNames(interfaces)); + } + + public static String[] getClassNames(Class<?>[] ifaces) { + List<String> ifaceNames = new ArrayList<String>(); + for (Class<?> iface : ifaces) { + ifaceNames.add(iface.getName()); + } + return ifaceNames.toArray(new String[]{}); + } +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java b/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java new file mode 100644 index 0000000..bff9503 --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java @@ -0,0 +1,73 @@ +/** + * 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.aries.rsa.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class StringPlus { + + private static final Logger LOG = LoggerFactory.getLogger(StringPlus.class); + + private StringPlus() { + // never constructed + } + + @SuppressWarnings("rawtypes") + public static List<String> normalize(Object object) { + if (object instanceof String) { + String s = (String)object; + String[] values = s.split(","); + List<String> list = new ArrayList<String>(); + for (String val : values) { + String actualValue = val.trim(); + if (!actualValue.isEmpty()) { + list.add(actualValue); + } + } + return list; + } + + if (object instanceof String[]) { + return Arrays.asList((String[])object); + } + + if (object instanceof Collection) { + Collection col = (Collection)object; + List<String> ar = new ArrayList<String>(col.size()); + for (Object o : col) { + if (o instanceof String) { + String s = (String)o; + ar.add(s); + } else { + LOG.warn("stringPlus contained non string element in list! Element was skipped"); + } + } + return ar; + } + + return null; + } + +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java b/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java deleted file mode 100644 index d7c648b..0000000 --- a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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.api; - -import java.util.Map; - -import org.osgi.framework.BundleContext; -import org.osgi.service.remoteserviceadmin.EndpointDescription; - -@SuppressWarnings("rawtypes") -public interface DistributionProvider { - - String[] getSupportedTypes(); - - /** - * @param serviceO service instance to be exported - * @param serviceContext bundle context of the bundle exporting the sevice - * @param effectiveProperties combined properties of the service and additional properties from rsa - * @param exportedInterfaces name of the interface to be exported - * @return Endpoint that represents the service that is exposed to the outside world - */ - Endpoint exportService(Object serviceO, - BundleContext serviceContext, - Map<String, Object> effectiveProperties, - Class[] exportedInterfaces); - - /** - * @param cl classloader of the consumer bundle - * @param consumerContext bundle context of the consumer bundle - * @param interfaces interfaces of the service to proxy - * @param endpoint description of the remote endpoint - * @return service proxy to be given to the requesting bundle - * @throws IntentUnsatisfiedException - */ - Object importEndpoint(ClassLoader cl, - BundleContext consumerContext, - Class[] interfaces, - EndpointDescription endpoint) - throws IntentUnsatisfiedException; -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java b/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java deleted file mode 100644 index f45b562..0000000 --- a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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.api; - -import java.io.Closeable; - -import org.osgi.service.remoteserviceadmin.EndpointDescription; - -public interface Endpoint extends Closeable { - EndpointDescription description(); -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java b/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java deleted file mode 100644 index cdc66ad..0000000 --- a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public final class EndpointHelper { - - private EndpointHelper() { - } - - public static void addObjectClass(Map<String, Object> props, Class<?>[] interfaces) { - props.put(org.osgi.framework.Constants.OBJECTCLASS, getClassNames(interfaces)); - } - - public static String[] getClassNames(Class<?>[] ifaces) { - List<String> ifaceNames = new ArrayList<String>(); - for (Class<?> iface : ifaces) { - ifaceNames.add(iface.getName()); - } - return ifaceNames.toArray(new String[]{}); - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportPolicy.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportPolicy.java b/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportPolicy.java deleted file mode 100644 index 9e82c04..0000000 --- a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportPolicy.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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.api; - -import java.util.Map; - -import org.osgi.framework.ServiceReference; - - -/** - * SPI for TopologyManagerExport. Allows to export services that are - * not marked for export as well customize the way services are exported. - * - * Use cases: - * - Mandate SSL and basic authoriziation by adding the respective intents and configs - * - Add logging interceptor as intent - * - Remove exported interfaces to filter out services - */ -public interface ExportPolicy { - /** - * Allows to supply additional properties for a service that are then - * given to RemoteServiceAdmin. The service will be exported - * if the original service or the additional properties contain the - * non empty property service.exported.interfaces. - * - * @param service to export - * @return additional properties for exported Service (must not be null) - */ - Map<String, ?> additionalParameters(ServiceReference<?> sref); -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/IntentUnsatisfiedException.java ---------------------------------------------------------------------- diff --git a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/IntentUnsatisfiedException.java b/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/IntentUnsatisfiedException.java deleted file mode 100644 index 4e27938..0000000 --- a/spi/src/main/java/org/apache/cxf/dosgi/dsw/api/IntentUnsatisfiedException.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.api; - -public class IntentUnsatisfiedException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - private final String intent; - - public IntentUnsatisfiedException(String intent) { - super(intent); - this.intent = intent; - } - - public String getIntent() { - return intent; - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/spi/src/test/java/org/apache/aries/rsa/util/StringPlusTest.java ---------------------------------------------------------------------- diff --git a/spi/src/test/java/org/apache/aries/rsa/util/StringPlusTest.java b/spi/src/test/java/org/apache/aries/rsa/util/StringPlusTest.java new file mode 100644 index 0000000..dd716e6 --- /dev/null +++ b/spi/src/test/java/org/apache/aries/rsa/util/StringPlusTest.java @@ -0,0 +1,54 @@ +/** + * 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.aries.rsa.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.junit.Test; + +public class StringPlusTest { + + @Test + public void testSplitString() { + List<String> values = StringPlus.normalize("1, 2"); + assertEquals(2, values.size()); + assertEquals("1", values.get(0)); + assertEquals("2", values.get(1)); + } + + @Test + public void testNormalizeStringPlus() { + String s1 = "s1"; + String s2 = "s2"; + String s3 = "s3"; + List<String> sa = Arrays.asList(s1, s2, s3); + Collection<Object> sl = Arrays.asList(s1, s2, s3, new Object()); // must be skipped + assertNull(StringPlus.normalize(new Object())); + assertEquals(Collections.singletonList(s1), StringPlus.normalize(s1)); + assertEquals(sa, StringPlus.normalize(sa)); + assertEquals(sa, StringPlus.normalize(sl)); + } + +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/topology-manager/bnd.bnd ---------------------------------------------------------------------- diff --git a/topology-manager/bnd.bnd b/topology-manager/bnd.bnd index 3ff22e0..779dd72 100644 --- a/topology-manager/bnd.bnd +++ b/topology-manager/bnd.bnd @@ -1 +1 @@ -Bundle-Activator: org.apache.cxf.dosgi.topologymanager.Activator +Bundle-Activator: org.apache.aries.rsa.topologymanager.Activator http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/topology-manager/pom.xml ---------------------------------------------------------------------- diff --git a/topology-manager/pom.xml b/topology-manager/pom.xml index 2df803e..015798d 100644 --- a/topology-manager/pom.xml +++ b/topology-manager/pom.xml @@ -38,6 +38,11 @@ <dependencies> <dependency> + <groupId>org.apache.aries.rsa</groupId> + <artifactId>spi</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>1.3</version>
