X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FtestUtils%2FConfiguredTest.java;h=90b3468291d4695dc00e4b829633c4fef80a09e0;hp=f8098ed8f0da886944600f118fd7e1551e1ee55e;hb=d7be034f96e06985f57d86d2779c434276b5bd4d;hpb=8c54b92566e72198941713fb384490e4c29e22ad diff --git a/tests/org/cacert/gigi/testUtils/ConfiguredTest.java b/tests/org/cacert/gigi/testUtils/ConfiguredTest.java index f8098ed8..90b34682 100644 --- a/tests/org/cacert/gigi/testUtils/ConfiguredTest.java +++ b/tests/org/cacert/gigi/testUtils/ConfiguredTest.java @@ -12,8 +12,11 @@ import java.security.KeyPairGenerator; import java.security.Signature; import java.util.Properties; import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.cacert.gigi.database.DatabaseConnection; +import org.cacert.gigi.database.DatabaseConnection.Link; import org.cacert.gigi.util.PEM; import org.junit.BeforeClass; @@ -47,6 +50,11 @@ public abstract class ConfiguredTest { } if ( !DatabaseConnection.isInited()) { DatabaseConnection.init(testProps); + try { + l = DatabaseConnection.newLink(false); + } catch (InterruptedException e) { + throw new Error(e); + } } } @@ -93,8 +101,19 @@ public abstract class ConfiguredTest { static int count = 0; + private static Link l; + public static String createUniqueName() { return "test" + System.currentTimeMillis() + "a" + (count++) + "u"; } + public static int countRegex(String text, String pattern) { + Pattern p = Pattern.compile(pattern); + Matcher m = p.matcher(text); + int i = 0; + while (m.find()) { + i++; + } + return i; + } }