[jboss-cvs] JBossAS SVN: r95603 - projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 27 05:20:37 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-27 05:20:36 -0400 (Tue, 27 Oct 2009)
New Revision: 95603
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/AbstractWebAppTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppExtenderTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppInterceptorTestCase.java
Log:
Reopen: NPE in JettyServerHandlerCollection
http://issues.ops4j.org/browse/PAXWEB-182
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/AbstractWebAppTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/AbstractWebAppTestCase.java 2009-10-27 07:01:07 UTC (rev 95602)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/AbstractWebAppTestCase.java 2009-10-27 09:20:36 UTC (rev 95603)
@@ -24,13 +24,14 @@
// $Id$
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import org.jboss.osgi.testing.OSGiTest;
/**
- * A test that deployes a WAR bundle
+ * Abstract base class for webapp example.
*
* @author thomas.diesler at jboss.com
* @since 06-Oct-2009
@@ -39,8 +40,35 @@
{
protected String getHttpResponse(String reqPath) throws Exception
{
- URL url = new URL("http://" + getServerHost() + ":8090/example-webapp" + reqPath);
- BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
- return br.readLine();
+ return getHttpResponse(reqPath, 0);
}
+
+ protected String getHttpResponse(String reqPath, int timeout) throws Exception
+ {
+ int fraction = 200;
+ int steps = Math.max(timeout / fraction, 1);
+
+ String line = null;
+ IOException lastException = null;
+ while (line == null && 0 < steps--)
+ {
+ try
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/example-webapp" + reqPath);
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ line = br.readLine();
+ br.close();
+ }
+ catch (IOException ex)
+ {
+ lastException = ex;
+ Thread.sleep(fraction);
+ }
+ }
+
+ if (line == null && lastException != null)
+ throw lastException;
+
+ return line;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppExtenderTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppExtenderTestCase.java 2009-10-27 07:01:07 UTC (rev 95602)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppExtenderTestCase.java 2009-10-27 09:20:36 UTC (rev 95603)
@@ -25,8 +25,6 @@
import static org.junit.Assert.assertEquals;
-import java.io.IOException;
-
import org.jboss.osgi.spi.capability.HttpServiceCapability;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTestHelper;
@@ -37,6 +35,10 @@
/**
* A test that deployes a WAR bundle
*
+ * Due to the nature of asynchronous event processing by the
+ * extender pattern, we cannot assume that the endpoint is
+ * available immediately
+ *
* @author thomas.diesler at jboss.com
* @since 06-Oct-2009
*/
@@ -67,49 +69,21 @@
@Test
public void testResourceAccess() throws Exception
{
- String line = getHttpResponse("/message.txt");
+ String line = getHttpResponse("/message.txt", 5000);
assertEquals("Hello from Resource", line);
}
@Test
public void testServletAccess() throws Exception
{
- String line = getHttpResponse("/servlet?test=plain");
+ String line = getHttpResponse("/servlet?test=plain", 5000);
assertEquals("Hello from Servlet", line);
}
@Test
public void testServletInitProps() throws Exception
{
- String line = getHttpResponse("/servlet?test=initProp");
+ String line = getHttpResponse("/servlet?test=initProp", 5000);
assertEquals("initProp=SomeValue", line);
}
-
- // Due to the nature of asynchronous event processing by the
- // extender pattern, we cannot assume that the endpoint is
- // available immediately
- protected String getHttpResponse(String reqPath) throws Exception
- {
- int timeout = 25;
- String line = null;
- IOException lastException = null;
- while (line == null && 0 < timeout--)
- {
- try
- {
- line = super.getHttpResponse(reqPath);
- }
- catch (IOException ex)
- {
- lastException = ex;
- }
- if (line == null)
- Thread.sleep(200);
- }
-
- if (line == null && lastException != null)
- throw lastException;
-
- return line;
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppInterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppInterceptorTestCase.java 2009-10-27 07:01:07 UTC (rev 95602)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppInterceptorTestCase.java 2009-10-27 09:20:36 UTC (rev 95603)
@@ -65,7 +65,8 @@
@Test
public void testResourceAccess() throws Exception
{
- String line = getHttpResponse("/message.txt");
+ // FIXME: http://issues.ops4j.org/browse/PAXWEB-182
+ String line = getHttpResponse("/message.txt", 30000);
assertEquals("Hello from Resource", line);
}
More information about the jboss-cvs-commits
mailing list