You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2013/06/27 12:47:11 UTC
svn commit: r1497292 - in /cxf/dosgi/trunk/systests2/multi-bundle: pom.xml
src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
Author: cschneider
Date: Thu Jun 27 10:47:11 2013
New Revision: 1497292
URL: http://svn.apache.org/r1497292
Log:
DOSGI-195 Wait for service to be exported
Modified:
cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
Modified: cxf/dosgi/trunk/systests2/multi-bundle/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/pom.xml?rev=1497292&r1=1497291&r2=1497292&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/pom.xml Thu Jun 27 10:47:11 2013
@@ -62,14 +62,7 @@
<version>${exam.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-aether</artifactId>
- <version>1.5.0</version>
- <scope>test</scope>
- </dependency>
-
+
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java?rev=1497292&r1=1497291&r2=1497292&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java Thu Jun 27 10:47:11 2013
@@ -19,8 +19,11 @@
package org.apache.cxf.dosgi.systests2.multi;
import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.URL;
import java.util.concurrent.TimeoutException;
import org.apache.cxf.aegis.databinding.AegisDatabinding;
@@ -32,6 +35,8 @@ import org.osgi.framework.ServiceReferen
public class AbstractDosgiTest {
+ private static final int TIMEOUT = 20;
+
protected ServiceReference waitService(BundleContext bc, Class<?> cls, String filter, int timeout)
throws Exception {
ServiceReference[] refs;
@@ -53,7 +58,7 @@ public class AbstractDosgiTest {
}
protected void waitPort(int port) throws Exception {
- for (int i = 0; i < 20; i++) {
+ for (int i = 0; i < TIMEOUT; i++) {
Socket s = null;
try {
s = new Socket((String)null, port);
@@ -101,4 +106,26 @@ public class AbstractDosgiTest {
socket.close();
}
}
+
+ protected void waitWebPage(String urlSt) throws InterruptedException {
+ int status = 0;
+ int seconds = 0;
+ while (status != 200) {
+ try {
+ URL url = new URL(urlSt);
+ HttpURLConnection con = (HttpURLConnection)url.openConnection();
+ status = con.getResponseCode();
+ System.out.println("Waiting" + status);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ Thread.sleep(1000);
+ seconds++;
+ if (seconds > TIMEOUT) {
+ throw new RuntimeException("Timeout waiting for web page " + urlSt);
+ }
+ }
+ }
}
Modified: cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java?rev=1497292&r1=1497291&r2=1497292&view=diff
==============================================================================
--- cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java (original)
+++ cxf/dosgi/trunk/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java Thu Jun 27 10:47:11 2013
@@ -59,10 +59,9 @@ public class TestExportRestService exten
@Test
public void testEndpointAvailable() throws Exception {
+ waitWebPage("http://localhost:8080/greeter/greeter/greeting/Chris");
try {
- waitPort(8080);
- // wait for service to be exported
- Thread.sleep(2000);
+
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
GreeterService greeterService = JAXRSClientFactory.create("http://localhost:8080/greeter",
GreeterService.class);