VMSFTPEntryParserTestpublic class VMSFTPEntryParserTest extends FTPParseTestFramework
Fields Summary |
---|
private static final String[] | badsamples | private static final String[] | goodsamples | private static final String | fullListing |
Constructors Summary |
---|
public VMSFTPEntryParserTest(String name)
super(name);
|
Methods Summary |
---|
public void | assertFileInListing(org.apache.commons.net.ftp.FTPFile[] listing, java.lang.String name)
for (int i = 0; i < listing.length; i++) {
if (name.equals(listing[i].getName())) {
return;
}
}
fail("File " + name + " not found in supplied listing");
| public void | assertFileNotInListing(org.apache.commons.net.ftp.FTPFile[] listing, java.lang.String name)
for (int i = 0; i < listing.length; i++) {
if (name.equals(listing[i].getName())) {
fail("Unexpected File " + name + " found in supplied listing");
}
}
| private void | checkPermisions(org.apache.commons.net.ftp.FTPFile dir)Method checkPermisions.
Verify that the VMS parser does NOT set the permissions.
assertTrue("Owner should not have read permission.",
!dir.hasPermission(FTPFile.USER_ACCESS,
FTPFile.READ_PERMISSION));
assertTrue("Owner should not have write permission.",
!dir.hasPermission(FTPFile.USER_ACCESS,
FTPFile.WRITE_PERMISSION));
assertTrue("Owner should not have execute permission.",
!dir.hasPermission(FTPFile.USER_ACCESS,
FTPFile.EXECUTE_PERMISSION));
assertTrue("Group should not have read permission.",
!dir.hasPermission(FTPFile.GROUP_ACCESS,
FTPFile.READ_PERMISSION));
assertTrue("Group should not have write permission.",
!dir.hasPermission(FTPFile.GROUP_ACCESS,
FTPFile.WRITE_PERMISSION));
assertTrue("Group should not have execute permission.",
!dir.hasPermission(FTPFile.GROUP_ACCESS,
FTPFile.EXECUTE_PERMISSION));
assertTrue("World should not have read permission.",
!dir.hasPermission(FTPFile.WORLD_ACCESS,
FTPFile.READ_PERMISSION));
assertTrue("World should not have write permission.",
!dir.hasPermission(FTPFile.WORLD_ACCESS,
FTPFile.WRITE_PERMISSION));
assertTrue("World should not have execute permission.",
!dir.hasPermission(FTPFile.WORLD_ACCESS,
FTPFile.EXECUTE_PERMISSION));
| protected java.lang.String[] | getBadListing()
return (badsamples);
| protected java.lang.String[] | getGoodListing()
return (goodsamples);
| protected org.apache.commons.net.ftp.FTPFileEntryParser | getParser()
ConfigurableFTPFileEntryParserImpl parser =
new VMSFTPEntryParser();
parser.configure(null);
return parser;
| protected org.apache.commons.net.ftp.FTPFileEntryParser | getVersioningParser()
ConfigurableFTPFileEntryParserImpl parser =
new VMSVersioningFTPEntryParser();
parser.configure(null);
return parser;
| public static junit.framework.TestSuite | suite()Method suite.
return(new TestSuite(VMSFTPEntryParserTest.class));
| public void | testParseFieldsOnDirectory()
FTPFile dir = getParser().parseFTPEntry("DATA.DIR;1 1/9 2-JUN-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,RE)");
assertTrue("Should be a directory.",
dir.isDirectory());
assertEquals("DATA.DIR",
dir.getName());
assertEquals(512,
dir.getSize());
assertEquals("Tue Jun 02 07:32:04 1998",
df.format(dir.getTimestamp().getTime()));
assertEquals("GROUP",
dir.getGroup());
assertEquals("OWNER",
dir.getUser());
checkPermisions(dir);
dir = getParser().parseFTPEntry("DATA.DIR;1 1/9 2-JUN-1998 07:32:04 [TRANSLATED] (RWED,RWED,RWED,RE)");
assertTrue("Should be a directory.",
dir.isDirectory());
assertEquals("DATA.DIR",
dir.getName());
assertEquals(512,
dir.getSize());
assertEquals("Tue Jun 02 07:32:04 1998",
df.format(dir.getTimestamp().getTime()));
assertEquals(null,
dir.getGroup());
assertEquals("TRANSLATED",
dir.getUser());
checkPermisions(dir);
| public void | testParseFieldsOnFile()
FTPFile file = getParser().parseFTPEntry("1-JUN.LIS;1 9/9 2-JUN-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,RE)");
assertTrue("Should be a file.",
file.isFile());
assertEquals("1-JUN.LIS",
file.getName());
assertEquals(9 * 512,
file.getSize());
assertEquals("Tue Jun 02 07:32:04 1998",
df.format(file.getTimestamp().getTime()));
assertEquals("GROUP",
file.getGroup());
assertEquals("OWNER",
file.getUser());
checkPermisions(file);
file = getParser().parseFTPEntry("1-JUN.LIS;1 9/9 2-JUN-1998 07:32:04 [TRANSLATED] (RWED,RWED,RWED,RE)");
assertTrue("Should be a file.",
file.isFile());
assertEquals("1-JUN.LIS",
file.getName());
assertEquals(9 * 512,
file.getSize());
assertEquals("Tue Jun 02 07:32:04 1998",
df.format(file.getTimestamp().getTime()));
assertEquals(null,
file.getGroup());
assertEquals("TRANSLATED",
file.getUser());
checkPermisions(file);
| public void | testWholeListParse()Test the parsing of the whole list.
VMSFTPEntryParser parser = new VMSFTPEntryParser();
parser.configure(null);
FTPListParseEngine engine = new FTPListParseEngine(parser);
engine.readServerList(
new ByteArrayInputStream(fullListing.getBytes()));
FTPFile[] files = engine.getFiles();
assertEquals(6, files.length);
assertFileInListing(files, "2-JUN.LIS");
assertFileInListing(files, "3-JUN.LIS");
assertFileInListing(files, "1-JUN.LIS");
assertFileNotInListing(files, "1-JUN.LIS;1");
| public void | testWholeListParseWithVersioning()Test the parsing of the whole list.
VMSFTPEntryParser parser = new VMSVersioningFTPEntryParser();
parser.configure(null);
FTPListParseEngine engine = new FTPListParseEngine(parser);
engine.readServerList(
new ByteArrayInputStream(fullListing.getBytes()));
FTPFile[] files = engine.getFiles();
assertEquals(3, files.length);
assertFileInListing(files, "1-JUN.LIS;1");
assertFileInListing(files, "2-JUN.LIS;1");
assertFileInListing(files, "3-JUN.LIS;4");
assertFileNotInListing(files, "3-JUN.LIS;1");
assertFileNotInListing(files, "3-JUN.LIS");
|
|