1 package org.apache.archiva.repository.maven.metadata.storage;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import junit.framework.TestCase;
22 import org.apache.archiva.configuration.ArchivaConfiguration;
23 import org.apache.archiva.configuration.Configuration;
24 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
25 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
26 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
27 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
28 import org.apache.archiva.filter.AllFilter;
29 import org.apache.archiva.filter.Filter;
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.storage.ReadMetadataRequest;
36 import org.apache.archiva.proxy.maven.WagonFactory;
37 import org.apache.archiva.proxy.maven.WagonFactoryRequest;
38 import org.apache.archiva.repository.RepositoryRegistry;
39 import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler;
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;
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;
58 import static org.mockito.Mockito.mock;
59 import static org.mockito.Mockito.when;
62 @RunWith ( ArchivaSpringJUnit4ClassRunner.class )
63 @ContextConfiguration ( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
64 public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest
67 private static final Filter<String> ALL = new AllFilter<String>();
70 @Named ( "repositoryStorage#maven2")
71 private Maven2RepositoryStorage storage;
73 private static final String TEST_REPO_ID = "test";
75 private static final String TEST_SNAP_REPO_ID = "tests";
77 private static final String TEST_REPO_GROUP_ID = "testrg";
79 private static final String TEST_REMOTE_REPO_ID = "central";
81 private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
83 private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
85 private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
87 private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
89 private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
91 private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
93 private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
95 private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
98 @Named ( "archivaConfiguration#default" )
99 private ArchivaConfiguration configuration;
102 RepositoryRegistry repositoryRegistry;
104 @SuppressWarnings( "unused" )
106 ManagedRepositoryHandler managedRepositoryHandler;
109 private WagonFactory wagonFactory;
111 ManagedRepositoryConfiguration testRepo;
113 ManagedRepositoryConfiguration testRepoS;
124 c = new Configuration();
126 testRepo = new ManagedRepositoryConfiguration();
127 testRepo.setId( TEST_REPO_ID );
128 testRepo.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toString() );
129 testRepo.setReleases( true );
130 testRepo.setSnapshots( false );
131 c.addManagedRepository( testRepo );
133 testRepoS = new ManagedRepositoryConfiguration();
134 testRepoS.setId( TEST_SNAP_REPO_ID );
135 testRepoS.setLocation( Paths.get( "target/test-repositorys" ).toAbsolutePath().toString() );
136 testRepoS.setReleases( false );
137 testRepoS.setSnapshots( true );
138 c.addManagedRepository( testRepoS );
140 RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
141 testRemoteRepo.setId( TEST_REMOTE_REPO_ID );
142 testRemoteRepo.setLayout( "default" );
143 testRemoteRepo.setName( "Central Repository" );
144 testRemoteRepo.setUrl( "http://central.repo.com/maven2" );
145 testRemoteRepo.setTimeout( 10 );
146 c.addRemoteRepository( testRemoteRepo );
148 ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
149 proxyConnector.setSourceRepoId( TEST_REPO_ID );
150 proxyConnector.setTargetRepoId( TEST_REMOTE_REPO_ID );
151 proxyConnector.setDisabled( false );
152 c.addProxyConnector( proxyConnector );
154 ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
155 proxyConnectors.setSourceRepoId( TEST_SNAP_REPO_ID );
156 proxyConnectors.setTargetRepoId( TEST_REMOTE_REPO_ID );
157 proxyConnectors.setDisabled( false );
158 c.addProxyConnector( proxyConnectors );
160 List<String> repos = new ArrayList<>();
161 repos.add( TEST_REPO_ID );
162 repos.add( TEST_SNAP_REPO_ID );
164 RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
165 repoGroup.setId( TEST_REPO_GROUP_ID );
166 repoGroup.setRepositories( repos );
167 c.addRepositoryGroup( repoGroup );
169 configuration.save( c );
170 repositoryRegistry.reload();
172 assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() );
173 assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );
175 assertTrue( c.getManagedRepositories().get( 1 ).isSnapshots() );
176 assertFalse( c.getManagedRepositories().get( 1 ).isReleases() );
178 wagonFactory = mock( WagonFactory.class );
180 storage.setWagonFactory( wagonFactory );
182 Wagon wagon = new MockWagon();
183 when( wagonFactory.getWagon( new WagonFactoryRequest().protocol( "wagon#http" ) ) ).thenReturn( wagon );
186 // Tests for MRM-1411 - START
188 public void testGetProjectVersionMetadataWithParentSuccessful()
191 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
192 "target/test-repository/com/example/test/test-artifact-module-a" );
193 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-root",
194 "target/test-repository/com/example/test/test-artifact-root" );
195 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
196 "target/test-repository/com/example/test/test-artifact-parent" );
198 ReadMetadataRequest readMetadataRequest =
199 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
200 "test-artifact-module-a" ).projectVersion( "1.0" );
201 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
203 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
204 assertEquals( "jar", facet.getPackaging() );
205 assertEquals( "http://maven.apache.org", metadata.getUrl() );
206 assertEquals( "com.example.test", facet.getParent().getGroupId() );
207 assertEquals( "test-artifact-root", facet.getParent().getArtifactId() );
208 assertEquals( "1.0", facet.getParent().getVersion() );
209 assertEquals( "test-artifact-module-a", facet.getArtifactId() );
210 assertEquals( "com.example.test", facet.getGroupId() );
211 assertNull( metadata.getCiManagement() );
212 assertNotNull( metadata.getDescription() );
214 checkApacheLicense( metadata );
216 assertEquals( "1.0", metadata.getId() );
217 assertEquals( "Test Artifact :: Module A", metadata.getName() );
218 String path = "test-artifact/trunk/test-artifact-module-a";
219 assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
220 assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
221 assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
223 List<Dependency> dependencies = metadata.getDependencies();
224 assertEquals( 2, dependencies.size() );
225 assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
226 assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
228 List<String> paths = new ArrayList<>();
229 paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
230 paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
231 paths.add( "target/test-repository/com/example/test/test-artifact-root" );
233 deleteTestArtifactWithParent( paths );
237 public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured()
240 // remove configuration
241 Configuration config = configuration.getConfiguration();
242 RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById( TEST_REMOTE_REPO_ID );
243 config.removeRemoteRepository( remoteRepo );
245 configuration.save( config );
247 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
248 "target/test-repository/com/example/test/test-artifact-module-a" );
249 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-root",
250 "target/test-repository/com/example/test/test-artifact-root" );
251 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
252 "target/test-repository/com/example/test/test-artifact-parent" );
254 ReadMetadataRequest readMetadataRequest =
255 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
256 "test-artifact-module-a" ).projectVersion( "1.0" );
257 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
258 assertEquals( "1.0", metadata.getId() );
260 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
261 assertNotNull( facet );
262 assertEquals( "com.example.test", facet.getGroupId() );
263 assertEquals( "test-artifact-module-a", facet.getArtifactId() );
264 assertEquals( "jar", facet.getPackaging() );
266 List<String> paths = new ArrayList<>();
267 paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
268 paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
269 paths.add( "target/test-repository/com/example/test/test-artifact-root" );
271 deleteTestArtifactWithParent( paths );
275 public void testGetProjectVersionMetadataWithParentNotInAnyRemoteRepo()
278 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-a",
279 "target/test-repository/com/example/test/test-artifact-module-a" );
281 ReadMetadataRequest readMetadataRequest =
282 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
283 "missing-parent" ).projectVersion( "1.1" );
285 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
287 assertEquals( "1.1", metadata.getId() );
289 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
290 assertNotNull( facet );
291 assertEquals( "com.example.test", facet.getGroupId() );
292 assertEquals( "missing-parent", facet.getArtifactId() );
293 assertEquals( "jar", facet.getPackaging() );
295 List<String> paths = new ArrayList<>();
296 paths.add( "target/test-repository/com/example/test/test-artifact-module-a" );
297 paths.add( "target/test-repository/com/example/test/test-artifact-parent" );
298 paths.add( "target/test-repository/com/example/test/test-artifact-root" );
300 deleteTestArtifactWithParent( paths );
304 public void testGetProjectVersionMetadataWithParentSnapshotVersion()
307 copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
308 "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
309 copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-root",
310 "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
311 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
312 "target/test-repositorys/com/example/test/test-artifact-parent" );
314 ReadMetadataRequest readMetadataRequest =
315 new ReadMetadataRequest( TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a",
318 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
320 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
321 assertEquals( "jar", facet.getPackaging() );
322 assertEquals( "com.example.test", facet.getParent().getGroupId() );
323 assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
324 assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
325 assertEquals( "test-snapshot-artifact-module-a", facet.getArtifactId() );
326 assertEquals( "com.example.test", facet.getGroupId() );
327 assertNull( metadata.getCiManagement() );
328 assertNotNull( metadata.getDescription() );
330 checkApacheLicense( metadata );
332 assertEquals( "1.1-SNAPSHOT", metadata.getId() );
333 assertEquals( "Test Snapshot Artifact :: Module A", metadata.getName() );
334 String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
335 assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
336 assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
337 assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
339 List<Dependency> dependencies = metadata.getDependencies();
340 assertEquals( 2, dependencies.size() );
341 assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
342 assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
344 List<String> paths = new ArrayList<>();
345 paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
346 paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
347 deleteTestArtifactWithParent( paths );
351 public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed()
354 copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a",
355 "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
356 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
357 "target/test-repositorys/com/example/test/test-artifact-parent" );
358 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-snapshot-artifact-root",
359 "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
361 ReadMetadataRequest readMetadataRequest =
362 new ReadMetadataRequest().repositoryId( TEST_SNAP_REPO_ID ).namespace( "com.example.test" ).projectId(
363 "test-snapshot-artifact-module-a" ).projectVersion( "1.1-SNAPSHOT" );
364 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
366 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
367 assertEquals( "jar", facet.getPackaging() );
368 assertEquals( "com.example.test", facet.getParent().getGroupId() );
369 assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
370 assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
371 assertEquals( "test-snapshot-artifact-module-a", facet.getArtifactId() );
372 assertEquals( "com.example.test", facet.getGroupId() );
373 assertNull( metadata.getCiManagement() );
374 assertNotNull( metadata.getDescription() );
376 checkApacheLicense( metadata );
378 assertEquals( "1.1-SNAPSHOT", metadata.getId() );
379 assertEquals( "Test Snapshot Artifact :: Module A", metadata.getName() );
380 String path = "test-snapshot-artifact/trunk/test-snapshot-artifact-module-a";
381 assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
382 assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
383 assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
385 List<Dependency> dependencies = metadata.getDependencies();
386 assertEquals( 2, dependencies.size() );
387 assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
388 assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
390 List<String> paths = new ArrayList<>();
391 paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" );
392 paths.add( "target/test-repositorys/com/example/test/test-snapshot-artifact-root" );
394 deleteTestArtifactWithParent( paths );
398 public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed2()
401 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-module-b",
402 "target/test-repository/com/example/test/test-artifact-module-b" );
403 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-artifact-parent",
404 "target/test-repository/com/example/test/test-artifact-parent" );
405 copyTestArtifactWithParent( "src/test/resources/com/example/test/test-snapshot-artifact-root",
406 "target/test-repository/com/example/test/test-snapshot-artifact-root" );
408 ReadMetadataRequest readMetadataRequest =
409 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
410 "test-artifact-module-b" ).projectVersion( "1.0" );
412 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
414 MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
415 assertEquals( "jar", facet.getPackaging() );
416 assertEquals( "com.example.test", facet.getParent().getGroupId() );
417 assertEquals( "test-snapshot-artifact-root", facet.getParent().getArtifactId() );
418 assertEquals( "1.1-SNAPSHOT", facet.getParent().getVersion() );
419 assertEquals( "test-artifact-module-b", facet.getArtifactId() );
420 assertEquals( "com.example.test", facet.getGroupId() );
421 assertNull( metadata.getCiManagement() );
422 assertNotNull( metadata.getDescription() );
424 checkApacheLicense( metadata );
426 assertEquals( "1.0", metadata.getId() );
427 assertEquals( "Test Artifact :: Module B", metadata.getName() );
428 String path = "test-snapshot-artifact/trunk/test-artifact-module-b";
429 assertEquals( TEST_SCM_CONN_BASE + path, metadata.getScm().getConnection() );
430 assertEquals( TEST_SCM_DEV_CONN_BASE + path, metadata.getScm().getDeveloperConnection() );
431 assertEquals( TEST_SCM_URL_BASE + path, metadata.getScm().getUrl() );
433 List<Dependency> dependencies = metadata.getDependencies();
434 assertEquals( 2, dependencies.size() );
435 assertDependency( dependencies.get( 0 ), "commons-io", "commons-io", "1.4" );
436 assertDependency( dependencies.get( 1 ), "junit", "junit", "3.8.1", "test" );
438 List<String> paths = new ArrayList<>();
439 paths.add( "target/test-repository/com/example/test/test-artifact-module-b" );
440 paths.add( "target/test-repository/com/example/test/test-snapshot-artifact-root" );
442 deleteTestArtifactWithParent( paths );
444 // Tests for MRM-1411 - END
446 private void assertDependency( Dependency dependency, String groupId, String artifactId, String version )
448 assertDependency( dependency, groupId, artifactId, version, "compile" );
451 private void assertDependency( Dependency dependency, String groupId, String artifactId, String version,
454 assertEquals( artifactId, dependency.getArtifactId() );
455 assertEquals( "jar", dependency.getType() );
456 assertEquals( version, dependency.getVersion() );
457 assertEquals( groupId, dependency.getNamespace() );
458 assertEquals( scope, dependency.getScope() );
459 assertNull( dependency.getClassifier() );
460 assertNull( dependency.getSystemPath() );
463 private void assertArtifact( ArtifactMetadata artifact, String id, int size, String sha1, String md5 )
465 assertEquals( id, artifact.getId() );
466 assertEquals( md5, artifact.getMd5() );
467 assertEquals( sha1, artifact.getSha1() );
468 assertEquals( size, artifact.getSize() );
469 assertEquals( "org.codehaus.plexus", artifact.getNamespace() );
470 assertEquals( "plexus-spring", artifact.getProject() );
471 assertEquals( "1.2", artifact.getVersion() );
472 assertEquals( TEST_REPO_ID, artifact.getRepositoryId() );
475 private void assertMailingList( MailingList mailingList, String name, String archive, String post, String subscribe,
476 String unsubscribe, List<String> otherArchives, boolean allowPost )
478 assertEquals( archive, mailingList.getMainArchiveUrl() );
481 assertEquals( post, mailingList.getPostAddress() );
485 assertNull( mailingList.getPostAddress() );
487 assertEquals( subscribe, mailingList.getSubscribeAddress() );
488 assertEquals( unsubscribe, mailingList.getUnsubscribeAddress() );
489 assertEquals( name, mailingList.getName() );
490 assertEquals( otherArchives, mailingList.getOtherArchives() );
493 private void assertMailingList( String prefix, MailingList mailingList, String name, boolean allowPost,
496 List<String> otherArchives = new ArrayList<>();
497 otherArchives.add( "http://www.mail-archive.com/" + prefix + "@archiva.apache.org" );
498 if ( nabbleUrl != null )
500 otherArchives.add( nabbleUrl );
502 otherArchives.add( "http://markmail.org/list/org.apache.archiva." + prefix );
503 assertMailingList( mailingList, name, "http://mail-archives.apache.org/mod_mbox/archiva-" + prefix + "/",
504 prefix + "@archiva.apache.org", prefix + "-subscribe@archiva.apache.org",
505 prefix + "-unsubscribe@archiva.apache.org", otherArchives, allowPost );
508 private void checkApacheLicense( ProjectVersionMetadata metadata )
510 assertEquals( Arrays.asList( new License( "The Apache Software License, Version 2.0",
511 "http://www.apache.org/licenses/LICENSE-2.0.txt" ) ),
512 metadata.getLicenses() );
515 private void checkOrganizationApache( ProjectVersionMetadata metadata )
517 assertEquals( "The Apache Software Foundation", metadata.getOrganization().getName() );
518 assertEquals( "http://www.apache.org/", metadata.getOrganization().getUrl() );
521 private void deleteTestArtifactWithParent( List<String> pathsToBeDeleted )
524 for ( String path : pathsToBeDeleted )
526 Path dir = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
527 org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir );
529 assertFalse( Files.exists(dir) );
531 Path dest = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-module-a" );
532 Path parentPom = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-parent" );
533 Path rootPom = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), "target/test-repository/com/example/test/test-artifact-root" );
535 org.apache.archiva.common.utils.FileUtils.deleteDirectory( dest );
536 org.apache.archiva.common.utils.FileUtils.deleteDirectory( parentPom );
537 org.apache.archiva.common.utils.FileUtils.deleteDirectory( rootPom );
539 assertFalse( Files.exists(dest) );
540 assertFalse( Files.exists(parentPom) );
541 assertFalse( Files.exists(rootPom) );
544 private Path copyTestArtifactWithParent( String srcPath, String destPath )
547 Path src = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), srcPath );
548 Path dest = Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), destPath );
550 FileUtils.copyDirectory( src.toFile(), dest.toFile() );
551 assertTrue( Files.exists(dest) );