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());
}
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;
}
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));
}
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));
}
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()));
}
Aggregations