Search in sources :

Example 6 with HazelcastInternalOSGiService

use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.

the class HazelcastOSGiServiceTest method newInstanceRegisteredAsServiceWhenRegistrationIsNotDisabled.

@Test
public void newInstanceRegisteredAsServiceWhenRegistrationIsNotDisabled() throws BundleException {
    HazelcastInternalOSGiService service = getService();
    service.newHazelcastInstance();
    assertNull(bundleContext.getServiceReference(HazelcastOSGiInstance.class.getName()));
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 7 with HazelcastInternalOSGiService

use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.

the class HazelcastOSGiServiceTest method allInstancesShutdownSuccessfully.

@Test
public void allInstancesShutdownSuccessfully() {
    Set<HazelcastOSGiInstance> osgiInstances = new HashSet<HazelcastOSGiInstance>();
    HazelcastInternalOSGiService service = getService();
    osgiInstances.add(service.newHazelcastInstance());
    osgiInstances.add(service.newHazelcastInstance(new Config("test-osgi-instance")));
    Set<HazelcastOSGiInstance> allOSGiInstances = service.getAllHazelcastInstances();
    for (HazelcastOSGiInstance osgiInstance : allOSGiInstances) {
        assertTrue(osgiInstance.getLifecycleService().isRunning());
        HazelcastInstance instance = osgiInstance.getDelegatedInstance();
        assertTrue(instance.getLifecycleService().isRunning());
    }
    service.shutdownAll();
    for (HazelcastOSGiInstance osgiInstance : osgiInstances) {
        assertFalse(osgiInstance.getLifecycleService().isRunning());
        HazelcastInstance instance = osgiInstance.getDelegatedInstance();
        assertFalse(instance.getLifecycleService().isRunning());
    }
    allOSGiInstances = service.getAllHazelcastInstances();
    assertEquals(0, allOSGiInstances.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) HashSet(java.util.HashSet) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 8 with HazelcastInternalOSGiService

use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.

the class HazelcastOSGiServiceTest method clusterNameIsSetToDefaultClusterNameOfBundleWhenGroupingIsNotDisabled.

@Test
public void clusterNameIsSetToDefaultClusterNameOfBundleWhenGroupingIsNotDisabled() {
    HazelcastInternalOSGiService service = getService();
    HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance();
    assertEquals(HazelcastInternalOSGiService.DEFAULT_CLUSTER_NAME, osgiInstance.getConfig().getClusterName());
    HazelcastInstance instance = osgiInstance.getDelegatedInstance();
    assertEquals(HazelcastInternalOSGiService.DEFAULT_CLUSTER_NAME, instance.getConfig().getClusterName());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 9 with HazelcastInternalOSGiService

use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.

the class HazelcastOSGiServiceTest method serviceDeactivatedAndThenActivatedSuccessfully.

@Test
public void serviceDeactivatedAndThenActivatedSuccessfully() throws BundleException {
    HazelcastInternalOSGiService service = getService();
    assertTrue(service.isActive());
    bundle.stop();
    assertFalse(service.isActive());
    assertNull(getService());
    bundle.start();
    assertTrue(service.isActive());
    assertNotNull(getService());
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 10 with HazelcastInternalOSGiService

use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.

the class HazelcastOSGiServiceTest method instanceShutdownSuccessfully.

@Test
public void instanceShutdownSuccessfully() {
    final String INSTANCE_NAME = "test-osgi-instance";
    HazelcastInternalOSGiService service = getService();
    Config config = new Config(INSTANCE_NAME);
    HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance(config);
    assertTrue(osgiInstance.getLifecycleService().isRunning());
    HazelcastInstance instance = osgiInstance.getDelegatedInstance();
    assertTrue(instance.getLifecycleService().isRunning());
    service.shutdownHazelcastInstance(osgiInstance);
    assertFalse(osgiInstance.getLifecycleService().isRunning());
    assertFalse(instance.getLifecycleService().isRunning());
    assertNull(service.getHazelcastInstanceByName(INSTANCE_NAME));
    assertFalse(service.getAllHazelcastInstances().contains(osgiInstance));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

HazelcastInternalOSGiService (com.hazelcast.osgi.impl.HazelcastInternalOSGiService)29 SlowTest (com.hazelcast.test.annotation.SlowTest)29 Test (org.junit.Test)29 HazelcastInstance (com.hazelcast.core.HazelcastInstance)19 Config (com.hazelcast.config.Config)15 GroupConfig (com.hazelcast.config.GroupConfig)4 HashSet (java.util.HashSet)3