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.maven2.MavenManagedRepository;
37 import org.apache.commons.io.FileUtils;
38 import org.apache.commons.lang.StringUtils;
39 import org.custommonkey.xmlunit.DetailedDiff;
40 import org.custommonkey.xmlunit.Diff;
41 import org.junit.Test;
42 import org.springframework.test.context.ContextConfiguration;
43 import org.xml.sax.SAXException;
45 import javax.inject.Inject;
46 import javax.inject.Named;
47 import javax.xml.parsers.ParserConfigurationException;
48 import java.io.IOException;
49 import java.nio.charset.Charset;
50 import java.nio.file.Files;
51 import java.nio.file.Path;
52 import java.nio.file.Paths;
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
58 import static org.junit.Assert.*;
63 @ContextConfiguration (
64 { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
65 public class MetadataToolsTest
66 extends AbstractRepositoryLayerTestCase
69 @Named ( "metadataTools#test" )
70 private MetadataTools tools;
73 @Named ( "archivaConfiguration#mock" )
74 protected MockConfiguration config;
77 public void testGatherSnapshotVersionsA()
80 removeProxyConnector( "test-repo", "apache-snapshots" );
81 removeProxyConnector( "test-repo", "internal-snapshots" );
82 removeProxyConnector( "test-repo", "snapshots.codehaus.org" );
84 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
85 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
86 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
87 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
88 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070316.175232-11" } );
92 public void testGatherSnapshotVersionsAWithProxies()
95 // These proxied repositories do not need to exist for the purposes of this unit test,
96 // just the repository ids are important.
97 createProxyConnector( "test-repo", "apache-snapshots" );
98 createProxyConnector( "test-repo", "internal-snapshots" );
99 createProxyConnector( "test-repo", "snapshots.codehaus.org" );
101 assertSnapshotVersions( "snap_shots_a", "1.0-alpha-11-SNAPSHOT",
102 new String[]{ "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-20070221.194724-2",
103 "1.0-alpha-11-20070302.212723-3", "1.0-alpha-11-20070303.152828-4",
104 "1.0-alpha-11-20070305.215149-5", "1.0-alpha-11-20070307.170909-6",
105 "1.0-alpha-11-20070314.211405-9", "1.0-alpha-11-20070315.033030-10"
106 /* Arrives in via snapshots.codehaus.org proxy */,
107 "1.0-alpha-11-20070316.175232-11" } );
111 public void testGetRepositorySpecificName()
114 RemoteRepositoryContent repoJavaNet =
115 createRemoteRepositoryContent( "maven2-repository.dev.java.net", "Java.net Repository for Maven 2",
116 "http://download.java.net/maven/2/", "default" );
117 RemoteRepositoryContent repoCentral =
118 createRemoteRepositoryContent( "central", "Central Global Repository", "http://repo1.maven.org/maven2/",
121 String convertedName =
122 tools.getRepositorySpecificName( repoJavaNet, "commons-lang/commons-lang/maven-metadata.xml" );
123 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-maven2-repository.dev.java.net.xml",
126 convertedName = tools.getRepositorySpecificName( repoCentral, "commons-lang/commons-lang/maven-metadata.xml" );
127 assertMetadataPath( "commons-lang/commons-lang/maven-metadata-central.xml", convertedName );
130 // TODO: replace with group tests
131 // public void testUpdateProjectBadArtifact()
136 // assertUpdatedProjectMetadata( "bad_artifact", null );
137 // fail( "Should have thrown an IOException on a bad artifact." );
139 // catch ( IOException e )
146 public void testUpdateProjectNonExistingVersion()
149 ManagedRepositoryContent testRepo = createTestRepoContent();
150 ProjectReference reference = new ProjectReference();
151 reference.setGroupId( "org.apache.archiva.metadata.tests" );
152 reference.setArtifactId( "missing_artifact" );
154 prepTestRepo( testRepo, reference );
156 // check metadata prior to update -- should contain the non-existing artifact version
157 assertProjectMetadata( testRepo, reference, "missing_artifact",
158 new String[]{ "1.0-SNAPSHOT", "1.1-SNAPSHOT", "1.2-SNAPSHOT" }, "1.2-SNAPSHOT", null );
160 tools.updateMetadata( testRepo, reference );
162 // metadata should not contain the non-existing artifact version -- 1.1-SNAPSHOT
163 assertProjectMetadata( testRepo, reference, "missing_artifact", new String[]{ "1.0-SNAPSHOT", "1.2-SNAPSHOT" },
164 "1.2-SNAPSHOT", null );
168 public void testUpdateProjectMissingMultipleVersions()
171 assertUpdatedProjectMetadata( "missing_metadata_b",
172 new String[]{ "1.0", "1.0.1", "2.0", "2.0.1", "2.0-20070821-dev" },
173 "2.0-20070821-dev", "2.0-20070821-dev" );
177 public void testUpdateProjectMissingMultipleVersionsWithProxies()
180 // Attach the (bogus) proxies to the managed repo.
181 // These proxied repositories do not need to exist for the purposes of this unit test,
182 // just the repository ids are important.
183 createProxyConnector( "test-repo", "central" );
184 createProxyConnector( "test-repo", "java.net" );
186 assertUpdatedProjectMetadata( "proxied_multi",
187 new String[]{ "1.0-spec" /* in java.net */, "1.0" /* in managed, and central */,
188 "1.0.1" /* in central */, "1.1" /* in managed */, "2.0-proposal-beta"
189 /* in java.net */, "2.0-spec" /* in java.net */, "2.0"
190 /* in central, and java.net */, "2.0.1" /* in java.net */, "2.1"
191 /* in managed */, "3.0" /* in central */, "3.1" /* in central */ }, "3.1",
196 public void testUpdateProjectSimpleYetIncomplete()
199 assertUpdatedProjectMetadata( "incomplete_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
203 public void testUpdateProjectSimpleYetMissing()
206 assertUpdatedProjectMetadata( "missing_metadata_a", new String[]{ "1.0" }, "1.0", "1.0" );
210 public void testUpdateVersionSimple10()
213 assertUpdatedReleaseVersionMetadata( "missing_metadata_a", "1.0" );
217 public void testUpdateVersionSimple20()
220 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0" );
224 public void testUpdateVersionSimple20NotSnapshot()
227 assertUpdatedReleaseVersionMetadata( "missing_metadata_b", "2.0-20070821-dev" );
231 public void testUpdateVersionSnapshotA()
234 assertUpdatedSnapshotVersionMetadata( "snap_shots_a", "1.0-alpha-11-SNAPSHOT", "20070316", "175232", "11" );
238 public void testToPathFromVersionReference()
240 VersionedReference reference = new VersionedReference();
241 reference.setGroupId( "com.foo" );
242 reference.setArtifactId( "foo-tool" );
243 reference.setVersion( "1.0" );
245 assertEquals( "com/foo/foo-tool/1.0/maven-metadata.xml", tools.toPath( reference ) );
249 public void testToPathFromProjectReference()
251 ProjectReference reference = new ProjectReference();
252 reference.setGroupId( "com.foo" );
253 reference.setArtifactId( "foo-tool" );
255 assertEquals( "com/foo/foo-tool/maven-metadata.xml", tools.toPath( reference ) );
259 public void testToProjectReferenceFooTools()
260 throws RepositoryMetadataException
262 assertProjectReference( "com.foo", "foo-tools", "com/foo/foo-tools/maven-metadata.xml" );
266 public void testToProjectReferenceAReallyLongPath()
267 throws RepositoryMetadataException
269 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
270 String artifactId = "a";
271 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/maven-metadata.xml";
273 assertProjectReference( groupId, artifactId, path );
277 public void testToProjectReferenceCommonsLang()
278 throws RepositoryMetadataException
280 String groupId = "commons-lang";
281 String artifactId = "commons-lang";
282 String path = "commons-lang/commons-lang/maven-metadata.xml";
284 assertProjectReference( groupId, artifactId, path );
287 private void assertProjectReference( String groupId, String artifactId, String path )
288 throws RepositoryMetadataException
290 ProjectReference reference = tools.toProjectReference( path );
292 assertNotNull( "Reference should not be null.", reference );
293 assertEquals( "ProjectReference.groupId", groupId, reference.getGroupId() );
294 assertEquals( "ProjectReference.artifactId", artifactId, reference.getArtifactId() );
298 public void testToVersionedReferenceFooTool()
299 throws RepositoryMetadataException
301 String groupId = "com.foo";
302 String artifactId = "foo-tool";
303 String version = "1.0";
304 String path = "com/foo/foo-tool/1.0/maven-metadata.xml";
306 assertVersionedReference( groupId, artifactId, version, path );
310 public void testToVersionedReferenceAReallyLongPath()
311 throws RepositoryMetadataException
313 String groupId = "net.i.have.a.really.long.path.just.for.the.hell.of.it";
314 String artifactId = "a";
315 String version = "1.1-alpha-1";
316 String path = "net/i/have/a/really/long/path/just/for/the/hell/of/it/a/1.1-alpha-1/maven-metadata.xml";
318 assertVersionedReference( groupId, artifactId, version, path );
322 public void testToVersionedReferenceCommonsLang()
323 throws RepositoryMetadataException
325 String groupId = "commons-lang";
326 String artifactId = "commons-lang";
327 String version = "2.1";
328 String path = "commons-lang/commons-lang/2.1/maven-metadata.xml";
330 assertVersionedReference( groupId, artifactId, version, path );
334 public void testToVersionedReferenceSnapshot()
335 throws RepositoryMetadataException
337 String groupId = "com.foo";
338 String artifactId = "foo-connector";
339 String version = "2.1-SNAPSHOT";
340 String path = "com/foo/foo-connector/2.1-SNAPSHOT/maven-metadata.xml";
342 assertVersionedReference( groupId, artifactId, version, path );
345 private void assertVersionedReference( String groupId, String artifactId, String version, String path )
346 throws RepositoryMetadataException
348 VersionedReference reference = tools.toVersionedReference( path );
349 assertNotNull( "Reference should not be null.", reference );
351 assertEquals( "VersionedReference.groupId", groupId, reference.getGroupId() );
352 assertEquals( "VersionedReference.artifactId", artifactId, reference.getArtifactId() );
353 assertEquals( "VersionedReference.version", version, reference.getVersion() );
356 private void assertSnapshotVersions( String artifactId, String version, String[] expectedVersions )
359 Path repoRootDir = Paths.get( "src/test/repositories/metadata-repository" );
361 VersionedReference reference = new VersionedReference();
362 reference.setGroupId( "org.apache.archiva.metadata.tests" );
363 reference.setArtifactId( artifactId );
364 reference.setVersion( version );
366 MavenManagedRepository repo =
367 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir );
369 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
371 ManagedRepositoryContent repoContent =
372 provider.createManagedContent( repo );
374 Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );
376 // Sort the list (for asserts)
377 List<String> testedVersions = new ArrayList<>();
378 testedVersions.addAll( testedVersionSet );
379 Collections.sort( testedVersions, new VersionComparator() );
381 // Test the expected array of versions, to the actual tested versions
382 assertEquals( "Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size() );
384 for ( int i = 0; i < expectedVersions.length; i++ )
386 String actualVersion = testedVersions.get( i );
387 assertEquals( "Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion );
391 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
392 ProjectReference reference )
393 throws LayoutException, IOException, SAXException, ParserConfigurationException
395 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
396 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
398 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
399 if ( !detailedDiff.similar() )
401 // If it isn't similar, dump the difference.
402 assertEquals( expectedMetadata, actualMetadata );
406 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
407 VersionedReference reference )
408 throws LayoutException, IOException, SAXException, ParserConfigurationException
410 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
411 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
413 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
414 if ( !detailedDiff.similar() )
416 // If it isn't similar, dump the difference.
417 assertEquals( expectedMetadata, actualMetadata );
421 private void assertMetadataPath( String expected, String actual )
423 assertEquals( "Repository Specific Metadata Path", expected, actual );
426 private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
427 String releaseVersion )
430 ManagedRepositoryContent testRepo = createTestRepoContent();
431 ProjectReference reference = new ProjectReference();
432 reference.setGroupId( "org.apache.archiva.metadata.tests" );
433 reference.setArtifactId( artifactId );
435 prepTestRepo( testRepo, reference );
437 tools.updateMetadata( testRepo, reference );
439 StringBuilder buf = new StringBuilder();
440 buf.append( "<metadata>\n" );
441 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
442 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
443 // buf.append( " <version>1.0</version>\n" );
445 if ( expectedVersions != null )
447 buf.append( " <versioning>\n" );
448 if ( latestVersion != null )
450 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
452 if ( releaseVersion != null )
454 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
457 buf.append( " <versions>\n" );
458 for ( int i = 0; i < expectedVersions.length; i++ )
460 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
462 buf.append( " </versions>\n" );
463 buf.append( " </versioning>\n" );
465 buf.append( "</metadata>" );
467 assertMetadata( buf.toString(), testRepo, reference );
470 private void assertProjectMetadata( ManagedRepositoryContent testRepo, ProjectReference reference,
471 String artifactId, String[] expectedVersions, String latestVersion,
472 String releaseVersion )
475 StringBuilder buf = new StringBuilder();
476 buf.append( "<metadata>\n" );
477 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
478 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
480 if ( expectedVersions != null )
482 buf.append( " <versioning>\n" );
483 if ( latestVersion != null )
485 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
487 if ( releaseVersion != null )
489 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
492 buf.append( " <versions>\n" );
493 for ( int i = 0; i < expectedVersions.length; i++ )
495 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
497 buf.append( " </versions>\n" );
498 buf.append( " </versioning>\n" );
500 buf.append( "</metadata>" );
502 assertMetadata( buf.toString(), testRepo, reference );
505 private void assertUpdatedReleaseVersionMetadata( String artifactId, String version )
508 ManagedRepositoryContent testRepo = createTestRepoContent();
509 VersionedReference reference = new VersionedReference();
510 reference.setGroupId( "org.apache.archiva.metadata.tests" );
511 reference.setArtifactId( artifactId );
512 reference.setVersion( version );
514 prepTestRepo( testRepo, reference );
516 tools.updateMetadata( testRepo, reference );
518 StringBuilder buf = new StringBuilder();
519 buf.append( "<metadata>\n" );
520 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
521 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
522 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
523 buf.append( "</metadata>" );
525 assertMetadata( buf.toString(), testRepo, reference );
528 private void assertUpdatedSnapshotVersionMetadata( String artifactId, String version, String expectedDate,
529 String expectedTime, String expectedBuildNumber )
532 ManagedRepositoryContent testRepo = createTestRepoContent();
533 VersionedReference reference = new VersionedReference();
534 reference.setGroupId( "org.apache.archiva.metadata.tests" );
535 reference.setArtifactId( artifactId );
536 reference.setVersion( version );
538 prepTestRepo( testRepo, reference );
540 tools.updateMetadata( testRepo, reference );
542 StringBuilder buf = new StringBuilder();
543 buf.append( "<metadata>\n" );
544 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
545 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
546 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
547 buf.append( " <versioning>\n" );
548 buf.append( " <snapshot>\n" );
549 buf.append( " <buildNumber>" ).append( expectedBuildNumber ).append( "</buildNumber>\n" );
550 buf.append( " <timestamp>" );
551 buf.append( expectedDate ).append( "." ).append( expectedTime );
552 buf.append( "</timestamp>\n" );
553 buf.append( " </snapshot>\n" );
554 buf.append( " <lastUpdated>" ).append( expectedDate ).append( expectedTime ).append( "</lastUpdated>\n" );
555 buf.append( " </versioning>\n" );
556 buf.append( "</metadata>" );
558 assertMetadata( buf.toString(), testRepo, reference );
561 private void removeProxyConnector( String sourceRepoId, String targetRepoId )
563 ProxyConnectorConfiguration toRemove = null;
564 for ( ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors() )
566 if ( pcc.getTargetRepoId().equals( targetRepoId ) && pcc.getSourceRepoId().equals( sourceRepoId ) )
571 if ( toRemove != null )
573 config.getConfiguration().removeProxyConnector( toRemove );
574 String prefix = "proxyConnectors.proxyConnector(" + "1" + ")"; // XXX
575 config.triggerChange( prefix + ".sourceRepoId", toRemove.getSourceRepoId() );
576 config.triggerChange( prefix + ".targetRepoId", toRemove.getTargetRepoId() );
577 config.triggerChange( prefix + ".proxyId", toRemove.getProxyId() );
578 config.triggerChange( prefix + ".policies.releases", toRemove.getPolicy( "releases", "" ) );
579 config.triggerChange( prefix + ".policies.checksum", toRemove.getPolicy( "checksum", "" ) );
580 config.triggerChange( prefix + ".policies.snapshots", toRemove.getPolicy( "snapshots", "" ) );
581 config.triggerChange( prefix + ".policies.cache-failures", toRemove.getPolicy( "cache-failures", "" ) );
585 private void createProxyConnector( String sourceRepoId, String targetRepoId )
587 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
588 connectorConfig.setSourceRepoId( sourceRepoId );
589 connectorConfig.setTargetRepoId( targetRepoId );
590 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE );
591 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS );
592 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS );
593 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO );
595 int count = config.getConfiguration().getProxyConnectors().size();
596 config.getConfiguration().addProxyConnector( connectorConfig );
598 // Proper Triggering ...
599 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
600 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
601 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
602 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
603 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
604 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
605 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
606 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
609 private ManagedRepositoryContent createTestRepoContent()
612 Path repoRoot = Paths.get( "target/metadata-tests/" + name.getMethodName() );
613 if ( Files.exists(repoRoot) )
615 org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRoot );
618 Files.createDirectories(repoRoot);
620 MavenManagedRepository repoConfig =
621 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
623 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
625 ManagedRepositoryContent repoContent =
626 provider.createManagedContent( repoConfig );
630 private void prepTestRepo( ManagedRepositoryContent repo, ProjectReference reference )
633 String groupDir = StringUtils.replaceChars( reference.getGroupId(), '.', '/' );
634 String path = groupDir + "/" + reference.getArtifactId();
636 Path srcRepoDir = Paths.get( "src/test/repositories/metadata-repository" );
637 Path srcDir = srcRepoDir.resolve( path );
638 Path destDir = Paths.get( repo.getRepoRoot(), path );
640 assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
641 Files.createDirectories(destDir);
643 FileUtils.copyDirectory( srcDir.toFile(), destDir.toFile() );
646 private void prepTestRepo( ManagedRepositoryContent repo, VersionedReference reference )
649 ProjectReference projectRef = new ProjectReference();
650 projectRef.setGroupId( reference.getGroupId() );
651 projectRef.setArtifactId( reference.getArtifactId() );
653 prepTestRepo( repo, projectRef );