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, "v1example.org");
23 assertEquals(0, d.getId());
25 Domain[] domains = us.getDomains();
26 assertEquals(1, domains.length);
27 assertEquals("v1example.org", domains[0].getSuffix());
28 assertEquals(domains[0].getOwner().getId(), us.getId());
29 assertNotEquals(0, domains[0].getId());
30 assertNotEquals(0, d.getId());
31 assertEquals(d.getId(), domains[0].getId());
33 Domain d2 = new Domain(us, "v2-example.org");
34 assertEquals(0, d2.getId());
37 domains = us.getDomains();
38 assertEquals(2, domains.length);
39 if ( !domains[1].getSuffix().equals("v2-example.org")) {
40 Domain d1 = domains[0];
41 domains[0] = domains[1];
44 assertEquals("v2-example.org", domains[1].getSuffix());
45 assertEquals(domains[0].getOwner().getId(), us.getId());
46 assertEquals(domains[1].getOwner().getId(), us.getId());
47 assertNotEquals(0, domains[0].getId());
48 assertNotEquals(0, d.getId());
49 assertEquals(d.getId(), domains[0].getId());
54 public void testDoubleDomain() throws InterruptedException, GigiApiException {
55 Domain d = new Domain(us, "dub-example.org");
58 Domain d2 = new Domain(us, "dub-example.org");
60 fail("expected exception");
61 } catch (GigiApiException e) {
67 public void testDoubleDomainDelete() throws InterruptedException, GigiApiException {
68 Domain d = new Domain(us, "delexample.org");
71 Domain d2 = new Domain(us, "delexample.org");
76 public void testDoubleInsertDomain() throws InterruptedException, GigiApiException {
77 Domain d = new Domain(us, "dins-example.org");
81 fail("expected exception");
82 } catch (GigiApiException e) {