commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1074666 - /commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java
Date Fri, 25 Feb 2011 18:55:58 GMT
Author: sebb
Date: Fri Feb 25 18:55:58 2011
New Revision: 1074666

URL: http://svn.apache.org/viewvc?rev=1074666&view=rev
Log:
Add tests using FTPFileConfig

Modified:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java?rev=1074666&r1=1074665&r2=1074666&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java
Fri Feb 25 18:55:58 2011
@@ -17,6 +17,7 @@
 package org.apache.commons.net.ftp.parser;
 import junit.framework.TestCase;
 
+import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFileEntryParser;
 
 
@@ -109,5 +110,34 @@ public class DefaultFTPFileEntryParserFa
             assertTrue(root instanceof InstantiationException);            
         }
     }
-}
+    
+    private void checkParserClass(FTPFileEntryParserFactory fact, String key, Class<?>
expected){
+        FTPClientConfig config = key == null ? new FTPClientConfig() : new FTPClientConfig(key);
+        FTPFileEntryParser parser = fact.createFileEntryParser(config);
+        assertNotNull(parser);
+        assertTrue("Expected "+expected.getCanonicalName()+" got "+parser.getClass().getCanonicalName(),
+                expected.isInstance(parser));
+    }
+    public void testDefaultParserFactoryConfig() throws Exception {
+        DefaultFTPFileEntryParserFactory factory =
+            new DefaultFTPFileEntryParserFactory();
 
+        try {
+            factory.createFileEntryParser((FTPClientConfig)null);
+            fail("Expected NullPointerException");
+        } catch (NullPointerException npe) {
+            // expected
+        }
+        checkParserClass(factory, null, UnixFTPEntryParser.class);
+
+        checkParserClass(factory, FTPClientConfig.SYST_OS400, OS400FTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_AS400, CompositeFileEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_L8, UnixFTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_MVS, MVSFTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_NETWARE, NetwareFTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_NT, NTFTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_OS2, OS2FTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_UNIX, UnixFTPEntryParser.class);
+        checkParserClass(factory, FTPClientConfig.SYST_VMS, VMSFTPEntryParser.class);
+    }
+}



Mime
View raw message