Search in sources :

Example 6 with MissingDependency

use of org.apache.felix.dm.diagnostics.MissingDependency in project felix by apache.

the class DiagnosticsTest method testMissingCustomDependencies.

public void testMissingCustomDependencies() {
    DependencyManager dm = getDM();
    Component component0 = dm.createComponent().setImplementation(C0.class).add(dm.createServiceDependency().setService(S1.class).setRequired(true)).add(dm.createServiceDependency().setService(S2.class).setRequired(true));
    Component component1 = dm.createComponent().setImplementation(S1Impl1.class).setInterface(S1.class.getName(), null).add(ToggleDependency.create());
    m_dm.add(component0);
    m_dm.add(component1);
    DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
    List<MissingDependency> missingCustomDependencies = graph.getMissingCustomDependencies();
    assertEquals(1, missingCustomDependencies.size());
    MissingDependency missingCustomeDependency = missingCustomDependencies.get(0);
    assertTrue(missingCustomeDependency.getType().equals("toggle"));
    assertTrue(missingCustomeDependency.getName().equals("false"));
    List<MissingDependency> missingDependencies = graph.getMissingDependencies("service");
    assertEquals(1, missingDependencies.size());
}
Also used : MissingDependency(org.apache.felix.dm.diagnostics.MissingDependency) DependencyManager(org.apache.felix.dm.DependencyManager) DependencyGraph(org.apache.felix.dm.diagnostics.DependencyGraph) Component(org.apache.felix.dm.Component)

Aggregations

DependencyGraph (org.apache.felix.dm.diagnostics.DependencyGraph)6 MissingDependency (org.apache.felix.dm.diagnostics.MissingDependency)6 Component (org.apache.felix.dm.Component)5 DependencyManager (org.apache.felix.dm.DependencyManager)5 ComponentDeclaration (org.apache.felix.dm.ComponentDeclaration)2 CircularDependency (org.apache.felix.dm.diagnostics.CircularDependency)2 ConfigurationDependency (org.apache.felix.dm.ConfigurationDependency)1 ServiceDependency (org.apache.felix.dm.ServiceDependency)1