Search in sources :

Example 66 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class GetCacheEntryRequestTest method testGetCacheEntry.

@Test
public void testGetCacheEntry() throws Exception {
    GetCacheEntryRequest request = new GetCacheEntryRequest("string", "test", "1");
    ICacheManager hazelcastCacheManager = hz.getCacheManager();
    ICache<String, String> cache = hazelcastCacheManager.getCache("test");
    cache.put("1", "one");
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    assertEquals("one", result.get("cacheBrowse_value").asString());
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) GetCacheEntryRequest(com.hazelcast.internal.management.request.GetCacheEntryRequest) ICacheManager(com.hazelcast.core.ICacheManager) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 67 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class GetClusterStateRequestTest method testGetClusterState.

@Test
public void testGetClusterState() throws Exception {
    GetClusterStateRequest request = new GetClusterStateRequest();
    ClusterState clusterState = cluster.getClusterState();
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    assertEquals(clusterState.name(), request.readResponse(result));
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) GetClusterStateRequest(com.hazelcast.internal.management.request.GetClusterStateRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 68 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class ThreadDumpRequestTest method testThreadDumpRequest.

@Test
public void testThreadDumpRequest() throws Exception {
    ThreadDumpRequest request = new ThreadDumpRequest(false);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    assertNotNull(request.readResponse(result));
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) ThreadDumpRequest(com.hazelcast.internal.management.request.ThreadDumpRequest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 69 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class TriggerPartialStartRequestTest method triggerPartialStart.

public static String triggerPartialStart(HazelcastInstance hz) throws Exception {
    ManagementCenterService managementCenterService = getNode(hz).getManagementCenterService();
    ConsoleRequest request = new TriggerPartialStartRequest();
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    return String.valueOf(request.readResponse(jsonObject));
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) ConsoleRequest(com.hazelcast.internal.management.request.ConsoleRequest) TriggerPartialStartRequest(com.hazelcast.internal.management.request.TriggerPartialStartRequest)

Example 70 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class WanPublisherConfigDTOTest method testSerialization.

@Test
public void testSerialization() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("key1", "value1");
    properties.put("key2", "value2");
    WanPublisherConfig expected = new WanPublisherConfig().setGroupName("myGroupName").setQueueCapacity(23).setClassName("myClassName").setQueueFullBehavior(WANQueueFullBehavior.THROW_EXCEPTION).setProperties(properties);
    WanPublisherConfigDTO dto = new WanPublisherConfigDTO(expected);
    JsonObject json = dto.toJson();
    WanPublisherConfigDTO deserialized = new WanPublisherConfigDTO(null);
    deserialized.fromJson(json);
    WanPublisherConfig actual = deserialized.getConfig();
    assertEquals(expected.getGroupName(), actual.getGroupName());
    assertEquals(expected.getQueueCapacity(), actual.getQueueCapacity());
    assertEquals(expected.getClassName(), actual.getClassName());
    assertEquals(expected.getQueueFullBehavior(), actual.getQueueFullBehavior());
    assertEquals(expected.getProperties(), actual.getProperties());
}
Also used : HashMap(java.util.HashMap) JsonObject(com.eclipsesource.json.JsonObject) WanPublisherConfig(com.hazelcast.config.WanPublisherConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

JsonObject (com.eclipsesource.json.JsonObject)126 Test (org.junit.Test)41 ParallelTest (com.hazelcast.test.annotation.ParallelTest)38 QuickTest (com.hazelcast.test.annotation.QuickTest)38 JsonArray (com.eclipsesource.json.JsonArray)14 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)12 HashMap (java.util.HashMap)12 Map (java.util.Map)9 JsonValue (com.eclipsesource.json.JsonValue)5 ExecuteScriptRequest (com.hazelcast.internal.management.request.ExecuteScriptRequest)5 BoxSharedLink (com.box.androidsdk.content.models.BoxSharedLink)4 WanPublisherConfig (com.hazelcast.config.WanPublisherConfig)4 ChangeClusterStateRequest (com.hazelcast.internal.management.request.ChangeClusterStateRequest)3 ChangeWanStateRequest (com.hazelcast.internal.management.request.ChangeWanStateRequest)3 ILogger (com.hazelcast.logging.ILogger)3 IOException (java.io.IOException)3 BoxEntity (com.box.androidsdk.content.models.BoxEntity)2 ParseException (com.eclipsesource.json.ParseException)2 ClusterState (com.hazelcast.cluster.ClusterState)2 MapConfig (com.hazelcast.config.MapConfig)2