Search in sources :

Example 6 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testConfigUpdate.

@Test
public void testConfigUpdate() throws Exception {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance = factory.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    ConnectionResponse response = communicator.configUpdate(config.getClusterName(), getPassword(), "hazelcast:\n");
    // Reload is enterprise feature. Should fail here.
    assertJsonContains(response.response, "status", "fail", "message", "Configuration Update requires Hazelcast Enterprise Edition");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RestApiConfig(com.hazelcast.config.RestApiConfig) HazelcastTestSupport.smallInstanceConfig(com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig) Config(com.hazelcast.config.Config) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testClusterShutdown.

@Test
public void testClusterShutdown() throws Exception {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    final HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance2);
    ConnectionResponse response = communicator.shutdownCluster(config.getClusterName(), getPassword());
    assertSuccessJson(response);
    assertTrueEventually(() -> {
        assertFalse(instance1.getLifecycleService().isRunning());
        assertFalse(instance2.getLifecycleService().isRunning());
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RestApiConfig(com.hazelcast.config.RestApiConfig) HazelcastTestSupport.smallInstanceConfig(com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig) Config(com.hazelcast.config.Config) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testForceAndPartialStart.

@Test
public void testForceAndPartialStart() throws IOException {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance = factory.newHazelcastInstance(config);
    final HTTPCommunicator communicator = new HTTPCommunicator(instance);
    String clusterName = config.getClusterName();
    ConnectionResponse resp1 = communicator.forceStart(clusterName, getPassword());
    assertEquals(HttpURLConnection.HTTP_OK, resp1.responseCode);
    assertJsonContains(resp1.response, "status", "fail");
    ConnectionResponse resp2 = communicator.partialStart(clusterName, getPassword());
    assertEquals(HttpURLConnection.HTTP_OK, resp2.responseCode);
    assertJsonContains(resp2.response, "status", "fail");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RestApiConfig(com.hazelcast.config.RestApiConfig) HazelcastTestSupport.smallInstanceConfig(com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig) Config(com.hazelcast.config.Config) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestCPSubsystemTest method test_forceDestroyCPGroup_withInvalidCredentials.

@Test
public void test_forceDestroyCPGroup_withInvalidCredentials() throws IOException {
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    instance1.getCPSubsystem().getAtomicLong("long1");
    ConnectionResponse response = new HTTPCommunicator(instance1).forceDestroyCPGroup(DEFAULT_GROUP_NAME, "x", "x");
    assertEquals(403, response.responseCode);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 10 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestCPSubsystemTest method test_forceCloseInvalidCPSession.

@Test
public void test_forceCloseInvalidCPSession() throws IOException {
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    instance1.getCPSubsystem().getAtomicLong("long1").set(5);
    ConnectionResponse response1 = new HTTPCommunicator(instance1).forceCloseCPSession(DEFAULT_GROUP_NAME, 1, clusterName, null);
    assertEquals(400, response1.responseCode);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)39 Test (org.junit.Test)39 HazelcastInstance (com.hazelcast.core.HazelcastInstance)36 SlowTest (com.hazelcast.test.annotation.SlowTest)25 QuickTest (com.hazelcast.test.annotation.QuickTest)14 CPMember (com.hazelcast.cp.CPMember)11 Config (com.hazelcast.config.Config)10 RestApiConfig (com.hazelcast.config.RestApiConfig)10 RestServerEndpointConfig (com.hazelcast.config.RestServerEndpointConfig)10 HazelcastTestSupport.smallInstanceConfig (com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig)10 JsonArray (com.hazelcast.internal.json.JsonArray)6 JsonObject (com.hazelcast.internal.json.JsonObject)6 JsonValue (com.hazelcast.internal.json.JsonValue)5 CPSession (com.hazelcast.cp.session.CPSession)2 CPGroup (com.hazelcast.cp.CPGroup)1 IAtomicLong (com.hazelcast.cp.IAtomicLong)1 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)1