Search in sources :

Example 1 with ServiceInterface2

use of org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2 in project sling by apache.

the class MockBundleContextDynamicReferencesTest method testAddRemoveMandatoryMultipleService.

@Test
public void testAddRemoveMandatoryMultipleService() {
    ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
    assertDependencies2(dependency2a, dependency2b);
    reg2b.unregister();
    assertDependencies2(dependency2a);
    // in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
    reg2a.unregister();
    assertDependencies2();
}
Also used : ServiceInterface2(org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Example 2 with ServiceInterface2

use of org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2 in project sling by apache.

the class MockBundleContextStaticGreedyReferencesTest method testAddRemoveMandatoryMultipleService_FailReg2aUnregister.

@Test(expected = ReferenceViolationException.class)
public void testAddRemoveMandatoryMultipleService_FailReg2aUnregister() {
    ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
    assertDependencies2(dependency2a, dependency2b);
    reg2b.unregister();
    assertDependencies2(dependency2a);
    // this should fail
    reg2a.unregister();
}
Also used : ServiceInterface2(org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Example 3 with ServiceInterface2

use of org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2 in project sling by apache.

the class MockBundleContextStaticGreedyReferencesTest method testAddRemoveMandatoryMultipleService.

@Test
public void testAddRemoveMandatoryMultipleService() {
    ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
    assertDependencies2(dependency2a, dependency2b);
    reg2b.unregister();
    assertDependencies2(dependency2a);
}
Also used : ServiceInterface2(org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Example 4 with ServiceInterface2

use of org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2 in project sling by apache.

the class MockBundleContextDynamicReferencesOsgiR6Test method testAddRemoveMandatoryMultipleService.

@Test
public void testAddRemoveMandatoryMultipleService() {
    ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
    assertDependencies2(dependency2a, dependency2b);
    reg2b.unregister();
    assertDependencies2(dependency2a);
    // in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
    reg2a.unregister();
    assertDependencies2();
}
Also used : ServiceInterface2(org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2) ServiceRegistration(org.osgi.framework.ServiceRegistration) Test(org.junit.Test)

Aggregations

ServiceInterface2 (org.apache.sling.testing.mock.osgi.OsgiServiceUtilTest.ServiceInterface2)4 Test (org.junit.Test)4 ServiceRegistration (org.osgi.framework.ServiceRegistration)4