Search in sources :

Example 26 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BackupManagerIT method testManagerBackupFromFile.

@Test
public void testManagerBackupFromFile() throws Exception {
    String name = "testManagerBackup";
    performTest(client -> {
        RestCacheManagerClient cm = client.cacheManager("clustered");
        RestResponse response = await(cm.createBackup(name));
        assertEquals(202, response.getStatus());
        response.close();
        return awaitOk(() -> cm.getBackup(name, false));
    }, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
        RestCacheManagerClient cm = client.cacheManager("clustered");
        RestResponse response = await(cm.restore(name, zip.getPath(), null));
        assertEquals(202, response.getStatus());
        return awaitCreated(() -> cm.getRestore(name));
    }, this::assertWildcardContent, true);
}
Also used : RestCacheManagerClient(org.infinispan.client.rest.RestCacheManagerClient) RestResponse(org.infinispan.client.rest.RestResponse) Test(org.junit.Test)

Example 27 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BackupManagerIT method testClusterBackupUpload.

@Test
public void testClusterBackupUpload() throws Exception {
    String name = "testClusterBackup";
    performTest(client -> {
        RestClusterClient cluster = client.cluster();
        RestResponse response = await(cluster.createBackup(name));
        assertEquals(202, response.getStatus());
        return awaitOk(() -> cluster.getBackup(name, false));
    }, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
        RestClusterClient c = client.cluster();
        RestResponse response = await(c.restore(name, zip));
        assertEquals(202, response.getStatus());
        return awaitCreated(() -> c.getRestore(name));
    }, this::assertWildcardContent, false);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClusterClient(org.infinispan.client.rest.RestClusterClient) Test(org.junit.Test)

Example 28 with RestResponse

use of org.infinispan.client.rest.RestResponse 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"));
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Test(org.junit.Test)

Example 29 with RestResponse

use of org.infinispan.client.rest.RestResponse 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());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.junit.Test)

Example 30 with RestResponse

use of org.infinispan.client.rest.RestResponse 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);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.junit.Test)

Aggregations

RestResponse (org.infinispan.client.rest.RestResponse)233 Test (org.testng.annotations.Test)108 Json (org.infinispan.commons.dataconversion.internal.Json)52 RestCacheClient (org.infinispan.client.rest.RestCacheClient)42 Test (org.junit.Test)41 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)39 RestClient (org.infinispan.client.rest.RestClient)37 RestEntity (org.infinispan.client.rest.RestEntity)36 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)23 HashMap (java.util.HashMap)8 RestCounterClient (org.infinispan.client.rest.RestCounterClient)8 TestClass (org.infinispan.rest.TestClass)8 RestSchemaClient (org.infinispan.client.rest.RestSchemaClient)7 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)6 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)6 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)6 Cache (org.infinispan.Cache)5 RestRawClient (org.infinispan.client.rest.RestRawClient)5 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)5