use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method bringBackupOnline.
private void bringBackupOnline(String site, String backup) {
RestCacheClient client = getCacheClient(site);
assertSuccessful(client.bringSiteOnline(backup));
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method getBackupStatus.
private String getBackupStatus(String site, String backup) {
RestCacheClient cacheClient = getCacheClient(site);
String cacheManagerAddress = getFirstCacheManagerAddress(site);
Json json = jsonResponseBody(cacheClient.backupStatus(backup));
return json.at(cacheManagerAddress).asString();
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method testCancelPushState.
@Test
public void testCancelPushState() throws Exception {
RestCacheClient cache = getCacheClient(LON);
RestCacheClient backupCache = getCacheClient(NYC);
// Take backup offline
takeBackupOffline(LON, NYC);
assertEquals(OFFLINE, getBackupStatus(LON, NYC));
// Write in the cache
int entries = 50;
IntStream.range(0, entries).forEach(i -> assertNoContent(cache.put(String.valueOf(i), "value")));
// Backup should be empty
assertEquals(entries, getCacheSize(cache));
assertEquals(0, getCacheSize(backupCache));
// Start state push
BlockXSitePushStateTransport transport = BlockXSitePushStateTransport.replace(cache(LON, 0));
transport.startBlocking();
assertSuccessful(cache.pushSiteState(NYC));
transport.waitForCommand();
// Cancel push
assertSuccessful(cache.cancelPushState(NYC));
transport.stopBlocking();
Json status = jsonResponseBody(cache.pushStateStatus());
assertEquals("CANCELED", status.at(NYC).asString());
// Clear status
assertSuccessful(cache.clearPushStateStatus());
status = jsonResponseBody(cache.pushStateStatus());
assertEquals(2, status.asMap().size());
assertEquals("IDLE", status.asMap().get(NYC));
assertEquals("IDLE", status.asMap().get(SFO));
assertSuccessful(cache.cancelReceiveState(NYC));
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutEntryWithTtlAndIdleTime.
@Test
public void shouldPutEntryWithTtlAndIdleTime() {
final RestCacheClient expirationCache = client.cache("expiration");
// when
CompletionStage<RestResponse> response = expirationCache.post("test", "test", 50, 50);
ResponseAssertion.assertThat(response).isOk();
RestResponse getResponse = join(expirationCache.get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
Assertions.assertThat(getLifespan(getResponse)).isEqualTo(50);
Assertions.assertThat(getMaxIdle(getResponse)).isEqualTo(50);
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceTest method shouldNegotiateFromPojoCacheWithoutAccept.
@Test
public void shouldNegotiateFromPojoCacheWithoutAccept() {
// given
TestClass testClass = new TestClass();
testClass.setName("test");
String json = testClass.toJson().toString();
RestCacheClient pojoCache = client.cache("pojoCache");
String key = "k1";
join(pojoCache.put("k1", json));
// when
RestResponse response = join(pojoCache.get(key, Collections.emptyMap()));
// then
assertThat(response).isOk();
assertThat(response).hasContentType(MediaType.TEXT_PLAIN_TYPE);
assertThat(response).hasReturnedText(json);
}
Aggregations