james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [7/9] james-project git commit: PROTOCOL-117 swap SearchResponseEncoderTest and ListResponseEncoderTest (no code change)
Date Wed, 08 Nov 2017 07:29:54 GMT
PROTOCOL-117 swap SearchResponseEncoderTest and ListResponseEncoderTest (no code change)


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

Branch: refs/heads/master
Commit: 78f23907f8405efdc69d7d22b41dfde821394c95
Parents: 7ed93d9
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Tue Nov 7 17:33:22 2017 +0100
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Tue Nov 7 17:55:48 2017 +0100

----------------------------------------------------------------------
 .../imap/encode/ListResponseEncoderTest.java    | 63 ++++++++++++++++----
 .../imap/encode/SearchResponseEncoderTest.java  | 63 ++++----------------
 2 files changed, 63 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/78f23907/protocols/imap/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
index 8c26450..67bd1bc 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
@@ -26,7 +26,8 @@ import static org.junit.Assert.assertTrue;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.encode.base.ByteImapResponseWriter;
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
-import org.apache.james.imap.message.response.SearchResponse;
+import org.apache.james.imap.message.response.LSubResponse;
+import org.apache.james.imap.message.response.ListResponse;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Before;
@@ -34,11 +35,7 @@ import org.junit.Test;
 
 public class ListResponseEncoderTest {
 
-    private static final long[] IDS = { 1, 4, 9, 16 };
-
-    private SearchResponse response;
-
-    private SearchResponseEncoder encoder;
+    private ListResponseEncoder encoder;
 
     private ImapEncoder mockNextEncoder;
 
@@ -50,20 +47,62 @@ public class ListResponseEncoderTest {
     @Before
     public void setUp() throws Exception {
         mockNextEncoder = context.mock(ImapEncoder.class);
-        response = new SearchResponse(IDS, null);
-        encoder = new SearchResponseEncoder(mockNextEncoder);
+        encoder = new ListResponseEncoder(mockNextEncoder);
     }
 
     @Test
     public void testIsAcceptable() {
-        assertTrue(encoder.isAcceptable(response));
+        assertTrue(encoder.isAcceptable(new ListResponse(true, true, true,
+                true, false, false, "name", '.')));
+        assertFalse(encoder.isAcceptable(new LSubResponse("name", true, '.')));
         assertFalse(encoder.isAcceptable(context.mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));
     }
 
     @Test
-    public void testEncode() throws Exception {
-        encoder.encode(response, composer, new FakeImapSession());
-        assertEquals("* SEARCH 1 4 9 16\r\n", writer.getString());
+	public void testName() throws Exception {     
+        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST () \".\" \"INBOX.name\"\r\n", writer.getString());
+    }
+
+    @Test
+	public void testDelimiter() throws Exception {
+        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST () \".\" \"INBOX.name\"\r\n", writer.getString());
+    }
+
+
+    @Test
+    public void testAllAttributes() throws Exception {
+        encoder.encode(new ListResponse(true, true, true, true, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST (\\Noinferiors \\Noselect \\Marked \\Unmarked) \".\" \"INBOX.name\"\r\n",
writer.getString());
+
+    }
+
+    @Test
+    public void testNoInferiors() throws Exception {      
+        encoder.encode(new ListResponse(true, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST (\\Noinferiors) \".\" \"INBOX.name\"\r\n", writer.getString());
+    }
+
+    @Test
+    public void testNoSelect() throws Exception {
+        encoder.encode(new ListResponse(false, true, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST (\\Noselect) \".\" \"INBOX.name\"\r\n", writer.getString());
+
+    }
+
+    @Test
+    public void testMarked() throws Exception {
+        encoder.encode(new ListResponse(false, false, true, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST (\\Marked) \".\" \"INBOX.name\"\r\n", writer.getString());
+
+    }
+
+    @Test
+    public void testUnmarked() throws Exception {
+        encoder.encode(new ListResponse(false, false, false, true, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
+        assertEquals("* LIST (\\Unmarked) \".\" \"INBOX.name\"\r\n", writer.getString());
+
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/78f23907/protocols/imap/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
index 1b2bb80..fe6d0a0 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
@@ -26,8 +26,7 @@ import static org.junit.Assert.assertTrue;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.encode.base.ByteImapResponseWriter;
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
-import org.apache.james.imap.message.response.LSubResponse;
-import org.apache.james.imap.message.response.ListResponse;
+import org.apache.james.imap.message.response.SearchResponse;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Before;
@@ -35,7 +34,11 @@ import org.junit.Test;
 
 public class SearchResponseEncoderTest {
 
-    private ListResponseEncoder encoder;
+    private static final long[] IDS = { 1, 4, 9, 16 };
+
+    private SearchResponse response;
+
+    private SearchResponseEncoder encoder;
 
     private ImapEncoder mockNextEncoder;
 
@@ -47,62 +50,20 @@ public class SearchResponseEncoderTest {
     @Before
     public void setUp() throws Exception {
         mockNextEncoder = context.mock(ImapEncoder.class);
-        encoder = new ListResponseEncoder(mockNextEncoder);
+        response = new SearchResponse(IDS, null);
+        encoder = new SearchResponseEncoder(mockNextEncoder);
     }
 
     @Test
     public void testIsAcceptable() {
-        assertTrue(encoder.isAcceptable(new ListResponse(true, true, true,
-                true, false, false, "name", '.')));
-        assertFalse(encoder.isAcceptable(new LSubResponse("name", true, '.')));
+        assertTrue(encoder.isAcceptable(response));
         assertFalse(encoder.isAcceptable(context.mock(ImapMessage.class)));
         assertFalse(encoder.isAcceptable(null));
     }
 
     @Test
-	public void testName() throws Exception {     
-        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST () \".\" \"INBOX.name\"\r\n", writer.getString());
-    }
-
-    @Test
-	public void testDelimiter() throws Exception {
-        encoder.encode(new ListResponse(false, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST () \".\" \"INBOX.name\"\r\n", writer.getString());
-    }
-
-
-    @Test
-    public void testAllAttributes() throws Exception {
-        encoder.encode(new ListResponse(true, true, true, true, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST (\\Noinferiors \\Noselect \\Marked \\Unmarked) \".\" \"INBOX.name\"\r\n",
writer.getString());
-
-    }
-
-    @Test
-    public void testNoInferiors() throws Exception {      
-        encoder.encode(new ListResponse(true, false, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST (\\Noinferiors) \".\" \"INBOX.name\"\r\n", writer.getString());
-    }
-
-    @Test
-    public void testNoSelect() throws Exception {
-        encoder.encode(new ListResponse(false, true, false, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST (\\Noselect) \".\" \"INBOX.name\"\r\n", writer.getString());
-
-    }
-
-    @Test
-    public void testMarked() throws Exception {
-        encoder.encode(new ListResponse(false, false, true, false, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST (\\Marked) \".\" \"INBOX.name\"\r\n", writer.getString());
-
-    }
-
-    @Test
-    public void testUnmarked() throws Exception {
-        encoder.encode(new ListResponse(false, false, false, true, false, false, "INBOX.name",
'.'), composer, new FakeImapSession());
-        assertEquals("* LIST (\\Unmarked) \".\" \"INBOX.name\"\r\n", writer.getString());
-
+    public void testEncode() throws Exception {
+        encoder.encode(response, composer, new FakeImapSession());
+        assertEquals("* SEARCH 1 4 9 16\r\n", writer.getString());
     }
 }


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