]> source.dussan.org Git - archiva.git/blob
8aaf3d82c546eb74352393ecffcba05285f8e73b
[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 junit.framework.TestCase;
23 import org.apache.archiva.configuration.ArchivaConfiguration;
24 import org.apache.archiva.configuration.Configuration;
25 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
26 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
27 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
28 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
29 import org.apache.archiva.metadata.model.ArtifactMetadata;
30 import org.apache.archiva.metadata.model.Dependency;
31 import org.apache.archiva.metadata.model.License;
32 import org.apache.archiva.metadata.model.MailingList;
33 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
34 import org.apache.archiva.filter.AllFilter;
35 import org.apache.archiva.filter.Filter;
36 import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
37 import org.apache.archiva.proxy.maven.WagonFactory;
38 import org.apache.archiva.proxy.maven.WagonFactoryRequest;
39 import org.apache.archiva.repository.RepositoryRegistry;
40 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
41 import org.apache.commons.io.FileUtils;
42 import org.apache.maven.wagon.Wagon;
43 import org.junit.Before;
44 import org.junit.Test;
45 import org.junit.runner.RunWith;
46 import org.springframework.test.context.ContextConfiguration;
47
48 import javax.inject.Inject;
49 import javax.inject.Named;
50 import java.io.IOException;
51 import java.nio.file.Files;
52 import java.nio.file.Path;
53 import java.nio.file.Paths;
54 import java.util.ArrayList;
55 import java.util.Arrays;
56 import java.util.List;
57
58 import static org.mockito.Mockito.mock;
59 import static org.mockito.Mockito.when;
60
61
62 @RunWith ( ArchivaSpringJUnit4ClassRunner.class )
63 @ContextConfiguration ( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
64 public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest
65     extends TestCase
66 {
67     private static final Filter<String> ALL = new AllFilter<String>();
68
69     @Inject
70     @Named ( "repositoryStorage#maven2")
71     private Maven2RepositoryStorage storage;
72
73     private static final String TEST_REPO_ID = "test";
74
75     private static final String TEST_SNAP_REPO_ID = "tests";
76
77     private static final String TEST_REPO_GROUP_ID = "testrg";
78
79     private static final String TEST_REMOTE_REPO_ID = "central";
80
81     private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
82
83     private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
84
85     private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
86
87     private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
88
89     private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
90
91     private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
92
93     private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
94
95     private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
96
97     @Inject
98     @Named ( "archivaConfiguration#default" )
99     private ArchivaConfiguration configuration;
100
101     @Inject
102     RepositoryRegistry repositoryRegistry;
103
104     private WagonFactory wagonFactory;
105
106     ManagedRepositoryConfiguration testRepo;
107
108     ManagedRepositoryConfiguration testRepoS;
109
110     Configuration c;
111
112     @Before
113     @Override
114     public void setUp()
115         throws Exception
116     {
117         super.setUp();
118
119         c = new Configuration();
120
121         testRepo = new ManagedRepositoryConfiguration();
122         testRepo.setId( TEST_REPO_ID );
123         testRepo.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toString() );
124         testRepo.setReleases( true );
125         testRepo.setSnapshots( false );
126         c.addManagedRepository( testRepo );
127
128         testRepoS = new ManagedRepositoryConfiguration();
129         testRepoS.setId( TEST_SNAP_REPO_ID );
130         testRepoS.setLocation( Paths.get( "target/test-repositorys" ).toAbsolutePath().toString() );
131         testRepoS.setReleases( false );
132         testRepoS.setSnapshots( true );
133         c.addManagedRepository( testRepoS );
134
135         RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
136         testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
137         testRemoteRepo.setLayout( "default" );
138         testRemoteRepo.setName( "Central Repository" );
139         testRemoteRepo.setUrl( "http://central.repo.com/maven2" );
140         testRemoteRepo.setTimeout( 10 );
141         c.addRemoteRepository( testRemoteRepo );
142
143         ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
144         proxyConnector.setSourceRepoId( TEST_REPO_ID );
145         proxyConnector.setTargetRepoId( TEST_REMOTE_REPO_ID );
146         proxyConnector.setDisabled( false );
147         c.addProxyConnector( proxyConnector );
148
149         ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
150         proxyConnectors.setSourceRepoId( TEST_SNAP_REPO_ID );
151         proxyConnectors.setTargetRepoId( TEST_REMOTE_REPO_ID );
152         proxyConnectors.setDisabled( false );
153         c.addProxyConnector( proxyConnectors );
154
155         List<String> repos = new ArrayList<>();
156         repos.add( TEST_REPO_ID );
157         repos.add( TEST_SNAP_REPO_ID );
158
159         RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
160         repoGroup.setId( TEST_REPO_GROUP_ID );
161         repoGroup.setRepositories( repos );
162         c.addRepositoryGroup( repoGroup );
163
164         configuration.save( c );
165         repositoryRegistry.reload();
166
167         assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() );
168         assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );
169
170         assertTrue( c.getManagedRepositories().get( 1 ).isSnapshots() );
171         assertFalse( c.getManagedRepositories().get( 1 ).isReleases() );
172
173         wagonFactory = mock( WagonFactory.class );
174
175         storage.setWagonFactory( wagonFactory );
176
177         Wagon wagon = new MockWagon();
178         when( wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#http" ) ) ).thenReturn( wagon );
179     }
180
181     // Tests for MRM-1411 - START
182     @Test
183     public void testGetProjectVersionMetadataWithParentSuccessful()
184         throws Exception
185     {
186         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
187                                     "target/test-repository/com/example/test/test-artifact-module-a" );
188         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-root",
189                 "target/test-repository/com/example/test/test-artifact-root" );
190         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
191                 "target/test-repository/com/example/test/test-artifact-parent" );
192
193         ReadMetadataRequest readMetadataRequest =
194             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
195                 "test-artifact-module-a" ).projectVersion( "1.0" );
196         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
197
198         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
199         assertEquals( "jar", facet.getPackaging() );
200         assertEquals( "http://maven.apache.org", metadata.getUrl() );
201         assertEquals( "com.example.test", facet.getParent().getGroupId() );
202         assertEquals( "test-artifact-root", facet.getParent().getArtifactId() );
203         assertEquals( "1.0", facet.getParent().getVersion() );
204         assertEquals( "test-artifact-module-a", facet.getArtifactId() );
205         assertEquals( "com.example.test", facet.getGroupId() );
206         assertNull( metadata.getCiManagement() );
207         assertNotNull( metadata.getDescription() );
208
209         checkApacheLicense( metadata );
210
211         assertEquals( "1.0", metadata.getId() );
212         assertEquals( "Test Artifact :: Module A", metadata.getName() );
213         String path = "test-artifact/trunk/test-artifact-module-a";
214         assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
215         assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
216         assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
217
218         List<Dependency> dependencies = metadata.getDependencies();
219         assertEquals( 2, dependencies.size() );
220         assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
221         assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
222
223         List<String> paths = new ArrayList<>();
224         paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
225         paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
226         paths.add( "target/test-repository/com/example/test/test-artifact-root" );
227
228         deleteTestArtifactWithParent( paths );
229     }
230
231     @Test
232     public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured()
233         throws Exception
234     {
235         // remove configuration
236         Configuration config = configuration.getConfiguration();
237         RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById( TEST_REMOTE_REPO_ID );
238         config.removeRemoteRepository( remoteRepo );
239
240         configuration.save( config );
241
242         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
243                                     "target/test-repository/com/example/test/test-artifact-module-a" );
244         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-root",
245                 "target/test-repository/com/example/test/test-artifact-root" );
246         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
247                 "target/test-repository/com/example/test/test-artifact-parent" );
248
249         ReadMetadataRequest readMetadataRequest =
250             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
251                 "test-artifact-module-a" ).projectVersion( "1.0" );
252         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
253         assertEquals( "1.0", metadata.getId() );
254
255         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
256         assertNotNull( facet );
257         assertEquals( "com.example.test", facet.getGroupId() );
258         assertEquals( "test-artifact-module-a", facet.getArtifactId() );
259         assertEquals( "jar", facet.getPackaging() );
260
261         List<String> paths = new ArrayList<>();
262         paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
263         paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
264         paths.add( "target/test-repository/com/example/test/test-artifact-root" );
265
266         deleteTestArtifactWithParent( paths );
267     }
268
269     @Test
270     public void testGetProjectVersionMetadataWithParentNotInAnyRemoteRepo()
271         throws Exception
272     {
273         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
274                                     "target/test-repository/com/example/test/test-artifact-module-a" );
275
276         ReadMetadataRequest readMetadataRequest =
277             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
278                 "missing-parent" ).projectVersion( "1.1" );
279
280         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
281
282         assertEquals( "1.1", metadata.getId() );
283
284         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
285         assertNotNull( facet );
286         assertEquals( "com.example.test", facet.getGroupId() );
287         assertEquals( "missing-parent", facet.getArtifactId() );
288         assertEquals( "jar", facet.getPackaging() );
289
290         List<String> paths = new ArrayList<>();
291         paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
292         paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
293         paths.add( "target/test-repository/com/example/test/test-artifact-root" );
294
295         deleteTestArtifactWithParent( paths );
296     }
297
298     @Test
299     public void testGetProjectVersionMetadataWithParentSnapshotVersion()
300         throws Exception
301     {
302         copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
303                                     "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
304         copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-root",
305                                     "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
306         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
307                 "target/test-repositorys/com/example/test/test-artifact-parent" );
308
309         ReadMetadataRequest readMetadataRequest =
310             new ReadMetadataRequest( TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
311                                      "1.1-SNAPSHOT" );
312
313         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
314
315         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
316         assertEquals( "jar", facet.getPackaging() );
317         assertEquals( "com.example.test", facet.getParent().getGroupId() );
318         assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
319         assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
320         assertEquals( "test-snapshot-artifact-module-a", facet.getArtifactId() );
321         assertEquals( "com.example.test", facet.getGroupId() );
322         assertNull( metadata.getCiManagement() );
323         assertNotNull( metadata.getDescription() );
324
325         checkApacheLicense( metadata );
326
327         assertEquals( "1.1-SNAPSHOT", metadata.getId() );
328         assertEquals( "Test Snapshot Artifact :: Module A", metadata.getName() );
329         String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
330         assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
331         assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
332         assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
333
334         List<Dependency> dependencies = metadata.getDependencies();
335         assertEquals( 2, dependencies.size() );
336         assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
337         assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
338
339         List<String> paths = new ArrayList<>();
340         paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
341         paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
342         deleteTestArtifactWithParent( paths );
343     }
344
345     @Test
346     public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed()
347         throws Exception
348     {
349         copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
350                                     "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
351         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
352                 "target/test-repositorys/com/example/test/test-artifact-parent" );
353         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-snapshot-artifact-root",
354                 "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
355
356         ReadMetadataRequest readMetadataRequest =
357             new ReadMetadataRequest().repositoryId( TEST_SNAP_REPO_ID ).namespace( "com.example.test" ).projectId(
358                 "test-snapshot-artifact-module-a" ).projectVersion( "1.1-SNAPSHOT" );
359         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
360
361         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
362         assertEquals( "jar", facet.getPackaging() );
363         assertEquals( "com.example.test", facet.getParent().getGroupId() );
364         assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
365         assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
366         assertEquals( "test-snapshot-artifact-module-a", facet.getArtifactId() );
367         assertEquals( "com.example.test", facet.getGroupId() );
368         assertNull( metadata.getCiManagement() );
369         assertNotNull( metadata.getDescription() );
370
371         checkApacheLicense( metadata );
372
373         assertEquals( "1.1-SNAPSHOT", metadata.getId() );
374         assertEquals( "Test Snapshot Artifact :: Module A", metadata.getName() );
375         String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
376         assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
377         assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
378         assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
379
380         List<Dependency> dependencies = metadata.getDependencies();
381         assertEquals( 2, dependencies.size() );
382         assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
383         assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
384
385         List<String> paths = new ArrayList<>();
386         paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
387         paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
388
389         deleteTestArtifactWithParent( paths );
390     }
391
392     @Test
393     public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed2()
394         throws Exception
395     {
396         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-b",
397                                     "target/test-repository/com/example/test/test-artifact-module-b" );
398         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
399                 "target/test-repository/com/example/test/test-artifact-parent" );
400         copyTestArtifactWithParent( "src/test/resources/com/example/test/test-snapshot-artifact-root",
401                 "target/test-repository/com/example/test/test-snapshot-artifact-root" );
402
403         ReadMetadataRequest readMetadataRequest =
404             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
405                 "test-artifact-module-b" ).projectVersion( "1.0" );
406
407         ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
408
409         MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
410         assertEquals( "jar", facet.getPackaging() );
411         assertEquals( "com.example.test", facet.getParent().getGroupId() );
412         assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
413         assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
414         assertEquals( "test-artifact-module-b", facet.getArtifactId() );
415         assertEquals( "com.example.test", facet.getGroupId() );
416         assertNull( metadata.getCiManagement() );
417         assertNotNull( metadata.getDescription() );
418
419         checkApacheLicense( metadata );
420
421         assertEquals( "1.0", metadata.getId() );
422         assertEquals( "Test Artifact :: Module B", metadata.getName() );
423         String path = "test-snapshot-artifact/trunk/test-artifact-module-b";
424         assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
425         assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
426         assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
427
428         List<Dependency> dependencies = metadata.getDependencies();
429         assertEquals( 2, dependencies.size() );
430         assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
431         assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
432
433         List<String> paths = new ArrayList<>();
434         paths.add( "target/test-repository/com/example/test/test-artifact-module-b" );
435         paths.add( "target/test-repository/com/example/test/test-snapshot-artifact-root" );
436
437         deleteTestArtifactWithParent( paths );
438     }
439     // Tests for MRM-1411 - END
440
441     private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
442     {
443         assertDependency( dependency, groupId, artifactId, version, "compile" );
444     }
445
446     private void assertDependency( Dependency dependency, String groupId, String artifactId, String version,
447                                    String scope )
448     {
449         assertEquals( artifactId, dependency.getArtifactId() );
450         assertEquals( "jar", dependency.getType() );
451         assertEquals( version, dependency.getVersion() );
452         assertEquals( groupId, dependency.getNamespace() );
453         assertEquals( scope, dependency.getScope() );
454         assertNull( dependency.getClassifier() );
455         assertNull( dependency.getSystemPath() );
456     }
457
458     private void assertArtifact( ArtifactMetadata artifact, String id, int size, String sha1, String md5 )
459     {
460         assertEquals( id, artifact.getId() );
461         assertEquals( md5, artifact.getMd5() );
462         assertEquals( sha1, artifact.getSha1() );
463         assertEquals( size, artifact.getSize() );
464         assertEquals( "org.codehaus.plexus", artifact.getNamespace() );
465         assertEquals( "plexus-spring", artifact.getProject() );
466         assertEquals( "1.2", artifact.getVersion() );
467         assertEquals( TEST_REPO_ID, artifact.getRepositoryId() );
468     }
469
470     private void assertMailingList( MailingList mailingList, String name, String archive, String post, String subscribe,
471                                     String unsubscribe, List<String> otherArchives, boolean allowPost )
472     {
473         assertEquals( archive, mailingList.getMainArchiveUrl() );
474         if ( allowPost )
475         {
476             assertEquals( post, mailingList.getPostAddress() );
477         }
478         else
479         {
480             assertNull( mailingList.getPostAddress() );
481         }
482         assertEquals( subscribe, mailingList.getSubscribeAddress() );
483         assertEquals( unsubscribe, mailingList.getUnsubscribeAddress() );
484         assertEquals( name, mailingList.getName() );
485         assertEquals( otherArchives, mailingList.getOtherArchives() );
486     }
487
488     private void assertMailingList( String prefix, MailingList mailingList, String name, boolean allowPost,
489                                     String nabbleUrl )
490     {
491         List<String> otherArchives = new ArrayList<>();
492         otherArchives.add( "http://www.mail-archive.com/" + prefix + "@archiva.apache.org" );
493         if ( nabbleUrl != null )
494         {
495             otherArchives.add( nabbleUrl );
496         }
497         otherArchives.add( "http://markmail.org/list/org.apache.archiva." + prefix );
498         assertMailingList( mailingList, name, "http://mail-archives.apache.org/mod_mbox/archiva-" + prefix + "/",
499                            prefix + "@archiva.apache.org", prefix + "-subscribe@archiva.apache.org",
500                            prefix + "-unsubscribe@archiva.apache.org", otherArchives, allowPost );
501     }
502
503     private void checkApacheLicense( ProjectVersionMetadata metadata )
504     {
505         assertEquals( Arrays.asList( new License( "The Apache Software License, Version 2.0",
506                                                   "http://www.apache.org/licenses/LICENSE-2.0.txt" ) ),
507                       metadata.getLicenses() );
508     }
509
510     private void checkOrganizationApache( ProjectVersionMetadata metadata )
511     {
512         assertEquals( "The Apache Software Foundation", metadata.getOrganization().getName() );
513         assertEquals( "http://www.apache.org/", metadata.getOrganization().getUrl() );
514     }
515
516     private void deleteTestArtifactWithParent( List<String> pathsToBeDeleted )
517         throws IOException
518     {
519         for ( String path : pathsToBeDeleted )
520         {
521             Path dir = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
522             org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir );
523
524             assertFalse( Files.exists(dir) );
525         }
526         Path dest = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
527         Path parentPom = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
528         Path rootPom = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
529
530         org.apache.archiva.common.utils.FileUtils.deleteDirectory( dest );
531         org.apache.archiva.common.utils.FileUtils.deleteDirectory( parentPom );
532         org.apache.archiva.common.utils.FileUtils.deleteDirectory( rootPom );
533
534         assertFalse( Files.exists(dest) );
535         assertFalse( Files.exists(parentPom) );
536         assertFalse( Files.exists(rootPom) );
537     }
538
539     private Path copyTestArtifactWithParent( String srcPath, String destPath )
540         throws IOException
541     {
542         Path src = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), srcPath );
543         Path dest = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), destPath );
544
545         FileUtils.copyDirectory( src.toFile(), dest.toFile() );
546         assertTrue( Files.exists(dest) );
547         return dest;
548     }
549
550 }