use of org.apache.archiva.configuration.RemoteRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method getRemoteConfiguration.
@Test
public void getRemoteConfiguration() throws Exception {
MavenRemoteRepository repo = new MavenRemoteRepository("test01", "My Test repo", Paths.get("target/remotes"));
repo.setLocation(new URI("https://this.is/a/test"));
repo.setScanned(true);
repo.setDescription(repo.getPrimaryLocale(), "This is a description");
repo.setLayout("maven2");
repo.setName(repo.getPrimaryLocale(), "test0003");
repo.setSchedulingDefinition("0 0 05 ? * WED");
RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class).get();
remoteIndexFeature.setProxyId("proxyabc");
remoteIndexFeature.setDownloadTimeout(Duration.ofSeconds(54));
remoteIndexFeature.setDownloadRemoteIndex(false);
remoteIndexFeature.setIndexUri(new URI("/this/remote/.index"));
remoteIndexFeature.setDownloadRemoteIndexOnStartup(true);
IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get();
indexCreationFeature.setIndexPath(new URI("/this/local/.index"));
RemoteRepositoryConfiguration cfg = provider.getRemoteConfiguration(repo);
assertEquals("https://this.is/a/test", cfg.getUrl());
assertEquals("This is a description", cfg.getDescription());
assertEquals("maven2", cfg.getLayout());
assertEquals("test0003", cfg.getName());
assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression());
assertEquals("/this/remote/.index", cfg.getRemoteIndexUrl());
assertEquals("proxyabc", cfg.getRemoteDownloadNetworkProxyId());
assertEquals(54, cfg.getRemoteDownloadTimeout());
assertFalse(cfg.isDownloadRemoteIndex());
assertTrue(cfg.isDownloadRemoteIndexOnStartup());
assertEquals("/this/local/.index", cfg.getIndexDir());
}
use of org.apache.archiva.configuration.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);
}
use of org.apache.archiva.configuration.RemoteRepositoryConfiguration 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);
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.RemoteRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
c.setVersion("2.0");
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);
RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
c.setRepositoryScanning(scCfg);
configuration.save(c);
assertFalse(configuration.isDefaulted());
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).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.RemoteRepositoryConfiguration in project archiva by apache.
the class RepositoryProviderMock method getRemoteConfiguration.
@Override
public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException {
RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration();
configuration.setId(remoteRepository.getId());
configuration.setName(remoteRepository.getName());
configuration.setDescription(remoteRepository.getDescription());
configuration.setLayout(remoteRepository.getLayout());
configuration.setRefreshCronExpression(remoteRepository.getSchedulingDefinition());
configuration.setCheckPath(remoteRepository.getCheckPath());
configuration.setExtraHeaders(remoteRepository.getExtraHeaders());
configuration.setExtraParameters(remoteRepository.getExtraParameters());
configuration.setTimeout((int) remoteRepository.getTimeout().getSeconds());
RepositoryCredentials creds = remoteRepository.getLoginCredentials();
if (creds != null) {
PasswordCredentials pwdCreds = (PasswordCredentials) creds;
configuration.setUsername(pwdCreds.getUsername());
configuration.setPassword(new String(pwdCreds.getPassword()));
}
configuration.setUrl(remoteRepository.getLocation() == null ? "" : remoteRepository.getLocation().toString());
RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
configuration.setDownloadRemoteIndex(rif.isDownloadRemoteIndex());
configuration.setDownloadRemoteIndexOnStartup(rif.isDownloadRemoteIndexOnStartup());
configuration.setIndexDir(rif.getIndexUri() == null ? "" : rif.getIndexUri().toString());
configuration.setRemoteDownloadNetworkProxyId(rif.getProxyId());
return configuration;
}
Aggregations