use of org.commonjava.indy.client.core.IndyClientException in project indy by Commonjava.
the class NPMGroupStoreFileTest method test.
@Test
public void test() throws Exception {
server.expect(server.formatUrl(REPO_X, PATH), 200, new ByteArrayInputStream(CONTENT_1.getBytes("UTF-8")));
server.expect(server.formatUrl(REPO_Y, PATH), 200, new ByteArrayInputStream(CONTENT_2.getBytes("UTF-8")));
final RemoteRepository repoX = new RemoteRepository(NPM_PKG_KEY, REPO_X, server.formatUrl(REPO_X));
client.stores().create(repoX, "adding npm remote repo", RemoteRepository.class);
final RemoteRepository repoY = new RemoteRepository(NPM_PKG_KEY, REPO_Y, server.formatUrl(REPO_Y));
client.stores().create(repoY, "adding npm remote repo", RemoteRepository.class);
final HostedRepository repoZ = new HostedRepository(NPM_PKG_KEY, REPO_Z);
client.stores().create(repoZ, "adding npm hosted repo", HostedRepository.class);
client.content().store(repoZ.getKey(), PATH, new ByteArrayInputStream(CONTENT_2.getBytes()));
final Group groupA = new Group(NPM_PKG_KEY, GROUP_A, repoX.getKey(), repoY.getKey());
client.stores().create(groupA, "adding npm group A repo", Group.class);
final Group groupB = new Group(NPM_PKG_KEY, GROUP_B, repoX.getKey(), repoZ.getKey());
client.stores().create(groupB, "adding npm group B repo", Group.class);
final String update = "This is a test: " + System.nanoTime();
try {
client.content().store(groupA.getKey(), PATH, new ByteArrayInputStream(update.getBytes()));
} catch (IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(ApplicationStatus.BAD_REQUEST.code()));
}
client.content().store(groupB.getKey(), PATH, new ByteArrayInputStream(update.getBytes()));
}
Aggregations