]> WPIA git - gigi.git/commitdiff
upd: allow clean testcase setup and teardown
authorFelix Dörre <felix@dogcraft.de>
Sun, 2 Jul 2017 18:58:51 +0000 (20:58 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 4 Jul 2017 18:51:22 +0000 (20:51 +0200)
This change allows executing of multiple ManagedTests in one JVM.
This is generally good to have clean code, but more practically it
enables re-running test cases multiple times. This is very useful for
debugging rarely occurring problems.

Change-Id: I0657c057f7504c51be32d2ed28bc8e33cd3a0b7c

tests/club/wpia/gigi/testUtils/ConfiguredTest.java
tests/club/wpia/gigi/testUtils/ManagedTest.java

index 711007a047eafe94703507f2ddac532650e8a8eb..483f25e1d80a99deb37029e538ce4840ae7f61fc 100644 (file)
@@ -78,6 +78,15 @@ public abstract class ConfiguredTest {
     public static Properties initEnvironment() throws IOException {
         TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         if (envInited) {
+            try {
+                synchronized (ConfiguredTest.class) {
+                    if (l == null) {
+                        l = DatabaseConnection.newLink(false);
+                    }
+                }
+            } catch (InterruptedException e) {
+                throw new Error(e);
+            }
             return generateProps();
         }
         envInited = true;
@@ -94,7 +103,9 @@ public abstract class ConfiguredTest {
             DatabaseConnection.init(testProps);
             try {
                 synchronized (ConfiguredTest.class) {
-                    l = DatabaseConnection.newLink(false);
+                    if (l == null) {
+                        l = DatabaseConnection.newLink(false);
+                    }
                 }
             } catch (InterruptedException e) {
                 throw new Error(e);
index f4ad8522899d4bc34c4c559658db86ecfe41a94e..fd602b8302750d2ad4de834182f8863097254f90 100644 (file)
@@ -196,6 +196,14 @@ public class ManagedTest extends ConfiguredTest {
         String type = testProps.getProperty("type");
         ter.destroy();
         if (type.equals("local")) {
+            if (testProps.getProperty("withSigner", "false").equals("true")) {
+                try {
+                    SimpleSigner.stopSigner();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+            inited = false;
             return;
         }
         gigi.destroy();
@@ -204,6 +212,7 @@ public class ManagedTest extends ConfiguredTest {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
+        inited = false;
     }
 
     public final String uniq = createUniqueName();