Search in sources :

Example 31 with IndyClientException

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()));
}
Also used : Group(org.commonjava.indy.model.core.Group) ByteArrayInputStream(java.io.ByteArrayInputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) IndyClientException(org.commonjava.indy.client.core.IndyClientException) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Aggregations

IndyClientException (org.commonjava.indy.client.core.IndyClientException)31 Test (org.junit.Test)21 InputStream (java.io.InputStream)17 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)13 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)12 HostedRepository (org.commonjava.indy.model.core.HostedRepository)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 StoreKey (org.commonjava.indy.model.core.StoreKey)9 IOException (java.io.IOException)6 HttpResources (org.commonjava.indy.client.core.helper.HttpResources)5 HttpResponse (org.apache.http.HttpResponse)3 StatusLine (org.apache.http.StatusLine)3 AbstractIndyFunctionalTest (org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest)3 Logger (org.slf4j.Logger)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 CountingInputStream (org.apache.commons.io.input.CountingInputStream)2 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpPost (org.apache.http.client.methods.HttpPost)2 IndyClientHttp (org.commonjava.indy.client.core.IndyClientHttp)2