View Javadoc

1   package org.apache.continuum.purge.executor;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Tests were taken from Archiva and added a check if metadata was deleted.
24   */
25  public class ReleasedSnapshotsRepositoryPurgeExecutorTest
26      extends AbstractPurgeExecutorTest
27  {
28      protected void setUp()
29          throws Exception
30      {
31          super.setUp();
32  
33          populateDefaultRepositoryForReleasedSnapshots();
34  
35          purgeDefaultRepoTask = getReleasedSnapshotsRepoPurgeTask();
36      }
37  
38      public void testDefaultRepoReleasedSnapshotsPurging()
39          throws Exception
40      {
41          String repoRoot = getDefaultRepositoryLocation().getAbsolutePath();
42  
43          String projectRoot1 = repoRoot + "/org/apache/maven/plugins/maven-assembly-plugin";
44          String projectRoot2 = repoRoot + "/org/apache/maven/plugins/maven-install-plugin";
45          String projectRoot3 = repoRoot + "/org/apache/maven/plugins/maven-plugin-plugin";
46  
47          purgeExecutor.executeTask( purgeDefaultRepoTask );
48  
49          assertMetadataDeleted( projectRoot1 );
50          assertMetadataDeleted( projectRoot2 );
51          assertMetadataDeleted( projectRoot3 );
52  
53          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar" );
54          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.sha1" );
55          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.jar.md5" );
56          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.pom" );
57          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.pom.sha1" );
58          assertDeleted( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070427.065136-1.pom.md5" );
59  
60          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.jar" );
61          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.jar.sha1" );
62          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.jar.md5" );
63          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.pom" );
64          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.pom.sha1" );
65          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070506.163513-2.pom.md5" );
66  
67          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.jar" );
68          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.jar.sha1" );
69          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.jar.md5" );
70          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.pom" );
71          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.sha1" );
72          assertExists( projectRoot1 + "/1.1.2-SNAPSHOT/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.md5" );
73  
74          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar" );
75          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.md5" );
76          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.jar.sha1" );
77          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom" );
78          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.md5" );
79          assertDeleted( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-SNAPSHOT.pom.sha1" );
80  
81          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar" );
82          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar.md5" );
83          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.jar.sha1" );
84          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom" );
85          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.md5" );
86          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20070513.034619-5.pom.sha1" );
87  
88          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar" );
89          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.md5" );
90          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.jar.sha1" );
91          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom" );
92          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.md5" );
93          assertExists( projectRoot2 + "/2.2-SNAPSHOT/maven-install-plugin-2.2-20061118.060401-2.pom.sha1" );
94  
95          // check if the snapshot version was removed
96          assertDeleted( projectRoot3 + "/2.3-SNAPSHOT" );
97          assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar" );
98          assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.md5" );
99          assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.jar.sha1" );
100         assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom" );
101         assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.md5" );
102         assertDeleted( projectRoot3 + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
103 
104         // check if the released version was not removed
105         assertExists( projectRoot3 + "/2.2" );
106         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.jar" );
107         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.jar.md5" );
108         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.jar.sha1" );
109         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.pom" );
110         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.pom.md5" );
111         assertExists( projectRoot3 + "/2.2/maven-plugin-plugin-2.2.pom.sha1" );
112 
113         assertExists( projectRoot3 + "/2.3" );
114         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.jar" );
115         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.jar.md5" );
116         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.jar.sha1" );
117         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.pom" );
118         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.pom.md5" );
119         assertExists( projectRoot3 + "/2.3/maven-plugin-plugin-2.3.pom.sha1" );
120     }
121 }