1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.net.ftp.parser;
18
19 import org.apache.commons.net.ftp.FTPFile;
20 import org.apache.commons.net.ftp.FTPFileEntryParser;
21
22
23
24 public class MLSxEntryParserTest extends AbstractFTPParseTest {
25
26 private static final String[] badsamples = { "Type=cdir;Modify=20141022065101;UNIX.mode=0775;/no/space",
27 "Type=cdir;Modify=20141022065103;UNIX.mode=0775;",
28 "/no/leading/space", "",
29 "Type=cdir;Modify=20141022065102;UNIX.mode=0775; ",
30 "Type=dir;Size; missing =size", "Type=dir missing-semicolon", "Type= missing value and semicolon", " ",
31 "Modify=2014; Short stamp", "Type=pdir;Modify=20141205180002Z; /trailing chars in Modify",
32 "Type=dir;Modify=2014102206510x2.999;UNIX.mode=0775; modify has spurious chars", };
33
34 private static final String[] goodsamples = { "Type=cdir;Modify=20141022065102;UNIX.mode=0775; /commons/net",
35 "Type=pdir;Modify=20141205180002;UNIX.mode=0775; /commons", "Type=file;Size=431;Modify=20130303210732;UNIX.mode=0664; HEADER.html",
36 "Type=file;Size=1880;Modify=20130611172748;UNIX.mode=0664; README.html",
37 "Type=file;Size=2364;Modify=20130611170131;UNIX.mode=0664; RELEASE-NOTES.txt", "Type=dir;Modify=20141022065102;UNIX.mode=0775; binaries",
38 "Type=dir;Modify=20141022065102.999;UNIX.mode=0775; source", " /no/facts",
39 "Type=; /empty/fact", "Size=; /empty/size", " Type=cdir;Modify=20141022065102;UNIX.mode=0775; /leading/space",
40
41 " ",
42 };
43
44 public MLSxEntryParserTest(final String name) {
45 super(name);
46 }
47
48 @Override
49 protected String[] getBadListing() {
50 return badsamples;
51 }
52
53 @Override
54 protected String[] getGoodListing() {
55 return goodsamples;
56 }
57
58 @Override
59 protected FTPFileEntryParser getParser() {
60 return MLSxEntryParser.getInstance();
61 }
62
63
64
65
66
67
68
69 @Override
70 protected FTPFile nullFileOrNullDate(final FTPFile f) {
71 return f;
72 }
73
74 @Override
75 public void testDefaultPrecision() {
76 testPrecision("Type=dir;Modify=20141022065102;UNIX.mode=0775; source", CalendarUnit.SECOND);
77
78 }
79
80 @Override
81 public void testParseFieldsOnDirectory() throws Exception {
82 }
83
84 @Override
85 public void testParseFieldsOnFile() throws Exception {
86 }
87
88 @Override
89 public void testRecentPrecision() {
90 testPrecision("Type=dir;Modify=20141022065102.999;UNIX.mode=0775; source", CalendarUnit.MILLISECOND);
91 }
92 }