1 package org.apache.archiva.repository;
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.admin.model.beans.RemoteRepository;
24 import org.apache.archiva.repository.maven2.MavenManagedRepository;
25 import org.apache.archiva.repository.maven2.MavenRemoteRepository;
26 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
27 import org.junit.Rule;
28 import org.junit.rules.TestName;
29 import org.junit.runner.RunWith;
30 import org.springframework.context.ApplicationContext;
31 import org.springframework.test.context.ContextConfiguration;
33 import javax.inject.Inject;
35 import java.net.URISyntaxException;
36 import java.nio.file.Path;
37 import java.util.Locale;
40 * AbstractRepositoryLayerTestCase
44 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
45 @ContextConfiguration( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } )
46 public abstract class AbstractRepositoryLayerTestCase
49 public TestName name = new TestName();
52 protected ApplicationContext applicationContext;
54 protected MavenManagedRepository createRepository( String id, String name, Path location )
56 MavenManagedRepository repo = new MavenManagedRepository( id, name);
57 repo.setLocation( location.toAbsolutePath().toUri() );
61 protected MavenRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
63 MavenRemoteRepository repo = new MavenRemoteRepository(id, name);
64 repo.setLocation( new URI( url ) );
68 protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, Path location,
72 MavenManagedRepository repo = new MavenManagedRepository( id, name );
73 repo.setLocation( location.toAbsolutePath().toUri() );
74 repo.setLayout( layout );
76 ManagedRepositoryContent repoContent =
77 applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
78 repoContent.setRepository( repo );
83 protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
86 MavenRemoteRepository repo = new MavenRemoteRepository(id, name);
87 repo.setLocation( new URI( url ) );
88 repo.setLayout( layout );
90 RemoteRepositoryContent repoContent =
91 applicationContext.getBean( "remoteRepositoryContent#" + layout, RemoteRepositoryContent.class );
92 repoContent.setRepository( repo );