Search in sources :

Example 1 with MultiManagedServiceTestActivator

use of org.apache.felix.cm.integration.helper.MultiManagedServiceTestActivator in project felix by apache.

the class MultiServicePIDTest method test_two_services_same_pid_in_same_bundle_configure_after_registration.

@Test
public void test_two_services_same_pid_in_same_bundle_configure_after_registration() throws BundleException {
    final String pid = "test.pid";
    bundle = installBundle(pid, MultiManagedServiceTestActivator.class);
    bundle.start();
    // give cm time for distribution
    delay();
    final MultiManagedServiceTestActivator tester = MultiManagedServiceTestActivator.INSTANCE;
    TestCase.assertNotNull("Activator not started !!", tester);
    // no configuration yet
    TestCase.assertNull("Expect Properties after Service Registration", tester.props);
    TestCase.assertEquals("Expect two update calls", 2, tester.numManagedServiceUpdatedCalls);
    configure(pid);
    delay();
    final Configuration config = getConfiguration(pid);
    TestCase.assertEquals(pid, config.getPid());
    TestCase.assertEquals(bundle.getLocation(), config.getBundleLocation());
    // assert activater has configuration (two calls, one per pid)
    TestCase.assertNotNull("Expect Properties after Service Registration", tester.props);
    TestCase.assertEquals("Expect another two single update call", 4, tester.numManagedServiceUpdatedCalls);
    bundle.uninstall();
    bundle = null;
    delay();
    TestCase.assertNull(config.getBundleLocation());
    // remove the configuration for good
    deleteConfig(pid);
}
Also used : MultiManagedServiceTestActivator(org.apache.felix.cm.integration.helper.MultiManagedServiceTestActivator) Configuration(org.osgi.service.cm.Configuration) Test(org.junit.Test)

Example 2 with MultiManagedServiceTestActivator

use of org.apache.felix.cm.integration.helper.MultiManagedServiceTestActivator in project felix by apache.

the class MultiServicePIDTest method test_two_services_same_pid_in_same_bundle_configure_before_registration.

@Test
public void test_two_services_same_pid_in_same_bundle_configure_before_registration() throws BundleException {
    final String pid = "test.pid";
    configure(pid);
    final Configuration config = getConfiguration(pid);
    TestCase.assertEquals(pid, config.getPid());
    TestCase.assertNull(config.getBundleLocation());
    bundle = installBundle(pid, MultiManagedServiceTestActivator.class);
    bundle.start();
    // give cm time for distribution
    delay();
    final MultiManagedServiceTestActivator tester = MultiManagedServiceTestActivator.INSTANCE;
    TestCase.assertNotNull("Activator not started !!", tester);
    // assert activater has configuration (two calls, one per pid)
    TestCase.assertNotNull("Expect Properties after Service Registration", tester.props);
    TestCase.assertEquals("Expect two update calls", 2, tester.numManagedServiceUpdatedCalls);
    TestCase.assertEquals(bundle.getLocation(), config.getBundleLocation());
    bundle.uninstall();
    bundle = null;
    delay();
    TestCase.assertNull(config.getBundleLocation());
    // remove the configuration for good
    deleteConfig(pid);
}
Also used : MultiManagedServiceTestActivator(org.apache.felix.cm.integration.helper.MultiManagedServiceTestActivator) Configuration(org.osgi.service.cm.Configuration) Test(org.junit.Test)

Aggregations

MultiManagedServiceTestActivator (org.apache.felix.cm.integration.helper.MultiManagedServiceTestActivator)2 Test (org.junit.Test)2 Configuration (org.osgi.service.cm.Configuration)2