use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration 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.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);
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.RemoteRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method createRemoteInstance.
@Test
public void createRemoteInstance() throws Exception {
RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
repo.setUsername("testuser001");
repo.setPassword("pwd0000abc");
repo.setCheckPath("test/check.html");
repo.setTimeout(50);
repo.setUrl("https://repo.maven.apache.org/maven2/test");
repo.setDownloadRemoteIndex(true);
repo.setDownloadRemoteIndexOnStartup(true);
Map<String, String> header = new HashMap<>();
header.put("header1", "value1");
header.put("header2", "value2");
repo.setExtraHeaders(header);
Map<String, String> params = new HashMap<>();
params.put("param1", "pval1");
params.put("param2", "pval2");
repo.setExtraParameters(params);
repo.setRefreshCronExpression("0 1 07 ? * MON");
repo.setRemoteDownloadTimeout(333);
repo.setRemoteIndexUrl("testremote/.index");
repo.setDescription("This is a test");
repo.setId("test001");
repo.setName("Remote Test Repo 001");
repo.setIndexDir("testindex/.index");
repo.setLayout("maven2");
repo.setType(RepositoryType.MAVEN.toString());
repo.setIndexDir("local/.index");
RemoteRepository mr = provider.createRemoteInstance(repo);
assertEquals("test001", mr.getId());
assertEquals("This is a test", mr.getDescription());
assertNotNull(mr.getLocation());
assertEquals("https://repo.maven.apache.org/maven2/test", mr.getLocation().toString());
assertEquals("Remote Test Repo 001", mr.getName());
assertEquals("test001", mr.getId());
assertEquals("0 1 07 ? * MON", mr.getSchedulingDefinition());
assertEquals(50, mr.getTimeout().get(ChronoUnit.SECONDS));
assertTrue(mr.isScanned());
assertNotNull(mr.getLoginCredentials());
assertTrue(mr.getLoginCredentials() instanceof PasswordCredentials);
PasswordCredentials creds = (PasswordCredentials) mr.getLoginCredentials();
assertEquals("testuser001", creds.getUsername());
assertEquals("pwd0000abc", new String(creds.getPassword()));
assertEquals("value1", mr.getExtraHeaders().get("header1"));
assertEquals("pval2", mr.getExtraParameters().get("param2"));
assertEquals("maven2", mr.getLayout());
try {
ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature(ArtifactCleanupFeature.class);
throw new Exception("artifactCleanupFeature should not be available");
} catch (UnsupportedFeatureException e) {
// correct
}
IndexCreationFeature indexCreationFeature = mr.getFeature(IndexCreationFeature.class);
assertEquals("local/.index", indexCreationFeature.getIndexPath().toString());
try {
StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature(StagingRepositoryFeature.class);
throw new Exception("stagingRepositoryFeature should not be available");
} catch (UnsupportedFeatureException e) {
// correct
}
RemoteIndexFeature remoteIndexFeature = mr.getFeature(RemoteIndexFeature.class);
assertNull(remoteIndexFeature.getProxyId());
}
use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method getRemoteConfiguration.
@Test
public void getRemoteConfiguration() throws Exception {
MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance("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);
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);
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.model.RemoteRepositoryConfiguration in project archiva by apache.
the class MockRepoAdmin method getRemoteRepositories.
@Override
public List<RemoteRepository> getRemoteRepositories() throws RepositoryAdminException {
List<RemoteRepository> remoteRepositories = new ArrayList<>(archivaConfiguration.getConfiguration().getRemoteRepositories().size());
for (RemoteRepositoryConfiguration repositoryConfiguration : archivaConfiguration.getConfiguration().getRemoteRepositories()) {
RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault(), repositoryConfiguration.getId(), repositoryConfiguration.getName(), repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(), repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(), repositoryConfiguration.getTimeout());
remoteRepository.setDownloadRemoteIndex(repositoryConfiguration.isDownloadRemoteIndex());
remoteRepository.setRemoteIndexUrl(repositoryConfiguration.getRemoteIndexUrl());
remoteRepository.setCronExpression(repositoryConfiguration.getRefreshCronExpression());
remoteRepository.setIndexDirectory(repositoryConfiguration.getIndexDir());
remoteRepository.setRemoteDownloadNetworkProxyId(repositoryConfiguration.getRemoteDownloadNetworkProxyId());
remoteRepository.setRemoteDownloadTimeout(repositoryConfiguration.getRemoteDownloadTimeout());
remoteRepository.setDownloadRemoteIndexOnStartup(repositoryConfiguration.isDownloadRemoteIndexOnStartup());
remoteRepositories.add(remoteRepository);
}
return remoteRepositories;
}
Aggregations