Repository: cxf-dosgi Updated Branches: refs/heads/master 3f8afd08c -> 5352c05d4
[DOSGI-249] Small fixes Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/5352c05d Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/5352c05d Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/5352c05d Branch: refs/heads/master Commit: 5352c05d4c19feff5c7b36c6d6819e52e913cba2 Parents: 3f8afd0 Author: Christian Schneider <[email protected]> Authored: Tue Aug 16 14:53:16 2016 +0200 Committer: Christian Schneider <[email protected]> Committed: Tue Aug 16 14:53:16 2016 +0200 ---------------------------------------------------------------------- distribution/features/pom.xml | 2 +- .../dosgi/itests/multi/AbstractDosgiTest.java | 1 - .../itests/multi/DummyTaskServiceImpl.java | 49 +++++++++++++++++++ .../dosgi/itests/multi/TestCustomIntent.java | 14 ++++-- .../dosgi/itests/multi/TestExportService.java | 50 +++++++++----------- .../dosgi/itests/multi/TestImportService.java | 23 ++++----- .../dosgi/itests/multi/TestTaskServiceImpl.java | 49 ------------------- .../customintent/CustomIntentActivator.java | 4 +- samples/rest/api/pom.xml | 2 +- samples/rest/client/pom.xml | 2 +- samples/rest/impl/pom.xml | 2 +- samples/rest/pom.xml | 2 +- samples/soap/api/pom.xml | 2 +- samples/soap/impl/pom.xml | 2 +- samples/soap/pom.xml | 2 +- 15 files changed, 99 insertions(+), 107 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/distribution/features/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/features/pom.xml b/distribution/features/pom.xml index dd2c9ad..22f8eeb 100644 --- a/distribution/features/pom.xml +++ b/distribution/features/pom.xml @@ -15,7 +15,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi</artifactId> <packaging>pom</packaging> - <name>CXF DOSGI Karaf Features</name> + <name>CXF DOSGi Karaf Features</name> <url>http://cxf.apache.org</url> <parent> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java index 2a1b148..16264bd 100644 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java @@ -81,7 +81,6 @@ public class AbstractDosgiTest { lastException = null; } catch (Throwable e) { lastException = e; - e.printStackTrace(); } try { Thread.sleep(1000); http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/DummyTaskServiceImpl.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/DummyTaskServiceImpl.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/DummyTaskServiceImpl.java new file mode 100644 index 0000000..82b0a31 --- /dev/null +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/DummyTaskServiceImpl.java @@ -0,0 +1,49 @@ +/** + * 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.itests.multi; + +import java.util.Collection; + +import org.apache.cxf.dosgi.samples.soap.Task; +import org.apache.cxf.dosgi.samples.soap.TaskService; + +public class DummyTaskServiceImpl implements TaskService { + + @Override + public Task get(Integer id) { + return new Task(1, "test", ""); + } + + @Override + public void addOrUpdate(Task task) { + throw new UnsupportedOperationException(); + } + + @Override + public void delete(Integer id) { + throw new UnsupportedOperationException(); + + } + + @Override + public Collection<Task> getAll() { + throw new UnsupportedOperationException(); + } + +} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestCustomIntent.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestCustomIntent.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestCustomIntent.java index a237834..b722255 100644 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestCustomIntent.java +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestCustomIntent.java @@ -18,10 +18,10 @@ */ package org.apache.cxf.dosgi.itests.multi; -import static org.apache.cxf.dosgi.itests.multi.TaskServiceProxyFactory.create; import static org.ops4j.pax.exam.CoreOptions.streamBundle; import java.io.InputStream; +import java.util.concurrent.Callable; import org.apache.cxf.dosgi.itests.multi.customintent.ChangeTitleInterceptor; import org.apache.cxf.dosgi.itests.multi.customintent.CustomFeature; @@ -53,9 +53,13 @@ public class TestCustomIntent extends AbstractDosgiTest { @Test public void testCustomIntent() throws Exception { - Thread.sleep(1000); - TaskService greeterService = create("http://localhost:8080/cxf/taskservice"); - Task task = greeterService.get(1); + final TaskService greeterService = TaskServiceProxyFactory.create("http://localhost:8080/cxf/taskservice"); + Task task = tryTo("Call TaskService", new Callable<Task>() { + public Task call() throws Exception { + return greeterService.get(1); + } + }); + Assert.assertEquals("changed", task.getTitle()); } @@ -64,7 +68,7 @@ public class TestCustomIntent extends AbstractDosgiTest { .add(CustomIntentActivator.class) // .add(CustomFeature.class) // .add(ChangeTitleInterceptor.class) // - .add(TestTaskServiceImpl.class) // + .add(DummyTaskServiceImpl.class) // .set(Constants.BUNDLE_SYMBOLICNAME, "CustomIntent") // .set(Constants.BUNDLE_ACTIVATOR, CustomIntentActivator.class.getName()) .build(TinyBundles.withBnd()); http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportService.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportService.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportService.java index 150d1d7..c8c619a 100644 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportService.java +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportService.java @@ -18,14 +18,12 @@ */ package org.apache.cxf.dosgi.itests.multi; -import java.io.IOException; import java.net.URL; -import java.util.concurrent.TimeoutException; +import java.util.concurrent.Callable; import javax.ws.rs.core.MediaType; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import org.apache.cxf.dosgi.samples.soap.Task; import org.apache.cxf.dosgi.samples.soap.TaskService; @@ -41,7 +39,6 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.xml.sax.SAXException; /** * Deploys the sample SOAP service and zookeeper discovery. @@ -74,17 +71,25 @@ public class TestExportService extends AbstractDosgiTest { @Test public void testSOAPCall() throws Exception { - waitPort(8080); - Thread.sleep(1000); checkWsdl(new URL(SERVICE_URI + "?wsdl")); - checkServiceCall(SERVICE_URI); + TaskService taskService = TaskServiceProxyFactory.create(SERVICE_URI); + Task task = taskService.get(1); + Assert.assertEquals("Buy some coffee", task.getTitle()); } @Test public void testRESTCall() throws Exception { - waitPort(8080); - Thread.sleep(1000); - checkRESTCall(REST_SERVICE_URI); + waitWebPage(REST_SERVICE_URI); + final WebClient client = WebClient.create(REST_SERVICE_URI + "/1"); + client.accept(MediaType.APPLICATION_XML_TYPE); + org.apache.cxf.dosgi.samples.rest.Task task = tryTo("Call REST Resource", + new Callable<org.apache.cxf.dosgi.samples.rest.Task>() { + public org.apache.cxf.dosgi.samples.rest.Task call() throws Exception { + return client.get(org.apache.cxf.dosgi.samples.rest.Task.class); + } + } + ); + Assert.assertEquals("Buy some coffee", task.getTitle()); } @Test @@ -94,30 +99,21 @@ public class TestExportService extends AbstractDosgiTest { zk.close(); } - private void checkWsdl(URL wsdlURL) throws ParserConfigurationException, SAXException, IOException { + private void checkWsdl(final URL wsdlURL) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setValidating(false); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(wsdlURL.openStream()); + final DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = tryTo("Parse WSDL", new Callable<Document>() { + public Document call() throws Exception { + return db.parse(wsdlURL.openStream()); + } + }); + Element el = doc.getDocumentElement(); Assert.assertEquals("definitions", el.getLocalName()); Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/", el.getNamespaceURI()); Assert.assertEquals("TaskServiceService", el.getAttribute("name")); } - private void checkServiceCall(String serviceUri) { - TaskService taskService = TaskServiceProxyFactory.create(serviceUri); - Task task = taskService.get(1); - Assert.assertEquals("Buy some coffee", task.getTitle()); - } - - private void checkRESTCall(String restServiceUri) throws InterruptedException, TimeoutException { - waitWebPage(REST_SERVICE_URI); - WebClient client = WebClient.create(REST_SERVICE_URI + "/1"); - client.accept(MediaType.APPLICATION_XML_TYPE); - org.apache.cxf.dosgi.samples.rest.Task task = client.get(org.apache.cxf.dosgi.samples.rest.Task.class); - Assert.assertEquals("Buy some coffee", task.getTitle()); - } - } http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestImportService.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestImportService.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestImportService.java index 61517f3..21f49d9 100644 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestImportService.java +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestImportService.java @@ -28,7 +28,6 @@ import javax.inject.Inject; import org.apache.cxf.dosgi.samples.soap.Task; import org.apache.cxf.dosgi.samples.soap.TaskService; import org.apache.cxf.endpoint.Server; -import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.junit.After; import org.junit.Assert; @@ -42,9 +41,8 @@ import org.ops4j.pax.tinybundles.core.TinyBundles; import org.osgi.framework.Constants; /** - * Creates a service outside OSGi, - * announces the service via the xml based discovery. - * Checks that the service proxy is created by CXF DOSGi and can be called. + * Creates a service outside OSGi, announces the service via the xml based discovery. Checks that the service + * proxy is created by CXF DOSGi and can be called. */ @RunWith(PaxExam.class) public class TestImportService extends AbstractDosgiTest { @@ -92,16 +90,11 @@ public class TestImportService extends AbstractDosgiTest { private Server publishService() { System.out.println("Publishing service"); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader()); - JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); - factory.setServiceClass(TaskService.class); - factory.setAddress("http://localhost:9191/taskservice"); - factory.setServiceBean(new TestTaskServiceImpl()); - return factory.create(); - } finally { - Thread.currentThread().setContextClassLoader(cl); - } + JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); + factory.setServiceClass(TaskService.class); + factory.setAddress("http://localhost:9191/taskservice"); + factory.setServiceBean(new DummyTaskServiceImpl()); + return factory.create(); + } } http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestTaskServiceImpl.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestTaskServiceImpl.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestTaskServiceImpl.java deleted file mode 100644 index 72a16d5..0000000 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestTaskServiceImpl.java +++ /dev/null @@ -1,49 +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.itests.multi; - -import java.util.Collection; - -import org.apache.cxf.dosgi.samples.soap.Task; -import org.apache.cxf.dosgi.samples.soap.TaskService; - -public class TestTaskServiceImpl implements TaskService { - - @Override - public Task get(Integer id) { - return new Task(1, "test", ""); - } - - @Override - public void addOrUpdate(Task task) { - throw new UnsupportedOperationException(); - } - - @Override - public void delete(Integer id) { - throw new UnsupportedOperationException(); - - } - - @Override - public Collection<Task> getAll() { - throw new UnsupportedOperationException(); - } - -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/customintent/CustomIntentActivator.java ---------------------------------------------------------------------- diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/customintent/CustomIntentActivator.java b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/customintent/CustomIntentActivator.java index ec9db36..a3e3feb 100644 --- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/customintent/CustomIntentActivator.java +++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/customintent/CustomIntentActivator.java @@ -21,7 +21,7 @@ package org.apache.cxf.dosgi.itests.multi.customintent; import java.util.Dictionary; import java.util.Hashtable; -import org.apache.cxf.dosgi.itests.multi.TestTaskServiceImpl; +import org.apache.cxf.dosgi.itests.multi.DummyTaskServiceImpl; import org.apache.cxf.dosgi.samples.soap.TaskService; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -39,7 +39,7 @@ public class CustomIntentActivator implements BundleActivator { props2.put("org.apache.cxf.ws.address", "/taskservice"); props2.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*"); props2.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "myIntent"); - context.registerService(TaskService.class, new TestTaskServiceImpl(), props2); + context.registerService(TaskService.class, new DummyTaskServiceImpl(), props2); } public void stop(BundleContext context) throws Exception { http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/rest/api/pom.xml ---------------------------------------------------------------------- diff --git a/samples/rest/api/pom.xml b/samples/rest/api/pom.xml index 3c91d30..71187c1 100644 --- a/samples/rest/api/pom.xml +++ b/samples/rest/api/pom.xml @@ -22,7 +22,7 @@ <groupId>org.apache.cxf.dosgi.samples</groupId> <artifactId>cxf-dosgi-samples-rest-api</artifactId> <packaging>bundle</packaging> - <name>CXF DOSGi samples REST API</name> + <name>CXF DOSGi Samples REST API</name> <parent> <groupId>org.apache.cxf.dosgi</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/rest/client/pom.xml ---------------------------------------------------------------------- diff --git a/samples/rest/client/pom.xml b/samples/rest/client/pom.xml index bacde9d..32573ab 100644 --- a/samples/rest/client/pom.xml +++ b/samples/rest/client/pom.xml @@ -14,7 +14,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi-samples-rest-client</artifactId> <packaging>bundle</packaging> - <name>CXF DOSGi samples REST Client</name> + <name>CXF DOSGi Samples REST Client</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/rest/impl/pom.xml ---------------------------------------------------------------------- diff --git a/samples/rest/impl/pom.xml b/samples/rest/impl/pom.xml index dc18337..3886700 100644 --- a/samples/rest/impl/pom.xml +++ b/samples/rest/impl/pom.xml @@ -15,7 +15,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi-samples-rest-impl</artifactId> <packaging>bundle</packaging> - <name>CXF DOSGi samples REST Impl</name> + <name>CXF DOSGi Samples REST Impl</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/rest/pom.xml ---------------------------------------------------------------------- diff --git a/samples/rest/pom.xml b/samples/rest/pom.xml index b40e0f7..2e591ad 100644 --- a/samples/rest/pom.xml +++ b/samples/rest/pom.xml @@ -16,7 +16,7 @@ <groupId>org.apache.cxf.dosgi.samples</groupId> <artifactId>cxf-dosgi-samples-rest-parent</artifactId> <packaging>pom</packaging> - <name>CXF DOSGi samples REST Parent</name> + <name>CXF DOSGi Samples REST Parent</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/soap/api/pom.xml ---------------------------------------------------------------------- diff --git a/samples/soap/api/pom.xml b/samples/soap/api/pom.xml index 9468c1a..253de6c 100644 --- a/samples/soap/api/pom.xml +++ b/samples/soap/api/pom.xml @@ -22,7 +22,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi-samples-soap-api</artifactId> <packaging>bundle</packaging> - <name>CXF DOSGi samples SOAP API</name> + <name>CXF DOSGi Samples SOAP API</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/soap/impl/pom.xml ---------------------------------------------------------------------- diff --git a/samples/soap/impl/pom.xml b/samples/soap/impl/pom.xml index 2dfb07a..439ae3d 100644 --- a/samples/soap/impl/pom.xml +++ b/samples/soap/impl/pom.xml @@ -21,7 +21,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi-samples-soap-impl</artifactId> <packaging>bundle</packaging> - <name>CXF DOSGi samples SOAP Impl</name> + <name>CXF DOSGi Samples SOAP Impl</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5352c05d/samples/soap/pom.xml ---------------------------------------------------------------------- diff --git a/samples/soap/pom.xml b/samples/soap/pom.xml index 59801ad..adf4b8d 100644 --- a/samples/soap/pom.xml +++ b/samples/soap/pom.xml @@ -14,7 +14,7 @@ <modelVersion>4.0.0</modelVersion> <artifactId>cxf-dosgi-samples-soap-parent</artifactId> <packaging>pom</packaging> - <name>CXF DOSGi samples SOAP Parent</name> + <name>CXF DOSGi Samples SOAP Parent</name> <parent> <groupId>org.apache.cxf.dosgi.samples</groupId>
