james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1151076 - in /james/mailbox/trunk: api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
Date Tue, 26 Jul 2011 12:40:56 GMT
Author: eric
Date: Tue Jul 26 12:40:55 2011
New Revision: 1151076

URL: http://svn.apache.org/viewvc?rev=1151076&view=rev
Log:
Move more test to the abstract so other implementations benefit from and reactivate the test
on inbox deletion which still breaks the maildir test (MAILBOX-73)

Modified:
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java
    james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java

Modified: james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java?rev=1151076&r1=1151075&r2=1151076&view=diff
==============================================================================
--- james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java
(original)
+++ james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/AbstractMailboxManagerTest.java
Tue Jul 26 12:40:55 2011
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.james.mailbox;
 
+import java.io.ByteArrayInputStream;
 import java.io.UnsupportedEncodingException;
+import java.util.Date;
+
+import javax.mail.Flags;
 
 import junit.framework.Assert;
 
@@ -37,7 +41,8 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class AbstractMailboxManagerTest {
     
-    private final static String USER1 = "USER1";
+    private final static String USER_1 = "USER_1";
+    private final static String USER_2 = "USER_2";
 
     /**
      * The mailboxManager that needs to get instanciated
@@ -50,8 +55,8 @@ public abstract class AbstractMailboxMan
 
         setMailboxManager(new MockMailboxManager(getMailboxManager()).getMockMailboxManager());
         
-        MailboxSession session = getMailboxManager().createSystemSession(USER1, LoggerFactory.getLogger("Mock"));
-        Assert.assertEquals(USER1, session.getUser().getUserName());
+        MailboxSession session = getMailboxManager().createSystemSession(USER_1, LoggerFactory.getLogger("Mock"));
+        Assert.assertEquals(USER_1, session.getUser().getUserName());
         
         getMailboxManager().startProcessingRequest(session);
         
@@ -77,12 +82,10 @@ public abstract class AbstractMailboxMan
         getMailboxManager().deleteMailbox(inbox, session);
         Assert.assertFalse(getMailboxManager().mailboxExists(inbox, session));
         
-        // TODO Temporary commented to avoid maildir test failure
-
-//        Assert.assertTrue(getMailboxManager().mailboxExists(inboxSubMailbox, session));
+        Assert.assertTrue(getMailboxManager().mailboxExists(inboxSubMailbox, session));
         
-//        getMailboxManager().deleteMailbox(inboxSubMailbox, session);
-//        Assert.assertFalse(getMailboxManager().mailboxExists(inboxSubMailbox, session));
+        getMailboxManager().deleteMailbox(inboxSubMailbox, session);
+        Assert.assertFalse(getMailboxManager().mailboxExists(inboxSubMailbox, session));
 
         getMailboxManager().logout(session, false);
         getMailboxManager().endProcessingRequest(session);
@@ -108,6 +111,18 @@ public abstract class AbstractMailboxMan
 
     }
     
+    
+    @Test
+    public void testCreateSubFolderDirectly() throws BadCredentialsException, MailboxException
{ 
+
+        MailboxSession session = getMailboxManager().createSystemSession(USER_2, LoggerFactory.getLogger("Test"));
+        getMailboxManager().createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE,
USER_2, "Trash"), session);
+        getMailboxManager().createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE,
USER_2, "INBOX.testfolder"), session);
+        
+        getMailboxManager().getMailbox(MailboxPath.inbox(session), session).appendMessage(new
ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false,
new Flags());
+
+    }
+
     /**
      * Implement this method to create the mailboxManager.
      * 

Modified: james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java?rev=1151076&r1=1151075&r2=1151076&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
(original)
+++ james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
Tue Jul 26 12:40:55 2011
@@ -18,30 +18,22 @@
  ****************************************************************/
 package org.apache.james.mailbox.maildir;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.fail;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.util.Date;
-
-import javax.mail.Flags;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.james.mailbox.AbstractMailboxManagerTest;
 import org.apache.james.mailbox.BadCredentialsException;
-import org.apache.james.mailbox.MailboxConstants;
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.MailboxExistsException;
-import org.apache.james.mailbox.AbstractMailboxManagerTest;
-import org.apache.james.mailbox.MailboxPath;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.LoggerFactory;
 
 /**
  * MaildirMailboxManagerTest that extends the StoreMailboxManagerTest.
@@ -127,7 +119,6 @@ public class MaildirMailboxManagerTest e
                 try {
                     deleteMaildirTestDirectory();
                 } catch (IOException e) {
-                    // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
             }
@@ -136,9 +127,12 @@ public class MaildirMailboxManagerTest e
 
     }
 
-    // See MAILBOX-31
+    /* (non-Javadoc)
+     * @see org.apache.james.mailbox.AbstractMailboxManagerTest#testCreateSubFolderDirectly()
+     */
     @Test
-    public void testCreateSubFolder() throws MailboxException {
+    @Override
+    public void testCreateSubFolderDirectly() throws BadCredentialsException, MailboxException
{ 
 
         if (OsDetector.isWindows()) {
             System.out.println("Maildir tests work only on non-windows systems. So skip the
test");
@@ -147,17 +141,19 @@ public class MaildirMailboxManagerTest e
             MaildirStore store = new MaildirStore(MAILDIR_HOME + "/%domain/%user", new JVMMailboxPathLocker());
             MaildirMailboxSessionMapperFactory mf = new MaildirMailboxSessionMapperFactory(store);
             StoreMailboxManager<Integer> manager = new StoreMailboxManager<Integer>(mf,
null, new JVMMailboxPathLocker());
-    
             manager.init();
+            setMailboxManager(manager);
+            try {
+                super.testCreateSubFolderDirectly();
+            } finally {
+                try {
+                    deleteMaildirTestDirectory();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+       
     
-            String user = "test@localhost";
-            MailboxSession session = manager.createSystemSession(user, LoggerFactory.getLogger("Test"));
-            manager.createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE, user,
"Trash"), session);
-            manager.createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE, user,
"INBOX.testfolder"), session);
-            
-            // this threw NPE
-            manager.getMailbox(MailboxPath.inbox(session), session).appendMessage(new ByteArrayInputStream("Subject:
test\r\n\r\ntestmail".getBytes()), new Date(), session, false, new Flags());
-
         }
 
     }
@@ -182,7 +178,6 @@ public class MaildirMailboxManagerTest e
             try {
                 deleteMaildirTestDirectory();
             } catch (IOException e) {
-                // TODO Auto-generated catch block
                 e.printStackTrace();
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message