1 package org.cacert.gigi;
3 import static org.junit.Assert.*;
5 import org.cacert.gigi.dbObjects.Domain;
6 import org.cacert.gigi.dbObjects.User;
7 import org.cacert.gigi.testUtils.ManagedTest;
10 public class TestDomain extends ManagedTest {
15 int uid = createVerifiedUser("fn", "ln", createUniqueName() + "pr@test-email.de", TEST_PASSWORD);
16 us = User.getById(uid);
20 public void testDomain() throws InterruptedException, GigiApiException {
21 assertEquals(0, us.getDomains().length);
22 Domain d = new Domain(us, us, "v1example.org");
23 Domain[] domains = us.getDomains();
24 assertEquals(1, domains.length);
25 assertEquals("v1example.org", domains[0].getSuffix());
26 assertEquals(domains[0].getOwner().getId(), us.getId());
27 assertNotEquals(0, domains[0].getId());
28 assertNotEquals(0, d.getId());
29 assertEquals(d.getId(), domains[0].getId());
31 new Domain(us, us, "v2-example.org");
33 domains = us.getDomains();
34 assertEquals(2, domains.length);
35 if ( !domains[1].getSuffix().equals("v2-example.org")) {
36 Domain d1 = domains[0];
37 domains[0] = domains[1];
40 assertEquals("v2-example.org", domains[1].getSuffix());
41 assertEquals(domains[0].getOwner().getId(), us.getId());
42 assertEquals(domains[1].getOwner().getId(), us.getId());
43 assertNotEquals(0, domains[0].getId());
44 assertNotEquals(0, d.getId());
45 assertEquals(d.getId(), domains[0].getId());
50 public void testDoubleDomain() throws InterruptedException, GigiApiException {
51 new Domain(us, us, "dub-example.org");
53 new Domain(us, us, "dub-example.org");
54 fail("expected exception, was able to insert domain (with different case) a second time");
55 } catch (GigiApiException e) {
61 public void testDoubleDomainCase() throws InterruptedException, GigiApiException {
62 Domain d = new Domain(us, us, "dub2-ExaMple.Org");
63 assertEquals("dub2-example.org", d.getSuffix());
65 new Domain(us, us, "duB2-eXample.oRG");
66 fail("expected exception, was able to insert domain (with different case) a second time");
67 } catch (GigiApiException e) {
73 public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
74 Domain d = new Domain(us, us, "delexample.org");
76 new Domain(us, us, "delexample.org");