Search in sources :

Example 6 with StoreKey

use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.

the class Propagate404NotFoundTest method run.

@Test
public void run() throws Exception {
    final String testRepo = "test";
    final String url = server.formatUrl(testRepo, "org/test/foo/1/foo-1.pom");
    final HttpGet get = new HttpGet(url);
    final CloseableHttpClient client = proxiedHttp();
    CloseableHttpResponse response = null;
    final InputStream stream = null;
    try {
        response = client.execute(get, proxyContext(USER, PASS));
        assertThat(response.getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_NOT_FOUND));
    } finally {
        IOUtils.closeQuietly(stream);
        HttpResources.cleanupResources(get, response, client);
    }
    final RemoteRepository remoteRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, "httprox_127-0-0-1_" + server.getPort()), RemoteRepository.class);
    assertThat(remoteRepo, notNullValue());
    assertThat(remoteRepo.getUrl(), equalTo(server.getBaseUri()));
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 7 with StoreKey

use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.

the class TrackedContentDTOTest method jsonRoundTrip_DownloadsNoUploads.

@Test
public void jsonRoundTrip_DownloadsNoUploads() throws IOException {
    Set<TrackedContentEntryDTO> downloads = setOf(new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom"), new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo2"), AccessChannel.MAVEN_REPO, "/path/to/another/file.pom"));
    TrackedContentDTO in = new TrackedContentDTO(new TrackingKey("key"), Collections.emptySet(), downloads);
    assertRoundTrip(in, (out) -> {
        assertNullOrEmpty(out.getUploads());
        assertContents(out.getDownloads(), in.getDownloads());
    });
}
Also used : StoreKey(org.commonjava.indy.model.core.StoreKey) TrackingKey(org.commonjava.indy.folo.model.TrackingKey) Test(org.junit.Test)

Example 8 with StoreKey

use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.

the class TrackedContentEntryDTOTest method jsonRoundTrip_Urls.

@Test
public void jsonRoundTrip_Urls() throws IOException {
    TrackedContentEntryDTO in = new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom");
    in.setLocalUrl("http://localhost:8080/api/remote/foo/path/to/my.pom");
    in.setOriginUrl("http://foo.com/repo/path/to/my.pom");
    assertRoundTrip(in, (out) -> {
        assertThat(out.getLocalUrl(), equalTo(out.getLocalUrl()));
        assertThat(out.getOriginUrl(), equalTo(out.getOriginUrl()));
    });
}
Also used : StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 9 with StoreKey

use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.

the class TrackedContentEntryDTOTest method jsonRoundTrip_Checksums.

@Test
public void jsonRoundTrip_Checksums() throws IOException {
    TrackedContentEntryDTO in = new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom");
    String content = "This is a test string";
    in.setMd5(DigestUtils.md5Hex(content));
    in.setSha256(DigestUtils.sha256Hex(content));
    in.setSha1(DigestUtils.shaHex(content));
    assertRoundTrip(in, (out) -> {
        assertThat(out.getMd5(), equalTo(in.getMd5()));
        assertThat(out.getSha256(), equalTo(in.getSha256()));
        assertThat(out.getSha1(), equalTo(in.getSha1()));
    });
}
Also used : StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 10 with StoreKey

use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.

the class AffectedStoreRecordTest method roundTripRecordWithTwoUploadsToJson.

@Test
public void roundTripRecordWithTwoUploadsToJson() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    record.add("/path/one", StoreEffect.UPLOAD);
    record.add("/path/two", StoreEffect.UPLOAD);
    final String json = mapper.writeValueAsString(record);
    System.out.println(json);
    final AffectedStoreRecord result = mapper.readValue(json, AffectedStoreRecord.class);
    assertThat(result, notNullValue());
    assertThat(result.getKey(), equalTo(record.getKey()));
    assertThat(result.getDownloadedPaths(), nullValue());
    assertThat(result.getUploadedPaths(), equalTo(record.getUploadedPaths()));
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Aggregations

StoreKey (org.commonjava.indy.model.core.StoreKey)186 Test (org.junit.Test)92 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)40 StoreType (org.commonjava.indy.model.core.StoreType)39 InputStream (java.io.InputStream)33 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)32 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)31 IndyDataException (org.commonjava.indy.data.IndyDataException)30 Group (org.commonjava.indy.model.core.Group)29 Transfer (org.commonjava.maven.galley.model.Transfer)27 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)24 Response (javax.ws.rs.core.Response)23 IOException (java.io.IOException)22 Logger (org.slf4j.Logger)21 ApiOperation (io.swagger.annotations.ApiOperation)20 ResponseUtils.formatResponse (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse)20 ArrayList (java.util.ArrayList)19 Path (javax.ws.rs.Path)19 ApiResponse (io.swagger.annotations.ApiResponse)18 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)18