use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class DeleteGroupWithContentTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
// Create hosted repo
final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "test_1");
assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
// Store pom file in hosted repo
client.content().store(repo.getKey(), pomPath, new ByteArrayInputStream(pomContent.getBytes()));
// Generate metadata file in hosted repo
try (InputStream in = client.content().get(repo.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the hosted meta file exists
ConcreteResource r_meta_hosted = new ConcreteResource(LocationUtils.toLocation(repo), metadataPath);
assertTrue(cacheProvider.exists(r_meta_hosted));
// Create group with hosted member
final Group group = new Group(MAVEN_PKG_KEY, "test_1", repo.getKey());
assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
// Generate group metadata file
try (InputStream in = client.content().get(group.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the group meta file exists
ConcreteResource r_meta = new ConcreteResource(LocationUtils.toLocation(group), metadataPath);
assertTrue(cacheProvider.exists(r_meta));
// Delete group
client.stores().delete(group.getKey(), "Delete", true);
assertThat(client.stores().exists(group.getKey()), equalTo(false));
// Verify the group meta file gone
assertFalse(cacheProvider.exists(r_meta));
// Verify hosted files not change (delete group not affect the files in hosted repo)
ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), pomPath);
assertTrue(cacheProvider.exists(r1));
assertTrue(cacheProvider.exists(r_meta_hosted));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupMetadataMergeWithRepoTimeoutTest method run.
@Test
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 */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.expect("GET", server.formatUrl(repo2, path), (request, response) -> {
try {
Thread.sleep(5000);
} catch (final InterruptedException e) {
}
response.setStatus(404);
});
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.setTimeoutSeconds(2);
remote2.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));
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 "));
final InputStream stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
final String metadata = IOUtils.toString(stream);
assertThat(metadata, equalTo(repo1Content));
stream.close();
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class NestedStoreInGroupWithErrorTest method run.
@Test
public void run() throws Exception {
final String path = "org/foo/bar/pom.xml";
final String repo1 = "repo1";
final String content = "This is a test: " + System.nanoTime();
final InputStream stream = new ByteArrayInputStream(content.getBytes());
server.expect(server.formatUrl(repo1, path), 200, stream);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1 = client.stores().create(remote1, "adding remote2", RemoteRepository.class);
final String repo2 = "repo2";
server.registerException(server.formatUrl(repo2, path), "upstream error", HttpStatus.SC_UNAUTHORIZED);
RemoteRepository remote2 = new RemoteRepository(repo2, server.formatUrl(repo2));
remote2.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));
remote2 = client.stores().create(remote2, "adding remote2", RemoteRepository.class);
final String gName = "test";
Group tgroup = new Group(gName, Arrays.asList(remote2.getKey(), remote1.getKey()));
client.stores().create(tgroup, "new group with remote2", Group.class);
try (InputStream is = client.content().get(group, gName, path)) {
assertThat(IOUtils.toString(is), equalTo(content));
}
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupMetadataMergeWithRepoErrorTest method run.
@Test
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 */
server.expect(server.formatUrl(repo1, path), 200, repo1Content);
server.registerException(server.formatUrl(repo2, path), "Server error");
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.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1));
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 "));
final InputStream stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
final String metadata = IOUtils.toString(stream);
assertThat(metadata, equalTo(repo1Content));
stream.close();
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ArtifactRefs_DependencyTwoExtraGroups_RuleTest method start.
@Override
public void start() throws Throwable {
super.start();
otherSource = new HostedRepository("otherSource");
otherSource = client.stores().create(otherSource, "Creating secondary content source", HostedRepository.class);
other = new Group("other", otherSource.getKey());
other = client.stores().create(other, "Creating secondary content group", Group.class);
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("{} contains members: {}", other, other.getConstituents());
thirdSource = new HostedRepository("thirdSource");
thirdSource = client.stores().create(thirdSource, "Creating tertiary content source", HostedRepository.class);
third = new Group("third", thirdSource.getKey());
third = client.stores().create(third, "Creating tertiary content group", Group.class);
logger.info("{} contains members: {}", third, third.getConstituents());
}
Aggregations