james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [01/18] james-project git commit: MAILBOX-266 JamesCapabilitiesTests should be located in an up to date project
Date Wed, 06 Apr 2016 09:21:45 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 8005257c4 -> d1d5712f9


MAILBOX-266 JamesCapabilitiesTests should be located in an up to date project


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

Branch: refs/heads/master
Commit: 41ca5753c037cad1649f660841ac2460e7f53b05
Parents: 8005257
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Mar 24 18:08:48 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Apr 6 16:06:26 2016 +0700

----------------------------------------------------------------------
 .../james/JamesCapabilitiesServerTest.java      |  99 ------------------
 server/container/guice/cassandra-guice/pom.xml  |   5 +
 .../james/JamesCapabilitiesServerTest.java      | 100 +++++++++++++++++++
 3 files changed, 105 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/41ca5753/server/container/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
b/server/container/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
deleted file mode 100644
index 6652b97..0000000
--- a/server/container/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ /dev/null
@@ -1,99 +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;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.jmap.methods.GetMessageListMethod;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestFilesystemModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.google.inject.util.Modules;
-
-public class JamesCapabilitiesServerTest {
-
-    private CassandraJamesServer server;
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
-
-    @Rule
-    public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private Module createModule(MailboxManager mailboxManager) {
-        return Modules.override(CassandraJamesServerMain.defaultModule)
-                .with(new TestElasticSearchModule(embeddedElasticSearch),
-                        new TestFilesystemModule(temporaryFolder),
-                        new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT),
-                        new AbstractModule() {
-                    
-                    @Override
-                    protected void configure() {
-                        bind(MailboxManager.class).toInstance(mailboxManager);
-                    }
-                    
-                    @Provides
-                    @Singleton
-                    com.datastax.driver.core.Session provideSession(CassandraModule cassandraModule)
{
-                        CassandraCluster cassandra = CassandraCluster.create(cassandraModule);
-                        return cassandra.getConf();
-                    }
-
-                });
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void startShouldFailWhenNoMoveCapability() throws Exception {
-        MailboxManager mailboxManager = mock(MailboxManager.class);
-        when(mailboxManager.getSupportedCapabilities())
-            .thenReturn(ImmutableList.of(MailboxManager.Capabilities.Basic));
-        server = new CassandraJamesServer(createModule(mailboxManager));
-        
-        server.start();
-        
-        // In case of non-failure
-        server.stop();
-    }
-
-    @Test
-    public void startShouldSucceedWhenMoveCapability() throws Exception {
-        MailboxManager mailboxManager = mock(MailboxManager.class);
-        when(mailboxManager.getSupportedCapabilities())
-            .thenReturn(ImmutableList.of(MailboxManager.Capabilities.Move));
-        server = new CassandraJamesServer(createModule(mailboxManager));
-        
-        server.start();
-        
-        server.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/41ca5753/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index b66fa2e..254d6ef 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -259,6 +259,11 @@
                     <version>${cassandra-unit.version}</version>
                     <scope>test</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.mockito</groupId>
+                    <artifactId>mockito-core</artifactId>
+                    <scope>test</scope>
+                </dependency>
             </dependencies>
         </profile>
         <profile>

http://git-wip-us.apache.org/repos/asf/james-project/blob/41ca5753/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
new file mode 100644
index 0000000..b691ec5
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -0,0 +1,100 @@
+/****************************************************************
+ * 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;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.jmap.methods.GetMessageListMethod;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.cassandra.CassandraId;
+import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+import com.datastax.driver.core.Session;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+
+public class JamesCapabilitiesServerTest {
+
+    private GuiceJamesServer<CassandraId> server;
+    private TemporaryFolder temporaryFolder = new TemporaryFolder();
+    private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
+
+    @Rule
+    public RuleChain chain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
+
+    @Test(expected=IllegalArgumentException.class)
+    public void startShouldFailWhenNoMoveCapability() throws Exception {
+        MailboxManager mailboxManager = mock(MailboxManager.class);
+        when(mailboxManager.getSupportedCapabilities())
+            .thenReturn(ImmutableList.of(MailboxManager.Capabilities.Basic));
+        server = createCassandraJamesServer(mailboxManager);
+
+        server.start();
+
+        // In case of non-failure
+        server.stop();
+    }
+
+    @Test
+    public void startShouldSucceedWhenMoveCapability() throws Exception {
+        MailboxManager mailboxManager = mock(MailboxManager.class);
+        when(mailboxManager.getSupportedCapabilities())
+            .thenReturn(ImmutableList.of(MailboxManager.Capabilities.Move));
+        server = createCassandraJamesServer(mailboxManager);
+
+        server.start();
+
+        server.stop();
+    }
+
+    private GuiceJamesServer<CassandraId> createCassandraJamesServer(final MailboxManager
mailboxManager) {
+        return new GuiceJamesServer<>(CassandraJamesServerMain.cassandraId)
+            .combineWith(CassandraJamesServerMain.cassandraServerModule)
+            .overrideWith(new TestElasticSearchModule(embeddedElasticSearch),
+                new TestFilesystemModule(temporaryFolder),
+                new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT),
+                new AbstractModule() {
+
+                    @Override
+                    protected void configure() {
+                        bind(MailboxManager.class).toInstance(mailboxManager);
+                    }
+
+                    @SuppressWarnings("unused")
+                    @Provides
+                    @Singleton
+                    Session provideSession(CassandraModule cassandraModule) {
+                        CassandraCluster cassandra = CassandraCluster.create(cassandraModule);
+                        return cassandra.getConf();
+                    }
+                });
+    }
+}


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