james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [5/5] james-project git commit: MAILBOX-267 ModSeqProvider and UidProvider should have all distinct tests and data definition
Date Mon, 02 May 2016 08:28:53 GMT
MAILBOX-267 ModSeqProvider and UidProvider should have all distinct tests and data definition


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0395ee41
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0395ee41
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0395ee41

Branch: refs/heads/master
Commit: 0395ee41b18912047e051d92bf29245bb7516009
Parents: f1d8c0d
Author: Matthieu Baechler <matthieu.baechler@linagora.com>
Authored: Tue Apr 19 16:09:47 2016 +0200
Committer: Matthieu Baechler <matthieu.baechler@linagora.com>
Committed: Mon May 2 10:25:02 2016 +0200

----------------------------------------------------------------------
 .../modules/CassandraModSeqModule.java          |  68 +++++++++
 .../modules/CassandraUidAndModSeqModule.java    |  73 ----------
 .../cassandra/modules/CassandraUidModule.java   |  68 +++++++++
 .../cassandra/CassandraMailboxManagerTest.java  |   6 +-
 ...assandraMailboxSessionMapperFactoryTest.java |   7 +-
 .../cassandra/mail/CassandraMapperProvider.java |   6 +-
 .../mail/CassandraModSeqProviderTest.java       | 103 +++++++++++++
 .../mail/CassandraUidAndModSeqProviderTest.java | 146 -------------------
 .../mail/CassandraUidProviderTest.java          | 103 +++++++++++++
 .../cassandra/host/CassandraHostSystem.java     |   6 +-
 .../modules/mailbox/CassandraMailboxModule.java |   3 +-
 11 files changed, 361 insertions(+), 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraModSeqModule.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraModSeqModule.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraModSeqModule.java
new file mode 100644
index 0000000..76b6f14
--- /dev/null
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraModSeqModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.cassandra.modules;
+
+import static com.datastax.driver.core.DataType.bigint;
+import static com.datastax.driver.core.DataType.timeuuid;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.backends.cassandra.components.CassandraIndex;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.backends.cassandra.components.CassandraTable;
+import org.apache.james.backends.cassandra.components.CassandraType;
+import org.apache.james.mailbox.cassandra.table.CassandraMessageModseqTable;
+
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+
+public class CassandraModSeqModule implements CassandraModule {
+
+    private final List<CassandraTable> tables;
+    private final List<CassandraIndex> index;
+    private final List<CassandraType> types;
+
+    public CassandraModSeqModule() {
+        tables = Arrays.asList(
+            new CassandraTable(CassandraMessageModseqTable.TABLE_NAME,
+                SchemaBuilder.createTable(CassandraMessageModseqTable.TABLE_NAME)
+                    .ifNotExists()
+                    .addPartitionKey(CassandraMessageModseqTable.MAILBOX_ID, timeuuid())
+                    .addColumn(CassandraMessageModseqTable.NEXT_MODSEQ, bigint())));
+        index = Collections.emptyList();
+        types = Collections.emptyList();
+    }
+
+    @Override
+    public List<CassandraTable> moduleTables() {
+        return tables;
+    }
+
+    @Override
+    public List<CassandraIndex> moduleIndex() {
+        return index;
+    }
+
+    @Override
+    public List<CassandraType> moduleTypes() {
+        return types;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidAndModSeqModule.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidAndModSeqModule.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidAndModSeqModule.java
deleted file mode 100644
index 65b2d84..0000000
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidAndModSeqModule.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.cassandra.modules;
-
-import com.datastax.driver.core.schemabuilder.SchemaBuilder;
-import org.apache.james.backends.cassandra.components.CassandraIndex;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.backends.cassandra.components.CassandraTable;
-import org.apache.james.backends.cassandra.components.CassandraType;
-import org.apache.james.mailbox.cassandra.table.CassandraMessageModseqTable;
-import org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static com.datastax.driver.core.DataType.bigint;
-import static com.datastax.driver.core.DataType.timeuuid;
-
-public class CassandraUidAndModSeqModule implements CassandraModule {
-
-    private final List<CassandraTable> tables;
-    private final List<CassandraIndex> index;
-    private final List<CassandraType> types;
-
-    public CassandraUidAndModSeqModule() {
-        tables = Arrays.asList(
-            new CassandraTable(CassandraMessageUidTable.TABLE_NAME,
-                SchemaBuilder.createTable(CassandraMessageUidTable.TABLE_NAME)
-                    .ifNotExists()
-                    .addPartitionKey(CassandraMessageUidTable.MAILBOX_ID, timeuuid())
-                    .addColumn(CassandraMessageUidTable.NEXT_UID, bigint())),
-            new CassandraTable(CassandraMessageModseqTable.TABLE_NAME,
-                SchemaBuilder.createTable(CassandraMessageModseqTable.TABLE_NAME)
-                    .ifNotExists()
-                    .addPartitionKey(CassandraMessageModseqTable.MAILBOX_ID, timeuuid())
-                    .addColumn(CassandraMessageModseqTable.NEXT_MODSEQ, bigint())));
-        index = Collections.emptyList();
-        types = Collections.emptyList();
-    }
-
-    @Override
-    public List<CassandraTable> moduleTables() {
-        return tables;
-    }
-
-    @Override
-    public List<CassandraIndex> moduleIndex() {
-        return index;
-    }
-
-    @Override
-    public List<CassandraType> moduleTypes() {
-        return types;
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidModule.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidModule.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidModule.java
new file mode 100644
index 0000000..4b5dd4d
--- /dev/null
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/modules/CassandraUidModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.cassandra.modules;
+
+import static com.datastax.driver.core.DataType.bigint;
+import static com.datastax.driver.core.DataType.timeuuid;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.backends.cassandra.components.CassandraIndex;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.backends.cassandra.components.CassandraTable;
+import org.apache.james.backends.cassandra.components.CassandraType;
+import org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable;
+
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+
+public class CassandraUidModule implements CassandraModule {
+
+    private final List<CassandraTable> tables;
+    private final List<CassandraIndex> index;
+    private final List<CassandraType> types;
+
+    public CassandraUidModule() {
+        tables = Arrays.asList(
+            new CassandraTable(CassandraMessageUidTable.TABLE_NAME,
+                SchemaBuilder.createTable(CassandraMessageUidTable.TABLE_NAME)
+                    .ifNotExists()
+                    .addPartitionKey(CassandraMessageUidTable.MAILBOX_ID, timeuuid())
+                    .addColumn(CassandraMessageUidTable.NEXT_UID, bigint())));
+        index = Collections.emptyList();
+        types = Collections.emptyList();
+    }
+
+    @Override
+    public List<CassandraTable> moduleTables() {
+        return tables;
+    }
+
+    @Override
+    public List<CassandraIndex> moduleIndex() {
+        return index;
+    }
+
+    @Override
+    public List<CassandraType> moduleTypes() {
+        return types;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
index 412c254..5f0371b 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
@@ -29,7 +29,8 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
@@ -48,7 +49,8 @@ public class CassandraMailboxManagerTest extends AbstractMailboxManagerTest
{
         new CassandraMailboxModule(),
         new CassandraMessageModule(),
         new CassandraMailboxCounterModule(),
-        new CassandraUidAndModSeqModule(),
+        new CassandraUidModule(),
+        new CassandraModSeqModule(),
         new CassandraSubscriptionModule()));
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
index 11e40c2..9e60854 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
@@ -23,10 +23,12 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
@@ -42,7 +44,8 @@ import org.slf4j.LoggerFactory;
  * 
  */
 public class CassandraMailboxSessionMapperFactoryTest {
-    private static final CassandraCluster CLUSTER = CassandraCluster.create(new CassandraUidAndModSeqModule());
+    private static final CassandraCluster CLUSTER = CassandraCluster.create(
+            new CassandraModuleComposite(new CassandraModSeqModule(), new CassandraUidModule()));
     private final static Logger LOG = LoggerFactory.getLogger(CassandraMailboxSessionMapperFactoryTest.class);
 
     @Before

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index 428cc5a..bc21830 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -8,7 +8,8 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
@@ -22,7 +23,8 @@ public class CassandraMapperProvider implements MapperProvider<CassandraId>
{
         new CassandraMailboxModule(),
         new CassandraMessageModule(),
         new CassandraMailboxCounterModule(),
-        new CassandraUidAndModSeqModule()));
+        new CassandraModSeqModule(),
+        new CassandraUidModule()));
 
     @Override
     public MailboxMapper<CassandraId> createMailboxMapper() throws MailboxException
{

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
new file mode 100644
index 0000000..f0d116a
--- /dev/null
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.cassandra.mail;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+
+import java.util.stream.LongStream;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.github.fge.lambdas.Throwing;
+
+public class CassandraModSeqProviderTest {
+
+    private static final CassandraCluster CASSANDRA = CassandraCluster.create(new CassandraModuleComposite(
+        new CassandraAclModule(),
+        new CassandraMailboxModule(),
+        new CassandraModSeqModule()));
+    
+    private static final int MAX_RETRY = 100;
+    
+    private CassandraModSeqProvider modSeqProvider;
+    private CassandraMailboxMapper mapper;
+    private SimpleMailbox<CassandraId> mailbox;
+
+    @Before
+    public void setUpClass() throws Exception {
+        CASSANDRA.ensureAllTables();
+        modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
+        mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(),
MAX_RETRY);
+        MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
+        mailbox = new SimpleMailbox<>(path, 1234);
+        mapper.save(mailbox);
+    }
+    
+    @After
+    public void cleanUp() {
+        CASSANDRA.clearAllTables();
+    }
+
+    @Test
+    public void highestModSeqShouldRetrieveValueStoredNextModSeq() throws Exception {
+        int nbEntries = 100;
+        long result = modSeqProvider.highestModSeq(null, mailbox);
+        assertEquals(0, result);
+        LongStream.range(0, nbEntries)
+            .forEach(Throwing.longConsumer(value -> {
+                        long uid = modSeqProvider.nextModSeq(null, mailbox);
+                        assertThat(uid).isEqualTo(modSeqProvider.highestModSeq(null, mailbox));
+                })
+            );
+    }
+
+    @Test
+    public void nextModSeqShouldIncrementValueByOne() throws Exception {
+        int nbEntries = 100;
+        long lastUid = modSeqProvider.highestModSeq(null, mailbox);
+        LongStream.range(lastUid + 1, lastUid + nbEntries)
+            .forEach(Throwing.longConsumer(value -> {
+                        long result = modSeqProvider.nextModSeq(null, mailbox);
+                        assertThat(value).isEqualTo(result);
+                })
+            );
+    }
+
+    @Test
+    public void nextModSeqShouldGenerateUniqueValuesWhenParallelCalls() throws Exception
{
+        int nbEntries = 100;
+        long nbValues = LongStream.range(0, nbEntries)
+            .parallel()
+            .map(Throwing.longUnaryOperator(x -> modSeqProvider.nextModSeq(null, mailbox)))
+            .distinct()
+            .count();
+        assertThat(nbValues).isEqualTo(nbEntries);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
deleted file mode 100644
index 4362168..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.cassandra.mail;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.LongStream;
-
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.github.fge.lambdas.Throwing;
-
-/**
- * Unit tests for UidProvider and ModSeqProvider.
- * 
- */
-public class CassandraUidAndModSeqProviderTest {
-
-    private static final CassandraCluster CASSANDRA = CassandraCluster.create(new CassandraModuleComposite(
-        new CassandraAclModule(),
-        new CassandraMailboxModule(),
-        new CassandraUidAndModSeqModule()));
-    private static final int MAX_RETRY = 100;
-    
-    private CassandraUidProvider uidProvider;
-    private CassandraModSeqProvider modSeqProvider;
-    private CassandraMailboxMapper mapper;
-    private SimpleMailbox<CassandraId> mailbox;
-
-    @Before
-    public void setUpClass() throws Exception {
-        CASSANDRA.ensureAllTables();
-        uidProvider = new CassandraUidProvider(CASSANDRA.getConf());
-        modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
-        mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(),
MAX_RETRY);
-        MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        mailbox = new SimpleMailbox<>(path, 1234);
-        mapper.save(mailbox);
-    }
-    
-    @After
-    public void cleanUp() {
-        CASSANDRA.clearAllTables();
-    }
-
-    @Test
-    public void lastUidShouldRetrieveValueStoredByNextUid() throws Exception {
-    	int nbEntries = 100;
-        long result = uidProvider.lastUid(null, mailbox);
-        assertEquals(0, result);
-        LongStream.range(0, nbEntries)
-            .forEach(Throwing.longConsumer(value -> {
-                        long uid = uidProvider.nextUid(null, mailbox);
-                        assertThat(uid).isEqualTo(uidProvider.lastUid(null, mailbox));
-                })
-            );
-    }
-
-    @Test
-    public void nextUidShouldIncrementValueByOne() throws Exception {
-    	int nbEntries = 100;
-        long lastUid = uidProvider.lastUid(null, mailbox);
-        LongStream.range(lastUid + 1, lastUid + nbEntries)
-            .forEach(Throwing.longConsumer(value -> {
-                        long result = uidProvider.nextUid(null, mailbox);
-                        assertThat(value).isEqualTo(result);
-                })
-            );
-    }
-
-    @Test
-    public void highestModSeqShouldRetrieveValueStoredNextModSeq() throws Exception {
-    	int nbEntries = 100;
-        long result = modSeqProvider.highestModSeq(null, mailbox);
-        assertEquals(0, result);
-        LongStream.range(0, nbEntries)
-            .forEach(Throwing.longConsumer(value -> {
-                        long uid = modSeqProvider.nextModSeq(null, mailbox);
-                        assertThat(uid).isEqualTo(modSeqProvider.highestModSeq(null, mailbox));
-                })
-            );
-    }
-
-    @Test
-    public void nextModSeqShouldIncrementValueByOne() throws Exception {
-    	int nbEntries = 100;
-    	long lastUid = modSeqProvider.highestModSeq(null, mailbox);
-        LongStream.range(lastUid + 1, lastUid + nbEntries)
-            .forEach(Throwing.longConsumer(value -> {
-                        long result = modSeqProvider.nextModSeq(null, mailbox);
-                        assertThat(value).isEqualTo(result);
-                })
-            );
-    }
-
-    @Test
-    public void nextModSeqShouldGenerateUniqueValuesWhenParallelCalls() throws Exception
{
-        int nbEntries = 100;
-        long nbValues = LongStream.range(0, nbEntries)
-            .parallel()
-            .map(Throwing.longUnaryOperator(x -> modSeqProvider.nextModSeq(null, mailbox)))
-            .distinct()
-            .count();
-        assertThat(nbValues).isEqualTo(nbEntries);
-    }
-    
-    @Test
-    public void nextUidShouldGenerateUniqueValuesWhenParallelCalls() throws Exception {
-        int nbEntries = 100;
-        long nbValues = LongStream.range(0, nbEntries)
-            .parallel()
-            .map(Throwing.longUnaryOperator(x -> uidProvider.nextUid(null, mailbox)))
-            .distinct()
-            .count();
-        assertThat(nbValues).isEqualTo(nbEntries);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
new file mode 100644
index 0000000..8b2bc24
--- /dev/null
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.cassandra.mail;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+
+import java.util.stream.LongStream;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.github.fge.lambdas.Throwing;
+
+public class CassandraUidProviderTest {
+
+    private static final CassandraCluster CASSANDRA = CassandraCluster.create(new CassandraModuleComposite(
+        new CassandraAclModule(),
+        new CassandraMailboxModule(),
+        new CassandraUidModule()));
+    
+    private static final int MAX_RETRY = 100;
+    
+    private CassandraUidProvider uidProvider;
+    private CassandraMailboxMapper mapper;
+    private SimpleMailbox<CassandraId> mailbox;
+
+    @Before
+    public void setUpClass() throws Exception {
+        CASSANDRA.ensureAllTables();
+        uidProvider = new CassandraUidProvider(CASSANDRA.getConf());
+        mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(),
MAX_RETRY);
+        MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
+        mailbox = new SimpleMailbox<>(path, 1234);
+        mapper.save(mailbox);
+    }
+    
+    @After
+    public void cleanUp() {
+        CASSANDRA.clearAllTables();
+    }
+
+    @Test
+    public void lastUidShouldRetrieveValueStoredByNextUid() throws Exception {
+        int nbEntries = 100;
+        long result = uidProvider.lastUid(null, mailbox);
+        assertEquals(0, result);
+        LongStream.range(0, nbEntries)
+            .forEach(Throwing.longConsumer(value -> {
+                        long uid = uidProvider.nextUid(null, mailbox);
+                        assertThat(uid).isEqualTo(uidProvider.lastUid(null, mailbox));
+                })
+            );
+    }
+
+    @Test
+    public void nextUidShouldIncrementValueByOne() throws Exception {
+        int nbEntries = 100;
+        long lastUid = uidProvider.lastUid(null, mailbox);
+        LongStream.range(lastUid + 1, lastUid + nbEntries)
+            .forEach(Throwing.longConsumer(value -> {
+                        long result = uidProvider.nextUid(null, mailbox);
+                        assertThat(value).isEqualTo(result);
+                })
+            );
+    }
+
+    @Test
+    public void nextUidShouldGenerateUniqueValuesWhenParallelCalls() throws Exception {
+        int nbEntries = 100;
+        long nbValues = LongStream.range(0, nbEntries)
+            .parallel()
+            .map(Throwing.longUnaryOperator(x -> uidProvider.nextUid(null, mailbox)))
+            .distinct()
+            .count();
+        assertThat(nbValues).isEqualTo(nbEntries);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index 0a23c85..470da42 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -36,7 +36,8 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -69,7 +70,8 @@ public class CassandraHostSystem extends JamesImapHostSystem {
             new CassandraMailboxModule(),
             new CassandraMessageModule(),
             new CassandraMailboxCounterModule(),
-            new CassandraUidAndModSeqModule(),
+            new CassandraUidModule(),
+            new CassandraModSeqModule(),
             new CassandraSubscriptionModule(),
             new CassandraQuotaModule());
         cassandraClusterSingleton = CassandraCluster.create(mailboxModule);

http://git-wip-us.apache.org/repos/asf/james-project/blob/0395ee41/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 98b6da8..883aad7 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -74,7 +74,8 @@ public class CassandraMailboxModule extends AbstractModule {
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraMessageModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule.class);
-        cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraUidAndModSeqModule.class);
+        cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraUidModule.class);
+        cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule.class);
         
         Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(CassandraMailboxManagerDefinition.class);
     }


---------------------------------------------------------------------
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