use of org.infinispan.client.rest.RestEntity 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);
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class Http2Test method secureUpgradeTest.
private void secureUpgradeTest(Protocol choice) {
// given
restServer = RestServerHelper.defaultRestServer().withKeyStore(KEY_STORE_PATH, STORE_PASSWORD, STORE_TYPE).start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(choice).security().ssl().trustStoreFileName(KEY_STORE_PATH).trustStorePassword(STORE_PASSWORD).hostnameVerifier((hostname, session) -> true);
client = RestClient.forConfiguration(builder.build());
RestEntity value = RestEntity.create(MediaType.APPLICATION_OCTET_STREAM, "test".getBytes(CharsetUtil.UTF_8));
CompletionStage<RestResponse> response = client.cache("defaultcache").post("test", value);
// then
ResponseAssertion.assertThat(response).isOk();
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class Http2Test method shouldUseHTTP1.
@Test
public void shouldUseHTTP1() {
restServer = RestServerHelper.defaultRestServer().start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort()).protocol(HTTP_11);
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").put("test", value);
Assertions.assertThat(join(response).getStatus()).isEqualTo(204);
Assertions.assertThat(restServer.getCacheManager().getCache().size()).isEqualTo(1);
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class CacheResourceV2Test method testCacheV2LifeCycle.
@Test
public void testCacheV2LifeCycle() throws Exception {
String xml = getResourceAsString("cache.xml", getClass().getClassLoader());
String json = getResourceAsString("cache.json", getClass().getClassLoader());
RestEntity xmlEntity = RestEntity.create(APPLICATION_XML, xml);
RestEntity jsonEntity = RestEntity.create(APPLICATION_JSON, json);
CompletionStage<RestResponse> response = client.cache("cache1").createWithConfiguration(xmlEntity, VOLATILE);
assertThat(response).isOk();
assertPersistence("cache1", false);
response = client.cache("cache2").createWithConfiguration(jsonEntity);
assertThat(response).isOk();
assertPersistence("cache2", true);
String mediaList = "application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
response = client.cache("cache1").configuration(mediaList);
assertThat(response).isOk();
String cache1Cfg = join(response).getBody();
response = client.cache("cache2").configuration();
assertThat(response).isOk();
String cache2Cfg = join(response).getBody();
assertEquals(cache1Cfg, cache2Cfg.replace("cache2", "cache1"));
response = client.cache("cache1").configuration("application/xml");
assertThat(response).isOk();
String cache1Xml = join(response).getBody();
ParserRegistry registry = new ParserRegistry();
Configuration xmlConfig = registry.parse(cache1Xml).getCurrentConfigurationBuilder().build();
assertEquals(1200000, xmlConfig.clustering().l1().lifespan());
assertEquals(60500, xmlConfig.clustering().stateTransfer().timeout());
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class CacheResourceV2Test method insertEntity.
private void insertEntity(int cacheKey, String type, int intValue, String stringValue) {
Json json = Json.object().set("_type", type).set("value", intValue).set("description", stringValue);
RestEntity restEntity = RestEntity.create(APPLICATION_JSON, json.toString());
RestCacheClient cacheClient = client.cache("indexedCache");
CompletionStage<RestResponse> response = cacheClient.put(String.valueOf(cacheKey), restEntity);
assertThat(response).isOk();
}
Aggregations