cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r703120 - /cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
Date Thu, 09 Oct 2008 10:33:16 GMT
Author: sergeyb
Date: Thu Oct  9 03:33:15 2008
New Revision: 703120

URL: http://svn.apache.org/viewvc?rev=703120&view=rev
Log:
DOSGI : removing a plain Thread.sleep call in BasicPublishHook test

Modified:
    cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java

Modified: cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java?rev=703120&r1=703119&r2=703120&view=diff
==============================================================================
--- cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
(original)
+++ cxf/sandbox/dosgi/systests/basic/src/test/java/org/apache/cxf/dosgi/systests/basic/BasicPublishHookTest.java
Thu Oct  9 03:33:15 2008
@@ -18,11 +18,14 @@
   */
 package org.apache.cxf.dosgi.systests.basic;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.jar.Manifest;
 
-
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.dosgi.samples.pojo.hello.GreeterException;
 import org.apache.cxf.dosgi.samples.pojo.hello.GreeterService;
@@ -106,11 +109,12 @@
         ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
         installBundle("org.apache.cxf", "cxf-dosgi-ri-samples-simple-pojo-impl", null, "jar");
-        Thread.sleep(20000);
-        // do the invocation using a CXF api 
+        
         // TODO : get this address using a DistributionProvider interface
         String address = "http://localhost:9005/greeter";
+        waitForEndpoint(address);
         
+        //do the invocation using a CXF api 
         GreeterService greeter1 = null;
         try {
             ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
@@ -125,6 +129,28 @@
             
     }
     
+    private void waitForEndpoint(String address) throws Exception {
+        
+        URL wsdlURL = new URL(address + "?wsdl");
+        
+        for (int counter = 1; counter <= 10; counter++) {
+            Thread.sleep(2000);
+            try {
+                BufferedReader is = new BufferedReader(
+                                        new InputStreamReader(wsdlURL.openStream()));
+                String line;
+                while ((line = is.readLine()) != null) {
+                    if (line.contains("definitions")) {
+                        System.out.println("Waited for endpoint for " + counter * 2 + " secs");
+                        return;
+                    }
+                }
+            } catch (IOException ex) {
+                // continue
+            }
+        }
+    }
+    
     private void useService(GreeterService greeter) throws Exception {
         assertNotNull(greeter);
         



Mime
View raw message