X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FtestUtils%2FPingTest.java;h=4fb49595c316e84a5e9452f14bd6ebb7e82fd991;hb=9136e3e03b6881b32aada896be3241e46cbd33d9;hp=5095d680690f8eb776c92125aaf4471aee071356;hpb=3e123160ad59a2e1162518923965562ff947b6d1;p=gigi.git diff --git a/tests/org/cacert/gigi/testUtils/PingTest.java b/tests/org/cacert/gigi/testUtils/PingTest.java index 5095d680..4fb49595 100644 --- a/tests/org/cacert/gigi/testUtils/PingTest.java +++ b/tests/org/cacert/gigi/testUtils/PingTest.java @@ -1,6 +1,7 @@ package org.cacert.gigi.testUtils; import static org.junit.Assert.*; +import static org.junit.Assume.*; import java.io.IOException; import java.net.HttpURLConnection; @@ -15,12 +16,19 @@ import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.database.GigiResultSet; import org.cacert.gigi.pages.account.domain.DomainOverview; -import org.junit.Before; +import org.junit.After; +/** + * Base class for test suites that check extensively if the domain-ping + * functionality wroks as expected. + */ public abstract class PingTest extends ClientTest { + protected String csrf; + protected static void updateService(String token, String value, String action) throws IOException, MalformedURLException { String manage = getTestProps().getProperty("domain.manage"); + assumeNotNull(manage); String url = manage + "t1=" + token + "&t2=" + value + "&action=" + action; assertEquals(200, ((HttpURLConnection) new URL(url).openConnection()).getResponseCode()); } @@ -48,7 +56,9 @@ public abstract class PingTest extends ClientTest { String newcontent = IOUtils.readURL(cookie(u.openConnection(), cookie)); Pattern dlink = Pattern.compile(DomainOverview.PATH + "([0-9]+)'>"); Matcher m1 = dlink.matcher(newcontent); - m1.find(); + if ( !m1.find()) { + throw new Error(newcontent); + } URL u2 = new URL(u.toString() + m1.group(1)); return u2; } @@ -65,14 +75,8 @@ public abstract class PingTest extends ClientTest { return m; } - private static boolean first = true; - - @Before + @After public void purgeDbAfterTest() throws SQLException, IOException { - if (first) { - first = false; - return; - } purgeDatabase(); }