use of com.hazelcast.cp.session.CPSession 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