use of org.apache.felix.scr.integration.components.circular.B in project felix by apache.
the class CircularReferenceTest method test_A11_B0n_immediate_B_first.
/**
* A > 1.1 > B > 0..n > A Both should start (B first), and B should have an A reference.
* @throws InvalidSyntaxException
*/
@Test
public void test_A11_B0n_immediate_B_first() throws InvalidSyntaxException {
String componentNameA = "3.A.1.1.dynamic";
final ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA, ComponentConfigurationDTO.ACTIVE);
A a = getServiceFromConfiguration(componentA, A.class);
assertEquals(1, a.getBs().size());
delay();
String componentNameB = "3.B.0.n.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName(componentNameB, ComponentConfigurationDTO.ACTIVE);
B b = getServiceFromConfiguration(componentB, B.class);
assertEquals(1, b.getAs().size());
}
use of org.apache.felix.scr.integration.components.circular.B in project felix by apache.
the class CircularReferenceTest method test_A11_B0n_immediate_A_first.
/**
* A > 1.1 > B > 0..n > A Both should start (A first), but B should not have an A reference.
* @throws InvalidSyntaxException
*/
@Test
public void test_A11_B0n_immediate_A_first() throws InvalidSyntaxException {
String componentNameA = "2.A.1.1.dynamic";
final ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE);
A a = getServiceFromConfiguration(componentA, A.class);
assertEquals(1, a.getBs().size());
delay();
String componentNameB = "2.B.0.n.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName(componentNameB, ComponentConfigurationDTO.ACTIVE);
B b = getServiceFromConfiguration(componentB, B.class);
assertEquals(1, b.getAs().size());
}
use of org.apache.felix.scr.integration.components.circular.B in project felix by apache.
the class CircularReferenceTest method do_testA11_immediate_B0n_delayed.
protected void do_testA11_immediate_B0n_delayed(String componentNameA, String componentNameB) throws InvalidSyntaxException {
final ComponentConfigurationDTO componentB = findComponentConfigurationByName(componentNameB, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE);
ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences(B.class.getName(), "(service.pid=" + componentNameB + ")");
TestCase.assertEquals(1, serviceReferencesB.length);
ServiceReference<B> serviceReferenceB = serviceReferencesB[0];
B b = bundleContext.getService(serviceReferenceB);
ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE);
ServiceReference[] serviceReferencesA = bundleContext.getServiceReferences(A.class.getName(), "(service.pid=" + componentNameA + ")");
TestCase.assertEquals(1, serviceReferencesA.length);
ServiceReference<A> serviceReferenceA = serviceReferencesA[0];
A a = bundleContext.getService(serviceReferenceA);
assertNotNull(a);
assertEquals(1, a.getBs().size());
delay();
assertEquals(1, b.getAs().size());
assertNotNull(b.getAs().get(0));
}
use of org.apache.felix.scr.integration.components.circular.B in project felix by apache.
the class CircularReferenceTest method test_A11_B0n_delayed_A_first.
/**
* A > 1.1 > B > 0..n > A Both should start, but B should not have an A reference.
*/
@Test
public void test_A11_B0n_delayed_A_first() throws InvalidSyntaxException {
String componentNameA = "4.A.1.1.dynamic";
final ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA, ComponentConfigurationDTO.SATISFIED);
String componentNameB = "4.B.0.n.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName(componentNameB, ComponentConfigurationDTO.SATISFIED);
delay();
A a = getServiceFromConfiguration(componentA, A.class);
assertEquals(1, a.getBs().size());
// async binding of a to b after circular ref detected
delay();
B b = getServiceFromConfiguration(componentB, B.class);
assertEquals(1, b.getAs().size());
}
use of org.apache.felix.scr.integration.components.circular.B in project felix by apache.
the class CircularReferenceTest method test_A11_B01_delayed_A_first.
/**
* A > 1.1 > B > 0..1 > A Both should start, but B should not have an A reference.
*/
@Test
public void test_A11_B01_delayed_A_first() throws InvalidSyntaxException {
String componentNameA = "7.A.1.1.dynamic";
final ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA, ComponentConfigurationDTO.SATISFIED);
String componentNameB = "7.B.0.1.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName(componentNameB, ComponentConfigurationDTO.SATISFIED);
ServiceReference[] serviceReferences = bundleContext.getServiceReferences(A.class.getName(), "(service.pid=" + componentNameA + ")");
TestCase.assertEquals(1, serviceReferences.length);
ServiceReference serviceReference = serviceReferences[0];
Object service = bundleContext.getService(serviceReference);
assertNotNull(service);
delay();
A a = getServiceFromConfiguration(componentA, A.class);
assertEquals(1, a.getBs().size());
B b = getServiceFromConfiguration(componentB, B.class);
assertEquals(1, b.getAs().size());
}
Aggregations