use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getCPGroupIds.
@Test
public void test_getCPGroupIds() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getAtomicLong("long1").set(5);
instance1.getCPSubsystem().getAtomicLong("long1@custom").set(5);
HTTPCommunicator communicator = new HTTPCommunicator(instance1);
ConnectionResponse response = communicator.getCPGroupIds();
assertEquals(200, response.responseCode);
JsonArray responseArr = (JsonArray) Json.parse(response.response);
boolean metadataCPGroupExists = false;
boolean defaultCPGroupExists = false;
boolean customCPGroupExists = false;
for (JsonValue val : responseArr) {
JsonObject obj = (JsonObject) val;
String name = obj.getString("name", "");
if (CPGroup.DEFAULT_GROUP_NAME.equals(name)) {
defaultCPGroupExists = true;
} else if (METADATA_CP_GROUP_NAME.equals(name)) {
metadataCPGroupExists = true;
} else if ("custom".equals(name)) {
customCPGroupExists = true;
}
}
assertTrue(metadataCPGroupExists);
assertTrue(defaultCPGroupExists);
assertTrue(customCPGroupExists);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_removeCPMemberFromNonMaster.
@Test
public void test_removeCPMemberFromNonMaster() throws IOException {
Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
waitUntilCPDiscoveryCompleted(instance2, instance3);
CPMember crashedCPMember = instance2.getCPSubsystem().getLocalCPMember();
instance2.getLifecycleService().terminate();
ConnectionResponse response = new HTTPCommunicator(instance3).removeCPMember(crashedCPMember.getUuid(), clusterName, null);
assertEquals(200, response.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_forceDestroyInvalidCPGroup.
@Test
public void test_forceDestroyInvalidCPGroup() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
ConnectionResponse response = new HTTPCommunicator(instance1).forceDestroyCPGroup("custom", clusterName, null);
assertEquals(400, response.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_forceCloseValidCPSession_withInvalidCredentials.
@Test
public void test_forceCloseValidCPSession_withInvalidCredentials() throws IOException, ExecutionException, InterruptedException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getLock("lock1").lock();
instance1.getCPSubsystem().getLock("lock1").unlock();
Collection<CPSession> sessions1 = instance1.getCPSubsystem().getCPSessionManagementService().getAllSessions(DEFAULT_GROUP_NAME).toCompletableFuture().get();
assertEquals(1, sessions1.size());
long sessionId = sessions1.iterator().next().id();
ConnectionResponse response = new HTTPCommunicator(instance1).forceCloseCPSession(DEFAULT_GROUP_NAME, sessionId, "x", "x");
assertEquals(403, response.responseCode);
Collection<CPSession> sessions2 = instance1.getCPSubsystem().getCPSessionManagementService().getAllSessions(DEFAULT_GROUP_NAME).toCompletableFuture().get();
assertEquals(1, sessions2.size());
}
Aggregations