[jboss-cvs] JBossAS SVN: r94502 - in projects/jboss-osgi/trunk: testsuite/example/src/test/java/org/jboss/test/osgi/example/http and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 8 02:15:26 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-08 02:15:25 -0400 (Thu, 08 Oct 2009)
New Revision: 94502

Modified:
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppTestCase.java
Log:
Give WebApp some time to response

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2009-10-08 05:10:10 UTC (rev 94501)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2009-10-08 06:15:25 UTC (rev 94502)
@@ -160,7 +160,7 @@
     <property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
   </bean>
   <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
-    <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+    <property name="system"><inject bean="ClassLoaderSystem"/></property>
   </bean>
   <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java	2009-10-08 05:10:10 UTC (rev 94501)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/HttpServiceTestCase.java	2009-10-08 06:15:25 UTC (rev 94502)
@@ -59,7 +59,7 @@
       // Allow 10s for the HttpService to become available
       long timeout = 50;
       OSGiServiceReference sref = runtime.getServiceReference(HttpService.class.getName());
-      while (sref == null && (timeout--) > 0)
+      while (sref == null &&  0 < timeout--)
       {
          Thread.sleep(200);
          sref = runtime.getServiceReference(HttpService.class.getName());

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppTestCase.java	2009-10-08 05:10:10 UTC (rev 94501)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppTestCase.java	2009-10-08 06:15:25 UTC (rev 94502)
@@ -21,11 +21,12 @@
  */
 package org.jboss.test.osgi.example.webapp;
 
-//$Id: $
+//$Id:$
 
 import static org.junit.Assert.assertEquals;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URL;
 
@@ -64,26 +65,47 @@
    }
 
    @Test
+   public void testResourceAccess() throws Exception
+   {
+      assertEquals("Hello from Resource", getHttpResponse("/message.txt"));
+   }
+   
+   @Test
    public void testServletAccess() throws Exception
    {
-      URL url = new URL("http://" + runtime.getServerHost() + ":8090/example-webapp/servlet?test=plain");
-      BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
-      assertEquals("Hello from Servlet", br.readLine());
+      assertEquals("Hello from Servlet", getHttpResponse("/servlet?test=plain"));
    }
 
    @Test
    public void testServletInitProps() throws Exception
    {
-      URL url = new URL("http://" + runtime.getServerHost() + ":8090/example-webapp/servlet?test=initProp");
-      BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
-      assertEquals("initProp=SomeValue", br.readLine());
+      assertEquals("initProp=SomeValue", getHttpResponse("/servlet?test=initProp"));
    }
 
-   @Test
-   public void testResourceAccess() throws Exception
+   private String getHttpResponse(String reqPath) throws Exception
    {
-      URL url = new URL("http://" + runtime.getServerHost() + ":8090/example-webapp/message.txt");
-      BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
-      assertEquals("Hello from Resource", br.readLine());
+      URL url = new URL("http://" + runtime.getServerHost() + ":8090/example-webapp" + reqPath);
+      
+      int timeout = 50;
+      String line = null;
+      IOException lastException = null;
+      while (line == null && 0 < timeout--)
+      {
+         try
+         {
+            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+            line = br.readLine();
+         }
+         catch (IOException ex)
+         {
+            lastException = ex;
+            Thread.sleep(200);
+         }
+      }
+      
+      if (line == null && lastException != null)
+         throw lastException;
+      
+      return line;
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list