[prev in list] [next in list] [prev in thread] [next in thread]
List: james-dev
Subject: [04/11] james-project git commit: MAILBOX-291 Allow to pass list as arguments of JPATestCluster
From: btellier () apache ! org
Date: 2017-03-31 1:47:20
Message-ID: aeb82d93f31e413286f88ca4517a0f51 () git ! apache ! org
[Download RAW message or body]
MAILBOX-291 Allow to pass list as arguments of JPATestCluster
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6c8a92c3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6c8a92c3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6c8a92c3
Branch: refs/heads/master
Commit: 6c8a92c3e759f15f33eeff58306c262feb748b14
Parents: 4fdd56a
Author: benwa <btellier@linagora.com>
Authored: Wed Mar 29 18:55:25 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Mar 31 08:46:25 2017 +0700
----------------------------------------------------------------------
.../james/backends/jpa/JpaTestCluster.java | 13 +++++++++++--
.../james/mailbox/jpa/JPAMailboxFixture.java | 20 ++++++++++++--------
2 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/6c8a92c3/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
----------------------------------------------------------------------
diff --git a/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java \
b/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java \
index f175ac6..59c66d1 100644
--- a/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
+++ b/backends-common/jpa/src/test/java/org/apache/james/backends/jpa/JpaTestCluster.java
@@ -19,8 +19,8 @@
package org.apache.james.backends.jpa;
-import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -30,10 +30,15 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableList;
public class JpaTestCluster {
public static JpaTestCluster create(Class<?>... clazz) {
+ return create(ImmutableList.copyOf(clazz));
+ }
+
+ public static JpaTestCluster create(List<Class<?>> clazz) {
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("openjpa.ConnectionDriverName", \
org.h2.Driver.class.getName());
properties.put("openjpa.ConnectionURL", \
"jdbc:h2:mem:mailboxintegration;DB_CLOSE_DELAY=-1"); // Memory H2 database @@ -46,7 \
+51,7 @@ public class JpaTestCluster {
properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, \
PrettyPrintLineLength=72"); properties.put("openjpa.MetaDataFactory", "jpa(Types=" +
Joiner.on(";").join(
- FluentIterable.from(Arrays.asList(clazz))
+ FluentIterable.from(clazz)
.transform(toFQDN()))
+ ")");
return new JpaTestCluster(OpenJPAPersistence.getEntityManagerFactory(properties));
@@ -72,6 +77,10 @@ public class JpaTestCluster {
}
public void clear(String... tables) {
+ clear(ImmutableList.copyOf(tables));
+ }
+
+ public void clear(List<String> tables) {
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
for(String tableName: tables) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/6c8a92c3/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxFixture.java \
b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxFixture.java index \
9749be3..154da10 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxFixture.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JPAMailboxFixture.java
@@ -19,6 +19,8 @@
package org.apache.james.mailbox.jpa;
+import java.util.List;
+
import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
import org.apache.james.mailbox.jpa.mail.model.JPAMailboxAnnotation;
import org.apache.james.mailbox.jpa.mail.model.JPAProperty;
@@ -32,36 +34,38 @@ import \
org.apache.james.mailbox.jpa.quota.model.MaxUserMessageCount; import \
org.apache.james.mailbox.jpa.quota.model.MaxUserStorage; import \
org.apache.james.mailbox.jpa.user.model.JPASubscription;
+import com.google.common.collect.ImmutableList;
+
public interface JPAMailboxFixture {
- Class<?>[] MAILBOX_PERSISTANCE_CLASSES = new Class[] {JPAMailbox.class,
+ List<Class<?>> MAILBOX_PERSISTANCE_CLASSES = \
ImmutableList.<Class<?>>of(JPAMailbox.class, AbstractJPAMailboxMessage.class,
JPAMailboxMessage.class,
JPAProperty.class,
JPAUserFlag.class,
JPAMailboxAnnotation.class,
JPASubscription.class
- };
+ );
- Class<?>[] QUOTA_PERSISTANCE_CLASSES = new Class[] {
+ List<Class<?>> QUOTA_PERSISTANCE_CLASSES = ImmutableList.<Class<?>>of(
MaxDefaultMessageCount.class,
MaxDefaultStorage.class,
MaxUserMessageCount.class,
MaxUserStorage.class,
JpaCurrentQuota.class
- };
+ );
- String[] MAILBOX_TABLE_NAMES = new String[] {"JAMES_MAIL_USERFLAG",
+ List<String> MAILBOX_TABLE_NAMES = \
ImmutableList.<String>of("JAMES_MAIL_USERFLAG", "JAMES_MAIL_PROPERTY",
"JAMES_MAILBOX_ANNOTATION",
"JAMES_MAILBOX",
- "JAMES_MAIL"};
+ "JAMES_MAIL");
- String[] QUOTA_TABLES_NAMES = new String[] {
+ List<String> QUOTA_TABLES_NAMES = ImmutableList.<String>of(
"JAMES_MAX_DEFAULT_MESSAGE_COUNT",
"JAMES_MAX_DEFAULT_STORAGE",
"JAMES_MAX_USER_MESSAGE_COUNT",
"JAMES_MAX_USER_STORAGE",
"JAMES_QUOTA_CURRENTQUOTA"
- };
+ );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic