From: Felix Dörre Date: Thu, 28 Aug 2014 13:35:01 +0000 (+0200) Subject: More DNS-ping and email ping failtests. X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=7f7a599fb3855b7056f0a79bfb73c393f8b21c12 More DNS-ping and email ping failtests. +profiling output for "purging Database" --- diff --git a/tests/org/cacert/gigi/ping/TestDNS.java b/tests/org/cacert/gigi/ping/TestDNS.java index 4ee94743..cf154199 100644 --- a/tests/org/cacert/gigi/ping/TestDNS.java +++ b/tests/org/cacert/gigi/ping/TestDNS.java @@ -29,7 +29,7 @@ import org.junit.Test; public class TestDNS extends ManagedTest { @Test - public void testDNSSanity() throws IOException, NamingException { + public void dnsSanity() throws IOException, NamingException { String token = RandomToken.generateToken(16); String value = RandomToken.generateToken(16); @@ -40,22 +40,35 @@ public class TestDNS extends ManagedTest { } @Test - public void testEmailAndDNSSuccess() throws IOException, InterruptedException, SQLException, NamingException { + public void emailAndDNSSuccess() throws IOException, InterruptedException, SQLException, NamingException { testEmailAndDNS(0, 0, true, true); } @After - public void test() throws SQLException, IOException { + public void purgeDbAfterTest() throws SQLException, IOException { purgeDatabase(); } @Test - public void testEmailAndDNSFail() throws IOException, InterruptedException, SQLException, NamingException { + public void dnsFail() throws IOException, InterruptedException, SQLException, NamingException { testEmailAndDNS(1, 0, false, true); - purgeDatabase(); + } + + @Test + public void dnsContentFail() throws IOException, InterruptedException, SQLException, NamingException { testEmailAndDNS(2, 0, false, true); } + @Test + public void emailFail() throws IOException, InterruptedException, SQLException, NamingException { + testEmailAndDNS(0, 1, true, false); + } + + @Test + public void emailAndDNSFail() throws IOException, InterruptedException, SQLException, NamingException { + testEmailAndDNS(2, 1, false, false); + } + public void testEmailAndDNS(int dnsVariant, int emailVariant, boolean successDNS, boolean successMail) throws IOException, InterruptedException, SQLException, NamingException { String email = createUniqueName() + "@example.org"; createVerifiedUser("a", "b", email, TEST_PASSWORD); @@ -93,8 +106,10 @@ public class TestDNS extends ManagedTest { URL u2 = new URL(u.toString() + m1.group(1)); TestMail mail = getMailReciever().recieve(); - String link = mail.extractLink(); - new URL(link).openConnection().getHeaderField(""); + if (emailVariant == 0) { + String link = mail.extractLink(); + new URL(link).openConnection().getHeaderField(""); + } PreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT COUNT(*) FROM domainPinglog"); while (true) { diff --git a/tests/org/cacert/gigi/testUtils/ManagedTest.java b/tests/org/cacert/gigi/testUtils/ManagedTest.java index 77822f52..637b272a 100644 --- a/tests/org/cacert/gigi/testUtils/ManagedTest.java +++ b/tests/org/cacert/gigi/testUtils/ManagedTest.java @@ -150,7 +150,8 @@ public class ManagedTest { } public static void purgeDatabase() throws SQLException, IOException { - System.out.println("... purging Database"); + System.out.print("... purging Database"); + long ms = System.currentTimeMillis(); try { DatabaseManager.run(new String[] { testProps.getProperty("sql.driver"), testProps.getProperty("sql.url"), testProps.getProperty("sql.user"), testProps.getProperty("sql.password") @@ -158,6 +159,7 @@ public class ManagedTest { } catch (ClassNotFoundException e) { e.printStackTrace(); } + System.out.println(" in " + (System.currentTimeMillis() - ms) + " ms"); } private static Properties generateMainProps() {