1 package org.apache.continuum.purge.executor;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class DaysOldDirectoryPurgeExecutorTest
26 extends AbstractPurgeExecutorTest
27 {
28 protected void setUp()
29 throws Exception
30 {
31 super.setUp();
32
33 purgeReleasesDirTask = getDaysOldReleasesDirPurgeTask();
34
35 purgeBuildOutputDirTask = getDaysOldBuildOutputDirPurgeTask();
36 }
37
38 public void testReleasesDirPurgingByLastModified()
39 throws Exception
40 {
41 populateReleasesDirectory();
42
43 String dirPath = getReleasesDirectoryLocation().getAbsolutePath();
44
45 setLastModified( dirPath, 1179382029, true );
46 setLastModified( dirPath + "/releases-1234567809", 1023453892, false );
47
48 purgeExecutor.executeTask( purgeReleasesDirTask );
49
50 assertDeleted( dirPath + "/releases-1234567809" );
51
52 assertExists( dirPath + "/1" );
53 assertExists( dirPath + "/releases-1234567890" );
54 assertExists( dirPath + "/releases-4234729018" );
55 }
56
57 public void testReleasesDirPurgingByOrderOfDeletion()
58 throws Exception
59 {
60 populateReleasesDirectory();
61
62 String dirPath = getReleasesDirectoryLocation().getAbsolutePath();
63
64 setLastModified( dirPath + "/releases-4234729018", new Long( "1234567809" ), false );
65 setLastModified( dirPath + "/releases-1234567809", new Long( "4234729018" ), false );
66 setLastModified( dirPath + "/releases-1234567890", new Long( "2234567890" ), false );
67
68 purgeExecutor.executeTask( purgeReleasesDirTask );
69
70 assertDeleted( dirPath + "/releases-4234729018" );
71
72 assertExists( dirPath + "/1" );
73 assertExists( dirPath + "/releases-1234567890" );
74 assertExists( dirPath + "/releases-1234567809" );
75 }
76
77 public void testBuildOutputPurgingByLastModified()
78 throws Exception
79 {
80 populateBuildOutputDirectory();
81
82 String dirPath = getBuildOutputDirectoryLocation().getAbsolutePath();
83
84 setLastModified( dirPath, 1179382029, true );
85 setLastModified( dirPath + "/1/1", 1023453892, false );
86 setLastModified( dirPath + "/1/1.log.txt", 1023453892, false );
87 setLastModified( dirPath + "/2/4", 1023453892, false );
88 setLastModified( dirPath + "/2/4.log.txt", 1023453892, false );
89
90 purgeExecutor.executeTask( purgeBuildOutputDirTask );
91
92 assertDeleted( dirPath + "/1/1" );
93 assertDeleted( dirPath + "/1/1.log.txt" );
94
95 assertExists( dirPath + "/1/3" );
96 assertExists( dirPath + "/1/3.log.txt" );
97 assertExists( dirPath + "/1/6" );
98 assertExists( dirPath + "/1/6.log.txt" );
99
100 assertDeleted( dirPath + "/2/4" );
101 assertDeleted( dirPath + "/2/4.log.txt" );
102
103 assertExists( dirPath + "/2/7" );
104 assertExists( dirPath + "/2/7.log.txt" );
105 assertExists( dirPath + "/2/9" );
106 assertExists( dirPath + "/2/9.log.txt" );
107 }
108
109 public void testBuildOutputPurgingByOrderOfDeletion()
110 throws Exception
111 {
112 populateBuildOutputDirectory();
113
114 String dirPath = getBuildOutputDirectoryLocation().getAbsolutePath();
115
116 setLastModified( dirPath + "/1/6", new Long( "1234567809" ), false );
117 setLastModified( dirPath + "/1/6.log.txt", new Long( "1234567809" ), false );
118 setLastModified( dirPath + "/1/1", new Long( "4234729018" ), false );
119 setLastModified( dirPath + "/1/1.log.txt", new Long( "4234729018" ), false );
120 setLastModified( dirPath + "/1/3", new Long( "2234567890" ), false );
121 setLastModified( dirPath + "/1/3.log.txt", new Long( "2234567890" ), false );
122
123 setLastModified( dirPath + "/2/7", new Long( "1234567809" ), false );
124 setLastModified( dirPath + "/2/7.log.txt", new Long( "1234567809" ), false );
125 setLastModified( dirPath + "/2/4", new Long( "4234729018" ), false );
126 setLastModified( dirPath + "/2/4.log.txt", new Long( "4234729018" ), false );
127 setLastModified( dirPath + "/2/9", new Long( "2234567890" ), false );
128 setLastModified( dirPath + "/2/9.log.txt", new Long( "2234567890" ), false );
129
130 purgeExecutor.executeTask( purgeBuildOutputDirTask );
131
132 assertDeleted( dirPath + "/1/6" );
133 assertDeleted( dirPath + "/1/6.log.txt" );
134
135 assertExists( dirPath + "/1/3" );
136 assertExists( dirPath + "/1/3.log.txt" );
137 assertExists( dirPath + "/1/1" );
138 assertExists( dirPath + "/1/1.log.txt" );
139
140 assertDeleted( dirPath + "/2/7" );
141 assertDeleted( dirPath + "/2/7.log.txt" );
142
143 assertExists( dirPath + "/2/4" );
144 assertExists( dirPath + "/2/4.log.txt" );
145 assertExists( dirPath + "/2/9" );
146 assertExists( dirPath + "/2/9.log.txt" );
147 }
148 }