use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method allInstancesShutdownSuccessfullyAlthoughThereIsExceptionWhileDeregister.
@Test
public void allInstancesShutdownSuccessfullyAlthoughThereIsExceptionWhileDeregister() {
Set<HazelcastOSGiInstance> osgiInstances = new HashSet<HazelcastOSGiInstance>();
registerDeregisterListener.throwExceptionOnDeregister = true;
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());
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method bundleOfServiceRetrievedSuccessfully.
@Test
public void bundleOfServiceRetrievedSuccessfully() {
HazelcastInternalOSGiService service = getService();
assertEquals(bundle, service.getOwnerBundle());
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method newInstanceNotRegisteredAsServiceWhenRegistrationIsDisabled.
@Test
public void newInstanceNotRegisteredAsServiceWhenRegistrationIsDisabled() throws BundleException {
String propValue = System.getProperty(HazelcastOSGiService.HAZELCAST_OSGI_REGISTER_DISABLED);
TestBundle testBundle = null;
try {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_REGISTER_DISABLED, "true");
testBundle = new TestBundle();
TestBundleContext testBundleContext = testBundle.getBundleContext();
testBundle.start();
HazelcastInternalOSGiService service = getService(testBundleContext);
assertNotNull(service);
service.newHazelcastInstance();
assertNull(testBundleContext.getServiceReference(HazelcastOSGiInstance.class.getName()));
} finally {
if (propValue != null) {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_REGISTER_DISABLED, propValue);
}
if (testBundle != null) {
testBundle.stop();
}
}
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method defaultInstanceNotExistWhenItIsNotSpecified.
@Test
public void defaultInstanceNotExistWhenItIsNotSpecified() {
HazelcastInternalOSGiService service = getService();
assertNull(service.getDefaultHazelcastInstance());
}
use of com.hazelcast.osgi.impl.HazelcastInternalOSGiService in project hazelcast by hazelcast.
the class HazelcastOSGiServiceTest method defaultInstanceExistWhenItIsSpecified.
@Test
public void defaultInstanceExistWhenItIsSpecified() throws BundleException {
String propValue = System.getProperty(HazelcastOSGiService.HAZELCAST_OSGI_START);
TestBundle testBundle = null;
try {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_START, "true");
testBundle = new TestBundle();
testBundle.start();
HazelcastInternalOSGiService service = getService(testBundle.getBundleContext());
assertNotNull(service);
assertNotNull(service.getDefaultHazelcastInstance());
} finally {
if (propValue != null) {
System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_START, propValue);
}
if (testBundle != null) {
testBundle.stop();
}
}
}
Aggregations