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.layout.LayoutException;
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 );
368 ManagedRepositoryContent repoContent =
369 applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
370 repoContent.setRepository( repo );
372 Set<String> testedVersionSet = tools.gatherSnapshotVersions( repoContent, reference );
374 // Sort the list (for asserts)
375 List<String> testedVersions = new ArrayList<>();
376 testedVersions.addAll( testedVersionSet );
377 Collections.sort( testedVersions, new VersionComparator() );
379 // Test the expected array of versions, to the actual tested versions
380 assertEquals( "Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size() );
382 for ( int i = 0; i < expectedVersions.length; i++ )
384 String actualVersion = testedVersions.get( i );
385 assertEquals( "Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion );
389 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
390 ProjectReference reference )
391 throws LayoutException, IOException, SAXException, ParserConfigurationException
393 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
394 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
396 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
397 if ( !detailedDiff.similar() )
399 // If it isn't similar, dump the difference.
400 assertEquals( expectedMetadata, actualMetadata );
404 private void assertMetadata( String expectedMetadata, ManagedRepositoryContent repository,
405 VersionedReference reference )
406 throws LayoutException, IOException, SAXException, ParserConfigurationException
408 Path metadataFile = Paths.get( repository.getRepoRoot(), tools.toPath( reference ) );
409 String actualMetadata = org.apache.archiva.common.utils.FileUtils.readFileToString( metadataFile, Charset.defaultCharset() );
411 DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
412 if ( !detailedDiff.similar() )
414 // If it isn't similar, dump the difference.
415 assertEquals( expectedMetadata, actualMetadata );
419 private void assertMetadataPath( String expected, String actual )
421 assertEquals( "Repository Specific Metadata Path", expected, actual );
424 private void assertUpdatedProjectMetadata( String artifactId, String[] expectedVersions, String latestVersion,
425 String releaseVersion )
428 ManagedRepositoryContent testRepo = createTestRepoContent();
429 ProjectReference reference = new ProjectReference();
430 reference.setGroupId( "org.apache.archiva.metadata.tests" );
431 reference.setArtifactId( artifactId );
433 prepTestRepo( testRepo, reference );
435 tools.updateMetadata( testRepo, reference );
437 StringBuilder buf = new StringBuilder();
438 buf.append( "<metadata>\n" );
439 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
440 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
441 // buf.append( " <version>1.0</version>\n" );
443 if ( expectedVersions != null )
445 buf.append( " <versioning>\n" );
446 if ( latestVersion != null )
448 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
450 if ( releaseVersion != null )
452 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
455 buf.append( " <versions>\n" );
456 for ( int i = 0; i < expectedVersions.length; i++ )
458 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
460 buf.append( " </versions>\n" );
461 buf.append( " </versioning>\n" );
463 buf.append( "</metadata>" );
465 assertMetadata( buf.toString(), testRepo, reference );
468 private void assertProjectMetadata( ManagedRepositoryContent testRepo, ProjectReference reference,
469 String artifactId, String[] expectedVersions, String latestVersion,
470 String releaseVersion )
473 StringBuilder buf = new StringBuilder();
474 buf.append( "<metadata>\n" );
475 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
476 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
478 if ( expectedVersions != null )
480 buf.append( " <versioning>\n" );
481 if ( latestVersion != null )
483 buf.append( " <latest>" ).append( latestVersion ).append( "</latest>\n" );
485 if ( releaseVersion != null )
487 buf.append( " <release>" ).append( releaseVersion ).append( "</release>\n" );
490 buf.append( " <versions>\n" );
491 for ( int i = 0; i < expectedVersions.length; i++ )
493 buf.append( " <version>" ).append( expectedVersions[i] ).append( "</version>\n" );
495 buf.append( " </versions>\n" );
496 buf.append( " </versioning>\n" );
498 buf.append( "</metadata>" );
500 assertMetadata( buf.toString(), testRepo, reference );
503 private void assertUpdatedReleaseVersionMetadata( String artifactId, String version )
506 ManagedRepositoryContent testRepo = createTestRepoContent();
507 VersionedReference reference = new VersionedReference();
508 reference.setGroupId( "org.apache.archiva.metadata.tests" );
509 reference.setArtifactId( artifactId );
510 reference.setVersion( version );
512 prepTestRepo( testRepo, reference );
514 tools.updateMetadata( testRepo, reference );
516 StringBuilder buf = new StringBuilder();
517 buf.append( "<metadata>\n" );
518 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
519 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
520 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
521 buf.append( "</metadata>" );
523 assertMetadata( buf.toString(), testRepo, reference );
526 private void assertUpdatedSnapshotVersionMetadata( String artifactId, String version, String expectedDate,
527 String expectedTime, String expectedBuildNumber )
530 ManagedRepositoryContent testRepo = createTestRepoContent();
531 VersionedReference reference = new VersionedReference();
532 reference.setGroupId( "org.apache.archiva.metadata.tests" );
533 reference.setArtifactId( artifactId );
534 reference.setVersion( version );
536 prepTestRepo( testRepo, reference );
538 tools.updateMetadata( testRepo, reference );
540 StringBuilder buf = new StringBuilder();
541 buf.append( "<metadata>\n" );
542 buf.append( " <groupId>" ).append( reference.getGroupId() ).append( "</groupId>\n" );
543 buf.append( " <artifactId>" ).append( reference.getArtifactId() ).append( "</artifactId>\n" );
544 buf.append( " <version>" ).append( reference.getVersion() ).append( "</version>\n" );
545 buf.append( " <versioning>\n" );
546 buf.append( " <snapshot>\n" );
547 buf.append( " <buildNumber>" ).append( expectedBuildNumber ).append( "</buildNumber>\n" );
548 buf.append( " <timestamp>" );
549 buf.append( expectedDate ).append( "." ).append( expectedTime );
550 buf.append( "</timestamp>\n" );
551 buf.append( " </snapshot>\n" );
552 buf.append( " <lastUpdated>" ).append( expectedDate ).append( expectedTime ).append( "</lastUpdated>\n" );
553 buf.append( " </versioning>\n" );
554 buf.append( "</metadata>" );
556 assertMetadata( buf.toString(), testRepo, reference );
559 private void removeProxyConnector( String sourceRepoId, String targetRepoId )
561 ProxyConnectorConfiguration toRemove = null;
562 for ( ProxyConnectorConfiguration pcc : config.getConfiguration().getProxyConnectors() )
564 if ( pcc.getTargetRepoId().equals( targetRepoId ) && pcc.getSourceRepoId().equals( sourceRepoId ) )
569 if ( toRemove != null )
571 config.getConfiguration().removeProxyConnector( toRemove );
572 String prefix = "proxyConnectors.proxyConnector(" + "1" + ")"; // XXX
573 config.triggerChange( prefix + ".sourceRepoId", toRemove.getSourceRepoId() );
574 config.triggerChange( prefix + ".targetRepoId", toRemove.getTargetRepoId() );
575 config.triggerChange( prefix + ".proxyId", toRemove.getProxyId() );
576 config.triggerChange( prefix + ".policies.releases", toRemove.getPolicy( "releases", "" ) );
577 config.triggerChange( prefix + ".policies.checksum", toRemove.getPolicy( "checksum", "" ) );
578 config.triggerChange( prefix + ".policies.snapshots", toRemove.getPolicy( "snapshots", "" ) );
579 config.triggerChange( prefix + ".policies.cache-failures", toRemove.getPolicy( "cache-failures", "" ) );
583 private void createProxyConnector( String sourceRepoId, String targetRepoId )
585 ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
586 connectorConfig.setSourceRepoId( sourceRepoId );
587 connectorConfig.setTargetRepoId( targetRepoId );
588 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CHECKSUM, ChecksumPolicy.IGNORE );
589 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS );
590 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.ALWAYS );
591 connectorConfig.addPolicy( ProxyConnectorConfiguration.POLICY_CACHE_FAILURES, CachedFailuresPolicy.NO );
593 int count = config.getConfiguration().getProxyConnectors().size();
594 config.getConfiguration().addProxyConnector( connectorConfig );
596 // Proper Triggering ...
597 String prefix = "proxyConnectors.proxyConnector(" + count + ")";
598 config.triggerChange( prefix + ".sourceRepoId", connectorConfig.getSourceRepoId() );
599 config.triggerChange( prefix + ".targetRepoId", connectorConfig.getTargetRepoId() );
600 config.triggerChange( prefix + ".proxyId", connectorConfig.getProxyId() );
601 config.triggerChange( prefix + ".policies.releases", connectorConfig.getPolicy( "releases", "" ) );
602 config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
603 config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
604 config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
607 private ManagedRepositoryContent createTestRepoContent()
610 Path repoRoot = Paths.get( "target/metadata-tests/" + name.getMethodName() );
611 if ( Files.exists(repoRoot) )
613 org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRoot );
616 Files.createDirectories(repoRoot);
618 MavenManagedRepository repoConfig =
619 createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot );
621 ManagedRepositoryContent repoContent =
622 applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
623 repoContent.setRepository( repoConfig );
627 private void prepTestRepo( ManagedRepositoryContent repo, ProjectReference reference )
630 String groupDir = StringUtils.replaceChars( reference.getGroupId(), '.', '/' );
631 String path = groupDir + "/" + reference.getArtifactId();
633 Path srcRepoDir = Paths.get( "src/test/repositories/metadata-repository" );
634 Path srcDir = srcRepoDir.resolve( path );
635 Path destDir = Paths.get( repo.getRepoRoot(), path );
637 assertTrue( "Source Dir exists: " + srcDir, Files.exists(srcDir) );
638 Files.createDirectories(destDir);
640 FileUtils.copyDirectory( srcDir.toFile(), destDir.toFile() );
643 private void prepTestRepo( ManagedRepositoryContent repo, VersionedReference reference )
646 ProjectReference projectRef = new ProjectReference();
647 projectRef.setGroupId( reference.getGroupId() );
648 projectRef.setArtifactId( reference.getArtifactId() );
650 prepTestRepo( repo, projectRef );