]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/testUtils/ManagedTest.java
upd: cleanup detection of error-messages in testCases
[gigi.git] / tests / org / cacert / gigi / testUtils / ManagedTest.java
index 9f22edf1940493f53af1c3900122fc0a5426beeb..f379b3f204d2d99f2f256be79e4173d34fcbce04 100644 (file)
@@ -43,6 +43,7 @@ import org.cacert.gigi.dbObjects.Domain;
 import org.cacert.gigi.dbObjects.DomainPingType;
 import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.dbObjects.Group;
+import org.cacert.gigi.dbObjects.Job;
 import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.Manager;
@@ -52,6 +53,7 @@ import org.cacert.gigi.testUtils.TestEmailReceiver.TestMail;
 import org.cacert.gigi.util.DatabaseManager;
 import org.cacert.gigi.util.ServerConstants;
 import org.cacert.gigi.util.SimpleSigner;
+import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -108,6 +110,9 @@ public class ManagedTest extends ConfiguredTest {
                 String[] parts = testProps.getProperty("mail").split(":", 2);
                 ter = new TestEmailReceiver(new InetSocketAddress(parts[0], Integer.parseInt(parts[1])));
                 ter.start();
+                if (testProps.getProperty("withSigner", "false").equals("true")) {
+                    SimpleSigner.runSigner();
+                }
                 return;
             }
             url = testProps.getProperty("name.www") + ":" + testProps.getProperty("serverPort.https");
@@ -156,6 +161,11 @@ public class ManagedTest extends ConfiguredTest {
 
     }
 
+    protected void await(Job j) throws InterruptedException {
+        SimpleSigner.ping();
+        j.waitFor(5000);
+    }
+
     public static void purgeDatabase() throws SQLException, IOException {
         System.out.print("... resetting Database");
         long ms = System.currentTimeMillis();
@@ -249,8 +259,16 @@ public class ManagedTest extends ConfiguredTest {
         return d;
     }
 
+    public static org.hamcrest.Matcher<String> hasError() {
+        return CoreMatchers.containsString("<div class='bg-danger error-msgs'>");
+    }
+
+    public static org.hamcrest.Matcher<String> hasNoError() {
+        return CoreMatchers.not(hasError());
+    }
+
     public static String fetchStartErrorMessage(String d) throws IOException {
-        String formFail = "<div class='formError'>";
+        String formFail = "<div class='bg-danger error-msgs'>";
         int idx = d.indexOf(formFail);
         if (idx == -1) {
             return null;
@@ -321,7 +339,7 @@ public class ManagedTest extends ConfiguredTest {
     }
 
     public static void makeAssurer(int uid) {
-        try (GigiPreparedStatement ps1 = new GigiPreparedStatement("INSERT INTO `cats_passed` SET `user_id`=?, `variant_id`=?")) {
+        try (GigiPreparedStatement ps1 = new GigiPreparedStatement("INSERT INTO cats_passed SET user_id=?, variant_id=?, language='en_EN', version=1")) {
             ps1.setInt(1, uid);
             ps1.setInt(2, CATS.ASSURER_CHALLENGE_ID);
             ps1.execute();