use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractMavenRepositorySearch method createRepositoryConfig.
protected ManagedRepositoryConfiguration createRepositoryConfig(String repository) {
ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
repositoryConfig.setId(repository);
repositoryConfig.setLocation(org.apache.archiva.common.utils.FileUtils.getBasedir() + "/target/repos/" + repository);
Path f = Paths.get(repositoryConfig.getLocation());
if (!Files.exists(f)) {
try {
Files.createDirectories(f);
} catch (IOException e) {
log.error("Could not create directories for {}", f);
}
}
repositoryConfig.setLayout("default");
repositoryConfig.setName(repository);
repositoryConfig.setScanned(true);
repositoryConfig.setSnapshots(false);
repositoryConfig.setReleases(true);
repositoryConfig.setIndexDir(DEFAULT_INDEX_PATH);
return repositoryConfig;
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractProxyTestCase method setUp.
@Before
public void setUp() throws Exception {
config = (MockConfiguration) applicationContext.getBean("archivaConfiguration#mock", ArchivaConfiguration.class);
config.getConfiguration().setManagedRepositories(new ArrayList<ManagedRepositoryConfiguration>());
config.getConfiguration().setRemoteRepositories(new ArrayList<RemoteRepositoryConfiguration>());
config.getConfiguration().setProxyConnectors(new ArrayList<ProxyConnectorConfiguration>());
ArchivaRuntimeConfiguration runtimeConfiguration = new ArchivaRuntimeConfiguration();
List<String> checksumTypes = new ArrayList<>();
checksumTypes.add("md5");
checksumTypes.add("sha256");
checksumTypes.add("sha1");
checksumTypes.add("asc");
runtimeConfiguration.setChecksumTypes(checksumTypes);
config.getConfiguration().setArchivaRuntimeConfiguration(runtimeConfiguration);
repositoryRegistry.setArchivaConfiguration(config);
// Setup source repository (using default layout)
String name = getClass().getSimpleName();
Path repoPath = Paths.get("target/test-repository/managed/" + name);
managedDefaultRepository = createRepository(ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath.toString(), "default");
managedDefaultDir = repoPath.resolve(ID_DEFAULT_MANAGED);
org.apache.archiva.repository.ManagedRepository repoConfig = repositoryRegistry.getManagedRepository(ID_DEFAULT_MANAGED);
// Setup target (proxied to) repository.
saveRemoteRepositoryConfig(ID_PROXIED1, "Proxied Repository 1", Paths.get(REPOPATH_PROXIED1).toUri().toURL().toExternalForm(), "default");
// Setup target (proxied to) repository.
saveRemoteRepositoryConfig(ID_PROXIED2, "Proxied Repository 2", Paths.get(REPOPATH_PROXIED2).toUri().toURL().toExternalForm(), "default");
repositoryRegistry.reload();
repositoryRegistry.putRepository(repoConfig);
// Setup the proxy handler.
// proxyHandler = applicationContext.getBean (RepositoryProxyHandler) lookup( RepositoryProxyHandler.class.getName() );
proxyHandler = applicationContext.getBean("repositoryProxyHandler#test", RepositoryProxyHandler.class);
assertNotNull(proxyRegistry);
assertTrue(proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).contains(proxyHandler));
// Setup the wagon mock.
wagonMock = mock(Wagon.class);
delegate = (WagonDelegate) applicationContext.getBean("wagon#http", Wagon.class);
delegate.setDelegate(wagonMock);
log.info("\n.\\ {}() \\._________________________________________\n", name);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractProxyTestCase method saveManagedRepositoryConfig.
protected void saveManagedRepositoryConfig(String id, String name, String path, String layout) {
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId(id);
repoConfig.setName(name);
repoConfig.setLayout(layout);
repoConfig.setLocation(path);
int count = config.getConfiguration().getManagedRepositories().size();
config.getConfiguration().addManagedRepository(repoConfig);
String prefix = "managedRepositories.managedRepository(" + count + ")";
config.triggerChange(prefix + ".id", repoConfig.getId());
config.triggerChange(prefix + ".name", repoConfig.getName());
config.triggerChange(prefix + ".location", repoConfig.getLocation());
config.triggerChange(prefix + ".layout", repoConfig.getLayout());
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration 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.ManagedRepositoryConfiguration 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);
}
Aggregations