You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/02/10 14:49:31 UTC

[karaf] branch karaf-4.2.x updated: Fix the WebTest once and forever...

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new d14fca7  Fix the WebTest once and forever...
     new e2219f5  Merge pull request #1292 from grgrzybek/karaf-4.2.x
d14fca7 is described below

commit d14fca7b01b6e76b1e567409485fdff5f48a4248
Author: Grzegorz Grzybek <gr...@gmail.com>
AuthorDate: Wed Feb 10 15:01:13 2021 +0100

    Fix the WebTest once and forever...
---
 .../src/test/java/org/apache/karaf/itests/WebTest.java     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/itests/test/src/test/java/org/apache/karaf/itests/WebTest.java b/itests/test/src/test/java/org/apache/karaf/itests/WebTest.java
index 13b6ed6..85f4588 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/WebTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/WebTest.java
@@ -29,6 +29,7 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
+import java.io.StringReader;
 import java.lang.management.ManagementFactory;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -69,6 +70,17 @@ public class WebTest extends BaseTest {
             Thread.sleep(500);
             listOutput = executeCommand("web:list");
         }
+        int bundleId = -1;
+        try (BufferedReader reader = new BufferedReader(new StringReader(listOutput))) {
+            String line = null;
+            while ((line = reader.readLine()) != null) {
+                if (line.contains("Deployed") && line.contains("karaf-war-example-webapp")) {
+                    String id = line.substring(0, line.indexOf(" "));
+                    bundleId = Integer.parseInt(id);
+                    break;
+                }
+            }
+        }
         URL url = new URL("http://localhost:" + getHttpPort() + "/test");
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setDoInput(true);
@@ -83,7 +95,7 @@ public class WebTest extends BaseTest {
         System.out.println(buffer.toString());
         assertContains("Hello World!", buffer.toString());
 
-        System.out.println(executeCommand("web:uninstall 132"));
+        System.out.println(executeCommand("web:uninstall " + bundleId));
         listOutput = executeCommand("web:list");
         System.out.println(listOutput);
         while (listOutput.contains("/test")) {