use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class RepoProxyCreatorWithNPMContentRewriteTest method run.
@Test
public void run() throws Exception {
final String remoteName = String.format("%s-%s", StoreType.group, REPO_NAME);
final StoreKey remoteKey = new StoreKey(NPMPackageTypeDescriptor.NPM_PKG_KEY, StoreType.remote, remoteName);
RemoteRepository remote = client.stores().load(remoteKey, RemoteRepository.class);
assertThat(remote, nullValue());
final String REMOTE_REPO_PATH = normalize(fixture.getUrl(), "content/npm/remote", remoteName);
final String GROUP_REPO_PATH = normalize(fixture.getUrl(), "content/npm/group", REPO_NAME);
final Group group = new Group(PKG_TYPE_NPM, REPO_NAME);
try (InputStream result = client.content().get(group.getKey(), PATH_ROOT)) {
assertThat(result, notNullValue());
final String content = IOUtils.toString(result);
logger.debug("NPM Rewrite content: {}", content);
assertThat(expectRepoUrlCountMatch, equalTo(StringUtils.countMatches(content, GROUP_REPO_PATH)));
assertThat(content.contains(REMOTE_REPO_PATH), equalTo(false));
}
remote = client.stores().load(remoteKey, RemoteRepository.class);
assertThat(remote, notNullValue());
}
use of org.commonjava.indy.model.core.Group 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.Group in project indy by Commonjava.
the class GroupHttpHeadersFromSameRepoAsPomTest method setupStores.
@Before
public void setupStores() throws Exception {
String changelog = "test setup";
repoX = client.stores().create(new RemoteRepository(REPO_X, server.formatUrl(REPO_X)), changelog, RemoteRepository.class);
repoY = client.stores().create(new RemoteRepository(REPO_Y, server.formatUrl(REPO_Y)), changelog, RemoteRepository.class);
content2 = CONTENT_2.getBytes("UTF-8");
server.expect(server.formatUrl(REPO_X, PATH), 200, CONTENT_1);
server.expect(server.formatUrl(REPO_Y, PATH), 200, new ByteArrayInputStream(content2));
groupA = client.stores().create(new Group(GROUP_A, repoX.getKey(), repoY.getKey()), changelog, Group.class);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupIgnoresDisabledRemoteRepositoryTest method run.
@Test
public void run() throws Exception {
final String repo1 = "repo1";
final String repo2 = "repo2";
final String path = "path/to/test.txt";
String disabledContent = "This is disabled.";
String enabledContent = "This is enabled.";
server.expect(server.formatUrl(repo1, path), 200, disabledContent);
server.expect(server.formatUrl(repo2, path), 200, enabledContent);
RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1));
remote1.setDisabled(true);
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 "));
final InputStream stream = client.content().get(group, g.getName(), path);
assertThat(stream, notNullValue());
final String content = IOUtils.toString(stream);
assertThat(content, equalTo(enabledContent));
stream.close();
}
use of org.commonjava.indy.model.core.Group 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");
}
Aggregations