Search in sources :

Example 16 with StoreKey

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

the class TrackedContentRecordTest method returnNullAffectedStoreRecordWhenCreateFlagIsFalse.

@Test
public void returnNullAffectedStoreRecordWhenCreateFlagIsFalse() {
    final TrackedContentRecord record = newRecord();
    assertThat(record.getAffectedStores(), nullValue());
    final StoreKey sk = new StoreKey(StoreType.hosted, "local");
    final AffectedStoreRecord storeRecord = record.getAffectedStore(sk, false);
    assertThat(storeRecord, nullValue());
    final Map<StoreKey, AffectedStoreRecord> affectedStores = record.getAffectedStores();
    assertThat(affectedStores, nullValue());
}
Also used : StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 17 with StoreKey

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

the class MemoryArtifactStoreQuery method getGroupOrdering.

private List<ArtifactStore> getGroupOrdering(final String groupName, final Map<StoreKey, ArtifactStore> stores, final boolean includeGroups, final boolean recurseGroups) throws IndyDataException {
    if (packageType == null) {
        throw new IndyDataException("packageType must be set on the query before calling this method!");
    }
    final Group master = (Group) stores.get(new StoreKey(packageType, StoreType.group, groupName));
    if (master == null) {
        return Collections.emptyList();
    }
    final List<ArtifactStore> result = new ArrayList<>();
    recurseGroup(master, stores, result, new HashSet<>(), includeGroups, recurseGroups);
    return result;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) ArrayList(java.util.ArrayList) StoreKey(org.commonjava.indy.model.core.StoreKey)

Example 18 with StoreKey

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

the class DownloadWhileProxyingInProgressTest method downloadWhileSlowProxyCompletes.

@Test
public void downloadWhileSlowProxyCompletes() throws Exception {
    RemoteRepository rmt = new RemoteRepository(STORE, server.formatUrl(STORE));
    rmt.setTimeoutSeconds(30);
    client.stores().create(rmt, "adding test proxy", RemoteRepository.class);
    final String path = "org/foo/foo-project/1/foo-1.txt";
    final byte[] data = ("This is a test: " + System.nanoTime()).getBytes();
    final CountDownLatch latch = new CountDownLatch(2);
    final ReluctantInputStream stream = new ReluctantInputStream(data);
    server.expect(server.formatUrl(STORE, path), 200, stream);
    final InputTimer input = new InputTimer(stream, 10000 / data.length, latch);
    newThread("input", input).start();
    final DelayedDownload download = new DelayedDownload(client, new StoreKey(remote, STORE), path, 5000, latch);
    newThread("download", download).start();
    System.out.println("Waiting for content transfers to complete.");
    latch.await();
    //        waitForEventPropagation();
    System.out.printf("Timing results:\n  Input started: {}\n  Input ended: {}\n  Download started: {}\n  Download ended: {}", input.getStartTime(), input.getEndTime(), download.getStartTime(), download.getEndTime());
    assertThat(download.getContent().toByteArray(), equalTo(data));
    assertThat(input.getEndTime() > download.getStartTime(), equalTo(true));
    final PathInfo result = client.content().getInfo(remote, STORE, path);
    assertThat("no result", result, notNullValue());
    assertThat("doesn't exist", result.exists(), equalTo(true));
}
Also used : ReluctantInputStream(org.commonjava.indy.ftest.core.fixture.ReluctantInputStream) InputTimer(org.commonjava.indy.ftest.core.fixture.InputTimer) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) PathInfo(org.commonjava.indy.client.core.helper.PathInfo) DelayedDownload(org.commonjava.indy.ftest.core.fixture.DelayedDownload) CountDownLatch(java.util.concurrent.CountDownLatch) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 19 with StoreKey

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

the class ContentExpirationTest method roundTrip.

@Test
public void roundTrip() throws Exception {
    final ContentExpiration exp = new ContentExpiration(new StoreKey(StoreType.remote, "test"), "/path/to/something.good");
    final IndyObjectMapper mapper = new IndyObjectMapper(false);
    final String json = mapper.writeValueAsString(exp);
    System.out.println(json);
    final ContentExpiration result = mapper.readValue(json, ContentExpiration.class);
    assertThat(result, equalTo(exp));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 20 with StoreKey

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

the class HttpProxyTest method proxy500As502.

@Test
@Ignore("return upstream 5xx class errors as 404 to keep Maven & co happy")
public void proxy500As502() throws Exception {
    final String testRepo = "test";
    final PomRef pom = loadPom("simple.pom", Collections.<String, String>emptyMap());
    final String url = server.formatUrl(testRepo, pom.path);
    server.registerException(new File("/" + testRepo, pom.path).getPath(), "Expected exception", 500);
    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_BAD_GATEWAY));
    } finally {
        IOUtils.closeQuietly(stream);
        HttpUtil.cleanupResources(client, get, response);
    }
    final RemoteRepository remoteRepo = (RemoteRepository) storeManager.getArtifactStore(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, "httprox_127-0-0-1"));
    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) File(java.io.File) StoreKey(org.commonjava.indy.model.core.StoreKey) Ignore(org.junit.Ignore) 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