You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/06/13 02:28:18 UTC

[3/5] james-project git commit: JAMES-2050 IMAPServer should be tested on added method

JAMES-2050 IMAPServer should be tested on added method


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

Branch: refs/heads/master
Commit: 1bb8211238c910f3fdb699f4a895b1d6959fc26d
Parents: 6d01474
Author: quynhn <qn...@linagora.com>
Authored: Mon Jun 12 11:33:48 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Mon Jun 12 17:45:18 2017 +0700

----------------------------------------------------------------------
 server/pom.xml                                  |  5 ++
 server/protocols/protocols-imap4/pom.xml        | 37 +++++++---
 .../james/imapserver/netty/IMAPServerTest.java  | 71 ++++++++++++++++++++
 3 files changed, 102 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1bb82112/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 5f497c3..3fd0e88 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -1067,6 +1067,11 @@
                 <artifactId>commons-cli</artifactId>
                 <version>${commons-cli.version}</version>
             </dependency>
+            <dependency>
+                <groupId>commons-logging</groupId>
+                <artifactId>commons-logging</artifactId>
+                <version>${commons-logging.version}</version>
+            </dependency>
 
             <!-- used by spring deployment -->
             <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1bb82112/server/protocols/protocols-imap4/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/pom.xml b/server/protocols/protocols-imap4/pom.xml
index 287ca40..d0d16f4 100644
--- a/server/protocols/protocols-imap4/pom.xml
+++ b/server/protocols/protocols-imap4/pom.xml
@@ -53,34 +53,49 @@
             <groupId>org.apache.james.protocols</groupId>
             <artifactId>protocols-imap</artifactId>
         </dependency>
-
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.james.protocols</groupId>
             <artifactId>protocols-netty</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.1_spec</artifactId>
         </dependency>
         <dependency>
             <groupId>commons-configuration</groupId>
             <artifactId>commons-configuration</artifactId>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+        </dependency>
+        <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-annotation_1.1_spec</artifactId>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
-          <groupId>javax.inject</groupId>
-          <artifactId>javax.inject</artifactId>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj-1.version}</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1bb82112/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
new file mode 100644
index 0000000..cc14eb6
--- /dev/null
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.imapserver.netty;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.imap.api.ImapConfiguration;
+import org.apache.james.imap.processor.IdleProcessor;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+
+import com.google.common.collect.ImmutableSet;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class IMAPServerTest {
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void getImapConfigurationShouldReturnDefaultValuesWhenEmpty() throws Exception {
+        ImapConfiguration imapConfiguration = IMAPServer.getImapConfiguration(new DefaultConfigurationBuilder());
+
+        ImapConfiguration expectImapConfiguration = ImapConfiguration.builder()
+                .enableIdle(IdleProcessor.DEFAULT_ENABLE_IDLE)
+                .idleTimeInterval(IdleProcessor.DEFAULT_HEARTBEAT_INTERVAL_IN_SECONDS)
+                .idleTimeIntervalUnit(IdleProcessor.DEFAULT_HEARTBEAT_INTERVAL_UNIT)
+                .disabledCaps(ImmutableSet.<String>of())
+                .build();
+
+        assertThat(imapConfiguration).isEqualTo(expectImapConfiguration);
+    }
+
+    @Test
+    public void getImapConfigurationShouldReturnSetValue() throws Exception {
+        DefaultConfigurationBuilder configurationBuilder = new DefaultConfigurationBuilder();
+        configurationBuilder.addProperty("enableIdle", "false");
+        configurationBuilder.addProperty("idleTimeInterval", "1");
+        configurationBuilder.addProperty("idleTimeIntervalUnit", "MINUTES");
+        configurationBuilder.addProperty("disabledCaps", "ACL | MOVE");
+        ImapConfiguration imapConfiguration = IMAPServer.getImapConfiguration(configurationBuilder);
+
+        ImapConfiguration expectImapConfiguration = ImapConfiguration.builder()
+                .enableIdle(false)
+                .idleTimeInterval(1)
+                .idleTimeIntervalUnit(TimeUnit.MINUTES)
+                .disabledCaps(ImmutableSet.of("ACL", "MOVE"))
+                .build();
+
+        assertThat(imapConfiguration).isEqualTo(expectImapConfiguration);
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org