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.admin.model.beans.ManagedRepository;
23 import org.apache.archiva.common.utils.VersionComparator;
24 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
25 import org.apache.archiva.metadata.repository.storage.maven2.conf.MockConfiguration;
26 import org.apache.archiva.model.ProjectReference;
27 import org.apache.archiva.model.VersionedReference;
28 import org.apache.archiva.policies.CachedFailuresPolicy;
29 import org.apache.archiva.policies.ChecksumPolicy;
30 import org.apache.archiva.policies.ReleasesPolicy;
31 import org.apache.archiva.policies.SnapshotsPolicy;
32 import org.apache.archiva.repository.AbstractRepositoryLayerTestCase;
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.layout.LayoutException;
37 import org.apache.archiva.repository.maven2.MavenManagedRepository;
38 import org.apache.commons.io.FileUtils;
39 import org.apache.commons.lang.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 @ContextConfiguration (
65 { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
66 public class MetadataToolsTest
67 extends AbstractRepositoryLayerTestCase
70 @Named ( "metadataTools#test" )
71 private MetadataTools tools;
74 @Named ( "archivaConfiguration#mock" )
75 protected MockConfiguration config;
78 public void testGatherSnapshotVersionsA()
81 removeProxyConnector( "test-repo", "apache-snapshots" );
82 removeProxyConnector( "test-repo", "internal-snapshots" );
83 removeProxyConnector( "test-repo", "snapshots.codehaus.org" );
85 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
86 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
87 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
88 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
89 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070316.175232-11" } );
93 public void testGatherSnapshotVersionsAWithProxies()
96 // These proxied repositories do not need to exist for the purposes of this unit test,
97 // just the repository ids are important.
98 createProxyConnector( "test-repo", "apache-snapshots" );
99 createProxyConnector( "test-repo", "internal-snapshots" );
100 createProxyConnector( "test-repo", "snapshots.codehaus.org" );
102 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
103 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
104 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
105 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
106 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070315.033030-10"
107 /* Arrives in via snapshots.codehaus.org proxy */,
108 "1.0-alpha-11-20070316.175232-11" } );
112 public void testGetRepositorySpecificName()
115 RemoteRepositoryContent repoJavaNet =
116 createRemoteRepositoryContent( "maven2-repository.dev.java.net", "Java.net Repository for Maven 2",
117 "http://download.java.net/maven/2/", "default" );
118 RemoteRepositoryContent repoCentral =
119 createRemoteRepositoryContent( "central", "Central Global Repository", "http://repo1.maven.org/maven2/",
122 String convertedName =
123 tools.getRepositorySpecificName( repoJavaNet, "commons-lang/commons-lang/maven-metadata.xml" );
124 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-maven2-repository.dev.java.net.xml",
127 convertedName = tools.getRepositorySpecificName( repoCentral, "commons-lang/commons-lang/maven-metadata.xml" );
128 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-central.xml", convertedName );
131 // TODO: replace with group tests
132 // public void testUpdateProjectBadArtifact()
137 // assertUpdatedProjectMetadata( "bad_artifact", null );
138 // fail( "Should have thrown an IOException on a bad artifact." );
140 // catch ( IOException e )
147 public void testUpdateProjectNonExistingVersion()
150 ManagedRepositoryContent testRepo = createTestRepoContent();
151 ProjectReference reference = new ProjectReference();
152 reference.setGroupId( "org.apache.archiva.metadata.tests" );
153 reference.setArtifactId( "missing_artifact" );
155 prepTestRepo( testRepo, reference );
157 // check metadata prior to update -- should contain the non-existing artifact version
158 assertProjectMetadata( testRepo, reference, "missing_artifact",
159 new String[]{ "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null );
161 tools.updateMetadata( testRepo, reference );
163 // metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
164 assertProjectMetadata( testRepo, reference, "missing_artifact", new String[]{ "1.0-SNAPSHOT", "1.2-SNAPSHOT" },
165 "1.2-SNAPSHOT", null );
169 public void testUpdateProjectMissingMultipleVersions()
172 assertUpdatedProjectMetadata( "missing_metadata_b",
173 new String[]{ "1.0", "1.0.1", "2.0", "2.0.1", "2.0-20070821-dev" },
174 "2.0-20070821-dev", "2.0-20070821-dev" );
178 public void testUpdateProjectMissingMultipleVersionsWithProxies()
181 // Attach the (bogus) proxies to the managed repo.
182 // These proxied repositories do not need to exist for the purposes of this unit test,
183 // just the repository ids are important.
184 createProxyConnector( "test-repo", "central" );
185 createProxyConnector( "test-repo", "java.net" );
187 assertUpdatedProjectMetadata( "proxied_multi",
188 new String[]{ "1.0-spec" /* in java.net */, "1.0" /* in managed, and central */,
189 "1.0.1" /* in central */, "1.1" /* in managed */, "2.0-proposal-beta"
190 /* in java.net */, "2.0-spec" /* in java.net */, "2.0"
191 /* in central, and java.net */, "2.0.1" /* in java.net */, "2.1"
192 /* in managed */, "3.0" /* in central */, "3.1" /* in central */ }, "3.1",
197 public void testUpdateProjectSimpleYetIncomplete()
200 assertUpdatedProjectMetadata( "incomplete_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
204 public void testUpdateProjectSimpleYetMissing()
207 assertUpdatedProjectMetadata( "missing_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
211 public void testUpdateVersionSimple10()
214 assertUpdatedReleaseVersionMetadata( "missing_metadata_a", "1.0" );
218 public void testUpdateVersionSimple20()
221 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0" );
225 public void testUpdateVersionSimple20NotSnapshot()
228 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0-20070821-dev" );
232 public void testUpdateVersionSnapshotA()
235 assertUpdatedSnapshotVersionMetadata( "snap_shots_a", "1.0-alpha-11-SNAPSHOT", "20070316", "175232", "11" );
239 public void testToPathFromVersionReference()
241 VersionedReference reference = new VersionedReference();
242 reference.setGroupId( "com.foo" );
243 reference.setArtifactId( "foo-tool" );
244 reference.setVersion( "1.0" );
246 assertEquals( "com/foo/foo-tool/1.0/maven-metadata.xml", tools.toPath( reference ) );
250 public void testToPathFromProjectReference()
252 ProjectReference reference = new ProjectReference();
253 reference.setGroupId( "com.foo" );
254 reference.setArtifactId( "foo-tool" );
256 assertEquals( "com/foo/foo-tool/maven-metadata.xml", tools.toPath( reference ) );
260 public void testToProjectReferenceFooTools()
261 throws RepositoryMetadataException
263 assertProjectReference( "com.foo", "foo-tools", "com/foo/foo-tools/maven-metadata.xml" );
267 public void testToProjectReferenceAReallyLongPath()
268 throws RepositoryMetadataException
270 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
271 String artifactId = "a";
272 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/maven-metadata.xml";
274 assertProjectReference( groupId, artifactId, path );
278 public void testToProjectReferenceCommonsLang()
279 throws RepositoryMetadataException
281 String groupId = "commons-lang";
282 String artifactId = "commons-lang";
283 String path = "commons-lang/commons-lang/maven-metadata.xml";
285 assertProjectReference( groupId, artifactId, path );
288 private void assertProjectReference( String groupId, String artifactId, String path )
289 throws RepositoryMetadataException
291 ProjectReference reference = tools.toProjectReference( path );
293 assertNotNull( "Reference should not be null.", reference );
294 assertEquals( "ProjectReference.groupId", groupId, reference.getGroupId() );
295 assertEquals( "ProjectReference.artifactId", artifactId, reference.getArtifactId() );
299 public void testToVersionedReferenceFooTool()
300 throws RepositoryMetadataException
302 String groupId = "com.foo";
303 String artifactId = "foo-tool";
304 String version = "1.0";
305 String path = "com/foo/foo-tool/1.0/maven-metadata.xml";
307 assertVersionedReference( groupId, artifactId, version, path );
311 public void testToVersionedReferenceAReallyLongPath()
312 throws RepositoryMetadataException
314 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
315 String artifactId = "a";
316 String version = "1.1-alpha-1";
317 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/1.1-alpha-1/maven-metadata.xml";
319 assertVersionedReference( groupId, artifactId, version, path );
323 public void testToVersionedReferenceCommonsLang()
324 throws RepositoryMetadataException
326 String groupId = "commons-lang";
327 String artifactId = "commons-lang";
328 String version = "2.1";
329 String path = "commons-lang/commons-lang/2.1/maven-metadata.xml";
331 assertVersionedReference( groupId, artifactId, version, path );
335 public void testToVersionedReferenceSnapshot()
336 throws RepositoryMetadataException
338 String groupId = "com.foo";
339 String artifactId = "foo-connector";
340 String version = "2.1-SNAPSHOT";
341 String path = "com/foo/foo-connector/2.1-SNAPSHOT/maven-metadata.xml";
343 assertVersionedReference( groupId, artifactId, version, path );
346 private void assertVersionedReference( String groupId, String artifactId, String version, String path )
347 throws RepositoryMetadataException
349 VersionedReference reference = tools.toVersionedReference( path );
350 assertNotNull( "Reference should not be null.", reference );
352 assertEquals( "VersionedReference.groupId", groupId, reference.getGroupId() );
353 assertEquals( "VersionedReference.artifactId", artifactId, reference.getArtifactId() );
354 assertEquals( "VersionedReference.version", version, reference.getVersion() );
357 private void assertSnapshotVersions( String artifactId, String version, String[] expectedVersions )
360 Path repoRootDir = Paths.get( "src/test/repositories/metadata-repository" );
362 VersionedReference reference = new VersionedReference();
363 reference.setGroupId( "org.apache.archiva.metadata.tests" );
364 reference.setArtifactId( artifactId );
365 reference.setVersion( version );
367 MavenManagedRepository repo =
368 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
370 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
372 ManagedRepositoryContent repoContent =
373 provider.createManagedContent( repo );
375 Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );
377 // Sort the list (for asserts)
378 List<String> testedVersions = new ArrayList<>();
379 testedVersions.addAll( testedVersionSet );
380 Collections.sort( testedVersions, new VersionComparator() );
382 // Test the expected array of versions, to the actual tested versions
383 assertEquals( "Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size() );
385 for ( int i = 0; i < expectedVersions.length; i++ )
387 String actualVersion = testedVersions.get( i );
388 assertEquals( "Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion );
392 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
393 ProjectReference reference )
394 throws LayoutException, IOException, SAXException, ParserConfigurationException
396 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
397 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
399 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
400 if ( !detailedDiff.similar() )
402 // If it isn't similar, dump the difference.
403 assertEquals( expectedMetadata, actualMetadata );
407 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
408 VersionedReference reference )
409 throws LayoutException, IOException, SAXException, ParserConfigurationException
411 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
412 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
414 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
415 if ( !detailedDiff.similar() )
417 // If it isn't similar, dump the difference.
418 assertEquals( expectedMetadata, actualMetadata );
422 private void assertMetadataPath( String expected, String actual )
424 assertEquals( "Repository Specific Metadata Path", expected, actual );
427 private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
428 String releaseVersion )
431 ManagedRepositoryContent testRepo = createTestRepoContent();
432 ProjectReference reference = new ProjectReference();
433 reference.setGroupId( "org.apache.archiva.metadata.tests" );
434 reference.setArtifactId( artifactId );
436 prepTestRepo( testRepo, reference );
438 tools.updateMetadata( testRepo, reference );
440 StringBuilder buf = new StringBuilder();
441 buf.append( "<metadata>\n" );
442 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
443 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
444 // buf.append( " <version>1.0</version>\n" );
446 if ( expectedVersions != null )
448 buf.append( " <versioning>\n" );
449 if ( latestVersion != null )
451 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
453 if ( releaseVersion != null )
455 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
458 buf.append( " <versions>\n" );
459 for ( int i = 0; i < expectedVersions.length; i++ )
461 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
463 buf.append( " </versions>\n" );
464 buf.append( " </versioning>\n" );
466 buf.append( "</metadata>" );
468 assertMetadata( buf.toString(), testRepo, reference );
471 private void assertProjectMetadata( ManagedRepositoryContent testRepo, ProjectReference reference,
472 String artifactId, String[] expectedVersions, String latestVersion,
473 String releaseVersion )
476 StringBuilder buf = new StringBuilder();
477 buf.append( "<metadata>\n" );
478 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
479 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
481 if ( expectedVersions != null )
483 buf.append( " <versioning>\n" );
484 if ( latestVersion != null )
486 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
488 if ( releaseVersion != null )
490 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
493 buf.append( " <versions>\n" );
494 for ( int i = 0; i < expectedVersions.length; i++ )
496 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
498 buf.append( " </versions>\n" );
499 buf.append( " </versioning>\n" );
501 buf.append( "</metadata>" );
503 assertMetadata( buf.toString(), testRepo, reference );
506 private void assertUpdatedReleaseVersionMetadata( String artifactId, String version )
509 ManagedRepositoryContent testRepo = createTestRepoContent();
510 VersionedReference reference = new VersionedReference();
511 reference.setGroupId( "org.apache.archiva.metadata.tests" );
512 reference.setArtifactId( artifactId );
513 reference.setVersion( version );
515 prepTestRepo( testRepo, reference );
517 tools.updateMetadata( testRepo, reference );
519 StringBuilder buf = new StringBuilder();
520 buf.append( "<metadata>\n" );
521 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
522 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
523 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
524 buf.append( "</metadata>" );
526 assertMetadata( buf.toString(), testRepo, reference );
529 private void assertUpdatedSnapshotVersionMetadata( String artifactId, String version, String expectedDate,
530 String expectedTime, String expectedBuildNumber )
533 ManagedRepositoryContent testRepo = createTestRepoContent();
534 VersionedReference reference = new VersionedReference();
535 reference.setGroupId( "org.apache.archiva.metadata.tests" );
536 reference.setArtifactId( artifactId );
537 reference.setVersion( version );
539 prepTestRepo( testRepo, reference );
541 tools.updateMetadata( testRepo, reference );
543 StringBuilder buf = new StringBuilder();
544 buf.append( "<metadata>\n" );
545 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
546 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
547 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
548 buf.append( " <versioning>\n" );
549 buf.append( " <snapshot>\n" );
550 buf.append( " <buildNumber>" ).append( expectedBuildNumber ).append( "</buildNumber>\n" );
551 buf.append( " <timestamp>" );
552 buf.append( expectedDate ).append( "." ).append( expectedTime );
553 buf.append( "</timestamp>\n" );
554 buf.append( " </snapshot>\n" );
555 buf.append( " <lastUpdated>" ).append( expectedDate ).append( expectedTime ).append( "</lastUpdated>\n" );
556 buf.append( " </versioning>\n" );
557 buf.append( "</metadata>" );
559 assertMetadata( buf.toString(), testRepo, reference );
562 private void removeProxyConnector( String sourceRepoId, String targetRepoId )
564 ProxyConnectorConfiguration toRemove = null;
565 for ( ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors() )
567 if ( pcc.getTargetRepoId().equals( targetRepoId ) && pcc.getSourceRepoId().equals( sourceRepoId ) )
572 if ( toRemove != null )
574 config.getConfiguration().removeProxyConnector( toRemove );
575 String prefix = "proxyConnectors.proxyConnector(" + "1" + ")"; // XXX
576 config.triggerChange( prefix + ".sourceRepoId", toRemove.getSourceRepoId() );
577 config.triggerChange( prefix + ".targetRepoId", toRemove.getTargetRepoId() );
578 config.triggerChange( prefix + ".proxyId", toRemove.getProxyId() );
579 config.triggerChange( prefix + ".policies.releases", toRemove.getPolicy( "releases", "" ) );
580 config.triggerChange( prefix + ".policies.checksum", toRemove.getPolicy( "checksum", "" ) );
581 config.triggerChange( prefix + ".policies.snapshots", toRemove.getPolicy( "snapshots", "" ) );
582 config.triggerChange( prefix + ".policies.cache-failures", toRemove.getPolicy( "cache-failures", "" ) );
586 private void createProxyConnector( String sourceRepoId, String targetRepoId )
588 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
589 connectorConfig.setSourceRepoId( sourceRepoId );
590 connectorConfig.setTargetRepoId( targetRepoId );
591 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE );
592 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS );
593 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS );
594 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO );
596 int count = config.getConfiguration().getProxyConnectors().size();
597 config.getConfiguration().addProxyConnector( connectorConfig );
599 // Proper Triggering ...
600 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
601 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
602 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
603 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
604 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
605 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
606 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
607 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
610 private ManagedRepositoryContent createTestRepoContent()
613 Path repoRoot = Paths.get( "target/metadata-tests/" + name.getMethodName() );
614 if ( Files.exists(repoRoot) )
616 org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRoot );
619 Files.createDirectories(repoRoot);
621 MavenManagedRepository repoConfig =
622 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
624 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
626 ManagedRepositoryContent repoContent =
627 provider.createManagedContent( repoConfig );
631 private void prepTestRepo( ManagedRepositoryContent repo, ProjectReference reference )
634 String groupDir = StringUtils.replaceChars( reference.getGroupId(), '.', '/' );
635 String path = groupDir + "/" + reference.getArtifactId();
637 Path srcRepoDir = Paths.get( "src/test/repositories/metadata-repository" );
638 Path srcDir = srcRepoDir.resolve( path );
639 Path destDir = Paths.get( repo.getRepoRoot(), path );
641 assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
642 Files.createDirectories(destDir);
644 FileUtils.copyDirectory( srcDir.toFile(), destDir.toFile() );
647 private void prepTestRepo( ManagedRepositoryContent repo, VersionedReference reference )
650 ProjectReference projectRef = new ProjectReference();
651 projectRef.setGroupId( reference.getGroupId() );
652 projectRef.setArtifactId( reference.getArtifactId() );
654 prepTestRepo( repo, projectRef );