use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method groupNameIsSetToDefaultGroupNameOfBundleWhenConfigIsGivenWithNullGroupConfigAndGroupingIsNotDisabled.
@Test
public void groupNameIsSetToDefaultGroupNameOfBundleWhenConfigIsGivenWithNullGroupConfigAndGroupingIsNotDisabled() {
Config config = new Config();
config.setGroupConfig(null);
HazelcastInternalOSGiService service = getService();
HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance(config);
assertEquals(HazelcastInternalOSGiService.DEFAULT_GROUP_NAME, osgiInstance.getConfig().getGroupConfig().getName());
HazelcastInstance instance = osgiInstance.getDelegatedInstance();
assertEquals(HazelcastInternalOSGiService.DEFAULT_GROUP_NAME, instance.getConfig().getGroupConfig().getName());
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method instanceShutdownSuccessfullyAlthoughThereIsExceptionWhileDeregister.
@Test
public void instanceShutdownSuccessfullyAlthoughThereIsExceptionWhileDeregister() {
final String INSTANCE_NAME = "test-osgi-instance";
registerDeregisterListener.throwExceptionOnDeregister = true;
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));
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method instanceRetrievedSuccessfullyWithItsName.
@Test
public void instanceRetrievedSuccessfullyWithItsName() {
final String INSTANCE_NAME = "test-osgi-instance";
HazelcastInternalOSGiService service = getService();
Config config = new Config(INSTANCE_NAME);
service.newHazelcastInstance(config);
HazelcastOSGiInstance osgiInstance = service.getHazelcastInstanceByName(INSTANCE_NAME);
assertNotNull(osgiInstance);
assertEquals(config, osgiInstance.getConfig());
HazelcastInstance instance = osgiInstance.getDelegatedInstance();
assertNotNull(instance);
assertEquals(config, instance.getConfig());
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method groupNameIsSetToSpecifiedGroupNameWhenGroupingIsDisabled.
@Test
public void groupNameIsSetToSpecifiedGroupNameWhenGroupingIsDisabled() throws BundleException {
final String GROUP_NAME = "my-osgi-group";
String propValue = System.getProperty(HazelcastOSGiService.HAZELCAST_OSGI_GROUPING_DISABLED);
TestBundle testBundle = null;
try {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_GROUPING_DISABLED, "true");
testBundle = new TestBundle();
TestBundleContext testBundleContext = testBundle.getBundleContext();
testBundle.start();
HazelcastInternalOSGiService service = getService(testBundleContext);
assertNotNull(service);
Config config = new Config();
config.getGroupConfig().setName(GROUP_NAME);
HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance(config);
assertEquals(GROUP_NAME, osgiInstance.getConfig().getGroupConfig().getName());
HazelcastInstance instance = osgiInstance.getDelegatedInstance();
assertEquals(GROUP_NAME, instance.getConfig().getGroupConfig().getName());
} finally {
if (propValue != null) {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_GROUPING_DISABLED, propValue);
}
if (testBundle != null) {
testBundle.stop();
}
}
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method serviceIsNotOperationalWhenItIsNotActive.
@Test
public void serviceIsNotOperationalWhenItIsNotActive() throws BundleException {
TestBundle testBundle = null;
try {
testBundle = new TestBundle();
TestBundleContext testBundleContext = testBundle.getBundleContext();
testBundle.start();
HazelcastInternalOSGiService service = getService(testBundleContext);
assertNotNull(service);
testBundle.stop();
testBundle = null;
try {
service.newHazelcastInstance();
fail("OSGI service is not active so it is not in operation mode." + " It is expected to get `IllegalStateException` here!");
} catch (IllegalStateException e) {
// since the bundle is not active, it is expected to get `IllegalStateException`
}
} finally {
if (testBundle != null) {
testBundle.stop();
}
}
}
Aggregations