]> source.dussan.org Git - archiva.git/blob
eb183343ba45f21e649d62afd6f4bb6c32bd15f7
[archiva.git] /
1 package org.apache.archiva.repository.content.maven2;
2
3 /*
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
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.archiva.common.filelock.FileLockManager;
23 import org.apache.archiva.common.utils.FileUtils;
24 import org.apache.archiva.configuration.ArchivaConfiguration;
25 import org.apache.archiva.configuration.FileType;
26 import org.apache.archiva.configuration.FileTypes;
27 import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
28 import org.apache.archiva.model.ArtifactReference;
29 import org.apache.archiva.repository.LayoutException;
30 import org.apache.archiva.repository.ManagedRepositoryContent;
31 import org.apache.archiva.repository.RepositoryContentProvider;
32 import org.apache.archiva.repository.maven2.MavenManagedRepository;
33 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
34 import org.apache.commons.lang3.StringUtils;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.springframework.context.ApplicationContext;
39 import org.springframework.test.context.ContextConfiguration;
40
41 import javax.inject.Inject;
42 import javax.inject.Named;
43 import java.io.IOException;
44 import java.net.URISyntaxException;
45 import java.nio.file.Path;
46 import java.nio.file.Paths;
47 import java.util.List;
48
49 import static org.junit.Assert.*;
50
51 /**
52  * RepositoryRequestTest
53  */
54 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
55 @ContextConfiguration( { "classpath*:/META-INF/spring-context.xml",
56     "classpath:/spring-context-repo-request-test.xml" } )
57 public class MavenRepositoryRequestInfoTest
58 {
59
60     @Inject
61     protected ApplicationContext applicationContext;
62
63     @Inject
64     FileTypes fileTypes;
65
66     @Inject
67     @Named( "archivaConfiguration#repo-request-test" )
68     private ArchivaConfiguration archivaConfiguration;
69
70     @Inject
71     List<? extends ArtifactMappingProvider> artifactMappingProviders;
72
73     @Inject
74     FileLockManager fileLockManager;
75
76     private MavenRepositoryRequestInfo repoRequest;
77
78
79     protected MavenManagedRepository createRepository( String id, String name, Path location ) throws IOException {
80         MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent().toAbsolutePath());
81         repo.setLocation( location.toAbsolutePath().toUri() );
82         return repo;
83     }
84
85     private Path getRepositoryPath(String repoName) {
86         try
87         {
88             return Paths.get( Thread.currentThread( ).getContextClassLoader( ).getResource( "repositories/" + repoName ).toURI( ) );
89         }
90         catch ( URISyntaxException e )
91         {
92             throw new RuntimeException( "Could not resolve repository path " + e.getMessage( ), e );
93         }
94     }
95
96     @Before
97     public void setUp()
98         throws Exception
99     {
100
101         Path repoDir = getRepositoryPath( "default-repository" );
102         MavenManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir );
103
104         FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
105         fileType.addPattern( "**/*.xml" );
106         assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
107
108         fileTypes.afterConfigurationChange( null, "fileType", null );
109
110         ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repository, artifactMappingProviders, fileTypes, fileLockManager);
111         //repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" );
112         repository.setContent(repoContent);
113         repoRequest = new MavenRepositoryRequestInfo(repository);
114     }
115
116     @Test
117     public void testInvalidRequestEmptyPath()
118     {
119         assertInvalidRequest( "" );
120     }
121
122     @Test
123     public void testInvalidRequestSlashOnly()
124     {
125         assertInvalidRequest( "//" );
126     }
127
128     @Test
129     public void testInvalidRequestNoArtifactId()
130     {
131         assertInvalidRequest( "groupId/jars/-1.0.jar" );
132     }
133
134
135     @Test
136     public void testInvalidRequestTooShort()
137     {
138         assertInvalidRequest( "org.apache.maven.test/artifactId-2.0.jar" );
139     }
140
141     @Test
142     public void testInvalidDefaultRequestBadLocation()
143     {
144         assertInvalidRequest( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
145     }
146
147     @Test( expected = LayoutException.class )
148     public void testValidLegacyGanymed()
149         throws Exception
150     {
151         assertValid( "ch.ethz.ganymed/jars/ganymed-ssh2-build210.jar", "ch.ethz.ganymed", "ganymed-ssh2", "build210",
152                      null, "jar" );
153     }
154
155     @Test
156     public void testValidDefaultGanymed()
157         throws Exception
158     {
159         assertValid( "ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar", "ch.ethz.ganymed",
160                      "ganymed-ssh2", "build210", null, "jar" );
161     }
162
163     @Test( expected = LayoutException.class )
164     public void testValidLegacyJavaxComm()
165         throws Exception
166     {
167         assertValid( "javax/jars/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", null, "jar" );
168     }
169
170     @Test
171     public void testValidDefaultJavaxComm()
172         throws Exception
173     {
174         assertValid( "javax/comm/3.0-u1/comm-3.0-u1.jar", "javax", "comm", "3.0-u1", null, "jar" );
175     }
176
177     @Test( expected = LayoutException.class )
178     public void testValidLegacyJavaxPersistence()
179         throws Exception
180     {
181         assertValid( "javax.persistence/jars/ejb-3.0-public_review.jar", "javax.persistence", "ejb",
182                      "3.0-public_review", null, "jar" );
183     }
184
185     @Test
186     public void testValidDefaultJavaxPersistence()
187         throws Exception
188     {
189         assertValid( "javax/persistence/ejb/3.0-public_review/ejb-3.0-public_review.jar", "javax.persistence", "ejb",
190                      "3.0-public_review", null, "jar" );
191     }
192
193     @Test( expected = LayoutException.class )
194     public void testValidLegacyMavenTestPlugin()
195         throws Exception
196     {
197         assertValid( "maven/jars/maven-test-plugin-1.8.2.jar", "maven", "maven-test-plugin", "1.8.2", null, "jar" );
198     }
199
200     @Test
201     public void testValidDefaultMavenTestPlugin()
202         throws Exception
203     {
204         assertValid( "maven/maven-test-plugin/1.8.2/maven-test-plugin-1.8.2.pom", "maven", "maven-test-plugin", "1.8.2",
205                      null, "pom" );
206     }
207
208     @Test( expected = LayoutException.class )
209     public void testValidLegacyCommonsLangJavadoc()
210         throws Exception
211     {
212         assertValid( "commons-lang/javadoc.jars/commons-lang-2.1-javadoc.jar", "commons-lang", "commons-lang", "2.1",
213                      "javadoc", "javadoc" );
214     }
215
216     @Test
217     public void testValidDefaultCommonsLangJavadoc()
218         throws Exception
219     {
220         assertValid( "commons-lang/commons-lang/2.1/commons-lang-2.1-javadoc.jar", "commons-lang", "commons-lang",
221                      "2.1", "javadoc", "javadoc" );
222     }
223
224     @Test( expected = LayoutException.class )
225     public void testValidLegacyDerbyPom()
226         throws Exception
227     {
228         assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
229         // Starting slash should not prevent detection.
230         assertValid( "/org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null,
231                      "pom" );
232     }
233
234     @Test
235     public void testValidDefaultDerbyPom()
236         throws Exception
237     {
238         assertValid( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0",
239                      null, "pom" );
240     }
241
242     @Test( expected = LayoutException.class )
243     public void testValidLegacyGeronimoEjbSpec()
244         throws Exception
245     {
246         assertValid( "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar", "org.apache.geronimo.specs",
247                      "geronimo-ejb_2.1_spec", "1.0.1", null, "jar" );
248     }
249
250     @Test
251     public void testValidDefaultGeronimoEjbSpec()
252         throws Exception
253     {
254         assertValid( "org/apache/geronimo/specs/geronimo-ejb_2.1_spec/1.0.1/geronimo-ejb_2.1_spec-1.0.1.jar",
255                      "org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", null, "jar" );
256     }
257
258     @Test( expected = LayoutException.class )
259     public void testValidLegacyLdapSnapshot()
260         throws Exception
261     {
262         assertValid( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom", "directory-clients", "ldap-clients",
263                      "0.9.1-SNAPSHOT", null, "pom" );
264     }
265
266     @Test
267     public void testValidDefaultLdapSnapshot()
268         throws Exception
269     {
270         assertValid( "directory-clients/ldap-clients/0.9.1-SNAPSHOT/ldap-clients-0.9.1-SNAPSHOT.pom",
271                      "directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", null, "pom" );
272     }
273
274     @Test( expected = LayoutException.class )
275     public void testValidLegacyTestArchSnapshot()
276         throws Exception
277     {
278         assertValid( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom", "test.maven-arch", "test-arch",
279                      "2.0.3-SNAPSHOT", null, "pom" );
280     }
281
282     @Test
283     public void testValidDefaultTestArchSnapshot()
284         throws Exception
285     {
286         assertValid( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.pom", "test.maven-arch",
287                      "test-arch", "2.0.3-SNAPSHOT", null, "pom" );
288     }
289
290     @Test( expected = LayoutException.class )
291     public void testValidLegacyOddDottedArtifactId()
292         throws Exception
293     {
294         assertValid( "com.company.department/poms/com.company.department.project-0.2.pom", "com.company.department",
295                      "com.company.department.project", "0.2", null, "pom" );
296     }
297
298     @Test
299     public void testValidDefaultOddDottedArtifactId()
300         throws Exception
301     {
302         assertValid( "com/company/department/com.company.department.project/0.2/com.company.department.project-0.2.pom",
303                      "com.company.department", "com.company.department.project", "0.2", null, "pom" );
304     }
305
306     @Test( expected = LayoutException.class )
307     public void testValidLegacyTimestampedSnapshot()
308         throws Exception
309     {
310         assertValid( "org.apache.archiva.test/jars/redonkulous-3.1-beta-1-20050831.101112-42.jar",
311                      "org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", null, "jar" );
312     }
313
314     @Test
315     public void testValidDefaultTimestampedSnapshot()
316         throws Exception
317     {
318         assertValid(
319             "org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar",
320             "org.apache.archiva.test", "redonkulous", "3.1-beta-1-20050831.101112-42", null, "jar" );
321     }
322
323     @Test
324     public void testIsSupportFile()
325     {
326         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
327         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
328         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
329         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
330         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
331         assertTrue( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) );
332
333         assertFalse( repoRequest.isSupportFile( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
334         assertFalse(
335             repoRequest.isSupportFile( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
336         assertFalse( repoRequest.isSupportFile( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
337         assertFalse( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
338         assertFalse( repoRequest.isSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
339         assertFalse( repoRequest.isSupportFile( "org/apache/derby/derby/maven-metadata.xml" ) );
340     }
341
342     @Test
343     public void testIsMetadata()
344     {
345         assertTrue( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
346         assertTrue( repoRequest.isMetadata( "org/apache/derby/derby/maven-metadata.xml" ) );
347
348         assertFalse( repoRequest.isMetadata( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
349         assertFalse(
350             repoRequest.isMetadata( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
351         assertFalse( repoRequest.isMetadata( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
352         assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
353         assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
354         assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
355     }
356
357     @Test
358     public void testIsMetadataSupportFile()
359     {
360         assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
361         assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml" ) );
362         assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml.sha1" ) );
363         assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml.md5" ) );
364
365         assertFalse( repoRequest.isMetadataSupportFile( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
366         assertFalse( repoRequest.isMetadataSupportFile(
367             "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
368         assertFalse(
369             repoRequest.isMetadataSupportFile( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
370         assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
371         assertFalse(
372             repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
373         assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
374         assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) );
375     }
376
377     @Test
378     public void testIsDefault()
379     {
380         assertNotEquals( "default", repoRequest.getLayout( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
381         assertNotEquals("default", repoRequest.getLayout( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ) );
382         assertNotEquals("default", repoRequest.getLayout( "commons-lang/jars/commons-lang-2.1-javadoc.jar" ) );
383
384         assertEquals("default", repoRequest.getLayout( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
385         assertEquals("default", repoRequest.getLayout( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
386         assertEquals("default", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
387         assertEquals("default", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
388         assertEquals("default", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
389         assertEquals("default", repoRequest.getLayout( "eclipse/jdtcore/maven-metadata.xml" ) );
390         assertEquals("default", repoRequest.getLayout( "eclipse/jdtcore/maven-metadata.xml.sha1" ) );
391         assertEquals("default", repoRequest.getLayout( "eclipse/jdtcore/maven-metadata.xml.md5" ) );
392
393         assertNotEquals("default", repoRequest.getLayout( null ) );
394         assertNotEquals("default", repoRequest.getLayout( "" ) );
395         assertNotEquals("default", repoRequest.getLayout( "foo" ) );
396         assertNotEquals("default", repoRequest.getLayout( "some.short/path" ) );
397     }
398
399     @Test
400     public void testIsLegacy()
401     {
402         assertEquals("legacy", repoRequest.getLayout( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
403         assertEquals("legacy", repoRequest.getLayout( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ) );
404         assertEquals("legacy", repoRequest.getLayout( "commons-lang/jars/commons-lang-2.1-javadoc.jar" ) );
405
406         assertNotEquals("legacy", repoRequest.getLayout( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
407         assertNotEquals("legacy", repoRequest.getLayout( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) );
408         assertNotEquals("legacy", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
409         assertNotEquals("legacy", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
410         assertNotEquals("legacy", repoRequest.getLayout( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
411
412         assertNotEquals("legacy", repoRequest.getLayout( null ) );
413         assertNotEquals("legacy", repoRequest.getLayout( "" ) );
414         assertNotEquals("legacy", repoRequest.getLayout( "some.short/path" ) );
415     }
416
417     private ManagedRepositoryContent createManagedRepo( String layout )
418         throws Exception
419     {
420         Path repoRoot = Paths.get( FileUtils.getBasedir() + "/target/test-repo" );
421         return createManagedRepositoryContent( "test-internal", "Internal Test Repo", repoRoot, layout );
422     }
423
424     /**
425      * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
426      */
427     @Test
428     public void testToNativePathArtifactDefaultToDefaultDualExtension()
429         throws Exception
430     {
431         ManagedRepositoryContent repository = createManagedRepo( "default" );
432
433         // Test (artifact) default to default - dual extension
434         assertEquals( "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip",
435                       repoRequest.toNativePath( "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip") );
436     }
437
438
439     @Test
440     public void testToNativePathMetadataDefaultToDefault()
441         throws Exception
442     {
443         ManagedRepositoryContent repository = createManagedRepo( "default" );
444
445         // Test (metadata) default to default
446         assertEquals( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1",
447                       repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1") );
448     }
449
450
451     @Test
452     public void testNativePathBadRequestTooShort()
453         throws Exception
454     {
455         ManagedRepositoryContent repository = createManagedRepo( "default" );
456
457         // Test bad request path (too short)
458         try
459         {
460             repoRequest.toNativePath( "org.apache.derby/license.txt");
461             fail( "Should have thrown an exception about a too short path." );
462         }
463         catch ( LayoutException e )
464         {
465             // expected path.
466         }
467     }
468
469     @Test
470     public void testNativePathBadRequestBlank()
471         throws Exception
472     {
473         ManagedRepositoryContent repository = createManagedRepo( "default" );
474
475         // Test bad request path (too short)
476         try
477         {
478             repoRequest.toNativePath( "");
479             fail( "Should have thrown an exception about an blank request." );
480         }
481         catch ( LayoutException e )
482         {
483             // expected path.
484         }
485     }
486
487     @Test
488     public void testNativePathBadRequestNull()
489         throws Exception
490     {
491         ManagedRepositoryContent repository = createManagedRepo( "default" );
492
493         // Test bad request path (too short)
494         try
495         {
496             repoRequest.toNativePath( null);
497             fail( "Should have thrown an exception about an null request." );
498         }
499         catch ( LayoutException e )
500         {
501             // expected path.
502         }
503     }
504
505     @Test
506     public void testNativePathBadRequestUnknownType()
507         throws Exception
508     {
509         ManagedRepositoryContent repository = createManagedRepo( "default" );
510
511         // Test bad request path (too short)
512         try
513         {
514             repoRequest.toNativePath( "org/apache/derby/derby/10.2.2.0/license.txt");
515             fail( "Should have thrown an exception about an invalid type." );
516         }
517         catch ( LayoutException e )
518         {
519             // expected path.
520         }
521     }
522
523
524     private void assertValid( String path, String groupId, String artifactId, String version, String classifier,
525                               String type )
526         throws Exception
527     {
528         String expectedId =
529             "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + ( classifier != null ?
530                 classifier + ":" : "" ) + type;
531
532         ArtifactReference reference = repoRequest.toArtifactReference( path );
533
534         assertNotNull( expectedId + " - Should not be null.", reference );
535
536         assertEquals( expectedId + " - Group ID", groupId, reference.getGroupId() );
537         assertEquals( expectedId + " - Artifact ID", artifactId, reference.getArtifactId() );
538         if ( StringUtils.isNotBlank( classifier ) )
539         {
540             assertEquals( expectedId + " - Classifier", classifier, reference.getClassifier() );
541         }
542         assertEquals( expectedId + " - Version ID", version, reference.getVersion() );
543         assertEquals( expectedId + " - Type", type, reference.getType() );
544     }
545
546     private void assertInvalidRequest( String path )
547     {
548         try
549         {
550             repoRequest.toArtifactReference( path );
551             fail( "Expected a LayoutException on an invalid path [" + path + "]" );
552         }
553         catch ( LayoutException e )
554         {
555             /* expected path */
556         }
557     }
558
559     protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, Path location,
560                                                                        String layout )
561         throws Exception
562     {
563         MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, archivaConfiguration.getRepositoryBaseDir());
564         repo.setLocation( location.toAbsolutePath().toUri() );
565         repo.setLayout( layout );
566
567         RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
568
569         ManagedRepositoryContent repoContent =
570             provider.createManagedContent( repo );
571
572         return repoContent;
573     }
574
575 }