use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class ForkedInfinispanServerDriver method getRestClient.
private RestClient getRestClient(int server) {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
// Filter driver properties for REST client configuration properties, e.g. security configuration
// and apply them before applying rest of the dynamically created configuration, e.g. port.
Properties securityConfigurationProperties = new Properties();
configuration.properties().entrySet().stream().filter(entry -> entry.getKey().toString().startsWith("infinispan.client.rest.")).forEach(entry -> securityConfigurationProperties.put(entry.getKey(), entry.getValue()));
builder.withProperties(securityConfigurationProperties);
// Ensure to not print out the *values*!!!
log.debugf("Configured client with the following properties: %s", securityConfigurationProperties.keySet().toString());
builder.addServer().host("localhost").port(getServerPort(server, ForkedServer.DEFAULT_SINGLE_PORT));
return RestClient.forConfiguration(builder.build());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class IgnoreCaches method testIgnoreCaches.
@Test
public void testIgnoreCaches() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
String testCache = SERVER_TEST.getMethodName();
assertTrue(getIgnoredCaches(client, CACHE_MANAGER).isEmpty());
assertCacheResponse(client, testCache, 404);
assertCacheResponse(client, PROTOBUF_METADATA_CACHE_NAME, 404);
ignoreCache(client, testCache);
assertEquals(singleton(testCache), getIgnoredCaches(client, CACHE_MANAGER));
assertCacheResponse(client, testCache, 503);
assertCacheResponse(client, PROTOBUF_METADATA_CACHE_NAME, 404);
ignoreCache(client, PROTOBUF_METADATA_CACHE_NAME);
assertEquals(asSet(testCache, PROTOBUF_METADATA_CACHE_NAME), getIgnoredCaches(client, CACHE_MANAGER));
assertCacheResponse(client, testCache, 503);
assertCacheResponse(client, PROTOBUF_METADATA_CACHE_NAME, 503);
unIgnoreCache(client, testCache);
assertEquals(singleton(PROTOBUF_METADATA_CACHE_NAME), getIgnoredCaches(client, CACHE_MANAGER));
assertCacheResponse(client, testCache, 404);
assertCacheResponse(client, PROTOBUF_METADATA_CACHE_NAME, 503);
unIgnoreCache(client, PROTOBUF_METADATA_CACHE_NAME);
assertTrue(getIgnoredCaches(client, CACHE_MANAGER).isEmpty());
assertCacheResponse(client, testCache, 404);
assertCacheResponse(client, PROTOBUF_METADATA_CACHE_NAME, 404);
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RestLoggingResource method testManipulateLogger.
@Test
public void testManipulateLogger() {
RestClient client = SERVER_TEST.rest().create();
// Create the logger
RestResponse response = sync(client.server().logging().setLogger("org.infinispan.TESTLOGGER", "WARN", "STDOUT"));
assertEquals(204, response.getStatus());
response = sync(client.server().logging().listLoggers());
assertTrue("Logger not found", findLogger(response, "org.infinispan.TESTLOGGER", "WARN", "STDOUT"));
// Update it
response = sync(client.server().logging().setLogger("org.infinispan.TESTLOGGER", "ERROR", "FILE"));
assertEquals(204, response.getStatus());
response = sync(client.server().logging().listLoggers());
assertTrue("Logger not found", findLogger(response, "org.infinispan.TESTLOGGER", "ERROR", "FILE"));
// Remove it
response = sync(client.server().logging().removeLogger("org.infinispan.TESTLOGGER"));
assertEquals(204, response.getStatus());
response = sync(client.server().logging().listLoggers());
assertFalse("Logger should not be found", findLogger(response, "org.infinispan.TESTLOGGER", "ERROR"));
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RestLoggingResource method testListAppenders.
@Test
public void testListAppenders() {
RestClient client = SERVER_TEST.rest().create();
RestResponse response = sync(client.server().logging().listAppenders());
String body = response.getBody();
Json appenders = Json.read(body);
assertEquals(body, 5, appenders.asMap().size());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RestLoggingResource method testListLoggers.
@Test
public void testListLoggers() {
RestClient client = SERVER_TEST.rest().create();
RestResponse response = sync(client.server().logging().listLoggers());
Json loggers = Json.read(response.getBody());
assertTrue(loggers.asJsonList().size() > 0);
}
Aggregations