Author: eric
Date: Sun Dec 26 10:30:21 2010
New Revision: 1052856
URL: http://svn.apache.org/viewvc?rev=1052856&view=rev
Log:
Use instance instead of static for before/after tests - fix the assert expected
value - make setMailboxManager abstract.
Modified:
james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/functional/maildir/MaildirMailboxManagerTest.java
Modified:
james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
URL:
http://svn.apache.org/viewvc/james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java?rev=1052856&r1=1052855&r2=1052856&view=diff
==============================================================================
---
james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
(original)
+++
james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
Sun Dec 26 10:30:21 2010
@@ -50,27 +50,32 @@ public abstract class MailboxManagerTest
* The mailboxManager that needs to get instanciated
* by the mailbox implementations.
*/
- private static MailboxManager mailboxManager;
+ protected MailboxManager mailboxManager;
/**
* Number of Domains to be created in the Mailbox Manager.
*/
- private static final int DOMAIN_COUNT = 5;
+ private static final int DOMAIN_COUNT = 3;
/**
* Number of Users (with INBOX) to be created in the Mailbox Manager.
*/
- private static final int USER_COUNT = 5;
+ private static final int USER_COUNT = 3;
/**
- * Number of Sub Mailboxes (mailbox in another mailbox) to be created in
the Mailbox Manager.
+ * Number of Sub Mailboxes (mailbox in INBOX) to be created in the Mailbox
Manager.
*/
- private static final int SUB_MAILBOXES_COUNT = 5;
+ private static final int SUB_MAILBOXES_COUNT = 3;
+
+ /**
+ * Number of Sub Sub Mailboxes (mailbox in a mailbox under INBOX) to be
created in the Mailbox Manager.
+ */
+ private static final int SUB_SUB_MAILBOXES_COUNT = 3;
/**
* Number of Messages per Mailbox to be created in the Mailbox Manager.
*/
- private static final int MESSAGE_PER_MAILBOX_COUNT = 5;
+ private static final int MESSAGE_PER_MAILBOX_COUNT = 3;
/**
* Create some INBOXes and their sub mailboxes and assert list() method.
@@ -87,8 +92,8 @@ public abstract class MailboxManagerTest
getMailboxManager().startProcessingRequest(mailboxSession);
Assert.assertEquals(DOMAIN_COUNT *
(USER_COUNT + // INBOX
- USER_COUNT * MESSAGE_PER_MAILBOX_COUNT + // INBOX.SUB_FOLDER
- USER_COUNT * MESSAGE_PER_MAILBOX_COUNT *
MESSAGE_PER_MAILBOX_COUNT), // INBOX.SUB_FOLDER.SUBSUB_FOLDER
+ USER_COUNT * SUB_MAILBOXES_COUNT + // INBOX.SUB_FOLDER
+ USER_COUNT * SUB_MAILBOXES_COUNT * SUB_SUB_MAILBOXES_COUNT),
// INBOX.SUB_FOLDER.SUBSUB_FOLDER
getMailboxManager().list(mailboxSession).size());
}
@@ -118,14 +123,14 @@ public abstract class MailboxManagerTest
for (int k=0; k < SUB_MAILBOXES_COUNT; k++) {
- folderName = folderName + ".SUB_FOLDER_" + k;
- mailboxPath = new MailboxPath("#private", user,
folderName);
+ String subFolderName = folderName + ".SUB_FOLDER_" + k;
+ mailboxPath = new MailboxPath("#private", user,
subFolderName);
createMailbox(mailboxSession, mailboxPath);
- for (int l=0; l < SUB_MAILBOXES_COUNT; l++) {
+ for (int l=0; l < SUB_SUB_MAILBOXES_COUNT; l++) {
- folderName = folderName + ".SUBSUB_FOLDER_" + l;
- mailboxPath = new MailboxPath("#private", user,
folderName);
+ String subSubfolderName = subFolderName +
".SUBSUB_FOLDER_" + l;
+ mailboxPath = new MailboxPath("#private", user,
subSubfolderName);
createMailbox(mailboxSession, mailboxPath);
}
@@ -163,9 +168,7 @@ public abstract class MailboxManagerTest
/**
* Setter to inject the mailboxManager.
*/
- protected static void setMailboxManager(MailboxManager mailboxManager) {
- MailboxManagerTest.mailboxManager = mailboxManager;
- }
+ protected abstract void setMailboxManager(MailboxManager mailboxManager);
/**
* Accessor to the mailboxManager.
@@ -173,7 +176,7 @@ public abstract class MailboxManagerTest
* @return the mailboxManager instance.
* @throws IllegalStateException in case of null mailboxManager
*/
- protected static MailboxManager getMailboxManager() {
+ protected MailboxManager getMailboxManager() {
if (mailboxManager == null) {
throw new IllegalStateException("Please setMailboxManager with a
non null value before requesting getMailboxManager()");
}
Modified:
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
URL:
http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java?rev=1052856&r1=1052855&r2=1052856&view=diff
==============================================================================
---
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
(original)
+++
james/mailbox/trunk/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerTest.java
Sun Dec 26 10:30:21 2010
@@ -19,19 +19,18 @@
package org.apache.james.mailbox.jcr;
import java.io.File;
-import java.io.UnsupportedEncodingException;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.jackrabbit.core.RepositoryImpl;
import org.apache.jackrabbit.core.config.RepositoryConfig;
import org.apache.james.mailbox.BadCredentialsException;
import org.apache.james.mailbox.MailboxException;
+import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManagerTest;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.jcr.mail.JCRCachingUidProvider;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.After;
+import org.junit.Before;
import org.xml.sax.InputSource;
/**
@@ -50,8 +49,8 @@ public class JCRMailboxManagerTest exten
*
* @throws Exception
*/
- @BeforeClass
- public static void setup() throws Exception {
+ @Before
+ public void setup() throws Exception {
new File(JACKRABBIT_HOME).delete();
@@ -74,15 +73,21 @@ public class JCRMailboxManagerTest exten
/**
- * @throws BadCredentialsException
- * @throws MailboxException
+ * Close system session and shutdown system repository.
*/
- @AfterClass
- public static void tearDown() throws BadCredentialsException,
MailboxException {
+ @After
+ public void tearDown() throws BadCredentialsException, MailboxException {
MailboxSession session =
getMailboxManager().createSystemSession("test", new SimpleLog("Test"));
session.close();
repository.shutdown();
new File(JACKRABBIT_HOME).delete();
}
+
+ /* (non-Javadoc)
+ * @see
org.apache.james.mailbox.MailboxManagerTest#setMailboxManager(org.apache.james.mailbox.MailboxManager)
+ */
+ protected void setMailboxManager(MailboxManager mailboxManager) {
+ this.mailboxManager = mailboxManager;
+ }
}
Modified:
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
URL:
http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java?rev=1052856&r1=1052855&r2=1052856&view=diff
==============================================================================
---
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
(original)
+++
james/mailbox/trunk/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxManagerTest.java
Sun Dec 26 10:30:21 2010
@@ -25,6 +25,7 @@ import javax.persistence.EntityManagerFa
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.james.mailbox.BadCredentialsException;
import org.apache.james.mailbox.MailboxException;
+import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManagerTest;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.jpa.mail.JPACachingUidProvider;
@@ -38,8 +39,8 @@ import org.apache.james.mailbox.jpa.mail
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.jpa.user.model.JPASubscription;
import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
/**
* JPAMailboxManagerTest that extends the StoreMailboxManagerTest.
@@ -56,8 +57,8 @@ public class JPAMailboxManagerTest exten
*
* @throws Exception
*/
- @BeforeClass
- public static void setup() throws Exception {
+ @Before
+ public void setup() throws Exception {
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("openjpa.ConnectionDriverName", "org.h2.Driver");
@@ -89,11 +90,18 @@ public class JPAMailboxManagerTest exten
* @throws MailboxException
* @throws BadCredentialsException
*/
- @AfterClass
- public static void tearDown() throws BadCredentialsException,
MailboxException {
+ @After
+ public void tearDown() throws BadCredentialsException, MailboxException {
MailboxSession session =
getMailboxManager().createSystemSession("test", new SimpleLog("Test"));
session.close();
entityManagerFactory.close();
}
+ /* (non-Javadoc)
+ * @see
org.apache.james.mailbox.MailboxManagerTest#setMailboxManager(org.apache.james.mailbox.MailboxManager)
+ */
+ protected void setMailboxManager(MailboxManager mailboxManager) {
+ this.mailboxManager = mailboxManager;
+ }
+
}
Modified:
james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/functional/maildir/MaildirMailboxManagerTest.java
URL:
http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/functional/maildir/MaildirMailboxManagerTest.java?rev=1052856&r1=1052855&r2=1052856&view=diff
==============================================================================
---
james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/functional/maildir/MaildirMailboxManagerTest.java
(original)
+++
james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/functional/maildir/MaildirMailboxManagerTest.java
Sun Dec 26 10:30:21 2010
@@ -19,17 +19,19 @@
package org.apache.james.mailbox.functional.maildir;
import java.io.File;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.apache.commons.io.FileUtils;
import org.apache.james.mailbox.BadCredentialsException;
import org.apache.james.mailbox.MailboxException;
+import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManagerTest;
import org.apache.james.mailbox.maildir.MaildirMailboxManager;
import org.apache.james.mailbox.maildir.MaildirMailboxSessionMapperFactory;
import org.apache.james.mailbox.maildir.MaildirStore;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -44,8 +46,8 @@ public class MaildirMailboxManagerTest e
*
* @throws Exception
*/
- @BeforeClass
- public static void setup() throws Exception {
+ @Before
+ public void setup() throws Exception {
FileUtils.deleteDirectory(new File(MAILDIR_HOME));
MaildirStore store = new MaildirStore(MAILDIR_HOME + "/%domain/%user");
MaildirMailboxSessionMapperFactory mf = new
MaildirMailboxSessionMapperFactory(store);
@@ -53,14 +55,13 @@ public class MaildirMailboxManagerTest e
}
/**
- * Close the system session and entityManagerFactory
+ * Delete Maildir directory after test.
*
- * @throws MailboxException
- * @throws BadCredentialsException
+ * @throws IOException
*/
- @AfterClass
- public static void tearDown() throws BadCredentialsException,
MailboxException {
-// FileUtils.deleteDirectory(new File(MAILDIR_HOME));
+ @After
+ public void tearDown() throws IOException {
+ FileUtils.deleteDirectory(new File(MAILDIR_HOME));
}
/* (non-Javadoc)
@@ -75,4 +76,11 @@ public class MaildirMailboxManagerTest e
}
}
+ /* (non-Javadoc)
+ * @see
org.apache.james.mailbox.MailboxManagerTest#setMailboxManager(org.apache.james.mailbox.MailboxManager)
+ */
+ protected void setMailboxManager(MailboxManager mailboxManager) {
+ this.mailboxManager = mailboxManager;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]