1 package org.apache.archiva.repository.metadata;
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
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
22 import org.apache.archiva.common.utils.VersionComparator;
23 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
24 import org.apache.archiva.metadata.repository.storage.maven2.conf.MockConfiguration;
25 import org.apache.archiva.model.ProjectReference;
26 import org.apache.archiva.model.VersionedReference;
27 import org.apache.archiva.policies.CachedFailuresPolicy;
28 import org.apache.archiva.policies.ChecksumPolicy;
29 import org.apache.archiva.policies.ReleasesPolicy;
30 import org.apache.archiva.policies.SnapshotsPolicy;
31 import org.apache.archiva.repository.AbstractRepositoryLayerTestCase;
32 import org.apache.archiva.repository.LayoutException;
33 import org.apache.archiva.repository.ManagedRepositoryContent;
34 import org.apache.archiva.repository.RemoteRepositoryContent;
35 import org.apache.archiva.repository.RepositoryContentProvider;
36 import org.apache.archiva.repository.metadata.base.MetadataTools;
37 import org.apache.archiva.repository.maven2.MavenManagedRepository;
38 import org.apache.commons.io.FileUtils;
39 import org.apache.commons.lang3.StringUtils;
40 import org.custommonkey.xmlunit.DetailedDiff;
41 import org.custommonkey.xmlunit.Diff;
42 import org.junit.Test;
43 import org.springframework.test.context.ContextConfiguration;
44 import org.xml.sax.SAXException;
46 import javax.inject.Inject;
47 import javax.inject.Named;
48 import javax.xml.parsers.ParserConfigurationException;
49 import java.io.IOException;
50 import java.nio.charset.Charset;
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.Collections;
56 import java.util.List;
59 import static org.junit.Assert.*;
64 @SuppressWarnings( "deprecation" )
65 @ContextConfiguration (
66 { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
67 public class MetadataToolsTest
68 extends AbstractRepositoryLayerTestCase
71 @Named ( "metadataTools#test" )
72 private MetadataTools tools;
75 @Named ( "archivaConfiguration#mock" )
76 protected MockConfiguration config;
79 public void testGatherSnapshotVersionsA()
82 removeProxyConnector( "test-repo", "apache-snapshots" );
83 removeProxyConnector( "test-repo", "internal-snapshots" );
84 removeProxyConnector( "test-repo", "snapshots.codehaus.org" );
86 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
87 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
88 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
89 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
90 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070316.175232-11" } );
94 public void testGatherSnapshotVersionsAWithProxies()
97 // These proxied repositories do not need to exist for the purposes of this unit test,
98 // just the repository ids are important.
99 createProxyConnector( "test-repo", "apache-snapshots" );
100 createProxyConnector( "test-repo", "internal-snapshots" );
101 createProxyConnector( "test-repo", "snapshots.codehaus.org" );
103 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
104 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
105 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
106 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
107 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070315.033030-10"
108 /* Arrives in via snapshots.codehaus.org proxy */,
109 "1.0-alpha-11-20070316.175232-11" } );
113 public void testGetRepositorySpecificName()
116 RemoteRepositoryContent repoJavaNet =
117 createRemoteRepositoryContent( "maven2-repository.dev.java.net", "Java.net Repository for Maven 2",
118 "http://download.java.net/maven/2/", "default" );
119 RemoteRepositoryContent repoCentral =
120 createRemoteRepositoryContent( "central", "Central Global Repository", "http://repo1.maven.org/maven2/",
123 String convertedName =
124 tools.getRepositorySpecificName( repoJavaNet, "commons-lang/commons-lang/maven-metadata.xml" );
125 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-maven2-repository.dev.java.net.xml",
128 convertedName = tools.getRepositorySpecificName( repoCentral, "commons-lang/commons-lang/maven-metadata.xml" );
129 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-central.xml", convertedName );
132 // TODO: replace with group tests
133 // public void testUpdateProjectBadArtifact()
138 // assertUpdatedProjectMetadata( "bad_artifact", null );
139 // fail( "Should have thrown an IOException on a bad artifact." );
141 // catch ( IOException e )
148 public void testUpdateProjectNonExistingVersion()
151 ManagedRepositoryContent testRepo = createTestRepoContent();
152 ProjectReference reference = new ProjectReference();
153 reference.setGroupId( "org.apache.archiva.metadata.tests" );
154 reference.setArtifactId( "missing_artifact" );
156 prepTestRepo( testRepo, reference );
158 // check metadata prior to update -- should contain the non-existing artifact version
159 assertProjectMetadata( testRepo, reference, "missing_artifact",
160 new String[]{ "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null );
162 tools.updateMetadata( testRepo, reference );
164 // metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
165 assertProjectMetadata( testRepo, reference, "missing_artifact", new String[]{ "1.0-SNAPSHOT", "1.2-SNAPSHOT" },
166 "1.2-SNAPSHOT", null );
170 public void testUpdateProjectMissingMultipleVersions()
173 assertUpdatedProjectMetadata( "missing_metadata_b",
174 new String[]{ "1.0", "1.0.1", "2.0", "2.0.1", "2.0-20070821-dev" },
175 "2.0-20070821-dev", "2.0-20070821-dev" );
179 public void testUpdateProjectMissingMultipleVersionsWithProxies()
182 // Attach the (bogus) proxies to the managed repo.
183 // These proxied repositories do not need to exist for the purposes of this unit test,
184 // just the repository ids are important.
185 createProxyConnector( "test-repo", "central" );
186 createProxyConnector( "test-repo", "java.net" );
188 assertUpdatedProjectMetadata( "proxied_multi",
189 new String[]{ "1.0-spec" /* in java.net */, "1.0" /* in managed, and central */,
190 "1.0.1" /* in central */, "1.1" /* in managed */, "2.0-proposal-beta"
191 /* in java.net */, "2.0-spec" /* in java.net */, "2.0"
192 /* in central, and java.net */, "2.0.1" /* in java.net */, "2.1"
193 /* in managed */, "3.0" /* in central */, "3.1" /* in central */ }, "3.1",
198 public void testUpdateProjectSimpleYetIncomplete()
201 assertUpdatedProjectMetadata( "incomplete_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
205 public void testUpdateProjectSimpleYetMissing()
208 assertUpdatedProjectMetadata( "missing_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
212 public void testUpdateVersionSimple10()
215 assertUpdatedReleaseVersionMetadata( "missing_metadata_a", "1.0" );
219 public void testUpdateVersionSimple20()
222 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0" );
226 public void testUpdateVersionSimple20NotSnapshot()
229 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0-20070821-dev" );
233 public void testUpdateVersionSnapshotA()
236 assertUpdatedSnapshotVersionMetadata( "snap_shots_a", "1.0-alpha-11-SNAPSHOT", "20070316", "175232", "11" );
240 public void testToPathFromVersionReference()
242 VersionedReference reference = new VersionedReference();
243 reference.setGroupId( "com.foo" );
244 reference.setArtifactId( "foo-tool" );
245 reference.setVersion( "1.0" );
247 assertEquals( "com/foo/foo-tool/1.0/maven-metadata.xml", tools.toPath( reference ) );
251 public void testToPathFromProjectReference()
253 ProjectReference reference = new ProjectReference();
254 reference.setGroupId( "com.foo" );
255 reference.setArtifactId( "foo-tool" );
257 assertEquals( "com/foo/foo-tool/maven-metadata.xml", tools.toPath( reference ) );
261 public void testToProjectReferenceFooTools()
262 throws RepositoryMetadataException
264 assertProjectReference( "com.foo", "foo-tools", "com/foo/foo-tools/maven-metadata.xml" );
268 public void testToProjectReferenceAReallyLongPath()
269 throws RepositoryMetadataException
271 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
272 String artifactId = "a";
273 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/maven-metadata.xml";
275 assertProjectReference( groupId, artifactId, path );
279 public void testToProjectReferenceCommonsLang()
280 throws RepositoryMetadataException
282 String groupId = "commons-lang";
283 String artifactId = "commons-lang";
284 String path = "commons-lang/commons-lang/maven-metadata.xml";
286 assertProjectReference( groupId, artifactId, path );
289 private void assertProjectReference( String groupId, String artifactId, String path )
290 throws RepositoryMetadataException
292 ProjectReference reference = tools.toProjectReference( path );
294 assertNotNull( "Reference should not be null.", reference );
295 assertEquals( "ProjectReference.groupId", groupId, reference.getGroupId() );
296 assertEquals( "ProjectReference.artifactId", artifactId, reference.getArtifactId() );
300 public void testToVersionedReferenceFooTool()
301 throws RepositoryMetadataException
303 String groupId = "com.foo";
304 String artifactId = "foo-tool";
305 String version = "1.0";
306 String path = "com/foo/foo-tool/1.0/maven-metadata.xml";
308 assertVersionedReference( groupId, artifactId, version, path );
312 public void testToVersionedReferenceAReallyLongPath()
313 throws RepositoryMetadataException
315 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
316 String artifactId = "a";
317 String version = "1.1-alpha-1";
318 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/1.1-alpha-1/maven-metadata.xml";
320 assertVersionedReference( groupId, artifactId, version, path );
324 public void testToVersionedReferenceCommonsLang()
325 throws RepositoryMetadataException
327 String groupId = "commons-lang";
328 String artifactId = "commons-lang";
329 String version = "2.1";
330 String path = "commons-lang/commons-lang/2.1/maven-metadata.xml";
332 assertVersionedReference( groupId, artifactId, version, path );
336 public void testToVersionedReferenceSnapshot()
337 throws RepositoryMetadataException
339 String groupId = "com.foo";
340 String artifactId = "foo-connector";
341 String version = "2.1-SNAPSHOT";
342 String path = "com/foo/foo-connector/2.1-SNAPSHOT/maven-metadata.xml";
344 assertVersionedReference( groupId, artifactId, version, path );
347 private void assertVersionedReference( String groupId, String artifactId, String version, String path )
348 throws RepositoryMetadataException
350 VersionedReference reference = tools.toVersionedReference( path );
351 assertNotNull( "Reference should not be null.", reference );
353 assertEquals( "VersionedReference.groupId", groupId, reference.getGroupId() );
354 assertEquals( "VersionedReference.artifactId", artifactId, reference.getArtifactId() );
355 assertEquals( "VersionedReference.version", version, reference.getVersion() );
358 private void assertSnapshotVersions( String artifactId, String version, String[] expectedVersions )
361 Path repoRootDir = Paths.get( "src/test/repositories/metadata-repository" );
363 VersionedReference reference = new VersionedReference();
364 reference.setGroupId( "org.apache.archiva.metadata.tests" );
365 reference.setArtifactId( artifactId );
366 reference.setVersion( version );
368 MavenManagedRepository repo =
369 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
371 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
373 ManagedRepositoryContent repoContent =
374 provider.createManagedContent( repo );
376 Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );
378 // Sort the list (for asserts)
379 List<String> testedVersions = new ArrayList<>();
380 testedVersions.addAll( testedVersionSet );
381 Collections.sort( testedVersions, new VersionComparator() );
383 // Test the expected array of versions, to the actual tested versions
384 assertEquals( "Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size() );
386 for ( int i = 0; i < expectedVersions.length; i++ )
388 String actualVersion = testedVersions.get( i );
389 assertEquals( "Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion );
393 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
394 ProjectReference reference )
395 throws LayoutException, IOException, SAXException, ParserConfigurationException
397 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
398 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
400 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
401 if ( !detailedDiff.similar() )
403 // If it isn't similar, dump the difference.
404 assertEquals( expectedMetadata, actualMetadata );
408 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
409 VersionedReference reference )
410 throws LayoutException, IOException, SAXException, ParserConfigurationException
412 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
413 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
415 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
416 if ( !detailedDiff.similar() )
418 // If it isn't similar, dump the difference.
419 assertEquals( expectedMetadata, actualMetadata );
423 private void assertMetadataPath( String expected, String actual )
425 assertEquals( "Repository Specific Metadata Path", expected, actual );
428 private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
429 String releaseVersion )
432 ManagedRepositoryContent testRepo = createTestRepoContent();
433 ProjectReference reference = new ProjectReference();
434 reference.setGroupId( "org.apache.archiva.metadata.tests" );
435 reference.setArtifactId( artifactId );
437 prepTestRepo( testRepo, reference );
439 tools.updateMetadata( testRepo, reference );
441 StringBuilder buf = new StringBuilder();
442 buf.append( "<metadata>\n" );
443 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
444 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
445 // buf.append( " <version>1.0</version>\n" );
447 if ( expectedVersions != null )
449 buf.append( " <versioning>\n" );
450 if ( latestVersion != null )
452 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
454 if ( releaseVersion != null )
456 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
459 buf.append( " <versions>\n" );
460 for ( int i = 0; i < expectedVersions.length; i++ )
462 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
464 buf.append( " </versions>\n" );
465 buf.append( " </versioning>\n" );
467 buf.append( "</metadata>" );
469 assertMetadata( buf.toString(), testRepo, reference );
472 private void assertProjectMetadata( ManagedRepositoryContent testRepo, ProjectReference reference,
473 String artifactId, String[] expectedVersions, String latestVersion,
474 String releaseVersion )
477 StringBuilder buf = new StringBuilder();
478 buf.append( "<metadata>\n" );
479 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
480 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
482 if ( expectedVersions != null )
484 buf.append( " <versioning>\n" );
485 if ( latestVersion != null )
487 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
489 if ( releaseVersion != null )
491 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
494 buf.append( " <versions>\n" );
495 for ( int i = 0; i < expectedVersions.length; i++ )
497 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
499 buf.append( " </versions>\n" );
500 buf.append( " </versioning>\n" );
502 buf.append( "</metadata>" );
504 assertMetadata( buf.toString(), testRepo, reference );
507 private void assertUpdatedReleaseVersionMetadata( String artifactId, String version )
510 ManagedRepositoryContent testRepo = createTestRepoContent();
511 VersionedReference reference = new VersionedReference();
512 reference.setGroupId( "org.apache.archiva.metadata.tests" );
513 reference.setArtifactId( artifactId );
514 reference.setVersion( version );
516 prepTestRepo( testRepo, reference );
518 tools.updateMetadata( testRepo, reference );
520 StringBuilder buf = new StringBuilder();
521 buf.append( "<metadata>\n" );
522 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
523 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
524 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
525 buf.append( "</metadata>" );
527 assertMetadata( buf.toString(), testRepo, reference );
530 private void assertUpdatedSnapshotVersionMetadata( String artifactId, String version, String expectedDate,
531 String expectedTime, String expectedBuildNumber )
534 ManagedRepositoryContent testRepo = createTestRepoContent();
535 VersionedReference reference = new VersionedReference();
536 reference.setGroupId( "org.apache.archiva.metadata.tests" );
537 reference.setArtifactId( artifactId );
538 reference.setVersion( version );
540 prepTestRepo( testRepo, reference );
542 tools.updateMetadata( testRepo, reference );
544 StringBuilder buf = new StringBuilder();
545 buf.append( "<metadata>\n" );
546 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
547 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
548 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
549 buf.append( " <versioning>\n" );
550 buf.append( " <snapshot>\n" );
551 buf.append( " <buildNumber>" ).append( expectedBuildNumber ).append( "</buildNumber>\n" );
552 buf.append( " <timestamp>" );
553 buf.append( expectedDate ).append( "." ).append( expectedTime );
554 buf.append( "</timestamp>\n" );
555 buf.append( " </snapshot>\n" );
556 buf.append( " <lastUpdated>" ).append( expectedDate ).append( expectedTime ).append( "</lastUpdated>\n" );
557 buf.append( " </versioning>\n" );
558 buf.append( "</metadata>" );
560 assertMetadata( buf.toString(), testRepo, reference );
563 private void removeProxyConnector( String sourceRepoId, String targetRepoId )
565 ProxyConnectorConfiguration toRemove = null;
566 for ( ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors() )
568 if ( pcc.getTargetRepoId().equals( targetRepoId ) && pcc.getSourceRepoId().equals( sourceRepoId ) )
573 if ( toRemove != null )
575 config.getConfiguration().removeProxyConnector( toRemove );
576 String prefix = "proxyConnectors.proxyConnector(" + "1" + ")"; // XXX
577 config.triggerChange( prefix + ".sourceRepoId", toRemove.getSourceRepoId() );
578 config.triggerChange( prefix + ".targetRepoId", toRemove.getTargetRepoId() );
579 config.triggerChange( prefix + ".proxyId", toRemove.getProxyId() );
580 config.triggerChange( prefix + ".policies.releases", toRemove.getPolicy( "releases", "" ) );
581 config.triggerChange( prefix + ".policies.checksum", toRemove.getPolicy( "checksum", "" ) );
582 config.triggerChange( prefix + ".policies.snapshots", toRemove.getPolicy( "snapshots", "" ) );
583 config.triggerChange( prefix + ".policies.cache-failures", toRemove.getPolicy( "cache-failures", "" ) );
587 private void createProxyConnector( String sourceRepoId, String targetRepoId )
589 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
590 connectorConfig.setSourceRepoId( sourceRepoId );
591 connectorConfig.setTargetRepoId( targetRepoId );
592 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE.getId() );
593 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() );
594 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS.getId() );
595 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO.getId() );
597 int count = config.getConfiguration().getProxyConnectors().size();
598 config.getConfiguration().addProxyConnector( connectorConfig );
600 // Proper Triggering ...
601 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
602 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
603 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
604 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
605 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
606 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
607 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
608 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
611 private ManagedRepositoryContent createTestRepoContent()
614 Path repoRoot = Paths.get( "target/metadata-tests/" + name.getMethodName() );
615 if ( Files.exists(repoRoot) )
617 org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRoot );
620 Files.createDirectories(repoRoot);
622 MavenManagedRepository repoConfig =
623 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
625 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
627 ManagedRepositoryContent repoContent =
628 provider.createManagedContent( repoConfig );
632 private void prepTestRepo( ManagedRepositoryContent repo, ProjectReference reference )
635 String groupDir = StringUtils.replaceChars( reference.getGroupId(), '.', '/' );
636 String path = groupDir + "/" + reference.getArtifactId();
638 Path srcRepoDir = Paths.get( "src/test/repositories/metadata-repository" );
639 Path srcDir = srcRepoDir.resolve( path );
640 Path destDir = Paths.get( repo.getRepoRoot(), path );
642 assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
643 Files.createDirectories(destDir);
645 FileUtils.copyDirectory( srcDir.toFile(), destDir.toFile() );
648 private void prepTestRepo( ManagedRepositoryContent repo, VersionedReference reference )
651 ProjectReference projectRef = new ProjectReference();
652 projectRef.setGroupId( reference.getGroupId() );
653 projectRef.setArtifactId( reference.getArtifactId() );
655 prepTestRepo( repo, projectRef );