use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class GroupDataManagerTCK method seedRepositoriesForGroupTests.
protected void seedRepositoriesForGroupTests() throws Exception {
manager = getFixtureProvider().getDataManager();
manager.storeArtifactStore(new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo1.maven.apache.org/maven2/"), summary, false, false, new EventMetadata());
manager.storeArtifactStore(new RemoteRepository(MAVEN_PKG_KEY, "repo2", "http://repo1.maven.org/maven2/"), summary, false, false, new EventMetadata());
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class RepositoryDataManagerTCK method createTwoReposAndRetrieveAll.
@Test
public void createTwoReposAndRetrieveAll() throws Exception {
final StoreDataManager manager = getFixtureProvider().getDataManager();
final RemoteRepository repo = new RemoteRepository("central", "http://repo1.maven.apache.org/maven2/");
storeRemoteRepository(repo);
final RemoteRepository repo2 = new RemoteRepository("test", "http://www.google.com");
storeRemoteRepository(repo2);
final List<RemoteRepository> repositories = manager.query().packageType(MAVEN_PKG_KEY).storeType(RemoteRepository.class).getAll();
assertThat(repositories, notNullValue());
assertThat(repositories.size(), equalTo(2));
Collections.sort(repositories, new Comparator<RemoteRepository>() {
@Override
public int compare(final RemoteRepository r1, final RemoteRepository r2) {
return r1.getName().compareTo(r2.getName());
}
});
ArtifactStore r = repositories.get(0);
assertThat(r.getName(), equalTo(repo.getName()));
r = repositories.get(1);
assertThat(r.getName(), equalTo(repo2.getName()));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class ProxyRemoteKojiContentTest method proxyBinaryRemoteKojiArtifact.
@Ignore
@Test
public void proxyBinaryRemoteKojiArtifact() throws Exception {
final String path = "org/apache/apache/18/apache-18.pom";
Indy client = new Indy("http://localhost:8080/api", new IndyObjectMapper(Collections.emptySet()), Collections.emptySet()).connect();
long elapse = getContent("build-x", client, path);
// the remote store should have been added to brew-binaries group
StoreListingDTO<RemoteRepository> repos = client.stores().listRemoteRepositories();
for (RemoteRepository repo : repos.getItems()) {
logger.debug("Repo " + repo.getName());
if (repo.getName().startsWith(KOJI_ORIGIN)) {
logger.debug("Koji repo patterns: " + repo.getPathMaskPatterns());
}
}
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class GroupMetaOverlapWithMetaOfHostedReposTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
final String repo1 = "repo1";
final String repo2 = "repo2";
final String path = "org/foo/bar/maven-metadata.xml";
/* @formatter:off */
final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.0</latest>\n" + " <release>1.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " </versions>\n" + " <lastUpdated>20150722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.expect(server.formatUrl(repo2, path), 200, repo2Content);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
Group g = new Group("test", remote1.getKey(), remote2.getKey());
g = client.stores().create(g, "adding group", Group.class);
System.out.printf("\n\nGroup constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
InputStream stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
String metadata = IOUtils.toString(stream);
/* @formatter:off */
final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(groupContent));
final String hostedRepo = "hostedRepo";
HostedRepository hostedRepository = new HostedRepository(hostedRepo);
hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
/* @formatter:off */
final String hostedMetaContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
client.content().store(hostedRepository.getKey(), path, new ByteArrayInputStream(hostedMetaContent.getBytes("UTF-8")));
final PathInfo p = client.content().getInfo(hosted, hostedRepo, path);
assertThat("hosted metadata should exist", p.exists(), equalTo(true));
g.addConstituent(hostedRepository);
client.stores().update(g, "add new hosted");
System.out.printf("\n\nUpdated group constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
waitForEventPropagation();
final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s-%s/%s", fixture.getBootOptions().getIndyHome(), group.name(), g.getName(), path);
assertThat("group metadata should be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(false));
stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
metadata = IOUtils.toString(stream);
/* @formatter:off */
final String updGroupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(updGroupContent));
}
use of org.commonjava.indy.model.core.RemoteRepository in project indy by Commonjava.
the class GroupMetaOverlapWithNestedGroupOfHostRepoMetaTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
final String repo1 = "repo1";
final String repo2 = "repo2";
final String path = "org/foo/bar/maven-metadata.xml";
/* @formatter:off */
final String repo1Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.0</latest>\n" + " <release>1.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " </versions>\n" + " <lastUpdated>20150722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repo2Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.expect(server.formatUrl(repo2, path), 200, repo2Content);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2 = client.stores().create(remote2, "adding remote", RemoteRepository.class);
// constructs 3 level group structure: top -> middle -> bottom
// and the bottom group contains repo1 and repo2
Group bottomGroup = new Group("bottom", remote1.getKey(), remote2.getKey());
bottomGroup = client.stores().create(bottomGroup, "adding bottom group", Group.class);
System.out.printf("\n\nBottom group constituents are:\n %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n "));
Group middleGroup = new Group("middle", bottomGroup.getKey());
middleGroup = client.stores().create(middleGroup, "adding middle group", Group.class);
System.out.printf("\n\nMiddle group constituents are:\n %s\n\n", StringUtils.join(middleGroup.getConstituents(), "\n "));
Group topGroup = new Group("top", middleGroup.getKey());
topGroup = client.stores().create(topGroup, "adding top group", Group.class);
System.out.printf("\n\nTop group constituents are:\n %s\n\n", StringUtils.join(topGroup.getConstituents(), "\n "));
InputStream stream = client.content().get(group, topGroup.getName(), path);
assertThat(stream, notNullValue());
String metadata = IOUtils.toString(stream);
stream.close();
/* @formatter:off */
final String groupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.1</latest>\n" + " <release>1.1</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " </versions>\n" + " <lastUpdated>20150822164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(groupContent));
final String hostedRepo = "hostedRepo";
HostedRepository hostedRepository = new HostedRepository(hostedRepo);
hostedRepository = client.stores().create(hostedRepository, "adding hosted", HostedRepository.class);
/* @formatter:off */
final String hostedMetaContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
client.content().store(hostedRepository.getKey(), path, new ByteArrayInputStream(hostedMetaContent.getBytes("UTF-8")));
final PathInfo p = client.content().getInfo(hosted, hostedRepo, path);
assertThat("hosted metadata should exist", p.exists(), equalTo(true));
// added hosted repo to bottom group and update
bottomGroup.addConstituent(hostedRepository);
client.stores().update(bottomGroup, "add new hosted to bottom");
System.out.printf("\n\nUpdated bottom group constituents are:\n %s\n\n", StringUtils.join(bottomGroup.getConstituents(), "\n "));
waitForEventPropagation();
// the top group should reflect the meta file deprecation and re-indexing
final String gpLevelMetaFilePath = String.format("%s/var/lib/indy/storage/%s-%s/%s", fixture.getBootOptions().getIndyHome(), group.name(), topGroup.getName(), path);
assertThat("group metadata should be removed after merging", new File(gpLevelMetaFilePath).exists(), equalTo(false));
stream = client.content().get(group, topGroup.getName(), path);
assertThat(stream, notNullValue());
metadata = IOUtils.toString(stream);
stream.close();
/* @formatter:off */
final String updGroupContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>1.2</latest>\n" + " <release>1.2</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>1.1</version>\n" + " <version>1.2</version>\n" + " </versions>\n" + " <lastUpdated>20150922164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
assertThat(metadata, equalTo(updGroupContent));
}
Aggregations