Search in sources :

Example 21 with ConnectionResponse

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

the class RestCPSubsystemTest method test_forceDestroyDefaultCPGroup.

@Test
public void test_forceDestroyDefaultCPGroup() throws IOException {
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    IAtomicLong long1 = instance1.getCPSubsystem().getAtomicLong("long1");
    ConnectionResponse response = new HTTPCommunicator(instance1).forceDestroyCPGroup(DEFAULT_GROUP_NAME, clusterName, null);
    assertEquals(200, response.responseCode);
    exception.expect(CPGroupDestroyedException.class);
    long1.set(5);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) IAtomicLong(com.hazelcast.cp.IAtomicLong) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 22 with ConnectionResponse

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

the class RestCPSubsystemTest method test_reset_withInvalidCredentials.

@Test
public void test_reset_withInvalidCredentials() throws IOException {
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
    for (HazelcastInstance instance : Arrays.asList(instance1, instance2, instance3)) {
        ConnectionResponse response = new HTTPCommunicator(instance).restart("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 23 with ConnectionResponse

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

the class RestCPSubsystemTest method test_removeCPMember.

@Test
public void test_removeCPMember() throws IOException {
    final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
    waitUntilCPDiscoveryCompleted(instance1, instance2, instance3);
    CPMember crashedCPMember = instance3.getCPSubsystem().getLocalCPMember();
    instance3.getLifecycleService().terminate();
    assertClusterSizeEventually(2, instance1, instance2);
    ConnectionResponse response = new HTTPCommunicator(instance1).removeCPMember(crashedCPMember.getUuid(), clusterName, null);
    assertEquals(200, response.responseCode);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) CPMember(com.hazelcast.cp.CPMember) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 24 with ConnectionResponse

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

the class RestClusterTest method testSetLicenseKey.

@Test
public void testSetLicenseKey() throws Exception {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance = factory.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    ConnectionResponse response = communicator.setLicense(config.getClusterName(), getPassword(), "whatever");
    assertSuccessJson(response);
}
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 25 with ConnectionResponse

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

the class RestClusterTest method testConfigReload.

@Test
public void testConfigReload() throws Exception {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance = factory.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    ConnectionResponse response = communicator.configReload(config.getClusterName(), getPassword());
    // Reload is enterprise feature. Should fail here.
    assertJsonContains(response.response, "status", "fail", "message", "Configuration Reload 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)

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