james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joac...@apache.org
Subject svn commit: r470831 - in /james/server/trunk/src/test/org/apache/james/imapserver: client/FetchCommand.java handler/session/BodyFetchSessionTest.java
Date Fri, 03 Nov 2006 14:12:58 GMT
Author: joachim
Date: Fri Nov  3 06:12:58 2006
New Revision: 470831

URL: http://svn.apache.org/viewvc?view=rev&rev=470831
Log:
smaller refactorings to applied patch

Modified:
    james/server/trunk/src/test/org/apache/james/imapserver/client/FetchCommand.java
    james/server/trunk/src/test/org/apache/james/imapserver/handler/session/BodyFetchSessionTest.java

Modified: james/server/trunk/src/test/org/apache/james/imapserver/client/FetchCommand.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/client/FetchCommand.java?view=diff&rev=470831&r1=470830&r2=470831
==============================================================================
--- james/server/trunk/src/test/org/apache/james/imapserver/client/FetchCommand.java (original)
+++ james/server/trunk/src/test/org/apache/james/imapserver/client/FetchCommand.java Fri Nov
 3 06:12:58 2006
@@ -31,9 +31,9 @@
     
     private FetchBody body;
     
-    private boolean oneSwitchOnly = false;
+    private boolean useParenthesis = true;
     
-    private boolean oneMessageOnly = false;
+    private boolean oneSeqNumberOnly = false;
 
     public FetchCommand(MimeMessage[] msgs, long from, long to) {
         statusResponse = "OK FETCH completed.";
@@ -42,16 +42,16 @@
         this.to = to;
     }
 
-    public FetchCommand(MimeMessage[] msgs, long from) {
+    public FetchCommand(MimeMessage[] msgs, long no) {
         statusResponse = "OK FETCH completed.";
         this.msgs = msgs;
-        this.from = from;
-        this.to = from;
-        this.oneMessageOnly = true;
+        this.from = no;
+        this.to = no;
+        this.oneSeqNumberOnly = true;
     }
 
-    public void setOneSwitchOnly(boolean oneSwitchOnly) {
-		this.oneSwitchOnly = oneSwitchOnly;
+    public void setUseParenthesis(boolean useParenthesis) {
+		this.useParenthesis = useParenthesis;
 	}
     
     public void setUids(long[] uids) {
@@ -60,56 +60,51 @@
     }
 
     public String getCommand() {
-        String command = "";
-        if (uid) {
-            command += "UID ";
-        }
-        command += "fetch " + from ;
-        if (!oneMessageOnly) {
-	        if (to > 0) {
-	            command += ":"+to;
-	        } else {
-	            command += ":*";
-	        }
-        }
-        if (oneSwitchOnly) {
-        	if (fetchFlags) {
-        		command += " FLAGS\n";
-        	} else if (fetchRfc822Size) {
-        		command += " RFC822.SIZE\n";
-        	} else if (body!=null) {
-        		command += " "+body.getCommand()+'\n';
-        	}
-        } else {
-	        command += " (";
-	        String items="";
-	        // FLAGS
-	        if (fetchFlags) {
-	            items += " FLAGS";  
-	        }
-	        // RFC822.SIZE
-	        if (fetchRfc822Size) {
-	            items += " RFC822.SIZE";
-	        }
-	        // BODY
-	        if (body!=null) {
-	            items += " "+body.getCommand();
-	        }
-	        
-	        
-	        if (items.length()>0) {
-	            items=items.substring(1);
-	        }
-	
-	        command += items+")\n";
-        }
-        return command;
-    }
+		String command = "";
+		if (uid) {
+			command += "UID ";
+		}
+		command += "fetch " + from;
+		if (!oneSeqNumberOnly) {
+			if (to > 0) {
+				command += ":" + to;
+			} else {
+				command += ":*";
+			}
+		}
+
+		command += " ";
+		if (useParenthesis) {
+			command += "(";
+		}
+		
+		String items = "";
+		// FLAGS
+		if (fetchFlags) {
+			items += " FLAGS";
+		}
+		// RFC822.SIZE
+		if (fetchRfc822Size) {
+			items += " RFC822.SIZE";
+		}
+		// BODY
+		if (body != null) {
+			items += " " + body.getCommand();
+		}
+
+		if (items.length() > 0) {
+			items = items.substring(1);
+		}
+		command += items;
+		if (useParenthesis) {
+			command += ")";
+		}
+		command += "\n";
+		return command;
+	}
 
     private List getSelectedMessageNumbers() {
         List selectedNumbers = new ArrayList();
-        
-        
         if (uid) {
             final long to;
             if (this.to>0) {

Modified: james/server/trunk/src/test/org/apache/james/imapserver/handler/session/BodyFetchSessionTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/imapserver/handler/session/BodyFetchSessionTest.java?view=diff&rev=470831&r1=470830&r2=470831
==============================================================================
--- james/server/trunk/src/test/org/apache/james/imapserver/handler/session/BodyFetchSessionTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/imapserver/handler/session/BodyFetchSessionTest.java
Fri Nov  3 06:12:58 2006
@@ -117,14 +117,14 @@
         verifyCommandOrdered(fc);
     }        
 
-    public void testSimpleFetch() throws ProtocolException, IOException, MessagingException,
MailboxManagerException {
+    public void testFetchBodyNoParenthesisOneSeqNumber() throws ProtocolException, IOException,
MessagingException, MailboxManagerException {
         verifyCommand(new LoginCommand(USER_NAME,USER_PASSWORD));
         verifyCommand(new SelectCommand("INBOX", msgs, getUidValidity(USER_MAILBOX_ROOT+".INBOX")));
         msgs=getMessages(USER_MAILBOX_ROOT+".INBOX");
         
         FetchCommand fc=new FetchCommand(msgs,1);
         fc.setFetchBody(new FetchBody(true));
-        fc.setOneSwitchOnly(true);
+        fc.setUseParenthesis(false);
         verifyCommandOrdered(fc);
     	
     }



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