james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [04/13] james-project git commit: JAMES-2588 Effectively remove HBase
Date Thu, 08 Nov 2018 10:46:13 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseClusterSingleton.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseClusterSingleton.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseClusterSingleton.java
deleted file mode 100644
index 246b97b..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseClusterSingleton.java
+++ /dev/null
@@ -1,175 +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.hbase;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.MiniHBaseCluster;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class that will creates a single instance of HBase MiniCluster.
- */
-public final class HBaseClusterSingleton {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseClusterSingleton.class);
-    private static final HBaseTestingUtility htu = new HBaseTestingUtility();
-    private static HBaseClusterSingleton cluster = null;
-    private MiniHBaseCluster hbaseCluster;
-    private Configuration conf;
-
-    /**
-     * Builds a MiniCluster instance.
-     * @return the {@link HBaseClusterSingleton} instance
-     * @throws RuntimeException
-     */
-    public static synchronized HBaseClusterSingleton build()
-            throws RuntimeException {
-        LOG.info("Retrieving cluster instance.");
-        if (cluster == null) {
-            cluster = new HBaseClusterSingleton();
-        }
-        return cluster;
-    }
-
-    private HBaseClusterSingleton() throws RuntimeException {
-        
-        // Workaround for HBASE-5711, we need to set config value dfs.datanode.data.dir.perm
-        // equal to the permissions of the temp dirs on the filesystem. These temp dirs were
-        // probably created using this process' umask. So we guess the temp dir permissions as
-        // 0777 & ~umask, and use that to set the config value.
-        try {
-            Process process = Runtime.getRuntime().exec("/bin/sh -c umask");
-            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
-            int rc = process.waitFor();
-            if (rc == 0) {
-                String umask = br.readLine();
-
-                int umaskBits = Integer.parseInt(umask, 8);
-                int permBits = 0777 & ~umaskBits;
-                String perms = Integer.toString(permBits, 8);
-                
-                LOG.info("Setting dfs.datanode.data.dir.perm to {}", perms);
-                htu.getConfiguration().set("dfs.datanode.data.dir.perm", perms);
-            } else {
-                LOG.warn("Failed running umask command in a shell, nonzero return value");
-            }
-        } catch (Exception e) {
-            // ignore errors, we might not be running on POSIX, or "sh" might not be on the path
-            LOG.warn("Couldn't get umask", e);
-        }
-        
-        htu.getConfiguration().setBoolean("dfs.support.append", true);
-        htu.getConfiguration().setInt("zookeeper.session.timeout", 20000);
-        try {
-            hbaseCluster = htu.startMiniCluster();
-            LOG.info("After cluster start-up.");
-            hbaseCluster.waitForActiveAndReadyMaster();
-            LOG.info("After active and ready.");
-            conf = hbaseCluster.getConfiguration();
-        } catch (Exception ex) {
-            throw new RuntimeException("Minicluster not starting.");
-        } finally {
-            if (hbaseCluster != null) {
-                // add a shutdown hook for shuting down the minicluster.
-                Runtime.getRuntime().addShutdownHook(new Thread(() -> {
-                    try {
-                        hbaseCluster.shutdown();
-                    } catch (IOException e) {
-                        throw new RuntimeException("Exception shuting down cluster.");
-                    }
-                }));
-            }
-        }
-    }
-
-    /**
-     * Return a configuration for the runnning MiniCluster.
-     * @return
-     */
-    public Configuration getConf() {
-        return conf;
-    }
-
-    /**
-     * Creates a table with the specified column families.
-     * @param tableName the table name
-     * @param columnFamilies the colum families
-     * @throws IOException
-     */
-    public void ensureTable(String tableName, String... columnFamilies) throws IOException {
-        byte[][] cfs = new byte[columnFamilies.length][];
-        for (int i = 0; i < columnFamilies.length; i++) {
-            cfs[i] = Bytes.toBytes(columnFamilies[i]);
-        }
-        ensureTable(Bytes.toBytes(tableName), cfs);
-    }
-
-    /**
-     * Creates a table with the specified column families.
-     * @param tableName the table name
-     * @param cfs the column families
-     * @throws IOException
-     */
-    public void ensureTable(byte[] tableName, byte[][] cfs) throws IOException {
-        HBaseAdmin admin = htu.getHBaseAdmin();
-        if (!admin.tableExists(tableName)) {
-            htu.createTable(tableName, cfs);
-        }
-    }
-
-    /**
-     * Delete all rows from specified table.
-     *
-     * @param tableName
-     */
-    public void clearTable(String tableName) {
-        HTable table = null;
-        ResultScanner scanner = null;
-        try {
-            table = new HTable(conf, tableName);
-            Scan scan = new Scan();
-            scan.setCaching(1000);
-            scanner = table.getScanner(scan);
-            Result result;
-            while ((result = scanner.next()) != null) {
-                Delete delete = new Delete(result.getRow());
-                table.delete(delete);
-            }
-        } catch (IOException ex) {
-            LOG.info("Exception clearing table {}", tableName);
-        } finally {
-            IOUtils.closeStream(scanner);
-            IOUtils.closeStream(table);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxIdDeserializerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxIdDeserializerTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxIdDeserializerTest.java
deleted file mode 100644
index 9dbe5aa..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxIdDeserializerTest.java
+++ /dev/null
@@ -1,53 +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.hbase;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.UUID;
-
-import org.apache.james.mailbox.store.mail.model.MailboxIdDeserialisationException;
-import org.junit.Before;
-import org.junit.Test;
-
-public class HBaseMailboxIdDeserializerTest {
-
-    private static final String UUID_STRING = "5530370f-44c6-4647-990e-7768ce5131d4";
-    private static final String MALFORMED_UUID_STRING = "xyz";
-    private static final HBaseId HBASE_ID = HBaseId.of(UUID.fromString(UUID_STRING));
-
-    private HBaseMailboxIdDeserializer mailboxIdDeserializer;
-
-    @Before
-    public void setUp() {
-        mailboxIdDeserializer = new HBaseMailboxIdDeserializer();
-    }
-
-    @Test
-    public void deserializeShouldWork() throws Exception {
-        assertThat(mailboxIdDeserializer.deserialize(UUID_STRING)).isEqualTo(HBASE_ID);
-    }
-
-    @Test(expected = MailboxIdDeserialisationException.class)
-    public void deserializeShouldThrowOnMalformedData() throws Exception {
-        mailboxIdDeserializer.deserialize(MALFORMED_UUID_STRING);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
deleted file mode 100644
index 3534db8..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
+++ /dev/null
@@ -1,111 +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.hbase;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxManagerStressTest;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
-import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authenticator;
-import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.junit.After;
-import org.junit.Ignore;
-
-@Ignore("https://issues.apache.org/jira/browse/MAILBOX-293")
-public class HBaseMailboxManagerStressTest extends MailboxManagerStressTest {
-
-    private static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-
-    @Override
-    protected MailboxManager provideManager() {
-        ensureTables();
-
-        HBaseUidProvider uidProvider = new HBaseUidProvider(CLUSTER.getConf());
-        HBaseModSeqProvider modSeqProvider = new HBaseModSeqProvider(CLUSTER.getConf());
-        MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
-        HBaseMailboxSessionMapperFactory mapperFactory = new HBaseMailboxSessionMapperFactory(CLUSTER.getConf(),
-            uidProvider, modSeqProvider, messageIdFactory);
-        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
-        StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
-
-        Authenticator noAuthenticator = null;
-        Authorizator noAuthorizator = null;
-        StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
-        HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
-            noAuthenticator,
-            noAuthorizator,
-            new JVMMailboxPathLocker(),
-            new MessageParser(),
-            messageIdFactory,
-            mailboxEventDispatcher,
-            delegatingListener,
-            annotationManager,
-            storeRightManager);
-
-        try {
-            manager.init();
-        } catch (MailboxException e) {
-            throw new RuntimeException(e);
-        }
-
-        return manager;
-    }
-
-    @After
-    public void tearDown() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    private void ensureTables() {
-        try {
-            CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-            CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-            CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
deleted file mode 100644
index a37e79d..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
+++ /dev/null
@@ -1,112 +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.hbase;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxManagerTest;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
-import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.Authenticator;
-import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.junit.After;
-import org.junit.Ignore;
-
-@Ignore("https://issues.apache.org/jira/browse/MAILBOX-293")
-public class HBaseMailboxManagerTest extends MailboxManagerTest {
-
-    private static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-
-    @Override
-    protected MailboxManager provideMailboxManager() {
-        ensureTables();
-
-        HBaseUidProvider uidProvider = new HBaseUidProvider(CLUSTER.getConf());
-        HBaseModSeqProvider modSeqProvider = new HBaseModSeqProvider(CLUSTER.getConf());
-        MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
-        HBaseMailboxSessionMapperFactory mapperFactory = new HBaseMailboxSessionMapperFactory(CLUSTER.getConf(),
-            uidProvider, modSeqProvider, messageIdFactory);
-        DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
-        MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
-        StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
-
-        Authenticator noAuthenticator = null;
-        Authorizator noAuthorizator = null;
-        StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
-        HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
-            noAuthenticator,
-            noAuthorizator,
-            new JVMMailboxPathLocker(),
-            new MessageParser(),
-            messageIdFactory,
-            mailboxEventDispatcher,
-            delegatingListener,
-            annotationManager,
-            storeRightManager);
-
-        try {
-            manager.init();
-        } catch (MailboxException e) {
-            throw new RuntimeException(e);
-        }
-
-        return manager;
-    }
-
-    @Override
-    @After
-    public void tearDown() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    private void ensureTables() {
-        try {
-            CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-            CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-            CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
deleted file mode 100644
index 8890662..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
+++ /dev/null
@@ -1,152 +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.hbase;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
-import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.ModSeqProvider;
-import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.user.SubscriptionMapper;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The MailboxSessionMapperFactory test.
- *
- */
-public class HBaseMailboxSessionMapperFactoryTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseMailboxSessionMapperFactoryTest.class);
-    private static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-    private static Configuration conf;
-
-    @Before
-    public void beforeMethod() throws IOException {
-        ensureTables();
-        clearTables();
-        conf = CLUSTER.getConf();
-    }
-
-    private void ensureTables() throws IOException {
-        CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-        CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-        CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-    }
-
-    private void clearTables() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    /**
-     * Test of createMessageMapper method, of class
-     * HBaseMailboxSessionMapperFactory.
-     */
-    @Test
-    public void testCreateMessageMapper() throws Exception {
-        LOG.info("createMessageMapper");
-        MailboxSession session = null;
-        MessageId.Factory messageIdFactory = null;
-        HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory);
-        MessageMapper messageMapper = instance.createMessageMapper(session);
-        assertThat(messageMapper).isNotNull();
-        assertThat(messageMapper).isInstanceOf(MessageMapper.class);
-    }
-
-    /**
-     * Test of createMailboxMapper method, of class
-     * HBaseMailboxSessionMapperFactory.
-     */
-    @Test
-    public void testCreateMailboxMapper() throws Exception {
-        LOG.info("createMailboxMapper");
-        MailboxSession session = null;
-        MessageId.Factory messageIdFactory = null;
-        HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory);
-        MailboxMapper mailboxMapper = instance.createMailboxMapper(session);
-        assertThat(mailboxMapper).isNotNull();
-        assertThat(mailboxMapper).isInstanceOf(MailboxMapper.class);
-    }
-
-    /**
-     * Test of createSubscriptionMapper method, of class
-     * HBaseMailboxSessionMapperFactory.
-     */
-    @Test
-    public void testCreateSubscriptionMapper() throws Exception {
-        LOG.info("createSubscriptionMapper");
-        MailboxSession session = null;
-        MessageId.Factory messageIdFactory = null;
-        HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null, messageIdFactory);
-        SubscriptionMapper subscriptionMapper = instance.createSubscriptionMapper(session);
-        assertThat(subscriptionMapper).isNotNull();
-        assertThat(subscriptionMapper).isInstanceOf(SubscriptionMapper.class);
-    }
-
-    /**
-     * Test of getModSeqProvider method, of class
-     * HBaseMailboxSessionMapperFactory.
-     */
-    @Test
-    public void testGetModSeqProvider() {
-        LOG.info("getModSeqProvider");
-        ModSeqProvider expResult = new HBaseModSeqProvider(conf);
-        MessageId.Factory messageIdFactory = null;
-        HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, expResult, messageIdFactory);
-        ModSeqProvider result = instance.getModSeqProvider();
-        assertThat(result).isEqualTo(expResult);
-    }
-
-    /**
-     * Test of getUidProvider method, of class HBaseMailboxSessionMapperFactory.
-     */
-    @Test
-    public void testGetUidProvider() {
-        LOG.info("getUidProvider");
-        UidProvider expResult = new HBaseUidProvider(conf);
-        MessageId.Factory messageIdFactory = null;
-        HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, expResult, null, messageIdFactory);
-        UidProvider result = instance.getUidProvider();
-        assertThat(result).isEqualTo(expResult);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java
deleted file mode 100644
index cf1ad95..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java
+++ /dev/null
@@ -1,159 +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.hbase;
-
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_ANSWERED;
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DELETED;
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DRAFT;
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_FLAGGED;
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_RECENT;
-import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_SEEN;
-import static org.apache.james.mailbox.hbase.FlagConvertor.userFlagToBytes;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_HIGHEST_MODSEQ;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_LASTUID;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_MESSAGE_COUNT;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAME;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAMESPACE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_UIDVALIDITY;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_USER;
-import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_MISSING;
-import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_PRESENT;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-import static org.apache.james.mailbox.hbase.HBaseUtils.flagsToPut;
-import static org.apache.james.mailbox.hbase.HBaseUtils.hBaseIdFromRowKey;
-import static org.apache.james.mailbox.hbase.HBaseUtils.toPut;
-import static org.apache.james.mailbox.hbase.PropertyConvertor.getProperty;
-import static org.apache.james.mailbox.hbase.PropertyConvertor.getValue;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.mail.Flags;
-
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.Property;
-import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty;
-import org.apache.james.mailbox.store.user.model.Subscription;
-import org.apache.james.mailbox.store.user.model.impl.SimpleSubscription;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Tests for HBase Mailbox store utility methods .
- */
-public class HBaseUtilsTest {
-    
-    /**
-     * Test of mailboxRowKey method, of class HBaseMailbox.
-     */
-    @Test
-    public void testRowKey_All() {
-        final HBaseMailbox mailbox = new HBaseMailbox(new MailboxPath("gsoc", "ieugen", "INBOX"), 1234);
-        HBaseId uuid = mailbox.getMailboxId();
-        byte[] expResult = uuid.toBytes();
-        byte[] result = mailbox.getMailboxId().toBytes();
-        assertThat(result).isEqualTo(expResult);
-
-        HBaseId newUUID = hBaseIdFromRowKey(result);
-        assertThat(newUUID).isEqualTo(uuid);
-
-        newUUID = hBaseIdFromRowKey(expResult);
-        assertThat(newUUID).isEqualTo(uuid);
-    }
-
-    /**
-     * Test of metadataToPut method, of class HBaseMailbox.
-     */
-    @Test
-    public void testMailboxToPut() {
-        final HBaseMailbox instance = new HBaseMailbox(new MailboxPath("gsoc", "ieugen", "INBOX"), 1234);
-
-        Put result = toPut(instance);
-        assertThat(result.getRow()).isEqualTo(instance.getMailboxId().toBytes());
-        assertThat(result.has(MAILBOX_CF, MAILBOX_USER, Bytes.toBytes(instance.getUser()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_NAME, Bytes.toBytes(instance.getName()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_NAMESPACE, Bytes.toBytes(instance.getNamespace()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_UIDVALIDITY, Bytes.toBytes(instance.getUidValidity()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_LASTUID, Bytes.toBytes(instance.getLastUid()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, Bytes.toBytes(instance.getHighestModSeq()))).isTrue();
-        assertThat(result.has(MAILBOX_CF, MAILBOX_MESSAGE_COUNT, Bytes.toBytes(0L))).isTrue();
-    }
-
-    /**
-     * Test of metadataToPut method for message.
-     */
-    @Ignore
-    @Test
-    public void testMessageToPut() {
-        // left to implement
-    }
-
-    @Test
-    public void testPropertyToBytes() {
-        final Property prop1 = new SimpleProperty("nspace", "localName", "test");
-        byte[] value = getValue(prop1);
-        final Property prop2 = getProperty(value);
-        assertThat(prop2.getNamespace()).isEqualTo(prop1.getNamespace());
-        assertThat(prop2.getLocalName()).isEqualTo(prop1.getLocalName());
-        assertThat(prop2.getValue()).isEqualTo(prop1.getValue());
-    }
-
-    @Test
-    public void testSubscriptionToPut() {
-        Subscription subscription = new SimpleSubscription("ieugen", "INBOX");
-        Put put = toPut(subscription);
-        assertThat(put.getRow()).isEqualTo(Bytes.toBytes(subscription.getUser()));
-        assertThat(put.has(SUBSCRIPTION_CF, Bytes.toBytes(subscription.getMailbox()), MARKER_PRESENT)).isTrue();
-    }
-
-    @Test
-    public void testFlagsToPut() {
-        final Flags flags = new Flags();
-        flags.add(Flags.Flag.SEEN);
-        flags.add(Flags.Flag.DRAFT);
-        flags.add(Flags.Flag.RECENT);
-        flags.add(Flags.Flag.FLAGGED);
-        flags.add("userFlag1");
-        flags.add("userFlag2");
-        HBaseId uuid = HBaseId.of(UUID.randomUUID());
-        DefaultMessageId messageId = new DefaultMessageId();
-        final SimpleMailboxMessage message = new SimpleMailboxMessage(messageId, new Date(), 100, 10, null, flags, new PropertyBuilder(), uuid);
-        message.setUid(MessageUid.of(1));
-        Put put = flagsToPut(message, flags);
-        //test for the system flags
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_SEEN, MARKER_PRESENT)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_DRAFT, MARKER_PRESENT)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_RECENT, MARKER_PRESENT)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_FLAGGED, MARKER_PRESENT)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_ANSWERED, MARKER_MISSING)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, FLAGS_DELETED, MARKER_MISSING)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, userFlagToBytes("userFlag1"), MARKER_PRESENT)).isTrue();
-        assertThat(put.has(MESSAGES_META_CF, userFlagToBytes("userFlag2"), MARKER_PRESENT)).isTrue();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
deleted file mode 100644
index 53ea5db..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
+++ /dev/null
@@ -1,353 +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.hbase.mail;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxFromResult;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.MailboxNotFoundException;
-import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import org.apache.james.mailbox.hbase.HBaseId;
-import org.apache.james.mailbox.hbase.io.ChunkInputStream;
-import org.apache.james.mailbox.hbase.io.ChunkOutputStream;
-import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * HBaseMailboxMapper unit tests.
- *
- */
-public class HBaseMailboxMapperTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseMailboxMapperTest.class);
-    public static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-    private static Configuration conf;
-    private static HBaseMailboxMapper mapper;
-    private static List<HBaseMailbox> mailboxList;
-    private static List<MailboxPath> pathsList;
-    private static List<HBaseId> idsList;
-    private static final int NAMESPACES = 5;
-    private static final int USERS = 5;
-    private static final int MAILBOX_NO = 5;
-    private static final char SEPARATOR = '%';
-
-    @Before
-    public void setUp() throws Exception {
-        ensureTables();
-        // start the test cluster
-        clearTables();
-        conf = CLUSTER.getConf();
-        fillMailboxList();
-        mapper = new HBaseMailboxMapper(conf);
-        for (HBaseMailbox mailbox : mailboxList) {
-            mapper.save(mailbox);
-        }
-    }
-
-    private void ensureTables() throws IOException {
-        CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-        CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-        CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-    }
-
-    private void clearTables() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    /**
-     * Test an ordered scenario with list, delete... methods.
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testMailboxMapperScenario() throws Exception {
-        testFindMailboxByPath();
-        testFindMailboxById();
-        testFindMailboxWithPathLike();
-        testList();
-        testSave();
-        testDelete();
-        testHasChildren();
-        //testDeleteAllMemberships(); // Ignore this test
-        testDeleteAllMailboxes();
-        testChunkStream();
-    }
-
-    /**
-     * Test of findMailboxByPath method, of class HBaseMailboxMapper.
-     */
-    private void testFindMailboxByPath() throws Exception {
-        LOG.info("findMailboxByPath");
-        HBaseMailbox mailbox;
-        for (MailboxPath path : pathsList) {
-            LOG.info("Searching for {}", path);
-            mailbox = (HBaseMailbox) mapper.findMailboxByPath(path);
-            assertThat(new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName())).isEqualTo(path);
-        }
-    }
-
-    private void testFindMailboxById() throws Exception {
-        LOG.info("findMailboxById");
-        HBaseMailbox mailbox;
-        for (MailboxId id : idsList) {
-            LOG.info("Searching for {}", id.serialize());
-            mailbox = (HBaseMailbox) mapper.findMailboxById(id);
-            assertThat(id).isEqualTo(mailbox.getMailboxId());
-        }
-    }
-
-    /**
-     * Test of findMailboxWithPathLike method, of class HBaseMailboxMapper.
-     */
-    private void testFindMailboxWithPathLike() throws Exception {
-        LOG.info("findMailboxWithPathLike");
-        MailboxPath path = pathsList.get(pathsList.size() / 2);
-
-        List<Mailbox> result = mapper.findMailboxWithPathLike(path);
-        assertThat(result.size()).isEqualTo(1);
-
-        int start = 3;
-        int end = 7;
-        MailboxPath newPath;
-
-        for (int i = start; i < end; i++) {
-            newPath = new MailboxPath(path.getNamespace(),
-                computeUserName(path.getUser(), i),
-                computeMailboxName(path.getName(), i));
-            addMailbox(new HBaseMailbox(newPath, 1234));
-        }
-        result = mapper.findMailboxWithPathLike(path);
-        assertThat(result.size()).isEqualTo(end - start + 1);
-    }
-
-    private String computeUserName(String user, int i) {
-        if (i % 2 == 0) {
-            return null;
-        }
-        return user;
-    }
-
-    private String computeMailboxName(String name, int i) {
-        return i + name + " " + i;
-    }
-
-    /**
-     * Test of list method, of class HBaseMailboxMapper.
-     */
-    private void testList() throws Exception {
-        LOG.info("list");
-        List<Mailbox> result = mapper.list();
-        assertThat(result.size()).isEqualTo(mailboxList.size());
-
-    }
-
-    /**
-     * Test of save method, of class HBaseMailboxMapper.
-     */
-    private void testSave() throws Exception {
-        LOG.info("save and mailboxFromResult");
-        final HTable mailboxes = new HTable(conf, MAILBOXES_TABLE);
-        try {
-            
-            final HBaseMailbox mlbx = mailboxList.get(mailboxList.size() / 2);
-        
-            final Get get = new Get(mlbx.getMailboxId().toBytes());
-            // get all columns for the DATA column family
-            get.addFamily(MAILBOX_CF);
-        
-            final Result result = mailboxes.get(get);
-            final HBaseMailbox newValue = (HBaseMailbox) mailboxFromResult(result);
-            assertThat(newValue).isEqualTo(mlbx);
-            assertThat(newValue.getUser()).isEqualTo(mlbx.getUser());
-            assertThat(newValue.getName()).isEqualTo(mlbx.getName());
-            assertThat(newValue.getNamespace()).isEqualTo(mlbx.getNamespace());
-            assertThat(newValue.getMailboxId()).isEqualTo(mlbx.getMailboxId());
-            assertThat(newValue.getLastUid()).isEqualTo(mlbx.getLastUid());
-            assertThat(newValue.getUidValidity()).isEqualTo(mlbx.getUidValidity());
-            assertThat(newValue.getHighestModSeq()).isEqualTo(mlbx.getHighestModSeq());
-            assertThat(newValue.getMailboxId().toBytes()).isEqualTo(mlbx.getMailboxId().toBytes());
-        } finally {
-            mailboxes.close();
-        }
-    }
-
-    /**
-     * Test of delete method, of class HBaseMailboxMapper.
-     */
-    private void testDelete() throws Exception {
-        LOG.info("delete");
-        // delete last 5 mailboxes from mailboxList
-        int offset = 5;
-        int notFoundCount = 0;
-
-        Iterator<HBaseMailbox> iterator = mailboxList.subList(mailboxList.size() - offset, mailboxList.size()).iterator();
-
-        while (iterator.hasNext()) {
-            HBaseMailbox mailbox = iterator.next();
-            mapper.delete(mailbox);
-            iterator.remove();
-            MailboxPath path = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
-            pathsList.remove(path);
-            LOG.info("Removing mailbox: {}", path);
-            try {
-                mapper.findMailboxByPath(path);
-            } catch (MailboxNotFoundException e) {
-                LOG.info("Succesfully removed {}", mailbox);
-                notFoundCount++;
-            }
-        }
-        assertThat(notFoundCount).isEqualTo(offset);
-        assertThat(mapper.list().size()).isEqualTo(mailboxList.size());
-    }
-
-    /**
-     * Test of hasChildren method, of class HBaseMailboxMapper.
-     */
-    private void testHasChildren() throws Exception {
-        LOG.info("hasChildren");
-        String oldName;
-        for (MailboxPath path : pathsList) {
-            final HBaseMailbox mailbox = new HBaseMailbox(path, 12455);
-            oldName = mailbox.getName();
-            if (path.getUser().equals("user3")) {
-                mailbox.setName("test");
-            }
-            boolean result = mapper.hasChildren(mailbox, SEPARATOR);
-            mailbox.setName(oldName);
-            if (path.getUser().equals("user3")) {
-                assertThat(result).isTrue();
-            } else {
-                assertThat(result).isFalse();
-            }
-
-        }
-    }
-
-    /**
-     * Test of deleteAllMailboxes method, of class HBaseMailboxMapper.
-     */
-    private void testDeleteAllMailboxes() throws MailboxException {
-        LOG.info("deleteAllMailboxes");
-        mapper.deleteAllMailboxes();
-        assertThat(mapper.list().size()).isEqualTo(0);
-        fillMailboxList();
-    }
-
-    private void testChunkStream() throws IOException {
-        LOG.info("Checking ChunkOutpuStream and ChunkInputStream");
-        final String original = "This is a proper test for the HBase ChunkInputStream and"
-                + "ChunkOutputStream. This text must be larger than the chunk size so we write"
-                + "and read more then one chunk size. I think that a few more lore ipsum lines"
-                + "will be enough."
-                + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "
-                + "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis "
-                + "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
-                + "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
-                + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa"
-                + " qui officia deserunt mollit anim id est laborum";
-        byte[] data = Bytes.toBytes(original);
-        // we make the column size = 10 bytes
-        ChunkOutputStream out = new ChunkOutputStream(conf,
-                MESSAGES_TABLE, MESSAGE_DATA_BODY_CF, Bytes.toBytes("10"), 10);
-        ChunkInputStream in = new ChunkInputStream(conf,
-                MESSAGES_TABLE, MESSAGE_DATA_BODY_CF, Bytes.toBytes("10"));
-        try {
-            //create the stream
-            ByteArrayInputStream bin = new ByteArrayInputStream(data);
-            ByteArrayOutputStream bout = new ByteArrayOutputStream(data.length);
-            int b;
-            while ((b = bin.read()) != -1) {
-                out.write(b);
-            }
-            out.close();
-            while ((b = in.read()) != -1) {
-                bout.write(b);
-            }
-            String s = bout.toString();
-            assertThat(s).isEqualTo(original);
-        } finally {
-            in.close();
-            out.close();
-        }
-    }
-
-    private static void fillMailboxList() {
-        mailboxList = new ArrayList<>();
-        pathsList = new ArrayList<>();
-        idsList = new ArrayList<>();
-        MailboxPath path;
-        String name;
-        for (int i = 0; i < NAMESPACES; i++) {
-            for (int j = 0; j < USERS; j++) {
-                for (int k = 0; k < MAILBOX_NO; k++) {
-                    if (j == 3) {
-                        name = "test" + SEPARATOR + "subbox" + k;
-                    } else {
-                        name = "mailbox" + k;
-                    }
-                    path = new MailboxPath("namespace" + i, "user" + j, name);
-                    pathsList.add(path);
-                    HBaseMailbox mailbox = new HBaseMailbox(path, 13);
-                    mailboxList.add(mailbox);
-                    idsList.add(mailbox.getMailboxId());
-                }
-            }
-        }
-        LOG.info("Created test case with {} mailboxes and {} paths",
-                mailboxList.size(), pathsList.size());
-    }
-
-    private void addMailbox(HBaseMailbox mailbox) throws MailboxException {
-        mailboxList.add(mailbox);
-        pathsList.add(new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()));
-        mapper = new HBaseMailboxMapper(conf);
-        mapper.save(mailbox);
-        LOG.info("Added new mailbox: {} paths: {}", mailboxList.size(), pathsList.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessageMapperTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessageMapperTest.java
deleted file mode 100644
index 5c9363e..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMessageMapperTest.java
+++ /dev/null
@@ -1,241 +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.hbase.mail;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-
-import javax.mail.Flags;
-import javax.mail.internet.SharedInputStream;
-import javax.mail.util.SharedByteArrayInputStream;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
-import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit tests for HBaseMessageMapper.
- *
- */
-public class HBaseMailboxMessageMapperTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseMailboxMapperTest.class);
-    public static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-    private static HBaseUidProvider uidProvider;
-    private static HBaseModSeqProvider modSeqProvider;
-    private static HBaseMessageMapper messageMapper;
-    private static final List<MailboxPath> MBOX_PATHS = new ArrayList<>();
-    private static final List<Mailbox> MBOXES = new ArrayList<>();
-    private static final List<MailboxMessage> MESSAGE_NO = new ArrayList<>();
-    private static final int COUNT = 5;
-    private static Configuration conf;
-    private DefaultMessageId.Factory messageIdFactory;
-    /*
-     * we mock a simple message content
-     */
-    private static final byte[] messageTemplate = Bytes.toBytes(
-            "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\n"
-            + "From: Fred Foobar <foobar@Blurdybloop.COM>\n"
-            + "Subject: Test 02\n"
-            + "To: mooch@owatagu.siam.edu\n"
-            + "MailboxMessage-Id: <B27397-0100000@Blurdybloop.COM>\n"
-            + "MIME-Version: 1.0\n"
-            + "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\n"
-            + "\n"
-            + "Test\n"
-            + "\n.");
-    private static final SharedInputStream content = new SharedByteArrayInputStream(messageTemplate);
-
-    @Before
-    public void setUp() throws Exception {
-        ensureTables();
-        clearTables();
-        conf = CLUSTER.getConf();
-        uidProvider = new HBaseUidProvider(conf);
-        modSeqProvider = new HBaseModSeqProvider(conf);
-        messageIdFactory = new DefaultMessageId.Factory();
-        generateTestData();
-        final MailboxSession session = new MockMailboxSession("ieugen");
-        messageMapper = new HBaseMessageMapper(session, uidProvider, modSeqProvider, messageIdFactory, conf);
-        for (MailboxMessage message : MESSAGE_NO) {
-            messageMapper.add(MBOXES.get(1), message);
-        }
-    }
-
-    private void ensureTables() throws IOException {
-        CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-        CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-        CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-    }
-
-    private void clearTables() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    public void generateTestData() {
-        final Random random = new Random();
-        MailboxPath mboxPath;
-        final PropertyBuilder propBuilder = new PropertyBuilder();
-
-        for (int i = 0; i < COUNT; i++) {
-            if (i % 2 == 0) {
-                mboxPath = new MailboxPath("gsoc", "ieugen" + i, "INBOX");
-            } else {
-                mboxPath = new MailboxPath("gsoc", "ieugen" + i, "INBOX.box" + i);
-            }
-            MBOX_PATHS.add(mboxPath);
-            MBOXES.add(new HBaseMailbox(MBOX_PATHS.get(i), random.nextLong()));
-            propBuilder.setProperty("gsoc", "prop" + i, "value");
-        }
-        propBuilder.setMediaType("text");
-        propBuilder.setSubType("html");
-        propBuilder.setTextualLineCount(2L);
-
-        SimpleMailboxMessage myMsg;
-        final Flags flags = new Flags(Flags.Flag.RECENT);
-        final Date today = new Date();
-
-        for (int i = 0; i < COUNT * 2; i++) {
-            myMsg = new SimpleMailboxMessage(messageIdFactory.generate(), today, messageTemplate.length,
-                    messageTemplate.length - 20, content, flags, propBuilder,
-                    MBOXES.get(1).getMailboxId());
-            if (i == COUNT * 2 - 1) {
-                flags.add(Flags.Flag.SEEN);
-                flags.remove(Flags.Flag.RECENT);
-                myMsg.setFlags(flags);
-            }
-            MESSAGE_NO.add(myMsg);
-        }
-    }
-
-    /**
-     * Test an ordered scenario with count, find, add... methods.
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testMessageMapperScenario() throws Exception {
-        testCountMessagesInMailbox();
-        testCountUnseenMessagesInMailbox();
-        testFindFirstUnseenMessageUid();
-        testFindRecentMessageUidsInMailbox();
-        testAdd();
-        testGetLastUid();
-        testGetHighestModSeq();
-    }
-
-    /**
-     * Test of countMessagesInMailbox method, of class HBaseMessageMapper.
-     */
-    private void testCountMessagesInMailbox() throws Exception {
-        LOG.info("countMessagesInMailbox");
-        long messageCount = messageMapper.countMessagesInMailbox(MBOXES.get(1));
-        assertThat(messageCount).isEqualTo(MESSAGE_NO.size());
-    }
-
-    /**
-     * Test of countUnseenMessagesInMailbox method, of class HBaseMessageMapper.
-     */
-    private void testCountUnseenMessagesInMailbox() throws Exception {
-        LOG.info("countUnseenMessagesInMailbox");
-        long unseen = messageMapper.countUnseenMessagesInMailbox(MBOXES.get(1));
-        assertThat(unseen).isEqualTo(MESSAGE_NO.size() - 1);
-    }
-
-    /**
-     * Test of findFirstUnseenMessageUid method, of class HBaseMessageMapper.
-     */
-    private void testFindFirstUnseenMessageUid() throws Exception {
-        LOG.info("findFirstUnseenMessageUid");
-        MessageUid uid = messageMapper.findFirstUnseenMessageUid(MBOXES.get(1));
-        assertThat(uid).isEqualTo(MessageUid.of(1));
-    }
-
-    /**
-     * Test of findRecentMessageUidsInMailbox method, of class
-     * HBaseMessageMapper.
-     */
-    private void testFindRecentMessageUidsInMailbox() throws Exception {
-        LOG.info("findRecentMessageUidsInMailbox");
-        List<MessageUid> recentMessages = messageMapper.findRecentMessageUidsInMailbox(MBOXES.get(1));
-        assertThat(recentMessages.size()).isEqualTo(MESSAGE_NO.size() - 1);
-    }
-
-    /**
-     * Test of add method, of class HBaseMessageMapper.
-     */
-    private void testAdd() throws Exception {
-        LOG.info("add");
-        // The tables should be deleted every time the tests run.
-        long msgCount = messageMapper.countMessagesInMailbox(MBOXES.get(1));
-        LOG.info("{} {}", msgCount, MESSAGE_NO.size());
-        assertThat(msgCount).isEqualTo(MESSAGE_NO.size());
-    }
-
-    /**
-     * Test of getLastUid method, of class HBaseMessageMapper.
-     */
-    private void testGetLastUid() throws Exception {
-        LOG.info("getLastUid");
-        MessageUid lastUid = messageMapper.getLastUid(MBOXES.get(1)).get();
-        assertThat(lastUid).isEqualTo(MessageUid.of(MESSAGE_NO.size()));
-    }
-
-    /**
-     * Test of getHighestModSeq method, of class HBaseMessageMapper.
-     */
-    private void testGetHighestModSeq() throws Exception {
-        LOG.info("getHighestModSeq");
-        long highestModSeq = messageMapper.getHighestModSeq(MBOXES.get(1));
-        assertThat(highestModSeq).isEqualTo(MESSAGE_NO.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseUidAndModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseUidAndModSeqProviderTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseUidAndModSeqProviderTest.java
deleted file mode 100644
index 4fbb051..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseUidAndModSeqProviderTest.java
+++ /dev/null
@@ -1,196 +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.hbase.mail;
-
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
-import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit tests for UidProvider and ModSeqProvider.
- *
- */
-public class HBaseUidAndModSeqProviderTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseUidAndModSeqProviderTest.class);
-    private static final HBaseClusterSingleton CLUSTER = HBaseClusterSingleton.build();
-    private static Configuration conf;
-    private static HBaseUidProvider uidProvider;
-    private static HBaseModSeqProvider modSeqProvider;
-    private static HBaseMailboxMapper mapper;
-    private static List<HBaseMailbox> mailboxList;
-    private static List<MailboxPath> pathsList;
-    private static final int NAMESPACES = 5;
-    private static final int USERS = 5;
-    private static final int MAILBOX_NO = 5;
-    private static final char SEPARATOR = '%';
-
-    @Before
-    public void setUpClass() throws Exception {
-        ensureTables();
-        clearTables();
-        conf = CLUSTER.getConf();
-        uidProvider = new HBaseUidProvider(conf);
-        modSeqProvider = new HBaseModSeqProvider(conf);
-        mapper = new HBaseMailboxMapper(conf);
-        fillMailboxList();
-        for (HBaseMailbox mailbox : mailboxList) {
-            mapper.save(mailbox);
-        }
-    }
-
-    private void ensureTables() throws IOException {
-        CLUSTER.ensureTable(MAILBOXES_TABLE, new byte[][]{MAILBOX_CF});
-        CLUSTER.ensureTable(MESSAGES_TABLE,
-                new byte[][]{MESSAGES_META_CF, MESSAGE_DATA_HEADERS_CF, MESSAGE_DATA_BODY_CF});
-        CLUSTER.ensureTable(SUBSCRIPTIONS_TABLE, new byte[][]{SUBSCRIPTION_CF});
-    }
-
-    private void clearTables() {
-        CLUSTER.clearTable(MAILBOXES);
-        CLUSTER.clearTable(MESSAGES);
-        CLUSTER.clearTable(SUBSCRIPTIONS);
-    }
-
-    private static void fillMailboxList() {
-        mailboxList = new ArrayList<>();
-        pathsList = new ArrayList<>();
-        MailboxPath path;
-        String name;
-        for (int i = 0; i < NAMESPACES; i++) {
-            for (int j = 0; j < USERS; j++) {
-                for (int k = 0; k < MAILBOX_NO; k++) {
-                    if (j == 3) {
-                        name = "test" + SEPARATOR + "subbox" + k;
-                    } else {
-                        name = "mailbox" + k;
-                    }
-                    path = new MailboxPath("namespace" + i, "user" + j, name);
-                    pathsList.add(path);
-                    mailboxList.add(new HBaseMailbox(path, 13));
-                }
-            }
-        }
-
-        LOG.info("Created test case with {} mailboxes and {} paths", mailboxList.size(),
-                pathsList.size());
-    }
-
-    /**
-     * Test of lastUid method, of class HBaseUidProvider.
-     */
-    @Test
-    public void testLastUid() throws Exception {
-        LOG.info("lastUid");
-        final MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        final HBaseMailbox newBox = new HBaseMailbox(path, 1234);
-        mapper.save(newBox);
-        mailboxList.add(newBox);
-        pathsList.add(path);
-        MailboxSession session = null;
-        Optional<MessageUid> result = uidProvider.lastUid(session, newBox);
-        assertThat(result).isEqualTo(Optional.empty());
-        for (int i = 1; i < 10; i++) {
-            MessageUid uid = uidProvider.nextUid(session, newBox);
-            assertThat(uidProvider.lastUid(session, newBox).get()).isEqualTo(uid);
-        }
-    }
-
-    /**
-     * Test of nextUid method, of class HBaseUidProvider.
-     */
-    @Test
-    public void testNextUid() throws Exception {
-        LOG.info("nextUid");
-        HBaseMailbox mailbox = mailboxList.get(mailboxList.size() / 2);
-        MailboxSession session = null;
-        Optional<MessageUid> lastUid = uidProvider.lastUid(session, mailbox);
-        for (int i = 0; i < 10; i++) {
-            if (lastUid.isPresent()) {
-                lastUid = Optional.of(lastUid.get().next());
-            } else {
-                lastUid = Optional.of(MessageUid.MIN_VALUE);
-            }
-            MessageUid result = uidProvider.nextUid(session, mailbox);
-            assertThat(result).isEqualTo(lastUid.get());
-        }
-    }
-
-    /**
-     * Test of highestModSeq method, of class HBaseModSeqProvider.
-     */
-    @Test
-    public void testHighestModSeq() throws Exception {
-        LOG.info("highestModSeq");
-        LOG.info("lastUid");
-        MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        HBaseMailbox newBox = new HBaseMailbox(path, 1234);
-        mapper.save(newBox);
-        mailboxList.add(newBox);
-        pathsList.add(path);
-        MailboxSession session = null;
-        long result = modSeqProvider.highestModSeq(session, newBox);
-        assertThat(result).isEqualTo(0);
-        for (int i = 1; i < 10; i++) {
-            long uid = modSeqProvider.nextModSeq(session, newBox);
-            assertThat(modSeqProvider.highestModSeq(session, newBox)).isEqualTo(uid);
-        }
-    }
-
-    /**
-     * Test of nextModSeq method, of class HBaseModSeqProvider.
-     */
-    @Test
-    public void testNextModSeq() throws Exception {
-        LOG.info("nextModSeq");
-        HBaseMailbox mailbox = mailboxList.get(mailboxList.size() / 2);
-        MailboxSession session = null;
-        long lastUid = modSeqProvider.highestModSeq(session, mailbox);
-        long result;
-        for (int i = (int) lastUid + 1; i < (lastUid + 10); i++) {
-            result = modSeqProvider.nextModSeq(session, mailbox);
-            assertThat(result).isEqualTo(i);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/81d65f1c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java
deleted file mode 100644
index 32def39..0000000
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java
+++ /dev/null
@@ -1,155 +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.hbase.mail.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.UUID;
-
-import org.apache.james.mailbox.hbase.HBaseId;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.junit.Test;
-
-/**
- * Unit tests for HBaseMailbox class.
- */
-public class HBaseMailboxTest {
-
-    /**
-     * Test of getter and setter for MailboxId
-     */
-    @Test
-    public void testGetSetMailboxId() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 10);
-
-        HBaseId expResult = HBaseId.of(UUID.randomUUID());
-        instance.setMailboxId(expResult);
-        assertThat(instance.getMailboxId()).isEqualTo(expResult);
-
-    }
-
-    /**
-     * Test of getter and setter for Namespace, of class HBaseMailbox.
-     */
-    @Test
-    public void testGetSetNamespace() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 124566);
-        String result = instance.getNamespace();
-        assertThat(result).isEqualTo(mailboxPath.getNamespace());
-
-        instance.setNamespace("newName");
-        assertThat(instance.getNamespace()).isEqualTo("newName");
-
-    }
-
-    /**
-     * Test of getter and setter for User, of class HBaseMailbox.
-     */
-    @Test
-    public void testGetSetUser() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 12);
-        String result = instance.getUser();
-        assertThat(result).isEqualTo(mailboxPath.getUser());
-
-        instance.setUser("eric");
-        assertThat(instance.getUser()).isEqualTo("eric");
-    }
-
-    /**
-     * Test of getter and setter for Name, of class HBaseMailbox.
-     */
-    @Test
-    public void testGetSetName() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 1677);
-        String result = instance.getName();
-        assertThat(result).isEqualTo(mailboxPath.getName());
-
-        instance.setName("newINBOX");
-        assertThat(instance.getName()).isEqualTo("newINBOX");
-    }
-
-    /**
-     * Test of getUidValidity method, of class HBaseMailbox.
-     */
-    @Test
-    public void testGetUidValidity() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 123345);
-        long expResult = 123345L;
-        long result = instance.getUidValidity();
-        assertThat(result).isEqualTo(expResult);
-
-    }
-
-    /**
-     * Test of hashCode method, of class HBaseMailbox.
-     */
-    @Test
-    public void testHashCode() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 1234);
-        // from the hashCode()
-        final int PRIME = 31;
-        int result = 1;
-        HBaseId mailboxId = instance.getMailboxId();
-        int expResult = PRIME * result + (int) (mailboxId.getRawId().getMostSignificantBits() ^ (mailboxId.getRawId().getMostSignificantBits() >>> 32));
-
-        assertThat(instance.hashCode()).isEqualTo(expResult);
-    }
-
-    /**
-     * Test of equals method, of class HBaseMailbox.
-     */
-    @Test
-    public void testEquals() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 12345);
-        final HBaseMailbox instance2 = new HBaseMailbox(mailboxPath, 12345);
-        instance2.setMailboxId(instance.getMailboxId());
-        assertThat(instance2).isEqualTo(instance);
-    }
-
-    /**
-     * Test of consumeUid method, of class HBaseMailbox.
-     */
-    @Test
-    public void testConsumeUid() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 10);
-        long expResult = instance.getLastUid() + 1;
-        long result = instance.consumeUid();
-        assertThat(result).isEqualTo(expResult);
-    }
-
-    /**
-     * Test of consumeModSeq method, of class HBaseMailbox.
-     */
-    @Test
-    public void testConsumeModSeq() {
-        final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
-        final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 10);
-        long expResult = instance.getHighestModSeq() + 1;
-        long result = instance.consumeModSeq();
-        assertThat(result).isEqualTo(expResult);
-    }
-}


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