use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class AbstractMavenRepositorySearch method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer"));
assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer")));
Files.createDirectories(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer"));
FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer"));
assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer")));
Files.createDirectories(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer"));
archivaConfig = mock(ArchivaConfiguration.class);
repositoryRegistry.setArchivaConfiguration(archivaConfig);
search = new MavenRepositorySearch(indexer, repositoryRegistry, proxyRegistry, queryCreator);
assertNotNull(repositoryRegistry);
config = new Configuration();
config.addManagedRepository(createRepositoryConfig(TEST_REPO_1));
config.addManagedRepository(createRepositoryConfig(TEST_REPO_2));
config.addManagedRepository(createRepositoryConfig(REPO_RELEASE));
when(archivaConfig.getDefaultLocale()).thenReturn(Locale.getDefault());
when(archivaConfig.getConfiguration()).thenReturn(config);
archivaConfig.save(any(Configuration.class), anyString());
repositoryRegistry.reload();
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(false);
c.addManagedRepository(testRepo);
testRepoS = new ManagedRepositoryConfiguration();
testRepoS.setId(TEST_SNAP_REPO_ID);
testRepoS.setLocation(Paths.get("target/test-repositorys").toAbsolutePath().toString());
testRepoS.setReleases(false);
testRepoS.setSnapshots(true);
c.addManagedRepository(testRepoS);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
proxyConnectors.setSourceRepoId(TEST_SNAP_REPO_ID);
proxyConnectors.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnectors.setDisabled(false);
c.addProxyConnector(proxyConnectors);
List<String> repos = new ArrayList<>();
repos.add(TEST_REPO_ID);
repos.add(TEST_SNAP_REPO_ID);
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
repoGroup.setId(TEST_REPO_GROUP_ID);
repoGroup.setRepositories(repos);
c.addRepositoryGroup(repoGroup);
configuration.save(c);
repositoryRegistry.reload();
assertFalse(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
assertTrue(c.getManagedRepositories().get(1).isSnapshots());
assertFalse(c.getManagedRepositories().get(1).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentNoRemoteReposConfigured.
@Test
public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured() throws Exception {
assertNotNull(storage);
// remove configuration
Configuration config = configuration.getConfiguration();
RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById(TEST_REMOTE_REPO_ID);
config.removeRemoteRepository(remoteRepo);
configuration.save(config);
assertNotNull(storage);
copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0"));
assertEquals("1.0", metadata.getId());
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
assertNotNull(facet);
assertEquals("com.example.test", facet.getGroupId());
assertEquals("test-artifact-module-a", facet.getArtifactId());
assertEquals("jar", facet.getPackaging());
List<String> paths = new ArrayList<>();
paths.add("target/test-repository/com/example/test/test-artifact-module-a");
paths.add("target/test-repository/com/example/test/test-artifact-parent");
paths.add("target/test-repository/com/example/test/test-artifact-root");
deleteTestArtifactWithParent(paths);
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411Test method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(true);
c.addManagedRepository(testRepo);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
configuration.save(c);
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
wagonFactory = mock(WagonFactory.class);
assertNotNull(storage);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest("wagon#http", new HashMap<String, String>()))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class RepositoryServletRepositoryGroupTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String appserverBase = getAppserverBase().toAbsolutePath().toString();
log.debug("Appserver Base {}", appserverBase);
Configuration configuration = archivaConfiguration.getConfiguration();
repoRootFirst = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_FIRST);
repoRootLast = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_LAST);
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
List<String> managedRepoIds = new ArrayList<>();
managedRepoIds.add(MANAGED_REPO_FIRST);
managedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_VALID_REPOS, managedRepoIds));
// Create the repository group with an invalid managed repository
repoRootInvalid = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_INVALID);
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository(MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true);
configuration.addManagedRepository(managedRepositoryConfiguration);
List<String> invalidManagedRepoIds = new ArrayList<>();
invalidManagedRepoIds.add(MANAGED_REPO_FIRST);
invalidManagedRepoIds.add(MANAGED_REPO_INVALID);
invalidManagedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds));
configuration.removeManagedRepository(managedRepositoryConfiguration);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRootInvalid);
repositoryRegistry.reload();
saveConfiguration(archivaConfiguration);
startRepository();
}
Aggregations