Search in sources :

Example 11 with HazelcastInternalOSGiService

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) HashSet(java.util.HashSet) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 12 with HazelcastInternalOSGiService

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());
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 13 with HazelcastInternalOSGiService

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();
        }
    }
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 14 with HazelcastInternalOSGiService

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());
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 15 with HazelcastInternalOSGiService

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();
        }
    }
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

HazelcastInternalOSGiService (com.hazelcast.osgi.impl.HazelcastInternalOSGiService)23 SlowTest (com.hazelcast.test.annotation.SlowTest)23 Test (org.junit.Test)23 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 Config (com.hazelcast.config.Config)11 GroupConfig (com.hazelcast.config.GroupConfig)11 HashSet (java.util.HashSet)3