|
5 | 5 |
|
6 | 6 | public class FileCommandsTest {
|
7 | 7 |
|
8 |
| - @Test |
9 |
| - public void ftCreateDir_NullPathException() { |
10 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftCreateDir(null, 1, null)); |
11 |
| - } |
12 |
| - |
13 |
| - @Test |
14 |
| - public void ftCreateDir() { |
15 |
| - final String expected = "ftcreatedir cid=1 cpw= dirname=\\/dir1"; |
16 |
| - Assert.assertEquals(expected, FileCommands.ftCreateDir("/dir1", 1, null).toString()); |
17 |
| - Assert.assertEquals(expected, FileCommands.ftCreateDir("dir1", 1, null).toString()); |
18 |
| - } |
19 |
| - |
20 |
| - @Test |
21 |
| - public void ftDeleteFile_EmptyFileArrayException() { |
22 |
| - final String[] filePaths = {}; |
23 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, filePaths)); |
24 |
| - } |
25 |
| - |
26 |
| - @Test |
27 |
| - public void ftDeleteFile_NullFileArrayException() { |
28 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, (String[]) null)); |
29 |
| - } |
30 |
| - |
31 |
| - @Test |
32 |
| - public void ftDeleteFile_NullFilePathException() { |
33 |
| - final String[] filePaths = {null}; |
34 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, filePaths)); |
35 |
| - } |
36 |
| - |
37 |
| - @Test |
38 |
| - public void ftDeleteFile() { |
39 |
| - final String[] filePaths = {"dir1", "/dir2"}; |
40 |
| - final String expected = "ftdeletefile cid=1 cpw= name=\\/dir1|name=\\/dir2"; |
41 |
| - Assert.assertEquals(expected, FileCommands.ftDeleteFile(1, null, filePaths).toString()); |
42 |
| - } |
43 |
| - |
44 |
| - @Test |
45 |
| - public void ftGetFileInfo_EmptyFileArrayException() { |
46 |
| - final String[] filePaths = {}; |
47 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, filePaths)); |
48 |
| - } |
49 |
| - |
50 |
| - @Test |
51 |
| - public void ftGetFileInfo_NullFileArrayException() { |
52 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, (String[]) null)); |
53 |
| - } |
54 |
| - |
55 |
| - @Test |
56 |
| - public void ftGetFileInfo_NullFilePathException() { |
57 |
| - final String[] filePaths = {null}; |
58 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, filePaths)); |
59 |
| - } |
60 |
| - |
61 |
| - @Test |
62 |
| - public void ftGetFileInfo() { |
63 |
| - final String[] filePaths = {"dir1", "/dir2"}; |
64 |
| - final String expected = "ftgetfileinfo cid=1 cpw= name=\\/dir1|cid=1 cpw= name=\\/dir2"; |
65 |
| - Assert.assertEquals(expected, FileCommands.ftGetFileInfo(1, null, filePaths).toString()); |
66 |
| - } |
67 |
| - |
68 |
| - @Test |
69 |
| - public void ftGetFileInfoArray_EmptyChannelIDArrayException() { |
70 |
| - final int[] channelIds = {}; |
71 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, null)); |
72 |
| - } |
73 |
| - |
74 |
| - @Test |
75 |
| - public void ftGetFileInfoArray_NullChannelIDArrayException() { |
76 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(null, null, null)); |
77 |
| - } |
78 |
| - |
79 |
| - @Test |
80 |
| - public void ftGetFileInfoArray_EmptyFileArrayException() { |
81 |
| - final int[] channelIds = {1}; |
82 |
| - final String[] filePaths = {}; |
83 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
84 |
| - } |
85 |
| - |
86 |
| - @Test |
87 |
| - public void ftGetFileInfoArray_NullFileArrayException() { |
88 |
| - final int[] channelIds = {1}; |
89 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, null)); |
90 |
| - } |
91 |
| - |
92 |
| - @Test |
93 |
| - public void ftGetFileInfoArray_ChannelIDsLengthFilePathsLengthException() { |
94 |
| - final int[] channelIds = {1}; |
95 |
| - final String[] filePaths = {"dir1", "dir2"}; |
96 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
97 |
| - } |
98 |
| - |
99 |
| - @Test |
100 |
| - public void ftGetFileInfoArray_PasswordsLengthFilePathsLengthException() { |
101 |
| - final int[] channelIds = {1, 2}; |
102 |
| - final String[] channelPasswords = {null}; |
103 |
| - final String[] filePaths = {"dir1", "dir2"}; |
104 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, channelPasswords, filePaths)); |
105 |
| - } |
106 |
| - |
107 |
| - @Test |
108 |
| - public void ftGetFileInfoArray_NullFilePathException() { |
109 |
| - final int[] channelIds = {1}; |
110 |
| - final String[] filePaths = {null}; |
111 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
112 |
| - } |
113 |
| - |
114 |
| - @Test |
115 |
| - public void ftGetFileInfoArray() { |
116 |
| - final int[] channelIds = {1, 2}; |
117 |
| - final String[] channelPasswords = {null, "pass2"}; |
118 |
| - final String[] filePaths = {"dir1", "/dir2"}; |
119 |
| - final String expected = "ftgetfileinfo cid=1 cpw= name=\\/dir1|cid=2 cpw=pass2 name=\\/dir2"; |
120 |
| - Assert.assertEquals(expected, FileCommands.ftGetFileInfo(channelIds, channelPasswords, filePaths).toString()); |
121 |
| - } |
122 |
| - |
123 |
| - @Test |
124 |
| - public void ftGetFileList_NullDirectoryPathException() { |
125 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileList(null, 1, null)); |
126 |
| - } |
127 |
| - |
128 |
| - @Test |
129 |
| - public void ftGetFileList() { |
130 |
| - final String expected = "ftgetfilelist cid=1 cpw= path=\\/dir1\\/"; |
131 |
| - Assert.assertEquals(expected, FileCommands.ftGetFileList("/dir1", 1, null).toString()); |
132 |
| - Assert.assertEquals(expected, FileCommands.ftGetFileList("dir1/", 1, null).toString()); |
133 |
| - } |
134 |
| - |
135 |
| - @Test |
136 |
| - public void ftInitDownload_NullDirectoryPathException() { |
137 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftInitDownload(1, null, 1, null)); |
138 |
| - } |
139 |
| - |
140 |
| - @Test |
141 |
| - public void ftInitDownload() { |
142 |
| - final String expected = "ftinitdownload clientftfid=1 name=\\/dir1 cid=1 cpw= seekpos=0 proto=0"; |
143 |
| - Assert.assertEquals(expected, FileCommands.ftInitDownload(1, "/dir1", 1, null).toString()); |
144 |
| - Assert.assertEquals(expected, FileCommands.ftInitDownload(1, "dir1", 1, null).toString()); |
145 |
| - } |
146 |
| - |
147 |
| - @Test |
148 |
| - public void ftInitUpload_NullDirectoryPathException() { |
149 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftInitUpload(1, null, 1, null, 1024, true)); |
150 |
| - } |
151 |
| - |
152 |
| - @Test |
153 |
| - public void ftInitUpload() { |
154 |
| - final String expected = "ftinitupload clientftfid=1 name=\\/dir1 cid=1 cpw= size=1024 overwrite=1 resume=0 proto=0"; |
155 |
| - Assert.assertEquals(expected, FileCommands.ftInitUpload(1, "/dir1", 1, null, 1024, true).toString()); |
156 |
| - Assert.assertEquals(expected, FileCommands.ftInitUpload(1, "dir1", 1, null, 1024, true).toString()); |
157 |
| - } |
158 |
| - |
159 |
| - @Test |
160 |
| - public void ftList() { |
161 |
| - final String expected = "ftlist"; |
162 |
| - Assert.assertEquals(expected, FileCommands.ftList().toString()); |
163 |
| - } |
164 |
| - |
165 |
| - @Test |
166 |
| - public void ftRenameFile_NullOldPathException() { |
167 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile(null, "dir2", 1, null)); |
168 |
| - } |
169 |
| - |
170 |
| - @Test |
171 |
| - public void ftRenameFile_NullNewPathException() { |
172 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile("dir1", null, 1, null)); |
173 |
| - } |
174 |
| - |
175 |
| - @Test |
176 |
| - public void ftRenameFile() { |
177 |
| - final String expected = "ftrenamefile cid=1 cpw= oldname=\\/dir1 newname=\\/dir2"; |
178 |
| - Assert.assertEquals(expected, FileCommands.ftRenameFile("/dir1", "dir2", 1, null).toString()); |
179 |
| - Assert.assertEquals(expected, FileCommands.ftRenameFile("dir1", "/dir2", 1, null).toString()); |
180 |
| - } |
181 |
| - |
182 |
| - @Test |
183 |
| - public void ftRenameFileAndChannel_NullOldPathException() { |
184 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile(null, "dir2", 1, null, 2, null)); |
185 |
| - } |
186 |
| - |
187 |
| - @Test |
188 |
| - public void ftRenameFileAndChannel_NullNewPathException() { |
189 |
| - Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile("dir1", null, 1, null, 2, null)); |
190 |
| - } |
191 |
| - |
192 |
| - @Test |
193 |
| - public void ftRenameFileAndChannel() { |
194 |
| - final String expected = "ftrenamefile cid=1 cpw= tcid=2 tcpw= oldname=\\/dir1 newname=\\/dir2"; |
195 |
| - Assert.assertEquals(expected, FileCommands.ftRenameFile("/dir1", "dir2", 1, null, 2, null).toString()); |
196 |
| - Assert.assertEquals(expected, FileCommands.ftRenameFile("dir1", "/dir2", 1, null, 2, null).toString()); |
197 |
| - } |
| 8 | +@Test |
| 9 | +public void ftCreateDir_NullPathException() { |
| 10 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftCreateDir(null, 1, null)); |
| 11 | +} |
| 12 | + |
| 13 | +@Test |
| 14 | +public void ftCreateDir() { |
| 15 | +final String expected = "ftcreatedir cid=1 cpw= dirname=\\/dir1"; |
| 16 | +Assert.assertEquals(expected, FileCommands.ftCreateDir("/dir1", 1, null).toString()); |
| 17 | +Assert.assertEquals(expected, FileCommands.ftCreateDir("dir1", 1, null).toString()); |
| 18 | +} |
| 19 | + |
| 20 | +@Test |
| 21 | +public void ftDeleteFile_EmptyFileArrayException() { |
| 22 | +final String[] filePaths = {}; |
| 23 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, filePaths)); |
| 24 | +} |
| 25 | + |
| 26 | +@Test |
| 27 | +public void ftDeleteFile_NullFileArrayException() { |
| 28 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, (String[]) null)); |
| 29 | +} |
| 30 | + |
| 31 | +@Test |
| 32 | +public void ftDeleteFile_NullFilePathException() { |
| 33 | +final String[] filePaths = {null}; |
| 34 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftDeleteFile(1, null, filePaths)); |
| 35 | +} |
| 36 | + |
| 37 | +@Test |
| 38 | +public void ftDeleteFile() { |
| 39 | +final String[] filePaths = {"dir1", "/dir2"}; |
| 40 | +final String expected = "ftdeletefile cid=1 cpw= name=\\/dir1|name=\\/dir2"; |
| 41 | +Assert.assertEquals(expected, FileCommands.ftDeleteFile(1, null, filePaths).toString()); |
| 42 | +} |
| 43 | + |
| 44 | +@Test |
| 45 | +public void ftGetFileInfo_EmptyFileArrayException() { |
| 46 | +final String[] filePaths = {}; |
| 47 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, filePaths)); |
| 48 | +} |
| 49 | + |
| 50 | +@Test |
| 51 | +public void ftGetFileInfo_NullFileArrayException() { |
| 52 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, (String[]) null)); |
| 53 | +} |
| 54 | + |
| 55 | +@Test |
| 56 | +public void ftGetFileInfo_NullFilePathException() { |
| 57 | +final String[] filePaths = {null}; |
| 58 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(1, null, filePaths)); |
| 59 | +} |
| 60 | + |
| 61 | +@Test |
| 62 | +public void ftGetFileInfo() { |
| 63 | +final String[] filePaths = {"dir1", "/dir2"}; |
| 64 | +final String expected = "ftgetfileinfo cid=1 cpw= name=\\/dir1|cid=1 cpw= name=\\/dir2"; |
| 65 | +Assert.assertEquals(expected, FileCommands.ftGetFileInfo(1, null, filePaths).toString()); |
| 66 | +} |
| 67 | + |
| 68 | +@Test |
| 69 | +public void ftGetFileInfoArray_EmptyChannelIDArrayException() { |
| 70 | +final int[] channelIds = {}; |
| 71 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, null)); |
| 72 | +} |
| 73 | + |
| 74 | +@Test |
| 75 | +public void ftGetFileInfoArray_NullChannelIDArrayException() { |
| 76 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(null, null, null)); |
| 77 | +} |
| 78 | + |
| 79 | +@Test |
| 80 | +public void ftGetFileInfoArray_EmptyFileArrayException() { |
| 81 | +final int[] channelIds = {1}; |
| 82 | +final String[] filePaths = {}; |
| 83 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
| 84 | +} |
| 85 | + |
| 86 | +@Test |
| 87 | +public void ftGetFileInfoArray_NullFileArrayException() { |
| 88 | +final int[] channelIds = {1}; |
| 89 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, null)); |
| 90 | +} |
| 91 | + |
| 92 | +@Test |
| 93 | +public void ftGetFileInfoArray_ChannelIDsLengthFilePathsLengthException() { |
| 94 | +final int[] channelIds = {1}; |
| 95 | +final String[] filePaths = {"dir1", "dir2"}; |
| 96 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
| 97 | +} |
| 98 | + |
| 99 | +@Test |
| 100 | +public void ftGetFileInfoArray_PasswordsLengthFilePathsLengthException() { |
| 101 | +final int[] channelIds = {1, 2}; |
| 102 | +final String[] channelPasswords = {null}; |
| 103 | +final String[] filePaths = {"dir1", "dir2"}; |
| 104 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, channelPasswords, filePaths)); |
| 105 | +} |
| 106 | + |
| 107 | +@Test |
| 108 | +public void ftGetFileInfoArray_NullFilePathException() { |
| 109 | +final int[] channelIds = {1}; |
| 110 | +final String[] filePaths = {null}; |
| 111 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileInfo(channelIds, null, filePaths)); |
| 112 | +} |
| 113 | + |
| 114 | +@Test |
| 115 | +public void ftGetFileInfoArray() { |
| 116 | +final int[] channelIds = {1, 2}; |
| 117 | +final String[] channelPasswords = {null, "pass2"}; |
| 118 | +final String[] filePaths = {"dir1", "/dir2"}; |
| 119 | +final String expected = "ftgetfileinfo cid=1 cpw= name=\\/dir1|cid=2 cpw=pass2 name=\\/dir2"; |
| 120 | +Assert.assertEquals(expected, FileCommands.ftGetFileInfo(channelIds, channelPasswords, filePaths).toString()); |
| 121 | +} |
| 122 | + |
| 123 | +@Test |
| 124 | +public void ftGetFileList_NullDirectoryPathException() { |
| 125 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftGetFileList(null, 1, null)); |
| 126 | +} |
| 127 | + |
| 128 | +@Test |
| 129 | +public void ftGetFileList() { |
| 130 | +final String expected = "ftgetfilelist cid=1 cpw= path=\\/dir1\\/"; |
| 131 | +Assert.assertEquals(expected, FileCommands.ftGetFileList("/dir1", 1, null).toString()); |
| 132 | +Assert.assertEquals(expected, FileCommands.ftGetFileList("dir1/", 1, null).toString()); |
| 133 | +} |
| 134 | + |
| 135 | +@Test |
| 136 | +public void ftInitDownload_NullDirectoryPathException() { |
| 137 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftInitDownload(1, null, 1, null)); |
| 138 | +} |
| 139 | + |
| 140 | +@Test |
| 141 | +public void ftInitDownload() { |
| 142 | +final String expected = "ftinitdownload clientftfid=1 name=\\/dir1 cid=1 cpw= seekpos=0 proto=0"; |
| 143 | +Assert.assertEquals(expected, FileCommands.ftInitDownload(1, "/dir1", 1, null).toString()); |
| 144 | +Assert.assertEquals(expected, FileCommands.ftInitDownload(1, "dir1", 1, null).toString()); |
| 145 | +} |
| 146 | + |
| 147 | +@Test |
| 148 | +public void ftInitUpload_NullDirectoryPathException() { |
| 149 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftInitUpload(1, null, 1, null, 1024, true)); |
| 150 | +} |
| 151 | + |
| 152 | +@Test |
| 153 | +public void ftInitUpload() { |
| 154 | +final String expected = "ftinitupload clientftfid=1 name=\\/dir1 cid=1 cpw= size=1024 overwrite=1 resume=0 proto=0"; |
| 155 | +Assert.assertEquals(expected, FileCommands.ftInitUpload(1, "/dir1", 1, null, 1024, true).toString()); |
| 156 | +Assert.assertEquals(expected, FileCommands.ftInitUpload(1, "dir1", 1, null, 1024, true).toString()); |
| 157 | +} |
| 158 | + |
| 159 | +@Test |
| 160 | +public void ftList() { |
| 161 | +final String expected = "ftlist"; |
| 162 | +Assert.assertEquals(expected, FileCommands.ftList().toString()); |
| 163 | +} |
| 164 | + |
| 165 | +@Test |
| 166 | +public void ftRenameFile_NullOldPathException() { |
| 167 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile(null, "dir2", 1, null)); |
| 168 | +} |
| 169 | + |
| 170 | +@Test |
| 171 | +public void ftRenameFile_NullNewPathException() { |
| 172 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile("dir1", null, 1, null)); |
| 173 | +} |
| 174 | + |
| 175 | +@Test |
| 176 | +public void ftRenameFile() { |
| 177 | +final String expected = "ftrenamefile cid=1 cpw= oldname=\\/dir1 newname=\\/dir2"; |
| 178 | +Assert.assertEquals(expected, FileCommands.ftRenameFile("/dir1", "dir2", 1, null).toString()); |
| 179 | +Assert.assertEquals(expected, FileCommands.ftRenameFile("dir1", "/dir2", 1, null).toString()); |
| 180 | +} |
| 181 | + |
| 182 | +@Test |
| 183 | +public void ftRenameFileAndChannel_NullOldPathException() { |
| 184 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile(null, "dir2", 1, null, 2, null)); |
| 185 | +} |
| 186 | + |
| 187 | +@Test |
| 188 | +public void ftRenameFileAndChannel_NullNewPathException() { |
| 189 | +Assert.assertThrows(IllegalArgumentException.class, () -> FileCommands.ftRenameFile("dir1", null, 1, null, 2, null)); |
| 190 | +} |
| 191 | + |
| 192 | +@Test |
| 193 | +public void ftRenameFileAndChannel() { |
| 194 | +final String expected = "ftrenamefile cid=1 cpw= tcid=2 tcpw= oldname=\\/dir1 newname=\\/dir2"; |
| 195 | +Assert.assertEquals(expected, FileCommands.ftRenameFile("/dir1", "dir2", 1, null, 2, null).toString()); |
| 196 | +Assert.assertEquals(expected, FileCommands.ftRenameFile("dir1", "/dir2", 1, null, 2, null).toString()); |
| 197 | +} |
198 | 198 | }
|
0 commit comments