use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RouteSelectorPerfTest method setUp.
@Before
public void setUp() {
hostedResource = new ConcreteResource(new CacheOnlyLocation(new HostedRepository(MAVEN_PKG_KEY, "hosted")), String.format("/path/to/my/hosted/%s", "index.html"));
remoteResource = new ConcreteResource(new RepositoryLocation(new RemoteRepository(MAVEN_PKG_KEY, "remote", "http://foo.bar/")), String.format("/path/to/my/remote/%s", "index.html"));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class StoreDataSetupAction method migrate.
@Override
public boolean migrate() throws IndyLifecycleException {
final ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Initializing default data.");
boolean changed = false;
try {
logger.info("Verfiying that Indy basic stores are installed...");
storeManager.install();
if (!storeManager.query().packageType(MAVEN_PKG_KEY).storeType(RemoteRepository.class).containsByName("central")) {
final RemoteRepository central = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2/");
central.setCacheTimeoutSeconds(86400);
storeManager.storeArtifactStore(central, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
changed = true;
}
if (!storeManager.query().packageType(MAVEN_PKG_KEY).storeType(HostedRepository.class).containsByName("local-deployments")) {
final HostedRepository local = new HostedRepository(MAVEN_PKG_KEY, "local-deployments");
local.setAllowReleases(true);
local.setAllowSnapshots(true);
local.setSnapshotTimeoutSeconds(86400);
storeManager.storeArtifactStore(local, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
changed = true;
}
if (!storeManager.query().packageType(MAVEN_PKG_KEY).storeType(Group.class).containsByName("public")) {
final Group pub = new Group(MAVEN_PKG_KEY, "public");
pub.addConstituent(new StoreKey(MAVEN_PKG_KEY, StoreType.remote, "central"));
pub.addConstituent(new StoreKey(MAVEN_PKG_KEY, StoreType.hosted, "local-deployments"));
storeManager.storeArtifactStore(pub, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
changed = true;
}
} catch (final IndyDataException e) {
throw new RuntimeException("Failed to boot indy components: " + e.getMessage(), e);
}
return changed;
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class SetBackSettingsManagerTest method settingsForGroup_OneRemoteOneHosted_HostedOmittedButAddedInComment.
@Test
public void settingsForGroup_OneRemoteOneHosted_HostedOmittedButAddedInComment() throws Exception {
final RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://foo.bar/");
remote.setDescription("Test Repository");
final HostedRepository hosted = new HostedRepository(MAVEN_PKG_KEY, "test-hosted");
store(remote);
store(hosted);
final Group group = new Group(MAVEN_PKG_KEY, "test-group", remote.getKey(), hosted.getKey());
store(group);
System.out.println("Group members:\n " + join(group.getConstituents(), "\n "));
assertThat(readSettings(group.getKey(), false), equalTo(null));
final List<String> lines = generateSettings(group.getKey());
assertThat("No repository with id: " + remote.getName() + " found in settings.xml for group!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
assertThat("Repository with id: " + hosted.getName() + " Should not be present in settings.xml for group!", lines.contains("<id>" + remote.getName() + "</id>"), equalTo(true));
assertThat("No entry for remote: " + remote.getKey().toString() + " found in settings.xml constituency comment!", lines.contains("* " + remote.getKey()), equalTo(true));
assertThat("No entry for hosted: " + hosted.getKey().toString() + " found in settings.xml constituency comment!", lines.contains("* " + hosted.getKey()), equalTo(true));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoFilesWithInterleavedVersions.
@Test
public void mergeTwoFilesWithInterleavedVersions() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-skip.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "simple-2.xml");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(3));
assertThat(versioning.getRelease(), equalTo("1.2"));
assertThat(versioning.getLatest(), equalTo("1.2"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
idx++;
assertThat(versions.get(idx), equalTo("1.2"));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MavenMetadataMergerTest method mergeTwoSimpleVersionMetadataFiles.
@Test
public void mergeTwoSimpleVersionMetadataFiles() throws Exception {
String path = "org/foo/bar/maven-metadata.xml";
HostedRepository h1 = new HostedRepository("test-hosted-1");
HostedRepository h2 = new HostedRepository("test-hosted-2");
Transfer t1 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h1), path));
initTestData(t1, VERSION_META + "simple-1.xml");
Transfer t2 = cacheProvider.getTransfer(new ConcreteResource(LocationUtils.toLocation(h2), path));
initTestData(t2, VERSION_META + "simple-2.xml");
Group g = new Group("test-group", h1.getKey(), h2.getKey());
List<Transfer> sources = Arrays.asList(t1, t2);
byte[] output = new MavenMetadataMerger(Collections.emptyList()).merge(sources, g, path);
Metadata merged = new MetadataXpp3Reader().read(new ByteArrayInputStream(output));
assertThat(merged.getGroupId(), equalTo("org.foo"));
assertThat(merged.getArtifactId(), equalTo("bar"));
Versioning versioning = merged.getVersioning();
assertThat(versioning, notNullValue());
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
assertThat(versioning.getRelease(), equalTo("1.1"));
assertThat(versioning.getLatest(), equalTo("1.1"));
int idx = 0;
assertThat(versions.get(idx), equalTo("1.0"));
idx++;
assertThat(versions.get(idx), equalTo("1.1"));
}
Aggregations