From 20c4322f87aa9abe1cf9147f5734f2df32eb8fa3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sun, 2 Jul 2017 20:58:51 +0200 Subject: [PATCH] upd: allow clean testcase setup and teardown 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 | 13 ++++++++++++- tests/club/wpia/gigi/testUtils/ManagedTest.java | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java index 711007a0..483f25e1 100644 --- a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java +++ b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java @@ -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); diff --git a/tests/club/wpia/gigi/testUtils/ManagedTest.java b/tests/club/wpia/gigi/testUtils/ManagedTest.java index f4ad8522..fd602b83 100644 --- a/tests/club/wpia/gigi/testUtils/ManagedTest.java +++ b/tests/club/wpia/gigi/testUtils/ManagedTest.java @@ -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(); -- 2.39.2