james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r638520 [1/3] - in /james/server/trunk/experimental-seda-imap-function/src/test: java/org/apache/james/test/functional/ resources/org/apache/james/test/functional/imap/scripts/
Date Tue, 18 Mar 2008 19:26:49 GMT
Author: rdonkin
Date: Tue Mar 18 12:26:45 2008
New Revision: 638520

URL: http://svn.apache.org/viewvc?rev=638520&view=rev
Log:
Tests for UID search

Added:
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchAtoms.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/UidSearchCombinations.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=638520&r1=638519&r2=638520&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
Tue Mar 18 12:26:45 2008
@@ -35,11 +35,11 @@
 
     public static final void main(String[] args) throws Exception {
         ScriptBuilder builder = ScriptBuilder.open("localhost", 143);
-        searchCombinations(builder);
+        searchAtoms(builder, true);
     }
     
-    public static void searchCombinations(ScriptBuilder builder) throws Exception {
-        setupSearch(builder);
+    public static void searchCombinations(ScriptBuilder builder, boolean uids) throws Exception
{
+        setupSearch(builder, uids);
         builder.body(COMMON_LETTER).undraft().unflagged().answered().search();
         builder.to(COMMON_LETTER).draft().flagged().answered().search();
         builder.to(COMMON_LETTER).smaller(10000).all().draft().search();
@@ -68,8 +68,8 @@
         builder.quit();
     }
     
-    public static void searchAtoms(ScriptBuilder builder) throws Exception {
-        setupSearch(builder);
+    public static void searchAtoms(ScriptBuilder builder, boolean uids) throws Exception
{
+        setupSearch(builder, uids);
         builder.all().search();
         builder.answered().search();
         builder.bcc(COMMON_LETTER).search();
@@ -183,10 +183,10 @@
         builder.quit();
     }
 
-    private static void setupSearch(ScriptBuilder builder) throws Exception {
-        builder.login();
-        builder.create();
-        builder.select();
+    private static void setupSearch(ScriptBuilder builder, boolean uids) throws Exception
{
+        builder.setUidSearch(uids);
+        setup(builder);
+        padUids(builder);
         loadLotsOfMail(builder);
         builder.store(builder.flags().add().flagged().range(1, 9));
         builder.store(builder.flags().add().answered().range(1, 4));
@@ -207,7 +207,20 @@
         builder.store(builder.flags().add().deleted().range(1,3));
     }
 
+    private static void setup(ScriptBuilder builder) throws Exception {
+        builder.login();
+        builder.create();
+        builder.select();
+    }
 
+    private static void padUids(ScriptBuilder builder) throws Exception {
+        builder.setFile("rfc822.mail");
+        for (int i=0;i<20;i++) {
+            builder.append();
+            builder.flagDeleted().expunge();
+        }
+    }
+    
     private static void loadLotsOfMail(ScriptBuilder builder) throws Exception {
         builder.append();
         builder.setFile("wild-example.mail");

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=638520&r1=638519&r2=638520&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
Tue Mar 18 12:26:45 2008
@@ -43,6 +43,7 @@
     
     private int tagCount = 0;
     
+    private boolean uidSearch = false;
     private boolean peek = false;
     private int messageNumber = 1;
     private String user = "imapuser";
@@ -69,6 +70,14 @@
         this.peek = peek;
     }
 
+    public final boolean isUidSearch() {
+        return uidSearch;
+    }
+
+    public final void setUidSearch(boolean uidSearch) {
+        this.uidSearch = uidSearch;
+    }
+
     public final String getBasedir() {
         return basedir;
     }
@@ -154,6 +163,16 @@
         createdMailbox = true;
     }
     
+    public ScriptBuilder flagDeleted() throws Exception {
+        store(new Flags().deleted().msn(messageNumber));
+        return this;
+    }
+    
+    public ScriptBuilder expunge() throws Exception {
+        command("EXPUNGE");
+        return this;
+    }
+    
     public void delete() throws Exception {
         if (createdMailbox) {
             command("DELETE " + mailbox);
@@ -161,6 +180,7 @@
     }
     
     public void search() throws Exception {
+        search.setUidSearch(uidSearch);
         command(search.command());
         search = new Search();
     }
@@ -558,13 +578,26 @@
 
         private StringBuffer buffer;
         private boolean first;
+        private boolean uidSearch = false;
         
         public Search() {
             clear();
         }
         
+        public final boolean isUidSearch() {
+            return uidSearch;
+        }
+
+        public final void setUidSearch(boolean uidSearch) {
+            this.uidSearch = uidSearch;
+        }
+
         public String command() {
-            return "SEARCH " + buffer.toString();
+            if (uidSearch) {
+                return "UID SEARCH " + buffer.toString();
+            } else {
+                return "SEARCH " + buffer.toString();
+            }
         }
         
         public void clear() {



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