SLING-5452 - also check for console readiness before uninstalling bundle, contributed by Thierry Ygé, thanks!

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1743378 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java b/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
index 846216e..c1a9a84 100644
--- a/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
+++ b/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
@@ -199,9 +199,9 @@
                 try {
                     httpClient.runTests(testPath, testReadyTimeoutSeconds);
                 } finally {
-                    httpClient.uninstallBundle(bundleSymbolicName);
+                    httpClient.uninstallBundle(bundleSymbolicName, webConsoleReadyTimeoutSeconds);
                 }
             }
         };
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
index e805e45..c90bff0 100644
--- a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
+++ b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
@@ -109,12 +109,14 @@
         }
     }
 
-    void uninstallBundle(String bundleSymbolicName) throws MalformedURLException, IOException {
+    void uninstallBundle(String bundleSymbolicName, int webConsoleReadyTimeoutSeconds) throws MalformedURLException, IOException {
         // equivalent of
         // curl -u admin:admin -F action=uninstall http://localhost:8080/system/console/bundles/$N
         final String url = baseUrl + "/system/console/bundles/" + bundleSymbolicName;
         final HttpURLConnection c = (HttpURLConnection)new URL(url).openConnection();
         
+        waitForStatus(url, 200, webConsoleReadyTimeoutSeconds * 1000);
+        
         try {
             setConnectionCredentials(c);
             new MultipartAdapter(c, CHARSET)
@@ -187,4 +189,4 @@
             c.disconnect();
         }
     }
-}
\ No newline at end of file
+}