1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
package net.sourceforge.pebble.domain; |
33 |
|
|
34 |
|
import java.io.BufferedWriter; |
35 |
|
import java.io.File; |
36 |
|
import java.io.FileWriter; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@author |
43 |
|
|
|
|
| 96,1% |
Uncovered Elements: 9 (232) |
Complexity: 45 |
Complexity Density: 0,23 |
|
44 |
|
public class FileManagerTest extends SingleBlogTestCase { |
45 |
|
|
46 |
|
private FileManager fileManager; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
48 |
70
|
protected void setUp() throws Exception {... |
49 |
70
|
super.setUp(); |
50 |
|
|
51 |
70
|
fileManager = new FileManager(blog, FileMetaData.BLOG_FILE); |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
57 |
2
|
public void testCreateFileManagerForBlogImages() {... |
58 |
2
|
fileManager = new FileManager(blog, FileMetaData.BLOG_IMAGE); |
59 |
2
|
assertEquals(new File(blog.getImagesDirectory()), fileManager.getRootDirectory()); |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
65 |
2
|
public void testCreateFileManagerForBlogFiles() {... |
66 |
2
|
fileManager = new FileManager(blog, FileMetaData.BLOG_FILE); |
67 |
2
|
assertEquals(new File(blog.getFilesDirectory()), fileManager.getRootDirectory()); |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
73 |
2
|
public void testCreateFileManagerForThemeFiles() {... |
74 |
2
|
Theme theme = new Theme(blog, "custom", "/some/path"); |
75 |
2
|
blog.setEditableTheme(theme); |
76 |
2
|
fileManager = new FileManager(blog, FileMetaData.THEME_FILE); |
77 |
2
|
assertEquals(blog.getEditableTheme().getPathToLiveTheme(), fileManager.getRootDirectory()); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
83 |
2
|
public void testCreateFileManagerForBlogData() {... |
84 |
2
|
fileManager = new FileManager(blog, FileMetaData.BLOG_DATA); |
85 |
2
|
assertEquals(new File(blog.getRoot()), fileManager.getRootDirectory()); |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
1
PASS
|
|
92 |
2
|
public void testGetFileMetaDataWithAbsolutePath() {... |
93 |
2
|
FileMetaData file = fileManager.getFileMetaData("/afile.zip"); |
94 |
2
|
assertFalse(file.isDirectory()); |
95 |
2
|
assertEquals("/", file.getPath()); |
96 |
2
|
assertEquals("afile.zip", file.getName()); |
97 |
|
|
98 |
2
|
file = fileManager.getFileMetaData("/a/a.txt"); |
99 |
2
|
assertFalse(file.isDirectory()); |
100 |
2
|
assertEquals("/a", file.getPath()); |
101 |
2
|
assertEquals("a.txt", file.getName()); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
1
PASS
|
|
108 |
2
|
public void testGetFileMetaDataWithPathAndName() {... |
109 |
2
|
FileMetaData file = fileManager.getFileMetaData("/", "afile.zip"); |
110 |
2
|
assertFalse(file.isDirectory()); |
111 |
2
|
assertEquals("/", file.getPath()); |
112 |
2
|
assertEquals("afile.zip", file.getName()); |
113 |
|
|
114 |
2
|
file = fileManager.getFileMetaData("/a", "a.txt"); |
115 |
2
|
assertFalse(file.isDirectory()); |
116 |
2
|
assertEquals("/a", file.getPath()); |
117 |
2
|
assertEquals("a.txt", file.getName()); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
123 |
2
|
public void testGetFileFromAbsolutePath() {... |
124 |
2
|
File file = fileManager.getFile("/afile.zip"); |
125 |
2
|
assertEquals(new File(blog.getFilesDirectory(), "afile.zip"), file); |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
131 |
2
|
public void testGetFileFromRelativePath() throws Exception {... |
132 |
2
|
File file = fileManager.getFile("afile.zip"); |
133 |
2
|
assertEquals(new File(blog.getFilesDirectory(), "afile.zip"), file); |
134 |
|
|
135 |
2
|
file = fileManager.getFile("./afile.zip"); |
136 |
2
|
assertEquals(new File(blog.getFilesDirectory(), "afile.zip").getCanonicalFile(), file.getCanonicalFile()); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
142 |
2
|
public void testFileIsUnderneathRootDirectory() {... |
143 |
2
|
File file = fileManager.getFile("/afile.zip"); |
144 |
2
|
assertTrue(fileManager.isUnderneathRootDirectory(file)); |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
150 |
2
|
public void testFileIsNotUnderneathRootDirectory() {... |
151 |
2
|
File file = fileManager.getFile("../afile.zip"); |
152 |
2
|
assertFalse(fileManager.isUnderneathRootDirectory(file)); |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
158 |
2
|
public void testCreateDirectory() throws Exception {... |
159 |
2
|
File newDirectory = fileManager.createDirectory("/", "asubdirectory"); |
160 |
2
|
assertEquals(new File(blog.getFilesDirectory(), "asubdirectory"), newDirectory); |
161 |
2
|
assertTrue(newDirectory.exists()); |
162 |
|
|
163 |
|
|
164 |
2
|
newDirectory.delete(); |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
170 |
2
|
public void testCreateDirectoryThrowsExceptionWhenOutsideOfRoot() {... |
171 |
2
|
try { |
172 |
2
|
fileManager.createDirectory("/", "../asubdirectory"); |
173 |
0
|
fail("Creating a directory outside of the root isn't allowed"); |
174 |
|
} catch (IllegalFileAccessException ifae) { |
175 |
|
} |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
181 |
2
|
public void testFileNotCopiedWhenNoNameGiven() throws Exception {... |
182 |
2
|
assertNull(fileManager.copyFile("/", "afile.txt", null)); |
183 |
2
|
assertNull(fileManager.copyFile("/", "afile.txt", "")); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
189 |
2
|
public void testFileNotCopiedWhenSameNameGiven() throws Exception {... |
190 |
2
|
assertNull(fileManager.copyFile("/", "afile.txt", "afile.txt")); |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
197 |
2
|
public void testCopyFileThrowsExceptionWhenOriginalFileOutsideOfRoot() throws Exception {... |
198 |
2
|
try { |
199 |
2
|
assertNull(fileManager.copyFile("/", "../afile.txt", "afile.txt")); |
200 |
0
|
fail("Copying a file outside of the root isn't allowed"); |
201 |
|
} catch (IllegalFileAccessException ifae) { |
202 |
|
} |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
209 |
2
|
public void testCopyFileThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
210 |
2
|
try { |
211 |
2
|
assertNull(fileManager.copyFile("/", "afile.txt", "../afile.txt")); |
212 |
0
|
fail("Copying a file outside of the root isn't allowed"); |
213 |
|
} catch (IllegalFileAccessException ifae) { |
214 |
|
} |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
220 |
2
|
public void testCopyFile() throws Exception {... |
221 |
2
|
File file = fileManager.getFile("/afile.txt"); |
222 |
2
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
223 |
2
|
writer.write("Testing..."); |
224 |
2
|
writer.flush(); |
225 |
2
|
writer.close(); |
226 |
|
|
227 |
2
|
File newFile = fileManager.copyFile("/", "afile.txt", "anewfile.txt"); |
228 |
2
|
assertNotNull(newFile); |
229 |
2
|
assertTrue(newFile.exists()); |
230 |
2
|
assertEquals(file.length(), newFile.length()); |
231 |
|
|
232 |
|
|
233 |
2
|
file.delete(); |
234 |
2
|
newFile.delete(); |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
240 |
2
|
public void testFileNotRenamedWhenNoNameGiven() throws Exception {... |
241 |
2
|
assertNull(fileManager.renameFile("/", "afile.txt", null)); |
242 |
2
|
assertNull(fileManager.renameFile("/", "afile.txt", "")); |
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
248 |
2
|
public void testFileNotRenamedWhenSameNameGiven() throws Exception {... |
249 |
2
|
assertNull(fileManager.renameFile("/", "afile.txt", "afile.txt")); |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
256 |
2
|
public void testRenameFileThrowsExceptionWhenOriginalFileOutsideOfRoot() throws Exception {... |
257 |
2
|
try { |
258 |
2
|
assertNull(fileManager.renameFile("/", "../afile.txt", "afile.txt")); |
259 |
0
|
fail("Renaming a file outside of the root isn't allowed"); |
260 |
|
} catch (IllegalFileAccessException ifae) { |
261 |
|
} |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
268 |
2
|
public void testRenameFileThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
269 |
2
|
try { |
270 |
2
|
assertNull(fileManager.renameFile("/", "afile.txt", "../afile.txt")); |
271 |
0
|
fail("Renaming a file outside of the root isn't allowed"); |
272 |
|
} catch (IllegalFileAccessException ifae) { |
273 |
|
} |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
279 |
2
|
public void testRenameFile() throws Exception {... |
280 |
2
|
File file = fileManager.getFile("/afile.txt"); |
281 |
2
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
282 |
2
|
writer.write("Testing..."); |
283 |
2
|
writer.flush(); |
284 |
2
|
writer.close(); |
285 |
2
|
long length = file.length(); |
286 |
|
|
287 |
2
|
File newFile = fileManager.renameFile("/", "afile.txt", "anewfile.txt"); |
288 |
2
|
assertNotNull(newFile); |
289 |
2
|
assertFalse(file.exists()); |
290 |
2
|
assertTrue(newFile.exists()); |
291 |
2
|
assertEquals(length, newFile.length()); |
292 |
|
|
293 |
|
|
294 |
2
|
newFile.delete(); |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
300 |
2
|
public void testDeleteFileThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
301 |
2
|
try { |
302 |
2
|
fileManager.deleteFile("/", "../afile.txt"); |
303 |
0
|
fail("Deleting a file outside of the root isn't allowed"); |
304 |
|
} catch (IllegalFileAccessException ifae) { |
305 |
|
} |
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0,07 |
1
PASS
|
|
311 |
2
|
public void testLoadFile() throws Exception {... |
312 |
2
|
File file = fileManager.getFile("/afile.txt"); |
313 |
2
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file)); |
314 |
2
|
writer.write("First line"); |
315 |
2
|
writer.newLine(); |
316 |
2
|
writer.write("Second line"); |
317 |
2
|
writer.flush(); |
318 |
2
|
writer.close(); |
319 |
|
|
320 |
2
|
StringBuffer expectedContent = new StringBuffer(); |
321 |
2
|
expectedContent.append("First line"); |
322 |
2
|
expectedContent.append(System.getProperty("line.separator")); |
323 |
2
|
expectedContent.append("Second line"); |
324 |
|
|
325 |
2
|
String content = fileManager.loadFile("/", "afile.txt"); |
326 |
2
|
assertEquals(expectedContent.toString(), content); |
327 |
|
|
328 |
|
|
329 |
2
|
file.delete(); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
335 |
2
|
public void testLoadFileThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
336 |
2
|
try { |
337 |
2
|
fileManager.loadFile("/", "../afile.txt"); |
338 |
0
|
fail("Loading a file outside of the root isn't allowed"); |
339 |
|
} catch (IllegalFileAccessException ifae) { |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
1
PASS
|
|
346 |
2
|
public void testSaveFile() throws Exception {... |
347 |
2
|
StringBuffer content = new StringBuffer(); |
348 |
2
|
content.append("First line"); |
349 |
2
|
content.append(System.getProperty("line.separator")); |
350 |
2
|
content.append("Second line"); |
351 |
|
|
352 |
2
|
fileManager.saveFile("/", "afile.txt", content.toString()); |
353 |
2
|
assertEquals(content.toString(), fileManager.loadFile("/", "afile.txt")); |
354 |
|
|
355 |
|
|
356 |
2
|
File file = fileManager.getFile("/afile.txt"); |
357 |
2
|
file.delete(); |
358 |
|
} |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
363 |
2
|
public void testSaveFileThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
364 |
2
|
try { |
365 |
2
|
fileManager.saveFile("/", "../afile.txt", "some content"); |
366 |
0
|
fail("Saving a file outside of the root isn't allowed"); |
367 |
|
} catch (IllegalFileAccessException ifae) { |
368 |
|
} |
369 |
|
} |
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0,04 |
1
PASS
|
|
374 |
2
|
public void testGetFiles() throws Exception {... |
375 |
|
|
376 |
2
|
fileManager.createDirectory("/", "a"); |
377 |
2
|
fileManager.createDirectory("/", "z"); |
378 |
2
|
fileManager.saveFile("/", "y.txt", "Some content"); |
379 |
2
|
fileManager.saveFile("/", "b.txt", "Some content"); |
380 |
|
|
381 |
2
|
List files = fileManager.getFiles("/"); |
382 |
2
|
assertEquals(4, files.size()); |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
2
|
FileMetaData file = (FileMetaData)files.get(0); |
387 |
2
|
assertEquals("a", file.getName()); |
388 |
2
|
assertEquals("/", file.getPath()); |
389 |
2
|
assertTrue(file.isDirectory()); |
390 |
2
|
file = (FileMetaData)files.get(1); |
391 |
2
|
assertEquals("z", file.getName()); |
392 |
2
|
assertEquals("/", file.getPath()); |
393 |
2
|
assertTrue(file.isDirectory()); |
394 |
2
|
file = (FileMetaData)files.get(2); |
395 |
2
|
assertEquals("b.txt", file.getName()); |
396 |
2
|
assertEquals("/", file.getPath()); |
397 |
2
|
assertFalse(file.isDirectory()); |
398 |
2
|
file = (FileMetaData)files.get(3); |
399 |
2
|
assertEquals("y.txt", file.getName()); |
400 |
2
|
assertEquals("/", file.getPath()); |
401 |
2
|
assertFalse(file.isDirectory()); |
402 |
|
|
403 |
|
|
404 |
2
|
fileManager.deleteFile("/", "a"); |
405 |
2
|
fileManager.deleteFile("/", "z"); |
406 |
2
|
fileManager.deleteFile("/", "y.txt"); |
407 |
2
|
fileManager.deleteFile("/", "b.txt"); |
408 |
|
} |
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
413 |
2
|
public void testGetFilesRecursively() throws Exception {... |
414 |
|
|
415 |
2
|
fileManager.createDirectory("/", "a"); |
416 |
2
|
fileManager.saveFile("/a", "a.txt", "Some content"); |
417 |
2
|
fileManager.saveFile("/", "b.txt", "Some content"); |
418 |
|
|
419 |
2
|
List files = fileManager.getFiles("/", true); |
420 |
2
|
assertEquals(3, files.size()); |
421 |
|
|
422 |
|
|
423 |
|
|
424 |
2
|
FileMetaData file = (FileMetaData)files.get(0); |
425 |
2
|
assertEquals("a", file.getName()); |
426 |
2
|
assertEquals("/", file.getPath()); |
427 |
2
|
assertTrue(file.isDirectory()); |
428 |
2
|
file = (FileMetaData)files.get(1); |
429 |
2
|
assertEquals("a.txt", file.getName()); |
430 |
2
|
assertEquals("/a", file.getPath()); |
431 |
2
|
assertFalse(file.isDirectory()); |
432 |
2
|
file = (FileMetaData)files.get(2); |
433 |
2
|
assertEquals("b.txt", file.getName()); |
434 |
2
|
assertEquals("/", file.getPath()); |
435 |
2
|
assertFalse(file.isDirectory()); |
436 |
|
|
437 |
|
|
438 |
2
|
fileManager.deleteFile("/a", "a.txt"); |
439 |
2
|
fileManager.deleteFile("/", "a"); |
440 |
2
|
fileManager.deleteFile("/", "b.txt"); |
441 |
|
} |
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
446 |
2
|
public void testGetFilesFromEmptyDirectory() throws Exception {... |
447 |
2
|
List files = fileManager.getFiles("/"); |
448 |
2
|
assertEquals(0, files.size()); |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
454 |
2
|
public void testGetFilesFromNonExistentDirectory() throws Exception {... |
455 |
|
|
456 |
2
|
Theme theme = new Theme(blog, "custom", "/some/path"); |
457 |
2
|
blog.setEditableTheme(theme); |
458 |
2
|
fileManager = new FileManager(blog, FileMetaData.THEME_FILE); |
459 |
2
|
List files = fileManager.getFiles("/"); |
460 |
2
|
assertEquals(0, files.size()); |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
1
PASS
|
|
466 |
2
|
public void testGetFilesThrowsExceptionWhenNewFileOutsideOfRoot() throws Exception {... |
467 |
2
|
try { |
468 |
2
|
fileManager.getFiles("../"); |
469 |
0
|
fail("Accessing files outside of the root isn't allowed"); |
470 |
|
} catch (IllegalFileAccessException ifae) { |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
477 |
2
|
public void testUrlForBlogFile() throws Exception {... |
478 |
2
|
fileManager = new FileManager(blog, FileMetaData.BLOG_FILE); |
479 |
2
|
fileManager.saveFile("/", "a.txt", "Some content"); |
480 |
|
|
481 |
2
|
List files = fileManager.getFiles("/"); |
482 |
2
|
FileMetaData file = (FileMetaData)files.get(0); |
483 |
2
|
assertEquals("files/a.txt", file.getUrl()); |
484 |
|
|
485 |
|
|
486 |
2
|
fileManager.deleteFile("/", "a.txt"); |
487 |
|
} |
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
492 |
2
|
public void testUrlForBlogImage() throws Exception {... |
493 |
2
|
fileManager = new FileManager(blog, FileMetaData.BLOG_IMAGE); |
494 |
2
|
fileManager.saveFile("/", "a.txt", "Some content"); |
495 |
|
|
496 |
2
|
List files = fileManager.getFiles("/"); |
497 |
2
|
FileMetaData file = (FileMetaData)files.get(0); |
498 |
2
|
assertEquals("images/a.txt", file.getUrl()); |
499 |
|
|
500 |
|
|
501 |
2
|
fileManager.deleteFile("/", "a.txt"); |
502 |
|
} |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
507 |
2
|
public void testUrlForThemeFile() throws Exception {... |
508 |
2
|
Theme theme = new Theme(blog, "theme", blog.getRoot()); |
509 |
2
|
File themeDirectory = new File(blog.getThemeDirectory()); |
510 |
2
|
themeDirectory.mkdir(); |
511 |
2
|
blog.setEditableTheme(theme); |
512 |
2
|
fileManager = new FileManager(blog, FileMetaData.THEME_FILE); |
513 |
2
|
fileManager.saveFile("/", "a.txt", "Some content"); |
514 |
|
|
515 |
2
|
List files = fileManager.getFiles("/"); |
516 |
2
|
FileMetaData file = (FileMetaData)files.get(0); |
517 |
2
|
assertEquals("theme/a.txt", file.getUrl()); |
518 |
|
|
519 |
|
|
520 |
2
|
fileManager.deleteFile("/", "a.txt"); |
521 |
2
|
themeDirectory.delete(); |
522 |
|
} |
523 |
|
|
524 |
|
} |