Methods Summary |
---|
private boolean | findByName(java.util.List fileList, java.lang.String string)
boolean found = false;
Iterator iter = fileList.iterator();
while (iter.hasNext() && !found)
{
Object element = iter.next();
if (element instanceof FTPFile)
{
FTPFile file = (FTPFile) element;
found = file.getName().equals(string);
}
else
{
String filename = (String) element;
found = filename.endsWith(string);
}
}
return found;
|
protected void | setUp()
super.setUp();
client = new FTPClient();
client.connect(hostName);
client.login("anonymous", "anonymous");
client.enterLocalPassiveMode();
|
public static final junit.framework.Test | suite()
String[][] testData =
{
{
"ftp.ibiblio.org", "unix", "vms",
"HA!", "javaio.jar",
"pub/languages/java/javafaq"
},
{
"ftp.wacom.com", "windows", "VMS", "HA!",
"wacom97.zip", "pub\\ftp\\drivers"
},
{
"h71000.www7.hp.com", "vms", "windows",
"[.HA!]", "ACLOCAL.M4;1",
"[.FREEWARE50.XTERM]"
}
};
Class clasz = ListingFunctionalTest.class;
Method[] methods = clasz.getDeclaredMethods();
TestSuite allSuites = new TestSuite("FTP Listing Functional Test Suite");
for (int i = 0; i < testData.length; i++)
{
TestSuite suite = new TestSuite(testData[i][VALID_PARSERKEY]);
for (int j = 0; j < methods.length; j++)
{
Method method = methods[j];
if (method.getName().startsWith("test"))
{
suite.addTest(new ListingFunctionalTest(
method.getName(),
testData[i]));
}
}
allSuites.addTest(suite);
}
return allSuites;
|
protected void | tearDown()
try
{
client.logout();
}
catch (IOException e)
{
e.printStackTrace();
}
if (client.isConnected())
{
client.disconnect();
}
client = null;
super.tearDown();
|
public void | testInitiateListParsing()
client.changeWorkingDirectory(validPath);
FTPListParseEngine engine = client.initiateListParsing();
List files = Arrays.asList(engine.getNext(25));
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testInitiateListParsingWithPath()
FTPListParseEngine engine = client.initiateListParsing(validParserKey,
validPath);
List files = Arrays.asList(engine.getNext(25));
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testInitiateListParsingWithPathAndAutodetection()
FTPListParseEngine engine = client.initiateListParsing(validPath);
List files = Arrays.asList(engine.getNext(25));
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testInitiateListParsingWithPathAndAutodetectionButEmpty()
FTPListParseEngine engine = client.initiateListParsing(invalidPath);
assertFalse(engine.hasNext());
|
public void | testInitiateListParsingWithPathAndIncorrectParser()
FTPListParseEngine engine = client.initiateListParsing(invalidParserKey,
invalidPath);
assertFalse(engine.hasNext());
|
public void | testListFiles()
FTPClientConfig config = new FTPClientConfig(validParserKey);
client.configure(config);
List files = Arrays.asList(client.listFiles(validPath));
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testListFilesWithAutodection()
client.changeWorkingDirectory(validPath);
List files = Arrays.asList(client.listFiles());
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testListFilesWithIncorrectParser()
FTPClientConfig config = new FTPClientConfig(invalidParserKey);
client.configure(config);
FTPFile[] files = client.listFiles(validPath);
assertEquals(0, files.length);
|
public void | testListFilesWithPathAndAutodectionButEmpty()
FTPFile[] files = client.listFiles(invalidPath);
assertEquals(0, files.length);
|
public void | testListFilesWithPathAndAutodetection()
List files = Arrays.asList(client.listFiles(validPath));
assertTrue(files.toString(),
findByName(files, validFilename));
|
public void | testListNames()
client.changeWorkingDirectory(validPath);
String[] names = client.listNames();
assertNotNull(names);
List lnames = Arrays.asList(names);
assertTrue(lnames.toString(),
lnames.contains(validFilename));
|
public void | testListNamesWithPath()
List names = Arrays.asList(client.listNames(validPath));
assertTrue(names.toString(),
findByName(names, validFilename));
|
public void | testListNamesWithPathButEmpty()
String[] names = client.listNames(invalidPath);
assertNull(names);
|