incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r481570 - in /incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver: clienttests/ ftplet/ test/
Date Sat, 02 Dec 2006 15:56:52 GMT
Author: ngn
Date: Sat Dec  2 07:56:51 2006
New Revision: 481570

URL: http://svn.apache.org/viewvc?view=rev&rev=481570
Log:
Moving writeToFile method to TestUtil

Modified:
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ClientTestTemplate.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/FtpMd5Test.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ListTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/SizeTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/test/TestUtil.java

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ClientTestTemplate.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ClientTestTemplate.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ClientTestTemplate.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ClientTestTemplate.java
Sat Dec  2 07:56:51 2006
@@ -173,18 +173,6 @@
         }
     }
     
-    protected void writeDataToFile(File file, byte[] data) throws IOException {
-        FileOutputStream fos = null;
-        
-        try{
-            fos = new FileOutputStream(file);
-            
-            fos.write(data);
-        } finally {
-            IoUtils.close(fos);
-        }
-    }
-    
     /*
      * (non-Javadoc)
      * 

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/FtpMd5Test.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/FtpMd5Test.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/FtpMd5Test.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/FtpMd5Test.java
Sat Dec  2 07:56:51 2006
@@ -24,6 +24,7 @@
 import java.util.Map;
 
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.ftpserver.test.TestUtil;
 
 
 
@@ -55,7 +56,7 @@
     }
 
     public void testMd5() throws Exception {
-        writeDataToFile(TEST_FILE1, testData);
+        TestUtil.writeDataToFile(TEST_FILE1, testData);
         
         assertTrue(TEST_FILE1.exists());
         
@@ -79,7 +80,7 @@
     }
 
     public void testMd5WithSpaceInFileName() throws Exception {
-        writeDataToFile(TEST_FILE_WITH_SPACE, testData);
+        TestUtil.writeDataToFile(TEST_FILE_WITH_SPACE, testData);
         
         assertTrue(TEST_FILE_WITH_SPACE.exists());
         
@@ -110,7 +111,7 @@
     public void testMd5WithPath() throws Exception {
         TEST_DIR1.mkdirs();
         assertTrue(TEST_DIR1.exists());
-        writeDataToFile(TEST_FILE_IN_DIR1, testData);
+        TestUtil.writeDataToFile(TEST_FILE_IN_DIR1, testData);
         assertTrue(TEST_FILE_IN_DIR1.exists());
         
         String fileName = TEST_DIR1.getName() + "/" + TEST_FILE_IN_DIR1.getName();
@@ -126,8 +127,8 @@
     }
     
     public void testMMd5() throws Exception {
-        writeDataToFile(TEST_FILE1, testData);
-        writeDataToFile(TEST_FILE_WITH_SPACE, testData2);
+        TestUtil.writeDataToFile(TEST_FILE1, testData);
+        TestUtil.writeDataToFile(TEST_FILE_WITH_SPACE, testData2);
         
         assertTrue(TEST_FILE1.exists());
         assertTrue(TEST_FILE_WITH_SPACE.exists());
@@ -141,7 +142,7 @@
     }
 
     public void testMMd5SingleFile() throws Exception {
-        writeDataToFile(TEST_FILE1, testData);
+        TestUtil.writeDataToFile(TEST_FILE1, testData);
         
         assertTrue(TEST_FILE1.exists());
         
@@ -153,7 +154,7 @@
     }
 
     public void testMMd5MixedFilesAndDirs() throws Exception {
-        writeDataToFile(TEST_FILE1, testData);
+        TestUtil.writeDataToFile(TEST_FILE1, testData);
         TEST_DIR1.mkdirs();
         
         assertTrue(TEST_FILE1.exists());

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ListTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ListTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ListTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/ListTest.java
Sat Dec  2 07:56:51 2006
@@ -107,7 +107,7 @@
         TEST_DIR1.mkdirs();
         TEST_DIR2.mkdirs();
         
-        writeDataToFile(TEST_FILE1, testData);
+        TestUtil.writeDataToFile(TEST_FILE1, testData);
         
         FTPFile[] files = client.listFiles();
 
@@ -145,6 +145,13 @@
         assertTrue(file.isDirectory());
     }
 
+    public void testListFileNonExistingFile() throws Exception {
+
+        FTPFile[] files = client.listFiles("foo");
+        
+        assertEquals(0, files.length);
+    }
+    
     public void testListNames() throws Exception {
         TEST_FILE1.createNewFile();
         TEST_FILE2.createNewFile();

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
Sat Dec  2 07:56:51 2006
@@ -44,7 +44,7 @@
 
     public void testRetrieve() throws Exception {
         
-        writeDataToFile(TEST_FILE, testData);
+        TestUtil.writeDataToFile(TEST_FILE, testData);
 
         assertTrue(TEST_FILE.exists());
 
@@ -71,7 +71,7 @@
     public void testRetrieveWithRestart() throws Exception {
         int skipLen = 4;
         
-        writeDataToFile(TEST_FILE, testData);
+        TestUtil.writeDataToFile(TEST_FILE, testData);
         
         assertTrue(TEST_FILE.exists());
         
@@ -94,7 +94,7 @@
         
         File testFile = new File(dir, TEST_FILENAME);
         
-        writeDataToFile(testFile, testData);
+        TestUtil.writeDataToFile(testFile, testData);
         
         assertTrue(testFile.exists());
         

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/SizeTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/SizeTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/SizeTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/SizeTest.java
Sat Dec  2 07:56:51 2006
@@ -22,6 +22,7 @@
 import java.io.File;
 
 import org.apache.commons.net.ftp.FTPReply;
+import org.apache.ftpserver.test.TestUtil;
 
 
 public class SizeTest extends ClientTestTemplate {
@@ -47,7 +48,7 @@
     }
     
     public void testSizeOnFile() throws Exception {
-        writeDataToFile(TEST_FILE1, TEST_DATA1);
+        TestUtil.writeDataToFile(TEST_FILE1, TEST_DATA1);
         
         assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("SIZE " + TEST_FILE1.getName())));
         assertSizeReply(client.getReplyString(), TEST_DATA1.length);

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
Sat Dec  2 07:56:51 2006
@@ -77,7 +77,7 @@
     
     public void testStoreWithRestart() throws Exception {
         File testFile = new File(ROOT_DIR, TEST_FILENAME);
-        writeDataToFile(testFile, testData);
+        TestUtil.writeDataToFile(testFile, testData);
         
         client.setRestartOffset(SKIP_LEN);
         assertTrue(client.storeFile(TEST_FILENAME, new ByteArrayInputStream(testData)));
@@ -189,7 +189,7 @@
     public void testAppend() throws Exception {
         File testFile = new File(ROOT_DIR, TEST_FILENAME);
         
-        writeDataToFile(testFile, testData);
+        TestUtil.writeDataToFile(testFile, testData);
 
         assertTrue(client.appendFile(TEST_FILENAME, new ByteArrayInputStream(testData)));
         
@@ -216,7 +216,7 @@
         TEST_DIR.mkdirs();
         File testFile = new File(TEST_DIR, TEST_FILENAME);
         
-        writeDataToFile(testFile, testData);
+        TestUtil.writeDataToFile(testFile, testData);
         
         assertTrue(client.appendFile("foo/bar/" + TEST_FILENAME, new ByteArrayInputStream(testData)));
         

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDefaultTest.java
Sat Dec  2 07:56:51 2006
@@ -71,7 +71,7 @@
     }
 
     public void testDelete() throws Exception {
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         assertTrue(client.deleteFile(TEST_FILE1.getName()));
@@ -98,7 +98,7 @@
     }
 
     public void testRename() throws Exception {
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         assertTrue(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));
@@ -108,7 +108,7 @@
     }
 
     public void testDownload() throws Exception {
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         
@@ -119,7 +119,7 @@
     }
 
     public void testAppend() throws Exception {
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
             

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/ftplet/FtpLetReturnDisconnectTest.java
Sat Dec  2 07:56:51 2006
@@ -110,7 +110,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         try {
@@ -131,7 +131,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         assertTrue(client.deleteFile(TEST_FILE1.getName()));
@@ -258,7 +258,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         try {
@@ -280,7 +280,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         assertTrue(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));
@@ -306,7 +306,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         try {
@@ -325,7 +325,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -348,7 +348,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         try {
@@ -369,7 +369,7 @@
             }
         };
         
-        writeDataToFile(TEST_FILE1, TESTDATA);
+        TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
         assertTrue(client.appendFile(TEST_FILE1.getName(), new ByteArrayInputStream(TESTDATA)));

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/test/TestUtil.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/test/TestUtil.java?view=diff&rev=481570&r1=481569&r2=481570
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/test/TestUtil.java (original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/test/TestUtil.java Sat Dec
 2 07:56:51 2006
@@ -22,6 +22,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
@@ -109,6 +110,18 @@
         }
         
         return (String[]) hostIps.toArray(new String[0]);
+    }
+    
+    public static void writeDataToFile(File file, byte[] data) throws IOException {
+        FileOutputStream fos = null;
+        
+        try{
+            fos = new FileOutputStream(file);
+            
+            fos.write(data);
+        } finally {
+            IoUtils.close(fos);
+        }
     }
     
     public static void assertFileEqual(byte[] expected, File file)



Mime
View raw message