Search in sources :

Example 1 with CPSubsystem

use of com.hazelcast.cp.CPSubsystem in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getLockCalledSuccessfullyOverOSGiInstance.

@Test
public void getLockCalledSuccessfullyOverOSGiInstance() {
    FencedLock mockLock = mock(FencedLock.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    CPSubsystem cpSubsystem = mock(CPSubsystem.class);
    when(mockHazelcastInstance.getCPSubsystem()).thenReturn(cpSubsystem);
    when(cpSubsystem.getLock("my-lock")).thenReturn(mockLock);
    assertEquals(mockLock, hazelcastOSGiInstance.getCPSubsystem().getLock("my-lock"));
    verify(cpSubsystem).getLock("my-lock");
}
Also used : FencedLock(com.hazelcast.cp.lock.FencedLock) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSubsystem(com.hazelcast.cp.CPSubsystem) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CPSubsystem

use of com.hazelcast.cp.CPSubsystem in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getAtomicLongCalledSuccessfullyOverOSGiInstance.

@Test
public void getAtomicLongCalledSuccessfullyOverOSGiInstance() {
    IAtomicLong mockAtomicLong = mock(IAtomicLong.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    CPSubsystem cpSubsystem = mock(CPSubsystem.class);
    when(mockHazelcastInstance.getCPSubsystem()).thenReturn(cpSubsystem);
    when(mockHazelcastInstance.getCPSubsystem().getAtomicLong("my-atomiclong")).thenReturn(mockAtomicLong);
    assertEquals(mockAtomicLong, hazelcastOSGiInstance.getCPSubsystem().getAtomicLong("my-atomiclong"));
    verify(cpSubsystem).getAtomicLong("my-atomiclong");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSubsystem(com.hazelcast.cp.CPSubsystem) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) IAtomicLong(com.hazelcast.cp.IAtomicLong) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with CPSubsystem

use of com.hazelcast.cp.CPSubsystem in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getAtomicReferenceCalledSuccessfullyOverOSGiInstance.

@Test
public void getAtomicReferenceCalledSuccessfullyOverOSGiInstance() {
    IAtomicReference<Object> mockAtomicReference = mock(IAtomicReference.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    CPSubsystem cpSubsystem = mock(CPSubsystem.class);
    when(mockHazelcastInstance.getCPSubsystem()).thenReturn(cpSubsystem);
    when(cpSubsystem.getAtomicReference("my-atomicreference")).thenReturn(mockAtomicReference);
    assertEquals(mockAtomicReference, hazelcastOSGiInstance.getCPSubsystem().getAtomicReference("my-atomicreference"));
    verify(cpSubsystem).getAtomicReference("my-atomicreference");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSubsystem(com.hazelcast.cp.CPSubsystem) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) DistributedObject(com.hazelcast.core.DistributedObject) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with CPSubsystem

use of com.hazelcast.cp.CPSubsystem in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getSemaphoreCalledSuccessfullyOverOSGiInstance.

@Test
public void getSemaphoreCalledSuccessfullyOverOSGiInstance() {
    ISemaphore mockSemaphore = mock(ISemaphore.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    CPSubsystem cpSubsystem = mock(CPSubsystem.class);
    when(mockHazelcastInstance.getCPSubsystem()).thenReturn(cpSubsystem);
    when(cpSubsystem.getSemaphore("my-semaphore")).thenReturn(mockSemaphore);
    assertEquals(mockSemaphore, hazelcastOSGiInstance.getCPSubsystem().getSemaphore("my-semaphore"));
    verify(cpSubsystem).getSemaphore("my-semaphore");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSubsystem(com.hazelcast.cp.CPSubsystem) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) ISemaphore(com.hazelcast.cp.ISemaphore) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with CPSubsystem

use of com.hazelcast.cp.CPSubsystem in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getCountDownLatchCalledSuccessfullyOverOSGiInstance.

@Test
public void getCountDownLatchCalledSuccessfullyOverOSGiInstance() {
    ICountDownLatch mockCountDownLatch = mock(ICountDownLatch.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    CPSubsystem cpSubsystem = mock(CPSubsystem.class);
    when(mockHazelcastInstance.getCPSubsystem()).thenReturn(cpSubsystem);
    when(cpSubsystem.getCountDownLatch("my-countdownlatch")).thenReturn(mockCountDownLatch);
    assertEquals(mockCountDownLatch, hazelcastOSGiInstance.getCPSubsystem().getCountDownLatch("my-countdownlatch"));
    verify(cpSubsystem).getCountDownLatch("my-countdownlatch");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CPSubsystem(com.hazelcast.cp.CPSubsystem) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) ICountDownLatch(com.hazelcast.cp.ICountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 CPSubsystem (com.hazelcast.cp.CPSubsystem)5 HazelcastOSGiTestUtil.createHazelcastOSGiInstance (com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 DistributedObject (com.hazelcast.core.DistributedObject)1 IAtomicLong (com.hazelcast.cp.IAtomicLong)1 ICountDownLatch (com.hazelcast.cp.ICountDownLatch)1 ISemaphore (com.hazelcast.cp.ISemaphore)1 FencedLock (com.hazelcast.cp.lock.FencedLock)1