]> source.dussan.org Git - archiva.git/blob
6ee6495409e369960675251576da17b480127981
[archiva.git] /
1 package org.apache.archiva.metadata.repository.storage.maven2;
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 import org.apache.archiva.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.model.Dependency;
24 import org.apache.archiva.metadata.model.FacetedMetadata;
25 import org.apache.archiva.metadata.model.License;
26 import org.apache.archiva.metadata.model.MailingList;
27 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
28 import org.apache.archiva.metadata.repository.MetadataRepository;
29 import org.apache.archiva.metadata.repository.MetadataResolutionException;
30 import org.apache.archiva.metadata.repository.filter.ExcludesFilter;
31 import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver;
32 import org.apache.archiva.reports.RepositoryProblemFacet;
33 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
34 import org.apache.maven.archiva.configuration.Configuration;
35 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
36 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
37
38 import java.util.ArrayList;
39 import java.util.Arrays;
40 import java.util.Collection;
41 import java.util.Collections;
42 import java.util.Comparator;
43 import java.util.List;
44
45 public class Maven2RepositoryMetadataResolverTest
46     extends PlexusInSpringTestCase
47 {
48     private Maven2RepositoryMetadataResolver resolver;
49
50     private static final String TEST_REPO_ID = "test";
51
52     private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
53
54     private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
55
56     private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
57
58     private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
59
60     private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
61
62     private MetadataRepository metadataRepository;
63
64     public void setUp()
65         throws Exception
66     {
67         super.setUp();
68
69         ArchivaConfiguration configuration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
70         Configuration c = new Configuration();
71         ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
72         testRepo.setId( TEST_REPO_ID );
73         testRepo.setLocation( getTestPath( "src/test/repositories/test" ) );
74         c.addManagedRepository( testRepo );
75         configuration.save( c );
76
77         resolver = (Maven2RepositoryMetadataResolver) lookup( StorageMetadataResolver.class, "maven2" );
78         metadataRepository = (MetadataRepository) lookup( MetadataRepository.class );
79         metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID );
80     }
81
82     public void testGetProjectVersionMetadata()
83         throws Exception
84     {
85         ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva",
86                                                                       "archiva-common", "1.2.1" );
87         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
88         assertEquals( "jar", facet.getPackaging() );
89         assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() );
90         assertEquals( "org.apache.archiva", facet.getParent().getGroupId() );
91         assertEquals( "archiva-base", facet.getParent().getArtifactId() );
92         assertEquals( "1.2.1", facet.getParent().getVersion() );
93         assertEquals( "archiva-common", facet.getArtifactId() );
94         assertEquals( "org.apache.archiva", facet.getGroupId() );
95         assertEquals( "continuum", metadata.getCiManagement().getSystem() );
96         assertEquals( "http://vmbuild.apache.org/continuum", metadata.getCiManagement().getUrl() );
97         assertNotNull( metadata.getDescription() );
98         // TODO: this would be better
99 //        assertEquals(
100 //            "Archiva is an application for managing one or more remote repositories, including administration, artifact handling, browsing and searching.",
101 //            metadata.getDescription() );
102         assertEquals( "1.2.1", metadata.getId() );
103         assertEquals( "jira", metadata.getIssueManagement().getSystem() );
104         assertEquals( "http://jira.codehaus.org/browse/MRM", metadata.getIssueManagement().getUrl() );
105         checkApacheLicense( metadata );
106         assertEquals( "Archiva Base :: Common", metadata.getName() );
107         String path = "archiva/tags/archiva-1.2.1/archiva-modules/archiva-base/archiva-common";
108         assertEquals( ASF_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
109         assertEquals( ASF_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
110         assertEquals( ASF_SCM_VIEWVC_BASE + path, metadata.getScm().getUrl() );
111         checkOrganizationApache( metadata );
112
113         assertEquals( 4, metadata.getMailingLists().size() );
114         assertMailingList( "users", metadata.getMailingLists().get( 0 ), "Archiva User List", true,
115                            "http://www.nabble.com/archiva-users-f16426.html" );
116         assertMailingList( "dev", metadata.getMailingLists().get( 1 ), "Archiva Developer List", true,
117                            "http://www.nabble.com/archiva-dev-f16427.html" );
118         assertMailingList( "commits", metadata.getMailingLists().get( 2 ), "Archiva Commits List", false, null );
119         assertMailingList( "issues", metadata.getMailingLists().get( 3 ), "Archiva Issues List", false,
120                            "http://www.nabble.com/Archiva---Issues-f29617.html" );
121
122         List<Dependency> dependencies = metadata.getDependencies();
123         assertEquals( 10, dependencies.size() );
124         assertDependency( dependencies.get( 0 ), "commons-lang", "commons-lang", "2.2" );
125         assertDependency( dependencies.get( 1 ), "commons-io", "commons-io", "1.4" );
126         assertDependency( dependencies.get( 2 ), "org.slf4j", "slf4j-api", "1.5.0" );
127         assertDependency( dependencies.get( 3 ), "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22" );
128         assertDependency( dependencies.get( 4 ), "org.codehaus.plexus", "plexus-spring", "1.2", "test" );
129         assertDependency( dependencies.get( 5 ), "xalan", "xalan", "2.7.0" );
130         assertDependency( dependencies.get( 6 ), "dom4j", "dom4j", "1.6.1", "test" );
131         assertDependency( dependencies.get( 7 ), "junit", "junit", "3.8.1", "test" );
132         assertDependency( dependencies.get( 8 ), "easymock", "easymock", "1.2_Java1.3", "test" );
133         assertDependency( dependencies.get( 9 ), "easymock", "easymockclassextension", "1.2", "test" );
134     }
135
136     // TODO: test snapshot, rest of artifacts
137     public void testGetArtifactMetadata()
138         throws Exception
139     {
140         Collection<ArtifactMetadata> springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus",
141                                                                               "plexus-spring", "1.2" );
142         List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts );
143
144         assertEquals( 3, artifacts.size() );
145
146         ArtifactMetadata artifactMetadata = artifacts.get( 0 );
147         assertEquals( "plexus-spring-1.2-sources.jar", artifactMetadata.getId() );
148         MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
149         assertEquals( 0, facet.getBuildNumber() );
150         assertNull( facet.getTimestamp() );
151         assertEquals( "sources", facet.getClassifier() );
152         // TODO
153 //        assertEquals( "java-source", facet.getType() );
154
155         artifactMetadata = artifacts.get( 1 );
156         assertEquals( "plexus-spring-1.2.jar", artifactMetadata.getId() );
157         facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
158         assertEquals( 0, facet.getBuildNumber() );
159         assertNull( facet.getTimestamp() );
160         assertNull( facet.getClassifier() );
161         // TODO
162 //        assertEquals( "jar", facet.getType() );
163
164         artifactMetadata = artifacts.get( 2 );
165         assertEquals( "plexus-spring-1.2.pom", artifactMetadata.getId() );
166         facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
167         assertEquals( 0, facet.getBuildNumber() );
168         assertNull( facet.getTimestamp() );
169         assertNull( facet.getClassifier() );
170         // TODO
171 //        assertEquals( "pom", facet.getType() );
172     }
173
174     private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
175     {
176         assertDependency( dependency, groupId, artifactId, version, "compile" );
177     }
178
179     private void assertDependency( Dependency dependency, String groupId, String artifactId, String version,
180                                    String scope )
181     {
182         assertEquals( artifactId, dependency.getArtifactId() );
183         assertEquals( "jar", dependency.getType() );
184         assertEquals( version, dependency.getVersion() );
185         assertEquals( groupId, dependency.getGroupId() );
186         assertEquals( scope, dependency.getScope() );
187         assertNull( dependency.getClassifier() );
188         assertNull( dependency.getSystemPath() );
189     }
190
191     public void testGetProjectVersionMetadataForTimestampedSnapshot()
192         throws Exception
193     {
194         ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache",
195                                                                       "5-SNAPSHOT" );
196         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
197         assertEquals( "pom", facet.getPackaging() );
198         assertEquals( "http://www.apache.org/", metadata.getUrl() );
199         assertNull( facet.getParent() );
200         assertEquals( "org.apache", facet.getGroupId() );
201         assertEquals( "apache", facet.getArtifactId() );
202         assertNull( metadata.getCiManagement() );
203         assertNotNull( metadata.getDescription() );
204         // TODO: this would be better
205 //        assertEquals(
206 //            "The Apache Software Foundation provides support for the Apache community of open-source software projects. " +
207 //                "The Apache projects are characterized by a collaborative, consensus based development process, an open " +
208 //                "and pragmatic software license, and a desire to create high quality software that leads the way in its " +
209 //                "field. We consider ourselves not simply a group of projects sharing a server, but rather a community of " +
210 //                "developers and users.", metadata.getDescription() );
211         assertEquals( "5-SNAPSHOT", metadata.getId() );
212         assertNull( metadata.getIssueManagement() );
213         checkApacheLicense( metadata );
214         assertEquals( "The Apache Software Foundation", metadata.getName() );
215         String path = "maven/pom/trunk/asf";
216         assertEquals( ASF_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
217         assertEquals( ASF_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
218         assertEquals( ASF_SCM_VIEWVC_BASE + path, metadata.getScm().getUrl() );
219         checkOrganizationApache( metadata );
220         assertEquals( 1, metadata.getMailingLists().size() );
221         assertMailingList( metadata.getMailingLists().get( 0 ), "Apache Announce List",
222                            "http://mail-archives.apache.org/mod_mbox/www-announce/", "announce@apache.org",
223                            "announce-subscribe@apache.org", "announce-unsubscribe@apache.org",
224                            Collections.<String>emptyList(), true );
225         assertEquals( Collections.<Dependency>emptyList(), metadata.getDependencies() );
226     }
227
228     public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata()
229         throws Exception
230     {
231         FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata",
232                                                                "1.0-SNAPSHOT" );
233         assertNull( metadata );
234     }
235
236     public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata()
237         throws Exception
238     {
239         FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata",
240                                                                "1.0-SNAPSHOT" );
241         assertNull( metadata );
242     }
243
244     public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata()
245         throws Exception
246     {
247         FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata",
248                                                                "1.0-SNAPSHOT" );
249         assertNull( metadata );
250     }
251
252     public void testGetProjectVersionMetadataForInvalidPom()
253         throws Exception
254     {
255         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
256
257         try
258         {
259             resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" );
260             fail( "Should have received an exception due to invalid POM" );
261         }
262         catch ( MetadataResolutionException e )
263         {
264             assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID,
265                                                                RepositoryProblemFacet.FACET_ID ).isEmpty() );
266             RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
267                                                                                                          RepositoryProblemFacet.FACET_ID,
268                                                                                                          "com.example.test/invalid-pom/1.0" );
269             assertEquals( "invalid-pom", facet.getProblem() );
270         }
271     }
272
273     public void testGetProjectVersionMetadataForMislocatedPom()
274         throws Exception
275     {
276         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
277
278         try
279         {
280             resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" );
281             fail( "Should have received an exception due to mislocated POM" );
282         }
283         catch ( MetadataResolutionException e )
284         {
285             assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID,
286                                                                RepositoryProblemFacet.FACET_ID ).isEmpty() );
287             RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
288                                                                                                          RepositoryProblemFacet.FACET_ID,
289                                                                                                          "com.example.test/mislocated-pom/1.0" );
290             assertEquals( "mislocated-pom", facet.getProblem() );
291         }
292     }
293
294     public void testGetProjectVersionMetadataForMissingPom()
295         throws Exception
296     {
297         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
298
299         FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" );
300         assertNull( metadata );
301
302         assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
303         RepositoryProblemFacet facet = (RepositoryProblemFacet) metadataRepository.getMetadataFacet( TEST_REPO_ID,
304                                                                                                      RepositoryProblemFacet.FACET_ID,
305                                                                                                      "com.example.test/missing-pom/1.0" );
306         assertEquals( "missing-pom", facet.getProblem() );
307
308     }
309
310     public void testGetRootNamespaces()
311     {
312         assertEquals( Arrays.asList( "com", "org" ), resolver.getRootNamespaces( TEST_REPO_ID ) );
313     }
314
315     public void testGetNamespaces()
316     {
317         assertEquals( Arrays.asList( "example" ), resolver.getNamespaces( TEST_REPO_ID, "com" ) );
318         assertEquals( Arrays.asList( "test" ), resolver.getNamespaces( TEST_REPO_ID, "com.example" ) );
319         assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "com.example.test" ) );
320
321         assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.getNamespaces( TEST_REPO_ID, "org" ) );
322         assertEquals( Arrays.asList( "archiva", "maven" ), resolver.getNamespaces( TEST_REPO_ID, "org.apache" ) );
323         assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) );
324         assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID,
325                                                                                     "org.apache.maven" ) );
326         assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID,
327                                                                                "org.apache.maven.plugins" ) );
328         assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID,
329                                                                                "org.apache.maven.shared" ) );
330
331         assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) );
332         assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) );
333     }
334
335     public void testGetProjects()
336     {
337         assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com" ) );
338         assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com.example" ) );
339         assertEquals( Arrays.asList( "incomplete-metadata", "invalid-pom", "malformed-metadata", "mislocated-pom",
340                                      "missing-metadata" ), resolver.getProjects( TEST_REPO_ID, "com.example.test" ) );
341
342         assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org" ) );
343         assertEquals( Arrays.asList( "apache" ), resolver.getProjects( TEST_REPO_ID, "org.apache" ) );
344         assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ),
345                       resolver.getProjects( TEST_REPO_ID, "org.apache.archiva" ) );
346         assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) );
347         assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID,
348                                                                              "org.apache.maven.plugins" ) );
349         assertEquals( Arrays.asList( "maven-downloader" ), resolver.getProjects( TEST_REPO_ID,
350                                                                                  "org.apache.maven.shared" ) );
351     }
352
353     public void testGetProjectVersions()
354     {
355         assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
356                                                                                     "incomplete-metadata" ) );
357         assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
358                                                                                     "malformed-metadata" ) );
359         assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
360                                                                                     "missing-metadata" ) );
361         assertEquals( Arrays.asList( "1.0" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test",
362                                                                            "invalid-pom" ) );
363
364         assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache",
365                                                                                        "apache" ) );
366
367         assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
368                                                                              "archiva" ) );
369         assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
370                                                                              "archiva-base" ) );
371         assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
372                                                                              "archiva-common" ) );
373         assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
374                                                                              "archiva-modules" ) );
375         assertEquals( Arrays.asList( "3" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva",
376                                                                          "archiva-parent" ) );
377
378         assertEquals( Collections.<String>emptyList(), resolver.getProjectVersions( TEST_REPO_ID,
379                                                                                     "org.apache.maven.shared",
380                                                                                     "maven-downloader" ) );
381     }
382
383     public void testGetArtifacts()
384     {
385         List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
386                                                                                                    "org.codehaus.plexus",
387                                                                                                    "plexus-spring",
388                                                                                                    "1.2" ) );
389         assertEquals( 3, artifacts.size() );
390         Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
391         {
392             public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
393             {
394                 return o1.getId().compareTo( o2.getId() );
395             }
396         } );
397
398         assertArtifact( artifacts.get( 0 ), "plexus-spring-1.2-sources.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
399         assertArtifact( artifacts.get( 1 ), "plexus-spring-1.2.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
400         assertArtifact( artifacts.get( 2 ), "plexus-spring-1.2.pom", 7407, "96b14cf880e384b2d15e8193c57b65c5420ca4c5",
401                         "f83aa25f016212a551a4b2249985effc" );
402     }
403
404     public void testGetArtifactsFiltered()
405     {
406         ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList(
407             "plexus-spring-1.2.pom" ) );
408         List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
409                                                                                                    "org.codehaus.plexus",
410                                                                                                    "plexus-spring",
411                                                                                                    "1.2", filter ) );
412         assertEquals( 2, artifacts.size() );
413         Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
414         {
415             public int compare( ArtifactMetadata o1, ArtifactMetadata o2 )
416             {
417                 return o1.getId().compareTo( o2.getId() );
418             }
419         } );
420
421         assertArtifact( artifacts.get( 0 ), "plexus-spring-1.2-sources.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
422         assertArtifact( artifacts.get( 1 ), "plexus-spring-1.2.jar", 0, EMPTY_SHA1, EMPTY_MD5 );
423     }
424
425     public void testGetArtifactsTimestampedSnapshots()
426     {
427         List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID,
428                                                                                                    "com.example.test",
429                                                                                                    "missing-metadata",
430                                                                                                    "1.0-SNAPSHOT" ) );
431         assertEquals( 1, artifacts.size() );
432
433         ArtifactMetadata artifact = artifacts.get( 0 );
434         assertEquals( "missing-metadata-1.0-20091101.112233-1.pom", artifact.getId() );
435         assertEquals( "com.example.test", artifact.getNamespace() );
436         assertEquals( "missing-metadata", artifact.getProject() );
437         assertEquals( "1.0-20091101.112233-1", artifact.getVersion() );
438         assertEquals( TEST_REPO_ID, artifact.getRepositoryId() );
439     }
440
441     private void assertArtifact( ArtifactMetadata artifact, String id, int size, String sha1, String md5 )
442     {
443         assertEquals( id, artifact.getId() );
444         assertEquals( md5, artifact.getMd5() );
445         assertEquals( sha1, artifact.getSha1() );
446         assertEquals( size, artifact.getSize() );
447         assertEquals( "org.codehaus.plexus", artifact.getNamespace() );
448         assertEquals( "plexus-spring", artifact.getProject() );
449         assertEquals( "1.2", artifact.getVersion() );
450         assertEquals( TEST_REPO_ID, artifact.getRepositoryId() );
451     }
452
453     private void assertMailingList( MailingList mailingList, String name, String archive, String post, String subscribe,
454                                     String unsubscribe, List<String> otherArchives, boolean allowPost )
455     {
456         assertEquals( archive, mailingList.getMainArchiveUrl() );
457         if ( allowPost )
458         {
459             assertEquals( post, mailingList.getPostAddress() );
460         }
461         else
462         {
463             assertNull( mailingList.getPostAddress() );
464         }
465         assertEquals( subscribe, mailingList.getSubscribeAddress() );
466         assertEquals( unsubscribe, mailingList.getUnsubscribeAddress() );
467         assertEquals( name, mailingList.getName() );
468         assertEquals( otherArchives, mailingList.getOtherArchives() );
469     }
470
471     private void assertMailingList( String prefix, MailingList mailingList, String name, boolean allowPost,
472                                     String nabbleUrl )
473     {
474         List<String> otherArchives = new ArrayList<String>();
475         otherArchives.add( "http://www.mail-archive.com/" + prefix + "@archiva.apache.org" );
476         if ( nabbleUrl != null )
477         {
478             otherArchives.add( nabbleUrl );
479         }
480         otherArchives.add( "http://markmail.org/list/org.apache.archiva." + prefix );
481         assertMailingList( mailingList, name, "http://mail-archives.apache.org/mod_mbox/archiva-" + prefix + "/",
482                            prefix + "@archiva.apache.org", prefix + "-subscribe@archiva.apache.org",
483                            prefix + "-unsubscribe@archiva.apache.org", otherArchives, allowPost );
484     }
485
486     private void checkApacheLicense( ProjectVersionMetadata metadata )
487     {
488         assertEquals( Arrays.asList( new License( "The Apache Software License, Version 2.0",
489                                                   "http://www.apache.org/licenses/LICENSE-2.0.txt" ) ),
490                       metadata.getLicenses() );
491     }
492
493     private void checkOrganizationApache( ProjectVersionMetadata metadata )
494     {
495         assertEquals( "The Apache Software Foundation", metadata.getOrganization().getName() );
496         assertEquals( "http://www.apache.org/", metadata.getOrganization().getUrl() );
497     }
498 }