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