]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/account/TestMailManagement.java
UPD: Cleanup User-class.
[gigi.git] / tests / org / cacert / gigi / pages / account / TestMailManagement.java
index 190dd5a0237e4ba98d1751ba7ff9e99f7747a456..bf97c26964c5c7a697d8fd6309eb973757f313d2 100644 (file)
@@ -12,16 +12,11 @@ import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
-import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.pages.account.mail.MailOverview;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestMailManagement extends ManagedTest {
-
-    private User u = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@example.org", TEST_PASSWORD));
-
-    private String cookie;
+public class TestMailManagement extends ClientTest {
 
     private String path = MailOverview.DEFAULT_PATH;
 
@@ -36,9 +31,9 @@ public class TestMailManagement extends ManagedTest {
     }
 
     @Test
-    public void testMailAddInternalFaulty() {
+    public void testMailAddInternalFaulty() throws GigiApiException {
         try {
-            new EmailAddress(u, "kurti ");
+            new EmailAddress(u, "kurti ", Locale.ENGLISH);
             fail();
         } catch (IllegalArgumentException e) {
             // Intended.
@@ -80,8 +75,7 @@ public class TestMailManagement extends ManagedTest {
 
     @Test
     public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
-        EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld");
-        adrr.insert(Language.getInstance(Locale.ENGLISH));
+        EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld", Locale.ENGLISH);
         assertNotNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId()));
         assertNotEquals(User.getById(u.getId()).getEmail(), adrr.getAddress());
         getMailReciever().clearMails();
@@ -136,4 +130,10 @@ public class TestMailManagement extends ManagedTest {
         u2 = User.getById(u2.getId());
         assertNotEquals(u2.getEmails().length, 0);
     }
+
+    @Test
+    public void testMailDeleteWebPrimary() throws MalformedURLException, UnsupportedEncodingException, IOException {
+        assertNotNull(executeBasicWebInteraction(cookie, path, "delete&delid[]=" + u.getEmails()[0].getId(), 0));
+        assertNotEquals(u.getEmails().length, 0);
+    }
 }