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 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.setup; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
|
38 |
|
import info.magnolia.cms.core.Path; |
39 |
|
import info.magnolia.module.cache.AbstractCacheTest; |
40 |
|
import info.magnolia.module.cache.filter.CacheResponseWrapper; |
41 |
|
import info.magnolia.module.delta.TaskExecutionException; |
42 |
|
|
43 |
|
import java.io.File; |
44 |
|
import java.io.IOException; |
45 |
|
|
46 |
|
import org.junit.Test; |
47 |
|
|
48 |
|
|
49 |
|
@link |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 4 |
Complexity Density: 0.19 |
|
51 |
|
public class RemoveCacheTempFilesTaskTest extends AbstractCacheTest { |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testDeleteTempFile() throws IOException, TaskExecutionException { |
55 |
|
|
56 |
1 |
File tempFile = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory()); |
57 |
|
|
58 |
1 |
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask(); |
59 |
|
|
60 |
|
|
61 |
1 |
removeCacheTempFilesTask.execute(null); |
62 |
|
|
63 |
|
|
64 |
1 |
assertFalse(tempFile.exists()); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
67 |
1 |
@Test... |
68 |
|
public void testDeleteMultipleTempFiles() throws IOException, TaskExecutionException { |
69 |
|
|
70 |
1 |
File tempFile = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory()); |
71 |
1 |
File tempFile1 = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory()); |
72 |
1 |
File tempFile2 = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory()); |
73 |
|
|
74 |
1 |
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask(); |
75 |
|
|
76 |
|
|
77 |
1 |
removeCacheTempFilesTask.execute(null); |
78 |
|
|
79 |
|
|
80 |
1 |
assertFalse(tempFile.exists()); |
81 |
1 |
assertFalse(tempFile1.exists()); |
82 |
1 |
assertFalse(tempFile2.exists()); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
85 |
1 |
@Test... |
86 |
|
public void testTempFileWhichDoesNotStartWithCacheTempPrefixIsNotDeleted() throws IOException, TaskExecutionException { |
87 |
|
|
88 |
1 |
File tempFile = File.createTempFile("blablabla" + CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory()); |
89 |
|
|
90 |
1 |
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask(); |
91 |
|
|
92 |
|
|
93 |
1 |
removeCacheTempFilesTask.execute(null); |
94 |
|
|
95 |
|
|
96 |
1 |
assertTrue(tempFile.exists()); |
97 |
|
|
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
100 |
1 |
@Test... |
101 |
|
public void testFolderWithCacheTempFilePrefixIsNotDeleted() throws IOException, TaskExecutionException { |
102 |
|
|
103 |
1 |
File directoryWithCacheTempFilePrefix = new File(Path.getTempDirectory() + "/" + CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX); |
104 |
1 |
directoryWithCacheTempFilePrefix.mkdir(); |
105 |
|
|
106 |
1 |
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask(); |
107 |
|
|
108 |
|
|
109 |
1 |
removeCacheTempFilesTask.execute(null); |
110 |
|
|
111 |
|
|
112 |
1 |
assertTrue(directoryWithCacheTempFilePrefix.exists()); |
113 |
|
|
114 |
|
} |
115 |
|
|
116 |
|
} |