incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r556342 - in /incubator/ftpserver/trunk/core/src: java/org/apache/ftpserver/DefaultFtpReply.java test/org/apache/ftpserver/DefaultFtpReplyTest.java
Date Sat, 14 Jul 2007 21:30:37 GMT
Author: ngn
Date: Sat Jul 14 14:30:36 2007
New Revision: 556342

URL: http://svn.apache.org/viewvc?view=rev&rev=556342
Log:
Add a more convinent constructor for creating multiline replies.

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultFtpReply.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/DefaultFtpReplyTest.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultFtpReply.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultFtpReply.java?view=diff&rev=556342&r1=556341&r2=556342
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultFtpReply.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultFtpReply.java Sat
Jul 14 14:30:36 2007
@@ -37,6 +37,17 @@
         this.code = code;
         this.message = message;
     }
+
+    public DefaultFtpReply(int code, String[] message) {
+        this.code = code;
+        
+        StringBuffer sb = new StringBuffer();
+        for(int i = 0; i<message.length; i++) {
+            sb.append(message[i]);
+            sb.append('\n');
+        }
+        this.message = sb.toString();
+    }
     /**
      * @return the code
      */

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/DefaultFtpReplyTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/DefaultFtpReplyTest.java?view=diff&rev=556342&r1=556341&r2=556342
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/DefaultFtpReplyTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/DefaultFtpReplyTest.java
Sat Jul 14 14:30:36 2007
@@ -31,13 +31,25 @@
     }
 
     public void testNullToString() {
-        DefaultFtpReply response = new DefaultFtpReply(123, null);
+        DefaultFtpReply response = new DefaultFtpReply(123, (String)null);
         
         assertEquals("123 \r\n", response.toString());
     }
 
     public void testMultipleLinesToString() {
         DefaultFtpReply response = new DefaultFtpReply(123, "foo\nbar\nbaz");
+        
+        assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
+    }
+
+    public void testMultipleLinesEndWithNewlineToString() {
+        DefaultFtpReply response = new DefaultFtpReply(123, "foo\nbar\nbaz\n");
+        
+        assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
+    }
+    
+    public void testArrayLinesToString() {
+        DefaultFtpReply response = new DefaultFtpReply(123, new String[]{"foo", "bar", "baz"});
         
         assertEquals("123-foo\r\nbar\r\n123 baz\r\n", response.toString());
     }



Mime
View raw message