use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class ConfigurationDependencyTest method testComponentWithRequiredConfigurationWithComponentArgAndServicePropertyPropagation.
public void testComponentWithRequiredConfigurationWithComponentArgAndServicePropertyPropagation() {
DependencyManager m = getDM();
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
Component s1 = m.createComponent().setImplementation(new ConfigurationConsumerWithComponentArg(e)).setInterface(Runnable.class.getName(), null).add(m.createConfigurationDependency().setPid(PID).setPropagate(true));
Component s2 = m.createComponent().setImplementation(new ConfigurationCreator(e, PID)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
Component s3 = m.createComponent().setImplementation(new ConfiguredServiceConsumer(e)).add(m.createServiceDependency().setService(Runnable.class, ("(testkey=testvalue)")).setRequired(true));
m.add(s1);
m.add(s2);
m.add(s3);
e.waitForStep(4, 50000000);
m.remove(s1);
m.remove(s2);
m.remove(s3);
// ensure we executed all steps inside the component instance
e.step(6);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class DiagnosticsTest method testSingleComponent.
public void testSingleComponent() throws Exception {
DependencyManager dm = getDM();
Component component = dm.createComponent().setImplementation(Object.class);
dm.add(component);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.ALL, DependencyState.ALL);
assertTrue(checkComponentCount(1, graph.getAllComponents().size()));
assertTrue(graph.getAllDependencies().isEmpty());
graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.ALL_UNAVAILABLE);
assertTrue(graph.getAllComponents().isEmpty());
assertTrue(graph.getAllDependencies().isEmpty());
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class DiagnosticsTest method testCircularDependencies.
public void testCircularDependencies() throws Exception {
DependencyManager dm = getDM();
Component component0 = dm.createComponent().setImplementation(C0.class).add(dm.createServiceDependency().setService(S1.class).setRequired(true));
Component component1 = dm.createComponent().setImplementation(S1Impl1.class).setInterface(S1.class.getName(), null).add(dm.createServiceDependency().setService(S2.class).setRequired(true));
Component component2 = dm.createComponent().setImplementation(S2Impl1.class).setInterface(S2.class.getName(), null).add(dm.createServiceDependency().setService(S1.class).setRequired(true));
m_dm.add(component0);
m_dm.add(component1);
m_dm.add(component2);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
List<CircularDependency> circularDependencies = graph.getCircularDependencies();
assertEquals(1, circularDependencies.size());
List<ComponentDeclaration> circularDependencyComponents = circularDependencies.get(0).getComponents();
assertTrue(circularDependencyComponents.contains(component1));
assertTrue(circularDependencyComponents.contains(component2));
assertFalse(circularDependencyComponents.contains(component0));
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class DiagnosticsTest method testConfigurationDependencyMissing.
public void testConfigurationDependencyMissing() throws Exception {
DependencyManager dm = getDM();
ConfigurationDependency configurationDependency1 = dm.createConfigurationDependency().setPid("missing.configuration.pid");
Component component1 = dm.createComponent().setImplementation(Object.class).add(configurationDependency1);
m_dm.add(component1);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
assertEquals(1, graph.getAllComponents().size());
assertEquals(1, graph.getAllDependencies().size());
List<MissingDependency> missingServiceDependencies = graph.getMissingDependencies("service");
assertTrue(missingServiceDependencies.isEmpty());
List<MissingDependency> missingConfigDependencies = graph.getMissingDependencies("configuration");
assertEquals(1, missingConfigDependencies.size());
MissingDependency missingConfigDependency = missingConfigDependencies.get(0);
assertEquals("missing.configuration.pid", missingConfigDependency.getName());
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class DiagnosticsTest method testProvidersWithoutProperties.
public void testProvidersWithoutProperties() throws Exception {
DependencyManager dm = getDM();
ServiceDependency serviceDependency1 = dm.createServiceDependency().setService(S1.class).setRequired(true);
Component component1 = dm.createComponent().setImplementation(C0.class).add(serviceDependency1);
Component component2 = dm.createComponent().setImplementation(S1Impl1.class).setInterface(S1.class.getName(), null);
Component component3 = dm.createComponent().setImplementation(S1Impl2.class).setInterface(S1.class.getName(), null);
dm.add(component1);
dm.add(component2);
dm.add(component3);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.ALL, DependencyState.ALL);
List<ComponentDeclaration> providers = graph.getProviders(serviceDependency1);
assertEquals(2, providers.size());
assertTrue(providers.contains(component2));
assertTrue(providers.contains(component3));
}
Aggregations