]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/TestDomain.java
fix: ResultSet.getDate is often wrong as it fetches day-precision times
[gigi.git] / tests / org / cacert / gigi / TestDomain.java
1 package org.cacert.gigi;
2
3 import static org.junit.Assert.*;
4
5 import org.cacert.gigi.dbObjects.Domain;
6 import org.cacert.gigi.testUtils.ClientBusinessTest;
7 import org.junit.Test;
8
9 public class TestDomain extends ClientBusinessTest {
10
11     @Test
12     public void testDomain() throws InterruptedException, GigiApiException {
13         assertEquals(0, u.getDomains().length);
14         Domain d = new Domain(u, u, "v1example.org");
15         Domain[] domains = u.getDomains();
16         assertEquals(1, domains.length);
17         assertEquals("v1example.org", domains[0].getSuffix());
18         assertEquals(domains[0].getOwner().getId(), u.getId());
19         assertNotEquals(0, domains[0].getId());
20         assertNotEquals(0, d.getId());
21         assertEquals(d.getId(), domains[0].getId());
22
23         new Domain(u, u, "v2-example.org");
24
25         domains = u.getDomains();
26         assertEquals(2, domains.length);
27         if ( !domains[1].getSuffix().equals("v2-example.org")) {
28             Domain d1 = domains[0];
29             domains[0] = domains[1];
30             domains[1] = d1;
31         }
32         assertEquals("v2-example.org", domains[1].getSuffix());
33         assertEquals(domains[0].getOwner().getId(), u.getId());
34         assertEquals(domains[1].getOwner().getId(), u.getId());
35         assertNotEquals(0, domains[0].getId());
36         assertNotEquals(0, d.getId());
37         assertEquals(d.getId(), domains[0].getId());
38
39     }
40
41     @Test
42     public void testDoubleDomain() throws InterruptedException, GigiApiException {
43         new Domain(u, u, "dub-example.org");
44         try {
45             new Domain(u, u, "dub-example.org");
46             fail("expected exception, was able to insert domain (with different case) a second time");
47         } catch (GigiApiException e) {
48             // expected
49         }
50     }
51
52     @Test
53     public void testDoubleDomainCase() throws InterruptedException, GigiApiException {
54         Domain d = new Domain(u, u, "dub2-ExaMple.Org");
55         assertEquals("dub2-example.org", d.getSuffix());
56         try {
57             new Domain(u, u, "duB2-eXample.oRG");
58             fail("expected exception, was able to insert domain (with different case) a second time");
59         } catch (GigiApiException e) {
60             // expected
61         }
62     }
63
64     @Test
65     public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
66         Domain d = new Domain(u, u, "delexample.org");
67         d.delete();
68         new Domain(u, u, "delexample.org");
69     }
70
71 }