Search in sources :

Example 46 with RestCacheClient

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));
}
Also used : RestCacheClient(org.infinispan.client.rest.RestCacheClient)

Example 47 with RestCacheClient

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();
}
Also used : RestCacheClient(org.infinispan.client.rest.RestCacheClient) Json(org.infinispan.commons.dataconversion.internal.Json)

Example 48 with RestCacheClient

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));
}
Also used : RestCacheClient(org.infinispan.client.rest.RestCacheClient) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.testng.annotations.Test) AbstractMultipleSitesTest(org.infinispan.xsite.AbstractMultipleSitesTest)

Example 49 with RestCacheClient

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);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) Test(org.testng.annotations.Test)

Example 50 with RestCacheClient

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);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TestClass(org.infinispan.rest.TestClass) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Test(org.testng.annotations.Test)

Aggregations

RestCacheClient (org.infinispan.client.rest.RestCacheClient)66 RestResponse (org.infinispan.client.rest.RestResponse)41 Test (org.testng.annotations.Test)34 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)16 RestEntity (org.infinispan.client.rest.RestEntity)14 Json (org.infinispan.commons.dataconversion.internal.Json)13 RestClient (org.infinispan.client.rest.RestClient)11 Test (org.junit.Test)8 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 AbstractMultipleSitesTest (org.infinispan.xsite.AbstractMultipleSitesTest)7 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)6 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)5 TestClass (org.infinispan.rest.TestClass)5 TestUser (org.infinispan.server.test.api.TestUser)5 DummyInMemoryStoreConfigurationBuilder (org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder)3 HashMap (java.util.HashMap)2 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)2 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)2 MediaType (org.infinispan.commons.dataconversion.MediaType)2 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)2