use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupMetadataMergeWhenGroupWithGroupMemberChangesTest method run.
@Test
public void run() throws Exception {
final String repoA = "hostedA";
final String repoB = "hostedB";
final String repoC = "hostedC";
final String path = "org/foo/bar/maven-metadata.xml";
/* @formatter:off */
final String repoAContent = "<?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>20150721164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repoBContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>2.0</latest>\n" + " <release>2.0</release>\n" + " <versions>\n" + " <version>2.0</version>\n" + " </versions>\n" + " <lastUpdated>20160722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
/* @formatter:off */
final String repoCContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>3.0</latest>\n" + " <release>3.0</release>\n" + " <versions>\n" + " <version>3.0</version>\n" + " </versions>\n" + " <lastUpdated>20160723164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
HostedRepository hostedA = createHostedAndStorePath(repoA, path, repoAContent);
try (final InputStream stream = client.content().get(hostedA.getKey(), path)) {
assertContent(repoAContent, IOUtils.toString(stream));
}
HostedRepository hostedB = createHostedAndStorePath(repoB, path, repoBContent);
try (final InputStream stream = client.content().get(hostedB.getKey(), path)) {
assertContent(repoBContent, IOUtils.toString(stream));
}
HostedRepository hostedC = createHostedAndStorePath(repoC, path, repoCContent);
try (final InputStream stream = client.content().get(hostedC.getKey(), path)) {
assertContent(repoCContent, IOUtils.toString(stream));
}
Group gX = new Group("groupX", hostedA.getKey(), hostedB.getKey());
gX = client.stores().create(gX, "adding group X", Group.class);
logger.debug("\n\nGroup constituents are:\n {}\n\n", StringUtils.join(gX.getConstituents(), "\n "));
Group gY = new Group("groupY", gX.getKey());
gY = client.stores().create(gY, "adding group Y", Group.class);
logger.debug("\n\nGroup constituents are:\n {}\n\n", StringUtils.join(gY.getConstituents(), "\n "));
/* @formatter:off */
final String mergedContent1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>2.0</latest>\n" + " <release>2.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>2.0</version>\n" + " </versions>\n" + " <lastUpdated>20160722164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
/* @formatter:on */
try (final InputStream stream = client.content().get(group, gY.getName(), path)) {
assertContent(mergedContent1, IOUtils.toString(stream));
}
gX.addConstituent(hostedC);
client.stores().update(gX, "test update");
gX = client.stores().load(StoreType.group, gX.getName(), Group.class);
logger.debug("\n\nGroup constituents are:\n {}\n\n", StringUtils.join(gX.getConstituents(), "\n "));
waitForEventPropagation();
/* @formatter:off */
final String mergedContent2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <metadata>\n" + " <groupId>org.foo</groupId>\n" + " <artifactId>bar</artifactId>\n" + " <versioning>\n" + " <latest>3.0</latest>\n" + " <release>3.0</release>\n" + " <versions>\n" + " <version>1.0</version>\n" + " <version>2.0</version>\n" + " <version>3.0</version>\n" + " </versions>\n" + " <lastUpdated>20160723164334</lastUpdated>\n" + " </versioning>\n" + "</metadata>\n";
try (final InputStream stream = client.content().get(group, gY.getName(), path)) {
assertContent(mergedContent2, IOUtils.toString(stream));
}
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractContentManagementTest method before.
@Before
public void before() throws Exception {
if (!createStandardTestStructures()) {
return;
}
final String changelog = "Create test structures";
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
client.stores().delete(remote, CENTRAL, "removing to setup test instance");
final RemoteRepository central = client.stores().create(new RemoteRepository(CENTRAL, server.formatUrl("central")), changelog, RemoteRepository.class);
Group g;
if (client.stores().exists(group, PUBLIC)) {
System.out.println("Loading pre-existing public group.");
g = client.stores().load(group, PUBLIC, Group.class);
} else {
System.out.println("Creating new group 'public'");
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class DownloadFromSecondRemoteAfterFirstHostedRepoTest method setupTest.
@Before
public void setupTest() throws Exception {
String change = "test setup";
hosted = client.stores().create(new HostedRepository(HOSTED), change, HostedRepository.class);
remote = client.stores().create(new RemoteRepository(REMOTE, server.formatUrl(REMOTE)), change, RemoteRepository.class);
group = client.stores().create(new Group(GROUP, hosted.getKey(), remote.getKey()), change, Group.class);
client.content().store(hosted.getKey(), JAR_PATH, new ByteArrayInputStream("This is the jar".getBytes()));
server.expect(server.formatUrl(REMOTE, PATH), 200, CONTENT);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ContentDeletionUpdateGroupMetadataTest method prepare.
final void prepare() throws Exception {
server.expect(server.formatUrl(repoA, path), 200, repoAContent);
server.expect(server.formatUrl(repoB, path), 200, repoBContent);
r1 = new RemoteRepository(repoA, server.formatUrl(repoA));
r2 = new RemoteRepository(repoB, server.formatUrl(repoB));
client.stores().create(r1, "adding remote-A", RemoteRepository.class);
client.stores().create(r2, "adding remote-B", RemoteRepository.class);
g = client.stores().create(new Group(groupName, r1.getKey(), r2.getKey()), "adding group", Group.class);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ContentNotAvailableInGroupWithDisabledRemoteTest method contentAccess.
@Test
public void contentAccess() throws Exception {
final String remoteName = "r";
final String groupName = "g";
final String path = "org/foo/bar/foo-bar-1.txt";
final String content = "This is a test";
server.expect(server.formatUrl(remoteName, path), 200, content);
RemoteRepository r = new RemoteRepository(remoteName, server.formatUrl(remoteName));
r = client.stores().create(r, "adding remote", RemoteRepository.class);
Group g = new Group(groupName, r.getKey());
g = client.stores().create(g, "adding group", Group.class);
try (InputStream in = client.content().get(g.getKey(), path)) {
assertThat(IOUtils.toString(in), equalTo(content));
}
r.setDisabled(true);
client.stores().update(r, "adding remote");
assertThat(client.content().exists(g.getKey(), path), equalTo(false));
}
Aggregations