use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testRebalancingActions.
@Test
public void testRebalancingActions() {
String cacheName = "default";
assertRebalancingStatus(cacheName, true);
RestCacheClient cacheClient = adminClient.cache(cacheName);
RestResponse response = join(cacheClient.disableRebalancing());
ResponseAssertion.assertThat(response).isOk();
assertRebalancingStatus(cacheName, false);
response = join(cacheClient.enableRebalancing());
ResponseAssertion.assertThat(response).isOk();
assertRebalancingStatus(cacheName, true);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testMutableAttributes.
@Test
public void testMutableAttributes() {
String cacheName = "mutable-attributes";
String json = "{\"local-cache\":{\"encoding\":{\"media-type\":\"text/plain\"}}}";
RestCacheClient cacheClient = createCache(adminClient, json, cacheName);
CompletionStage<RestResponse> response = cacheClient.configurationAttributes(true);
assertThat(response).isOk();
Json attributes = Json.read(join(response).getBody());
assertEquals(10, attributes.asJsonMap().size());
assertEquals("long", attributes.at("clustering.remote-timeout").at("type").asString());
assertEquals(15000, attributes.at("clustering.remote-timeout").at("value").asLong());
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method testCreateAndUseCache.
private void testCreateAndUseCache(String name) {
String cacheConfig = "{\"distributed-cache\":{\"mode\":\"SYNC\"}}";
RestCacheClient cacheClient = client.cache(name);
RestEntity config = RestEntity.create(APPLICATION_JSON, cacheConfig);
CompletionStage<RestResponse> response = cacheClient.createWithConfiguration(config);
assertThat(response).isOk();
CompletionStage<RestResponse> sizeResponse = cacheClient.size();
assertThat(sizeResponse).isOk();
assertThat(sizeResponse).containsReturnedText("0");
RestResponse namesResponse = join(client.caches());
assertThat(namesResponse).isOk();
List<String> names = Json.read(namesResponse.getBody()).asJsonList().stream().map(Json::asString).collect(Collectors.toList());
assertTrue(names.contains(name));
CompletionStage<RestResponse> putResponse = cacheClient.post("key", "value");
assertThat(putResponse).isOk();
CompletionStage<RestResponse> getResponse = cacheClient.get("key");
assertThat(getResponse).isOk();
assertThat(getResponse).containsReturnedText("value");
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class Http2Test method shouldReportErrorCorrectly.
@Test
public void shouldReportErrorCorrectly() {
restServer = RestServerHelper.defaultRestServer().withKeyStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).withTrustStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder config = new RestClientConfigurationBuilder();
config.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(HTTP_20).priorKnowledge(true).security().ssl().enable().trustStoreFileName(KEY_STORE_PATH).trustStorePassword(STORE_PASSWORD).trustStoreType(STORE_TYPE).keyStoreFileName(KEY_STORE_PATH).keyStorePassword(STORE_PASSWORD).keyStoreType(STORE_TYPE).hostnameVerifier((hostname, session) -> true);
client = RestClient.forConfiguration(config.build());
CompletionStage<RestResponse> response = client.raw().get("/invalid");
ResponseAssertion.assertThat(response).isNotFound();
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class Http2Test method clearTextUpgrade.
private void clearTextUpgrade(boolean previousKnowledge) {
restServer = RestServerHelper.defaultRestServer().start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).priorKnowledge(previousKnowledge).protocol(Protocol.HTTP_20);
client = RestClient.forConfiguration(builder.build());
CompletionStage<RestResponse> response = client.cacheManager("default").info();
ResponseAssertion.assertThat(response).isOk();
RestEntity value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, "test".getBytes(CharsetUtil.UTF_8));
response = client.cache("defaultcache").post("test", value);
Assertions.assertThat(join(response).getStatus()).isEqualTo(204);
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
Aggregations