import java.util.regex.Matcher;
import java.util.regex.Pattern;
-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.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);
}
protected void waitForPings(int count) throws SQLException, InterruptedException {
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT COUNT(*) FROM domainPinglog");
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < 10000) {
- GigiResultSet rs = ps.executeQuery();
- rs.next();
- if (rs.getInt(1) >= count) {
- break;
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT COUNT(*) FROM `domainPinglog`")) {
+ long start = System.currentTimeMillis();
+ while (System.currentTimeMillis() - start < 10000) {
+ GigiResultSet rs = ps.executeQuery();
+ rs.next();
+ if (rs.getInt(1) >= count) {
+ break;
+ }
+ Thread.sleep(200);
}
- Thread.sleep(200);
}
}
URLConnection openConnection = u.openConnection();
openConnection.setRequestProperty("Cookie", cookie);
openConnection.setDoOutput(true);
- openConnection.getOutputStream().write(content.getBytes());
+ openConnection.getOutputStream().write(content.getBytes("UTF-8"));
openConnection.getHeaderField("Location");
String newcontent = IOUtils.readURL(cookie(u.openConnection(), cookie));