Search in sources :

Example 26 with HazelcastInternalOSGiService

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

the class HazelcastOSGiServiceTest method serviceRetrievedSuccessfully.

@Test
public void serviceRetrievedSuccessfully() {
    HazelcastInternalOSGiService service = getService();
    assertNotNull(service);
}
Also used : HazelcastInternalOSGiService(com.hazelcast.osgi.impl.HazelcastInternalOSGiService) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 27 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 28 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 29 with HazelcastInternalOSGiService

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

the class HazelcastOSGiServiceTest method clusterNameIsSetToSpecifiedClusterNameWhenGroupingIsDisabled.

@Test
public void clusterNameIsSetToSpecifiedClusterNameWhenGroupingIsDisabled() throws BundleException {
    final String CLUSTER_NAME = "my-osgi-cluster";
    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.setClusterName(CLUSTER_NAME);
        HazelcastOSGiInstance osgiInstance = service.newHazelcastInstance(config);
        assertEquals(CLUSTER_NAME, osgiInstance.getConfig().getClusterName());
        HazelcastInstance instance = osgiInstance.getDelegatedInstance();
        assertEquals(CLUSTER_NAME, instance.getConfig().getClusterName());
    } finally {
        if (propValue != null) {
            System.setProperty(HazelcastOSGiService.HAZELCAST_OSGI_GROUPING_DISABLED, propValue);
        }
        if (testBundle != null) {
            testBundle.stop();
        }
    }
}
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