use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestOperations method taskFilter.
@Test
public void taskFilter() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.protocol(protocol);
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestResponse tasks = sync(client.tasks().list(ResultType.USER));
List<Json> taskListNode = Json.read(tasks.getBody()).asJsonList();
taskListNode.forEach(n -> assertFalse(n.at("name").asString().startsWith("@@")));
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestOperations method testRestOperations.
@Test
public void testRestOperations() {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.protocol(protocol);
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestCacheClient cache = client.cache(SERVER_TEST.getMethodName());
RestResponse response = sync(cache.put("k1", "v1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(cache.get("k1"));
assertEquals(200, response.getStatus());
assertEquals(protocol, response.getProtocol());
assertEquals("v1", response.getBody());
response = sync(cache.remove("k1"));
assertEquals(204, response.getStatus());
assertEquals(protocol, response.getProtocol());
response = sync(cache.get("k1"));
assertEquals(404, response.getStatus());
assertEquals(protocol, response.getProtocol());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class RestOperations method testPutWithTimeToLive.
@Test
public void testPutWithTimeToLive() throws InterruptedException {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.protocol(protocol);
RestClient client = SERVER_TEST.rest().withClientConfiguration(builder).create();
RestCacheClient cache = client.cache(SERVER_TEST.getMethodName());
sync(cache.post("k1", "v1", 1, 1));
assertEquals(HttpResponseStatus.OK.code(), sync(cache.get("k1")).getStatus());
Thread.sleep(2000);
assertEquals(HttpResponseStatus.NOT_FOUND.code(), sync(cache.get("k1")).getStatus());
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class XSiteResourceTest method startServers.
@BeforeClass
public void startServers() {
sites.forEach(site -> {
String siteName = site.getSiteName();
EmbeddedCacheManager cm = site.cacheManagers().iterator().next();
RestServerHelper restServerHelper = new RestServerHelper(cm);
restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
restServerPerSite.put(siteName, restServerHelper);
RestClientConfiguration clientConfig = new RestClientConfigurationBuilder().addServer().host("127.0.0.1").port(restServerHelper.getPort()).build();
RestClient client = RestClient.forConfiguration(clientConfig);
clientPerSite.put(siteName, client);
});
}
use of org.infinispan.client.rest.configuration.RestClientConfigurationBuilder in project infinispan by infinispan.
the class AuthenticationTest method beforeMethod.
@BeforeMethod(alwaysRun = true)
public void beforeMethod() {
SecurityDomain securityDomainMock = mock(SecurityDomain.class);
Subject user = TestingUtil.makeSubject("test");
doReturn(user).when(securityDomainMock).authenticate(eq("test"), eq("test"));
BasicAuthenticator basicAuthenticator = new BasicAuthenticator(securityDomainMock, REALM);
restServer = RestServerHelper.defaultRestServer().withAuthenticator(basicAuthenticator).start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder configurationBuilder = new RestClientConfigurationBuilder();
configurationBuilder.addServer().host(restServer.getHost()).port(restServer.getPort());
client = RestClient.forConfiguration(configurationBuilder.build());
}
Aggregations