]> WPIA git - gigi.git/commitdiff
chg: Do not leak the DB connection when tests are done
authorBenny Baumann <BenBE1987@gmx.net>
Sun, 7 Aug 2016 00:52:30 +0000 (02:52 +0200)
committerBenny Baumann <BenBE1987@gmx.net>
Sun, 7 Aug 2016 11:49:51 +0000 (13:49 +0200)
This also helps to avoid warnings by the compiler about l being unused

Change-Id: Ia370ebf3e48b8309196aa61c2baa1301095ae40b

tests/org/cacert/gigi/testUtils/ConfiguredTest.java

index 892dfefee9f48bdf45de91be5fa01fadb6aeed53..fda87cf142377a806be0aa3109612e0dff29116a 100644 (file)
@@ -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.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;
 import org.junit.BeforeClass;
 
 import sun.security.pkcs10.PKCS10;
@@ -71,6 +72,8 @@ public abstract class ConfiguredTest {
         initEnvironment();
     }
 
         initEnvironment();
     }
 
+    private static Link l;
+
     public static Properties initEnvironment() throws IOException {
         TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
         if (envInited) {
     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);
             }
         }
                 throw new Error(e);
             }
         }
+
         return props;
         return props;
+    }
 
 
+    @AfterClass
+    public static void closeDBLink() {
+        if (l != null) {
+            l.close();
+            l = null;
+        }
     }
 
     private static Properties generateProps() throws Error {
     }
 
     private static Properties generateProps() throws Error {
@@ -164,8 +175,6 @@ public abstract class ConfiguredTest {
 
     static int count = 0;
 
 
     static int count = 0;
 
-    private static Link l;
-
     public static String createRandomIDString() {
         final char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
         final int idStringLength = 16;
     public static String createRandomIDString() {
         final char[] chars = "abcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
         final int idStringLength = 16;