use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RepoProxyPatternsTest method setupRepos.
@Before
public void setupRepos() throws Exception {
server.expect(server.formatUrl(REPO_NAME, PATH1), 200, new ByteArrayInputStream(CONTENT1.getBytes()));
remote = client.stores().create(new RemoteRepository(PKG_TYPE_MAVEN, REPO_NAME, server.formatUrl(REPO_NAME)), "remote pnc-builds", RemoteRepository.class);
// hosted = new HostedRepository( MavenPackageTypeDescriptor.MAVEN_PKG_KEY, REPO_NAME );
hosted = client.stores().create(new HostedRepository(PKG_TYPE_MAVEN, REPO_NAME), "hosted pnc-builds", HostedRepository.class);
client.content().store(hosted.getKey(), PATH2, new ByteArrayInputStream(CONTENT2.getBytes()));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupContentCopiedEarlierInMembershipIsReturnedTest method setupStores.
@Before
public void setupStores() throws IndyClientException, UnsupportedEncodingException {
String changelog = "test setup";
repoX = client.stores().create(new HostedRepository(REPO_X), changelog, HostedRepository.class);
repoY = client.stores().create(new HostedRepository(REPO_Y), changelog, HostedRepository.class);
groupA = client.stores().create(new Group(GROUP_A, repoX.getKey()), changelog, Group.class);
groupB = client.stores().create(new Group(GROUP_B, repoY.getKey(), groupA.getKey()), changelog, Group.class);
client.content().store(repoX.getKey(), PATH, new ByteArrayInputStream(CONTENT_1.getBytes("UTF-8")));
content2 = CONTENT_2.getBytes("UTF-8");
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupMetadataMergeInfoGenTest 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);
HostedRepository hostedB = createHostedAndStorePath(repoB, path, repoBContent);
HostedRepository hostedC = createHostedAndStorePath(repoC, path, repoCContent);
Group g = new Group("test", hostedA.getKey());
g = client.stores().create(g, "adding group", Group.class);
try (final InputStream stream = client.content().get(group, g.getName(), path)) {
System.out.println(IOUtils.toString(stream));
}
assertInfoContent(g, path, "maven:hosted:hostedA\n");
g.addConstituent(hostedB.getKey());
g = updateAndRetrieve(g, "adding group", path);
assertInfoContent(g, path, "maven:hosted:hostedA\nmaven:hosted:hostedB\n");
g.removeConstituent(hostedA.getKey());
g = updateAndRetrieve(g, "removing group", path);
assertInfoContent(g, path, "maven:hosted:hostedB\n");
g.addConstituent(hostedC.getKey());
g = updateAndRetrieve(g, "adding group", path);
assertInfoContent(g, path, "maven:hosted:hostedB\nmaven:hosted:hostedC\n");
hostedB.setDisabled(true);
client.stores().update(hostedB, "disabled");
try (final InputStream stream = client.content().get(group, g.getName(), path)) {
System.out.println(IOUtils.toString(stream));
}
assertInfoContent(g, path, "maven:hosted:hostedC\n");
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupMetadataMergeWhenGroupWithGroupMemberChangesTest method createHostedAndStorePath.
private HostedRepository createHostedAndStorePath(final String repoName, final String path, final String content) throws Exception {
HostedRepository hosted = new HostedRepository(repoName);
hosted = client.stores().create(hosted, "adding " + repoName, HostedRepository.class);
if (StringUtils.isNotBlank(content)) {
client.content().store(hosted.getKey(), path, new ByteArrayInputStream(content.getBytes()));
}
return hosted;
}
use of org.commonjava.indy.model.core.HostedRepository 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));
}
}
Aggregations