Author: andygumbrecht
Date: Thu Jul 24 01:55:49 2014
New Revision: 1612979

URL: http://svn.apache.org/r1612979
Log:
Retry a few times

Modified:
    
tomee/tomee/branches/tomee-1.7.x/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java

Modified: 
tomee/tomee/branches/tomee-1.7.x/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java?rev=1612979&r1=1612978&r2=1612979&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/TomEEMavenPluginTest.java
 Thu Jul 24 01:55:49 2014
@@ -22,6 +22,8 @@ import org.apache.openejb.maven.plugin.U
 import org.junit.Rule;
 import org.junit.Test;
 
+import java.io.IOException;
+import java.net.URI;
 import java.net.URL;
 
 import static org.hamcrest.CoreMatchers.containsString;
@@ -36,6 +38,26 @@ public class TomEEMavenPluginTest {
 
     @Test
     public void simpleStart() throws Exception {
-        assertThat(IO.slurp(new URL(url + "/docs")), containsString("Apache 
Tomcat"));
+        final String slurp = slurp(URI.create(url + "/docs").toURL(), 5);
+        assertThat(slurp, containsString("Apache Tomcat"));
+    }
+
+    private String slurp(final URL url, int attempts) throws IOException {
+        try {
+            return IO.slurp(url);
+        } catch (final IOException e) {
+            if (attempts < 1) {
+                throw e;
+            } else {
+                try {
+                    Thread.sleep(1000);
+                    return slurp(url, --attempts);
+                } catch (final InterruptedException ie) {
+                    //
+                }
+            }
+        }
+
+        return "";
     }
 }


Reply via email to