Search in sources :

Example 6 with CPSession

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSession(com.hazelcast.cp.session.CPSession) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

CPSession (com.hazelcast.cp.session.CPSession)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Test (org.junit.Test)3 CPGroupId (com.hazelcast.cp.CPGroupId)2 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)2 SlowTest (com.hazelcast.test.annotation.SlowTest)2 PartitionSpecificRunnableAdaptor (com.hazelcast.cp.internal.util.PartitionSpecificRunnableAdaptor)1 JsonArray (com.hazelcast.internal.json.JsonArray)1 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections.unmodifiableCollection (java.util.Collections.unmodifiableCollection)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Semaphore (java.util.concurrent.Semaphore)1