1 package org.apache.archiva.repository.maven;
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
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.repository.ManagedRepositoryContent;
22 import org.apache.archiva.repository.RemoteRepositoryContent;
23 import org.apache.archiva.repository.RepositoryContentProvider;
24 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
25 import org.junit.Rule;
26 import org.junit.rules.TestName;
27 import org.junit.runner.RunWith;
28 import org.springframework.context.ApplicationContext;
29 import org.springframework.test.context.ContextConfiguration;
31 import javax.inject.Inject;
32 import java.io.IOException;
34 import java.net.URISyntaxException;
35 import java.nio.file.Path;
36 import java.nio.file.Paths;
39 * AbstractRepositoryLayerTestCase
43 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
44 @ContextConfiguration( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-repository-conf.xml" } )
45 public abstract class AbstractRepositoryLayerTestCase
48 public TestName name = new TestName();
51 protected ApplicationContext applicationContext;
53 protected MavenManagedRepository createRepository( String id, String name, Path location ) throws IOException {
54 MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent().toAbsolutePath());
55 repo.setLocation( location.toAbsolutePath().toUri() );
59 protected MavenRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException, IOException {
60 MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance(id, name, Paths.get("target/remotes"));
61 repo.setLocation( new URI( url ) );
65 protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, Path location,
69 MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent() );
70 repo.setLocation( location.toAbsolutePath().toUri() );
71 repo.setLayout( layout );
73 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
74 ManagedRepositoryContent repoContent =
75 provider.createManagedContent( repo );
80 protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
83 MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance(id, name, Paths.get("target/remotes"));
84 repo.setLocation( new URI( url ) );
85 repo.setLayout( layout );
87 RepositoryContentProvider provider = applicationContext.getBean( "repositoryContentProvider#maven", RepositoryContentProvider.class );
88 RemoteRepositoryContent repoContent =
89 provider.createRemoteContent( repo );