You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by dl...@apache.org on 2009/05/27 15:03:36 UTC

svn commit: r779153 - /mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java

Author: dlat
Date: Wed May 27 13:03:36 2009
New Revision: 779153

URL: http://svn.apache.org/viewvc?rev=779153&view=rev
Log:
FTPSERVER-306 EOL sequence is lost if the file wasn't correctly transformed to NVT format (this is, the sent new line sequence  is different from \r\n) - Test case modified in order to prevent commons-ftp from transforming line separator sequences to CRLF.

Modified:
    mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java

Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java?rev=779153&r1=779152&r2=779153&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/StoreTest.java Wed May 27 13:03:36 2009
@@ -16,46 +16,38 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.ftpserver.clienttests;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
 
+import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPReply;
 import org.apache.ftpserver.test.TestUtil;
 
 /**
-*
-* @author The Apache MINA Project (dev@mina.apache.org)
-*
-*/
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ *
+ */
 public class StoreTest extends ClientTestTemplate {
+
     private static final String EOL = System.getProperty("line.separator");
     private static final String CRLF = "\r\n";
     private static final String LF = "\n";
-
-    
     private static final String TESTDATA = "TESTDATA" + EOL + "line2" + EOL;
     private static final String TESTDATA_CRLF = "TESTDATA" + CRLF + "line2" + CRLF;
     private static final String TESTDATA_LF = "TESTDATA" + LF + "line2" + LF;
-
     private static final String ENCODING = "UTF-8";
-
     private static final String TEST_FILENAME = "test.txt";
-
     private static final String TEST_FILENAME_WITH_LEADING_SPACE = " leading.txt";
-
     private static final int SKIP_LEN = 4;
-
     private static final File TEST_DIR = new File(ROOT_DIR, "foo/bar");
-
     private static byte[] testData = null;
     private static byte[] testDataCrLf = null;
-     private static byte[] testDataLf = null;
-
+    private static byte[] testDataLf = null;
     private static byte[] doubleTestData = null;
-
     private static byte[] oneAndAHalfTestData = null;
 
     /*
@@ -99,13 +91,17 @@
         TestUtil.assertFileEqual(testData, testFile);
     }
 
-      /**
+    /**
      * We should always store files with the local line endings (FTPSERVER-184)
      *
      */
     public void testStoreWithLf() throws Exception {
         File testFile = new File(ROOT_DIR, TEST_FILENAME);
-
+        // We set the client to binary mode while we inform the server that we want to use ASCII mode
+        // This way, we can test FTPSERVER-306 in the cases where the FTPClient does not transform line separators to \r\n
+        client.setFileType(FTP.BINARY_FILE_TYPE);
+        assertTrue(FTPReply.isPositiveCompletion(client.type(FTP.ASCII_FILE_TYPE)));
+        
         assertTrue(client.storeFile(TEST_FILENAME, new ByteArrayInputStream(
                 testDataLf)));
 
@@ -113,7 +109,6 @@
         TestUtil.assertFileEqual(testData, testFile);
     }
 
-    
     public void testStoreWithLeadingSpace() throws Exception {
         File testFile = new File(ROOT_DIR, TEST_FILENAME_WITH_LEADING_SPACE);
 
@@ -134,7 +129,6 @@
      * testStoreInValidFileName() throws Exception { assertEquals(550
      * ,client.sendCommand("STOR foo:bar;foo")); }
      */
-
     public void testStoreWithRestart() throws Exception {
         File testFile = new File(ROOT_DIR, TEST_FILENAME);
         TestUtil.writeDataToFile(testFile, testData);
@@ -338,5 +332,4 @@
         assertTrue(testFile.exists());
         TestUtil.assertFileEqual(testData, testFile);
     }
-
 }