use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class RemoteRepositoryHandlerTest method putWithConfiguration.
@Test
void putWithConfiguration() throws RepositoryException {
String id = "test-repo-05";
try {
RemoteRepositoryHandler repoHandler = createHandler();
RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration);
RemoteRepository repo = repoHandler.get(id);
assertNotNull(repo);
assertEquals(id, repo.getId());
assertEquals("n-" + id, repo.getName());
assertTrue(hasRepositoryInConfig(id));
} finally {
removeRepositoryFromConfig(id);
}
}
use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class RemoteRepositoryHandlerTest method removeWithoutSave.
@Test
void removeWithoutSave() throws RepositoryException {
final String id = "test-repo-09";
RemoteRepositoryHandler repoHandler = createHandler();
Configuration aCfg = new Configuration();
RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration, aCfg);
assertTrue(aCfg.getRemoteRepositories().stream().anyMatch(g -> g != null && id.equals(g.getId())));
repoHandler.remove(id, aCfg);
assertNull(repoHandler.get(id));
assertTrue(aCfg.getRemoteRepositories().stream().noneMatch(g -> g != null && id.equals(g.getId())));
assertNull(repoHandler.get(id));
}
use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class ArchivaRepositoryRegistryTest method putRemoteRepositoryFromConfig.
@Test
public void putRemoteRepositoryFromConfig() throws Exception {
RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration();
cfg.setId("test002");
cfg.setName("This is test 002");
RemoteRepository repo = repositoryRegistry.putRepository(cfg);
assertNotNull(repo);
assertEquals("test002", repo.getId());
assertEquals("This is test 002", repo.getName());
assertNotNull(repo.getContent());
archivaConfiguration.reload();
Collection<RemoteRepository> repos = repositoryRegistry.getRemoteRepositories();
assertEquals(2, repos.size());
RemoteRepository internalRepo = repositoryRegistry.getRemoteRepository("central");
cfg = new RemoteRepositoryConfiguration();
cfg.setId("central");
cfg.setName("This is central test 002");
repo = repositoryRegistry.putRepository(cfg);
assertEquals("This is central test 002", repo.getName());
assertEquals(2, repositoryRegistry.getRemoteRepositories().size());
repositoryRegistry.reload();
assertEquals(2, repositoryRegistry.getRemoteRepositories().size());
}
use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class MavenProxyPropertyLoaderTest method testLoadValidMavenProxyConfiguration.
@Test
public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException {
Path confFile = ArchivaConfigurationTest.getTestFile("src/test/conf/maven-proxy-complete.conf");
Configuration configuration = new Configuration();
NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
proxy.setHost("original-host");
// overwritten
configuration.addNetworkProxy(proxy);
loader.load(Files.newInputStream(confFile), configuration);
Map<String, ManagedRepositoryConfiguration> repositoryIdMap = configuration.getManagedRepositoriesAsMap();
assertEquals("Count repositories", 1, repositoryIdMap.size());
assertRepositoryExists("maven-proxy", "target", repositoryIdMap.get("maven-proxy"));
Map<String, RemoteRepositoryConfiguration> remoteRepositoryMap = configuration.getRemoteRepositoriesAsMap();
assertEquals("Count repositories", 4, remoteRepositoryMap.size());
assertRepositoryExists("local-repo", "file://target", remoteRepositoryMap.get("local-repo"));
assertRepositoryExists("www-ibiblio-org", "http://www.ibiblio.org/maven2", remoteRepositoryMap.get("www-ibiblio-org"));
assertRepositoryExists("dist-codehaus-org", "http://dist.codehaus.org", remoteRepositoryMap.get("dist-codehaus-org"));
assertRepositoryExists("private-example-com", "http://private.example.com/internal", remoteRepositoryMap.get("private-example-com"));
}
use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method testGetProjectVersionMetadataWithParentNoRemoteReposConfigured.
@Test
public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured() throws Exception {
// remove configuration
Configuration config = configuration.getConfiguration();
RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById(TEST_REMOTE_REPO_ID);
config.removeRemoteRepository(remoteRepo);
configuration.save(config);
copyTestArtifactWithParent("src/test/resources/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
copyTestArtifactWithParent("src/test/resources/com/example/test/test-artifact-root", "target/test-repository/com/example/test/test-artifact-root");
copyTestArtifactWithParent("src/test/resources/com/example/test/test-artifact-parent", "target/test-repository/com/example/test/test-artifact-parent");
ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(TEST_REPO_ID).namespace("com.example.test").projectId("test-artifact-module-a").projectVersion("1.0");
ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(readMetadataRequest);
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);
}
Aggregations