]> WPIA git - gigi.git/blob - tests/club/wpia/gigi/pages/account/TestDomain.java
fix: ResultSet.getDate is often wrong as it fetches day-precision times
[gigi.git] / tests / club / wpia / gigi / pages / account / TestDomain.java
1 package club.wpia.gigi.pages.account;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.net.URLEncoder;
7
8 import org.junit.Test;
9
10 import club.wpia.gigi.dbObjects.Domain;
11 import club.wpia.gigi.pages.account.domain.DomainOverview;
12 import club.wpia.gigi.testUtils.ClientTest;
13
14 public class TestDomain extends ClientTest {
15
16     public TestDomain() throws IOException {}
17
18     @Test
19     public void testAdd() throws IOException {
20         assertNull(addDomain(cookie, uniq + ".de"));
21         assertNotNull(addDomain(cookie, uniq + ".de"));
22     }
23
24     @Test
25     public void testInvalid() throws IOException {
26         assertNotNull(addDomain(cookie, uniq + ".invalid"));
27     }
28
29     @Test
30     public void testHighFinancialValue() throws IOException {
31         assertNotNull(addDomain(cookie, "google.com"));
32     }
33
34     @Test
35     public void testDelete() throws IOException {
36         String domain = uniq + ".de";
37         assertNull(addDomain(cookie, domain));
38         Domain d0 = Domain.searchDomain(domain);
39         assertNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d0.getId(), 0));
40         // double delete
41         assertNotNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d0.getId(), 0));
42         // re-add
43         assertNull(addDomain(cookie, domain));
44         Domain d1 = Domain.searchDomain(domain);
45         assertNotEquals(d0.getId(), d1.getId());
46         assertNull(executeBasicWebInteraction(cookie, DomainOverview.PATH, "delete=" + d1.getId(), 0));
47     }
48
49     public static String addDomain(String session, String domain) throws IOException {
50         return executeBasicWebInteraction(session, DomainOverview.PATH, "adddomain&newdomain=" + URLEncoder.encode(domain, "UTF-8"), 1);
51     }
52 }