From: Benny Baumann Date: Sun, 7 Aug 2016 00:52:30 +0000 (+0200) Subject: chg: Do not leak the DB connection when tests are done X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=0d9465248c016d99ac04e10b34d141a5811fac6f chg: Do not leak the DB connection when tests are done This also helps to avoid warnings by the compiler about l being unused Change-Id: Ia370ebf3e48b8309196aa61c2baa1301095ae40b --- diff --git a/tests/org/cacert/gigi/testUtils/ConfiguredTest.java b/tests/org/cacert/gigi/testUtils/ConfiguredTest.java index 892dfefe..fda87cf1 100644 --- a/tests/org/cacert/gigi/testUtils/ConfiguredTest.java +++ b/tests/org/cacert/gigi/testUtils/ConfiguredTest.java @@ -39,6 +39,7 @@ import org.cacert.gigi.util.PEM; import org.cacert.gigi.util.PasswordHash; import org.cacert.gigi.util.ServerConstants; import org.cacert.gigi.util.TimeConditions; +import org.junit.AfterClass; import org.junit.BeforeClass; import sun.security.pkcs10.PKCS10; @@ -71,6 +72,8 @@ public abstract class ConfiguredTest { initEnvironment(); } + private static Link l; + public static Properties initEnvironment() throws IOException { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if (envInited) { @@ -94,8 +97,16 @@ public abstract class ConfiguredTest { throw new Error(e); } } + return props; + } + @AfterClass + public static void closeDBLink() { + if (l != null) { + l.close(); + l = null; + } } private static Properties generateProps() throws Error { @@ -164,8 +175,6 @@ public abstract class ConfiguredTest { static int count = 0; - private static Link l; - public static String createRandomIDString() { final char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray(); final int idStringLength = 16;