[DOSGI-249] Small fixes
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>
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 @@
lastException = null;
} catch (Throwable e) {
lastException = e;
- e.printStackTrace();
}
try {
Thread.sleep(1000);
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/DummyTaskServiceImpl.java
similarity index 95%
rename from itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestTaskServiceImpl.java
rename to itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/DummyTaskServiceImpl.java
index 72a16d5..82b0a31 100644
--- 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/DummyTaskServiceImpl.java
@@ -23,7 +23,7 @@
import org.apache.cxf.dosgi.samples.soap.Task;
import org.apache.cxf.dosgi.samples.soap.TaskService;
-public class TestTaskServiceImpl implements TaskService {
+public class DummyTaskServiceImpl implements TaskService {
@Override
public Task get(Integer id) {
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 @@
@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 @@
.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());
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.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 @@
@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 @@
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());
- }
-
}
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 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.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 @@
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();
+
}
}
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 @@
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 @@
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 {
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>
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>
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>
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>
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>
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>
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>