james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1685959 - in /james/mailbox/trunk/cassandra/src: main/java/org/apache/james/mailbox/cassandra/ main/java/org/apache/james/mailbox/cassandra/mail/ main/resources/META-INF/spring/ test/java/org/apache/james/mailbox/cassandra/ test/java/org/a...
Date Wed, 17 Jun 2015 09:04:30 GMT
Author: btellier
Date: Wed Jun 17 09:04:29 2015
New Revision: 1685959

URL: http://svn.apache.org/r1685959
Log:
MAILBOX-239 Adding support for user defined types

Added:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTypesProvider.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTypeProviderTest.java
Modified:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/SessionFactory.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
    james/mailbox/trunk/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
Wed Jun 17 09:04:29 2015
@@ -40,16 +40,18 @@ import com.datastax.driver.core.Session;
 public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFactory<UUID>
{
     private static final int DEFAULT_MAX_RETRY = 1000;
 
-    private Session session;
-    private UidProvider<UUID> uidProvider;
-    private ModSeqProvider<UUID> modSeqProvider;
+    private final Session session;
+    private final UidProvider<UUID> uidProvider;
+    private final ModSeqProvider<UUID> modSeqProvider;
+    private final CassandraTypesProvider typesProvider;
     private int maxRetry;
 
-    public CassandraMailboxSessionMapperFactory(UidProvider<UUID> uidProvider, ModSeqProvider<UUID>
modSeqProvider, Session session) {
+    public CassandraMailboxSessionMapperFactory(UidProvider<UUID> uidProvider, ModSeqProvider<UUID>
modSeqProvider, Session session, CassandraTypesProvider typesProvider) {
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
         this.session = session;
         this.maxRetry = DEFAULT_MAX_RETRY;
+        this.typesProvider = typesProvider;
     }
 
     public void setMaxRetry(int maxRetry) {
@@ -63,7 +65,7 @@ public class CassandraMailboxSessionMapp
 
     @Override
     public MailboxMapper<UUID> createMailboxMapper(MailboxSession mailboxSession) {
-        return new CassandraMailboxMapper(session, maxRetry);
+        return new CassandraMailboxMapper(session, typesProvider, maxRetry);
     }
 
     @Override

Added: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTypesProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTypesProvider.java?rev=1685959&view=auto
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTypesProvider.java
(added)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraTypesProvider.java
Wed Jun 17 09:04:29 2015
@@ -0,0 +1,84 @@
+/****************************************************************
+ * 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;
+
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.UserType;
+import com.datastax.driver.core.schemabuilder.CreateType;
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+import com.google.common.collect.ImmutableMap;
+import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable;
+
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static com.datastax.driver.core.DataType.text;
+
+public class CassandraTypesProvider {
+
+    public enum TYPE {
+        MailboxBase(CassandraMailboxTable.MAILBOX_BASE,
+            SchemaBuilder.createType(CassandraMailboxTable.MAILBOX_BASE)
+                .ifNotExists()
+                .addColumn(CassandraMailboxTable.MailboxBase.NAMESPACE, text())
+                .addColumn(CassandraMailboxTable.MailboxBase.USER, text()))
+        ;
+
+        private final String name;
+        private final CreateType createStatement;
+
+        TYPE(String name, CreateType createStatement) {
+            this.name = name;
+            this.createStatement = createStatement;
+        }
+
+        public String getName() {
+            return name;
+        }
+    }
+
+    private final ImmutableMap<TYPE, UserType> userTypes;
+    private final Session session;
+
+    public CassandraTypesProvider(Session session) {
+        this.session = session;
+        initializeTypes();
+        userTypes = ImmutableMap.<TYPE, UserType>builder()
+            .putAll(Arrays.stream(TYPE.values())
+                .collect(Collectors.toMap(
+                    (type) -> type,
+                    (type) -> session.getCluster()
+                        .getMetadata()
+                        .getKeyspace(session.getLoggedKeyspace())
+                        .getUserType(type.name)))).build();
+    }
+
+    public UserType getDefinedUserType(TYPE type) {
+        return Optional.ofNullable(userTypes.get(type))
+            .orElseThrow(() -> new RuntimeException("Cassandra UDT " + type.getName()
+ " can not be retrieved"));
+    }
+
+    public void initializeTypes() {
+        Arrays.asList(TYPE.values())
+            .forEach((type) -> session.execute(type.createStatement));
+    }
+
+}

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/SessionFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/SessionFactory.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/SessionFactory.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/SessionFactory.java
Wed Jun 17 09:04:29 2015
@@ -27,6 +27,7 @@ public class SessionFactory {
 
     public static Session createSession(Cluster cluster, String keyspace) {
         Session session = cluster.connect(keyspace);
+        new CassandraTypesProvider(session);
         new CassandraTableManager(session)
             .ensureAllTables();
         return session;

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
Wed Jun 17 09:04:29 2015
@@ -27,6 +27,8 @@ import java.util.UUID;
 
 import com.datastax.driver.core.utils.UUIDs;
 import com.google.common.base.Preconditions;
+import org.apache.james.mailbox.cassandra.CassandraTypesProvider;
+import org.apache.james.mailbox.cassandra.CassandraTypesProvider.TYPE;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -47,12 +49,15 @@ import org.apache.james.mailbox.store.ma
  */
 public class CassandraMailboxMapper implements MailboxMapper<UUID> {
 
-    private Session session;
-    private int maxRetry;
+    public static final String WILDCARD = "%";
+    private final Session session;
+    private final int maxRetry;
+    private final CassandraTypesProvider typesProvider;
 
-    public CassandraMailboxMapper(Session session, int maxRetry) {
+    public CassandraMailboxMapper(Session session, CassandraTypesProvider typesProvider,
int maxRetry) {
         this.session = session;
         this.maxRetry = maxRetry;
+        this.typesProvider = typesProvider;
     }
 
     @Override

Modified: james/mailbox/trunk/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
(original)
+++ james/mailbox/trunk/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
Wed Jun 17 09:04:29 2015
@@ -40,6 +40,7 @@
         <constructor-arg index="0" ref="cassandra-uidProvider"/>
         <constructor-arg index="1" ref="cassandra-modSeqProvider"/>
         <constructor-arg index="2" ref="cassandra-session"/>
+        <constructor-arg index="3" ref="cassandra-type-provider"/>
     </bean>
 
     <bean id="cassandra-uidProvider" class="org.apache.james.mailbox.cassandra.mail.CassandraUidProvider">
@@ -80,4 +81,8 @@
         <constructor-arg index="1" value="${cassandra.keyspace}"/>
     </bean>
 
+    <bean id="cassandra-type-provider" class="org.apache.james.mailbox.cassandra.CassandraTypesProvider">
+        <constructor-arg index="0" ref="cassandra-session"/>
+    </bean>
+
 </beans>

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraClusterSingleton.java
Wed Jun 17 09:04:29 2015
@@ -45,6 +45,7 @@ public final class CassandraClusterSingl
     private static final Logger LOG = LoggerFactory.getLogger(CassandraClusterSingleton.class);
     private static CassandraClusterSingleton cluster = null;
     private Session session;
+    private CassandraTypesProvider typesProvider;
 
     /**
      * Builds a MiniCluster instance.
@@ -65,6 +66,7 @@ public final class CassandraClusterSingl
             EmbeddedCassandraServerHelper.startEmbeddedCassandra();
             session = new FunctionRunnerWithRetry<Session>(MAX_RETRY)
                 .executeAndRetrieveObject(CassandraClusterSingleton.this::tryInitializeSession);
+            typesProvider = new CassandraTypesProvider(session);
         } catch(Exception exception) {
             Throwables.propagate(exception);
         }
@@ -102,4 +104,7 @@ public final class CassandraClusterSingl
         }
     }
 
+    public CassandraTypesProvider getTypesProvider() {
+        return typesProvider;
+    }
 }

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
Wed Jun 17 09:04:29 2015
@@ -71,7 +71,10 @@ public class CassandraMailboxManagerTest
     protected void createMailboxManager() throws MailboxException {
         final CassandraUidProvider uidProvider = new CassandraUidProvider(CASSANDRA.getConf());
         final CassandraModSeqProvider modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
-        final CassandraMailboxSessionMapperFactory mapperFactory = new CassandraMailboxSessionMapperFactory(uidProvider,
modSeqProvider, CASSANDRA.getConf());
+        final CassandraMailboxSessionMapperFactory mapperFactory = new CassandraMailboxSessionMapperFactory(uidProvider,
+            modSeqProvider,
+            CASSANDRA.getConf(),
+            CASSANDRA.getTypesProvider());
 
         final CassandraMailboxManager manager = new CassandraMailboxManager(mapperFactory,
null, new JVMMailboxPathLocker());
         manager.init();

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
Wed Jun 17 09:04:29 2015
@@ -59,7 +59,7 @@ public class CassandraMailboxSessionMapp
     public void testCreateMessageMapper() throws Exception {
         LOG.info("createMessageMapper");
         MailboxSession session = null;
-        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null);
+        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null, null);
         MessageMapper<UUID> messageMapper = instance.createMessageMapper(session);
         assertNotNull(messageMapper);
         assertTrue(messageMapper instanceof MessageMapper);
@@ -73,7 +73,7 @@ public class CassandraMailboxSessionMapp
     public void testCreateMailboxMapper() throws Exception {
         LOG.info("createMailboxMapper");
         MailboxSession session = null;
-        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null);
+        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null, null);
         MailboxMapper<UUID> mailboxMapper = instance.createMailboxMapper(session);
         assertNotNull(mailboxMapper);
         assertTrue(mailboxMapper instanceof MailboxMapper);
@@ -87,7 +87,7 @@ public class CassandraMailboxSessionMapp
     public void testCreateSubscriptionMapper() throws Exception {
         LOG.info("createSubscriptionMapper");
         MailboxSession session = null;
-        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null);
+        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
null, null, null);
         SubscriptionMapper subscriptionMapper = instance.createSubscriptionMapper(session);
         assertNotNull(subscriptionMapper);
         assertTrue(subscriptionMapper instanceof SubscriptionMapper);
@@ -101,7 +101,7 @@ public class CassandraMailboxSessionMapp
     public void testGetModSeqProvider() {
         LOG.info("getModSeqProvider");
         ModSeqProvider<UUID> expResult = new CassandraModSeqProvider(CLUSTER.getConf());
-        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
expResult, null);
+        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null,
expResult, null, null);
         ModSeqProvider<UUID> result = instance.getModSeqProvider();
         assertEquals(expResult, result);
     }
@@ -114,7 +114,7 @@ public class CassandraMailboxSessionMapp
     public void testGetUidProvider() {
         LOG.info("getUidProvider");
         UidProvider<UUID> expResult = new CassandraUidProvider(CLUSTER.getConf());
-        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory((CassandraUidProvider)
expResult, null, null);
+        CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory((CassandraUidProvider)
expResult, null, null, null);
         UidProvider<UUID> result = instance.getUidProvider();
         assertEquals(expResult, result);
     }

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
Wed Jun 17 09:04:29 2015
@@ -34,11 +34,12 @@ public class CassandraSubscriptionManage
     @Override
     public SubscriptionManager createSubscriptionManager() {
         return new CassandraSubscriptionManager(
-                new CassandraMailboxSessionMapperFactory(
-                        new CassandraUidProvider(cassandra.getConf()),
-                        new CassandraModSeqProvider(cassandra.getConf()),
-                        cassandra.getConf()
-                )
+            new CassandraMailboxSessionMapperFactory(
+                new CassandraUidProvider(cassandra.getConf()),
+                new CassandraModSeqProvider(cassandra.getConf()),
+                cassandra.getConf(),
+                cassandra.getTypesProvider()
+            )
         );
     }
 }

Added: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTypeProviderTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTypeProviderTest.java?rev=1685959&view=auto
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTypeProviderTest.java
(added)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTypeProviderTest.java
Wed Jun 17 09:04:29 2015
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CassandraTypeProviderTest {
+
+    private CassandraClusterSingleton cassandra;
+
+    @Before
+    public void setUp() {
+        cassandra = CassandraClusterSingleton.build();
+        cassandra.getTypesProvider().initializeTypes();
+        cassandra.ensureAllTables();
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void getDefinedUserTypeShouldNotReturnNullNorFailWhenTypeIsDefined() {
+        assertThat(cassandra.getTypesProvider().getDefinedUserType(CassandraTypesProvider.TYPE.MailboxBase))
+            .isNotNull();
+    }
+
+    @Test
+    public void initializeTypesShouldCreateTheTypes() {
+        deleteMailboxBaseType();
+        CassandraTypesProvider cassandraTypesProviderTest = new CassandraTypesProvider(cassandra.getConf());
+        assertThat(cassandraTypesProviderTest.getDefinedUserType(CassandraTypesProvider.TYPE.MailboxBase))
+            .isNotNull();
+    }
+
+    @Test
+    public void initializeTypesShouldNotFailIfCalledTwice() {
+        new CassandraTypesProvider(cassandra.getConf());
+        assertThat(cassandra.getTypesProvider().getDefinedUserType(CassandraTypesProvider.TYPE.MailboxBase))
+            .isNotNull();
+    }
+
+    private void deleteMailboxBaseType() {
+        try {
+            // We need to drop the tables using the type we want to delete
+            cassandra.getConf().execute(SchemaBuilder.dropTable(CassandraTableManager.TABLE.Mailbox.name()));
+            cassandra.getConf().execute(SchemaBuilder.dropType(CassandraTypesProvider.TYPE.MailboxBase.getName()));
+        } catch (Exception exception) {
+            exception.printStackTrace();
+            fail("Exception is thrown on Type deletion");
+        }
+    }
+
+
+
+}

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
Wed Jun 17 09:04:29 2015
@@ -3,6 +3,7 @@ package org.apache.james.mailbox.cassand
 import com.datastax.driver.core.utils.UUIDs;
 import org.apache.james.mailbox.cassandra.CassandraClusterSingleton;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
+import org.apache.james.mailbox.cassandra.CassandraTypesProvider;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
@@ -20,7 +21,8 @@ public class CassandraMapperProvider imp
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),
-            cassandra.getConf()
+            cassandra.getConf(),
+            cassandra.getTypesProvider()
         ).getMailboxMapper(new MockMailboxSession("benwa"));
     }
 
@@ -29,7 +31,8 @@ public class CassandraMapperProvider imp
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),
-            cassandra.getConf()
+            cassandra.getConf(),
+            cassandra.getTypesProvider()
         ).getMessageMapper(new MockMailboxSession("benwa"));
     }
 

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java?rev=1685959&r1=1685958&r2=1685959&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
Wed Jun 17 09:04:29 2015
@@ -57,7 +57,7 @@ public class CassandraUidAndModSeqProvid
         CASSANDRA.ensureAllTables();
         uidProvider = new CassandraUidProvider(CASSANDRA.getConf());
         modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
-        mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), MAX_RETRY);
+        mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(),
MAX_RETRY);
         fillMailboxList();
         for (SimpleMailbox<UUID> mailbox : mailboxList) {
             mapper.save(mailbox);



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