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 rd...@apache.org on 2008/03/29 11:18:19 UTC
svn commit: r642525 - in
/james/server/trunk/experimental-seda-imap-function/src/test:
java/org/apache/james/test/functional/
resources/org/apache/james/test/functional/imap/scripts/
Author: rdonkin
Date: Sat Mar 29 03:18:18 2008
New Revision: 642525
URL: http://svn.apache.org/viewvc?rev=642525&view=rev
Log:
Test script for partial fetch
Added:
james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test
Modified:
james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/CreateScript.java
james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/ScriptBuilder.java
Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/CreateScript.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/CreateScript.java?rev=642525&r1=642524&r2=642525&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/CreateScript.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/CreateScript.java Sat Mar 29 03:18:18 2008
@@ -35,7 +35,32 @@
public static final void main(String[] args) throws Exception {
ScriptBuilder builder = ScriptBuilder.open("localhost", 143);
- searchAtoms(builder, true);
+ bodyPartialFetch(builder);
+ }
+
+ public static void bodyPartialFetch(ScriptBuilder builder) throws Exception {
+ builder.login();
+ builder.create();
+ builder.select();
+ builder.setFile("multipart-mixed.mail");
+ builder.append();
+ builder.select();
+ builder.partial(0, 10).fetchSection("");
+ builder.partial(0, 100).fetchSection("");
+ builder.partial(0, 1000).fetchSection("");
+ builder.partial(0, 10000).fetchSection("");
+ builder.partial(0, 100000).fetchSection("");
+ builder.partial(100, 10).fetchSection("");
+ builder.partial(100, 100).fetchSection("");
+ builder.partial(100, 1000).fetchSection("");
+ builder.partial(100, 10000).fetchSection("");
+ builder.partial(100, 100000).fetchSection("");
+ builder.partial(10000, 10).fetchSection("");
+ builder.partial(10000, 100).fetchSection("");
+ builder.partial(10000, 1000).fetchSection("");
+ builder.partial(10000, 10000).fetchSection("");
+ builder.partial(10000, 100000).fetchSection("");
+ builder.quit();
}
public static void searchCombinations(ScriptBuilder builder, boolean uids) throws Exception {
Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/ScriptBuilder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/ScriptBuilder.java?rev=642525&r1=642524&r2=642525&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/ScriptBuilder.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/ScriptBuilder.java Sat Mar 29 03:18:18 2008
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.WritableByteChannel;
@@ -55,6 +56,7 @@
private final Client client;
private Fetch fetch = new Fetch();
private Search search = new Search();
+ private String partialFetch = "";
public ScriptBuilder(final Client client) {
@@ -154,8 +156,9 @@
response();
}
- public void select() throws Exception {
+ public ScriptBuilder select() throws Exception {
command("SELECT " + mailbox);
+ return this;
}
public void create() throws Exception {
@@ -398,15 +401,21 @@
return search;
}
- public void fetchSection(String section) throws Exception {
+ public ScriptBuilder partial(long start, long octets) {
+ partialFetch = "<" + start + "." + octets + ">";
+ return this;
+ }
+
+ public ScriptBuilder fetchSection(String section) throws Exception {
final String body;
if (peek) {
body = " (BODY.PEEK[";
} else {
body = " (BODY[";
}
- final String command = "FETCH " + messageNumber + body + section + "])";
+ final String command = "FETCH " + messageNumber + body + section + "]" + partialFetch + ")";
command(command);
+ return this;
}
public void fetchAllMessages() throws Exception {
@@ -1168,9 +1177,10 @@
}
private static final class Out {
+ private final CharBuffer lineBuffer = CharBuffer.allocate(1048);
private boolean isClient = false;
public void client() {
- System.out.print("C: ");
+ lineBuffer.put("C: ");
isClient = true;
}
@@ -1178,18 +1188,18 @@
if (!isClient) {
escape(next);
}
- System.out.print(next);
+ lineBuffer.put(next);
}
private void escape(char next) {
if (next == '\\' || next == '*' || next=='.' || next == '[' || next == ']' || next == '+'
|| next == '(' || next == ')' || next == '{' || next == '}' || next == '?') {
- System.out.print('\\');
+ lineBuffer.put('\\');
}
}
public void server() {
- System.out.print("S: ");
+ lineBuffer.put("S: ");
isClient = false;
}
@@ -1207,11 +1217,17 @@
phrase = StringUtils.replace(phrase, "{", "\\{");
phrase = StringUtils.replace(phrase, "?", "\\?");
}
- System.out.print(phrase);
+ lineBuffer.put(phrase);
}
public void lineEnd() {
- System.out.println();
+ lineBuffer.flip();
+ String line = lineBuffer.toString();
+ line = StringUtils.replace(line, "OK Create completed", "OK CREATE completed");
+ line = StringUtils.replace(line, "OK Fetch completed", "OK FETCH completed");
+ line = StringUtils.replace(line, "OK Append completed", "OK APPEND completed");
+ System.out.println(line);
+ lineBuffer.clear();
}
}
Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test?rev=642525&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test (added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BodyPartialFetch.test Sat Mar 29 03:18:18 2008
@@ -0,0 +1,322 @@
+S: \* OK Dovecot ready\.
+C: A1 LOGIN imapuser password
+S: A1 OK Logged in\.
+C: A2 CREATE testmailbox
+S: A2 OK Create completed\.
+C: A3 SELECT testmailbox
+S: \* FLAGS \(\\Answered \\Flagged \\Deleted \\Seen \\Draft\)
+S: \* OK \[PERMANENTFLAGS \(\\Answered \\Flagged \\Deleted \\Seen \\Draft \\\*\)\] Flags permitted\.
+S: \* 0 EXISTS
+S: \* 0 RECENT
+S: \* OK \[UIDVALIDITY 1206782202\] UIDs valid
+S: \* OK \[UIDNEXT 1\] Predicted next UID
+S: A3 OK \[READ-WRITE\] Select completed\.
+C: A4 APPEND testmailbox {765+}
+C: From: Timothy Tayler <ti...@example.org>
+C: To: Samual Smith <sa...@example.org>
+C: Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)
+C: Subject: A Multipart Email
+C: Content-Type: multipart/mixed;boundary=1729
+C:
+C: Start with a preamble
+C:
+C: --1729
+C: Content-Type: text/plain; charset=US-ASCII
+C:
+C: Rhubarb!
+C:
+C: --1729
+C: Content-Type: text/html; charset=US-ASCII
+C:
+C: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+C:
+C: --1729
+C: Content-Type: application/xhtml+xml
+C:
+C: <!DOCTYPE html
+C: PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+C: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+C: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+C:
+C: --1729
+C: Content-Type: image/jpeg
+C: Content-Transfer-Encoding: base64
+C:
+C: 1234567890ABCDEFGHIJKLMNOPQ
+C:
+C: --1729--
+C:
+S: \* 1 EXISTS
+S: \* 1 RECENT
+S: A4 OK Append completed\.
+C: A5 SELECT testmailbox
+S: \* FLAGS \(\\Answered \\Flagged \\Deleted \\Seen \\Draft\)
+S: \* OK \[PERMANENTFLAGS \(\\Answered \\Flagged \\Deleted \\Seen \\Draft \\\*\)\] Flags permitted\.
+S: \* 1 EXISTS
+S: \* 1 RECENT
+S: \* OK \[UNSEEN 1\] First unseen\.
+S: \* OK \[UIDVALIDITY 1206782202\] UIDs valid
+S: \* OK \[UIDNEXT 2\] Predicted next UID
+S: A5 OK \[READ-WRITE\] Select completed\.
+C: A6 FETCH 1 (BODY[]<0.10>)
+S: \* 1 FETCH \(FLAGS \(\\Seen \\Recent\) BODY\[\]<0> \{10\}
+S: From: Timo\)
+S: A6 OK Fetch completed\.
+C: A7 FETCH 1 (BODY[]<0.100>)
+S: \* 1 FETCH \(BODY\[\]<0> \{100\}
+S: From: Timothy Tayler <timothy@example\.org>
+S: To: Samual Smith <samual@example\.org>
+S: Date: Thu, 14 Feb\)
+S: A7 OK Fetch completed\.
+C: A8 FETCH 1 (BODY[]<0.1000>)
+S: \* 1 FETCH \(BODY\[\]<0> \{765\}
+S: From: Timothy Tayler <timothy@example\.org>
+S: To: Samual Smith <samual@example\.org>
+S: Date: Thu, 14 Feb 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A8 OK Fetch completed\.
+C: A9 FETCH 1 (BODY[]<0.10000>)
+S: \* 1 FETCH \(BODY\[\]<0> \{765\}
+S: From: Timothy Tayler <timothy@example\.org>
+S: To: Samual Smith <samual@example\.org>
+S: Date: Thu, 14 Feb 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A9 OK Fetch completed\.
+C: A10 FETCH 1 (BODY[]<0.100000>)
+S: \* 1 FETCH \(BODY\[\]<0> \{765\}
+S: From: Timothy Tayler <timothy@example\.org>
+S: To: Samual Smith <samual@example\.org>
+S: Date: Thu, 14 Feb 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A10 OK Fetch completed\.
+C: A11 FETCH 1 (BODY[]<100.10>)
+S: \* 1 FETCH \(BODY\[\]<100> \{10\}
+S: 2008 12:0\)
+S: A11 OK Fetch completed\.
+C: A12 FETCH 1 (BODY[]<100.100>)
+S: \* 1 FETCH \(BODY\[\]<100> \{100\}
+S: 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+\)
+S: A12 OK Fetch completed\.
+C: A13 FETCH 1 (BODY[]<100.1000>)
+S: \* 1 FETCH \(BODY\[\]<100> \{665\}
+S: 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A13 OK Fetch completed\.
+C: A14 FETCH 1 (BODY[]<100.10000>)
+S: \* 1 FETCH \(BODY\[\]<100> \{665\}
+S: 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A14 OK Fetch completed\.
+C: A15 FETCH 1 (BODY[]<100.100000>)
+S: \* 1 FETCH \(BODY\[\]<100> \{665\}
+S: 2008 12:00:00 \+0000 \(GMT\)
+S: Subject: A Multipart Email
+S: Content-Type: multipart/mixed;boundary=1729
+S:
+S: Start with a preamble
+S:
+S: --1729
+S: Content-Type: text/plain; charset=US-ASCII
+S:
+S: Rhubarb!
+S:
+S: --1729
+S: Content-Type: text/html; charset=US-ASCII
+S:
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: application/xhtml\+xml
+S:
+S: <!DOCTYPE html
+S: PUBLIC "-//W3C//DTD XHTML 1\.0 Strict//EN"
+S: "http://www\.w3\.org/TR/xhtml1/DTD/xhtml1-strict\.dtd">
+S: <html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>
+S:
+S: --1729
+S: Content-Type: image/jpeg
+S: Content-Transfer-Encoding: base64
+S:
+S: 1234567890ABCDEFGHIJKLMNOPQ
+S:
+S: --1729--
+S: \)
+S: A15 OK Fetch completed\.
+C: A16 FETCH 1 (BODY[]<10000.10>)
+S: \* 1 FETCH \(BODY\[\]<10000> \{0\}
+S: \)
+S: A16 OK Fetch completed\.
+C: A17 FETCH 1 (BODY[]<10000.100>)
+S: \* 1 FETCH \(BODY\[\]<10000> \{0\}
+S: \)
+S: A17 OK Fetch completed\.
+C: A18 FETCH 1 (BODY[]<10000.1000>)
+S: \* 1 FETCH \(BODY\[\]<10000> \{0\}
+S: \)
+S: A18 OK Fetch completed\.
+C: A19 FETCH 1 (BODY[]<10000.10000>)
+S: \* 1 FETCH \(BODY\[\]<10000> \{0\}
+S: \)
+S: A19 OK Fetch completed\.
+C: A20 FETCH 1 (BODY[]<10000.100000>)
+S: \* 1 FETCH \(BODY\[\]<10000> \{0\}
+S: \)
+S: A20 OK Fetch completed\.
+C: A21 DELETE testmailbox
+S: A21 OK Delete completed\.
+C: A22 LOGOUT
+S: \* BYE Logging out
+S: A22 OK Logout completed\.
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org