use of org.apache.felix.dm.diagnostics.MissingDependency in project felix by apache.
the class DMCommand method wtf.
public void wtf() {
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
List<ComponentDeclaration> unregisteredComponents = graph.getAllComponents();
if (unregisteredComponents.isEmpty()) {
System.out.println("No unregistered components found");
} else {
String message = unregisteredComponents.size() + " unregistered components found";
System.out.println(message);
System.out.println("----------------------------------------------------".substring(0, message.length()));
}
listResolvedBundles();
listInstalledBundles();
List<CircularDependency> circularDependencies = graph.getCircularDependencies();
if (!circularDependencies.isEmpty()) {
System.out.println("Circular dependencies:");
printCircularDependencies(circularDependencies);
}
List<MissingDependency> missingConfigDependencies = graph.getMissingDependencies(CONFIGURATION);
if (!missingConfigDependencies.isEmpty()) {
System.out.println("The following configuration(s) are missing: ");
printMissingDependencies(missingConfigDependencies);
}
List<MissingDependency> missingServiceDependencies = graph.getMissingDependencies(SERVICE);
if (!missingServiceDependencies.isEmpty()) {
System.out.println("The following service(s) are missing: ");
printMissingDependencies(missingServiceDependencies);
}
List<MissingDependency> missingResourceDependencies = graph.getMissingDependencies(RESOURCE);
if (!missingResourceDependencies.isEmpty()) {
System.out.println("The following resource(s) are missing: ");
printMissingDependencies(missingResourceDependencies);
}
List<MissingDependency> missingBundleDependencies = graph.getMissingDependencies(BUNDLE);
if (!missingBundleDependencies.isEmpty()) {
System.out.println("The following bundle(s) are missing: ");
printMissingDependencies(missingBundleDependencies);
}
List<MissingDependency> missingCustomDependencies = graph.getMissingCustomDependencies();
if (!missingCustomDependencies.isEmpty()) {
System.out.println("The following custom dependency(ies) are missing: ");
printMissingCustomDependencies(missingCustomDependencies);
}
}
use of org.apache.felix.dm.diagnostics.MissingDependency 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.diagnostics.MissingDependency in project felix by apache.
the class DiagnosticsTest method testGraphsWithSeveralComponentDependencyCombinations.
public void testGraphsWithSeveralComponentDependencyCombinations() throws Exception {
DependencyManager dm = getDM();
Component component0 = dm.createComponent().setImplementation(C0.class).add(dm.createServiceDependency().setService(S1.class).setRequired(true)).add(dm.createServiceDependency().setService(S3.class).setRequired(true)).add(dm.createServiceDependency().setService(S4.class).setRequired(true));
Component component1 = dm.createComponent().setImplementation(C1.class).add(dm.createServiceDependency().setService(S5.class).setRequired(true)).add(dm.createServiceDependency().setService(S6.class).setRequired(true)).add(dm.createServiceDependency().setService(S7.class).setRequired(true));
Component s1Impl1 = dm.createComponent().setImplementation(S1Impl1.class).setInterface(S1.class.getName(), null).add(dm.createServiceDependency().setService(S2.class).setRequired(true));
Component s1Impl2 = dm.createComponent().setImplementation(S1Impl2.class).setInterface(S1.class.getName(), null);
Component s3Impl1 = dm.createComponent().setImplementation(S3Impl1.class).setInterface(S3.class.getName(), null).add(dm.createConfigurationDependency().setPid("missing.config.pid"));
Component s3s4Impl = dm.createComponent().setImplementation(S3S4Impl.class).setInterface(new String[] { S3.class.getName(), S4.class.getName() }, null);
Component s4Impl1 = dm.createComponent().setImplementation(S4Impl1.class).setInterface(S4.class.getName(), null);
Component s5Impl1 = dm.createComponent().setImplementation(S5Impl1.class).setInterface(S5.class.getName(), null);
Component s6s7Impl = dm.createComponent().setImplementation(S6S7Impl.class).setInterface(new String[] { S6.class.getName(), S7.class.getName() }, null).add(dm.createServiceDependency().setService(S8.class).setRequired(true));
Component s8Impl1 = dm.createComponent().setImplementation(S8Impl1.class).setInterface(S8.class.getName(), null).add(dm.createServiceDependency().setService(S6.class).setRequired(true));
dm.add(component0);
dm.add(component1);
dm.add(s1Impl1);
dm.add(s1Impl2);
dm.add(s3Impl1);
dm.add(s3s4Impl);
dm.add(s4Impl1);
dm.add(s5Impl1);
dm.add(s6s7Impl);
dm.add(s8Impl1);
// graph containing all components and dependencies
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.ALL, DependencyState.ALL);
List<ComponentDeclaration> allComponents = graph.getAllComponents();
assertTrue(checkComponentCount(10, allComponents.size()));
List<MissingDependency> missingDependencies = graph.getMissingDependencies("service");
assertEquals(1, missingDependencies.size());
missingDependencies = graph.getMissingDependencies("configuration");
assertEquals(1, missingDependencies.size());
List<CircularDependency> circularDependencies = graph.getCircularDependencies();
assertEquals(1, circularDependencies.size());
CircularDependency circularDependency = circularDependencies.get(0);
assertEquals(3, circularDependency.getComponents().size());
assertTrue(circularDependency.getComponents().contains(s6s7Impl));
assertTrue(circularDependency.getComponents().contains(s8Impl1));
// graph containing unregistered components and unavailable required dependencies
graph = null;
graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
List<ComponentDeclaration> unregComponents = graph.getAllComponents();
assertEquals(5, unregComponents.size());
assertTrue(unregComponents.contains(s1Impl1));
assertTrue(unregComponents.contains(s3Impl1));
assertTrue(unregComponents.contains(component1));
assertTrue(unregComponents.contains(s6s7Impl));
assertTrue(unregComponents.contains(s8Impl1));
assertFalse(unregComponents.contains(component0));
circularDependencies = graph.getCircularDependencies();
assertEquals(1, circularDependencies.size());
circularDependency = circularDependencies.get(0);
assertEquals(3, circularDependency.getComponents().size());
assertTrue(circularDependency.getComponents().contains(s6s7Impl));
assertTrue(circularDependency.getComponents().contains(s8Impl1));
missingDependencies = graph.getMissingDependencies("service");
assertEquals(1, missingDependencies.size());
missingDependencies = graph.getMissingDependencies("configuration");
assertEquals(1, missingDependencies.size());
// call getCircularDependencies again on the same graph
circularDependencies = graph.getCircularDependencies();
assertEquals(1, circularDependencies.size());
circularDependency = circularDependencies.get(0);
assertEquals(3, circularDependency.getComponents().size());
assertTrue(circularDependency.getComponents().contains(s6s7Impl));
assertTrue(circularDependency.getComponents().contains(s8Impl1));
List<MissingDependency> allMissingDependencies = graph.getMissingDependencies(null);
assertEquals(2, allMissingDependencies.size());
}
use of org.apache.felix.dm.diagnostics.MissingDependency in project felix by apache.
the class DiagnosticsTest method testWithTwoProvidersOneUnavailable.
public void testWithTwoProvidersOneUnavailable() {
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);
Component component2 = dm.createComponent().setImplementation(S1Impl2.class).setInterface(S1.class.getName(), null).add(dm.createServiceDependency().setService(S2.class).setRequired(true));
dm.add(component0);
dm.add(component1);
dm.add(component2);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
assertEquals(1, graph.getAllComponents().size());
List<MissingDependency> missingDependencies = graph.getMissingDependencies("service");
assertEquals(1, missingDependencies.size());
MissingDependency missingDependency = missingDependencies.get(0);
assertTrue(missingDependency.getName().equals(S2.class.getName()));
}
use of org.apache.felix.dm.diagnostics.MissingDependency in project felix by apache.
the class DiagnosticsTest method testServiceDependencyMissing.
public void testServiceDependencyMissing() throws Exception {
DependencyManager dm = getDM();
ServiceDependency serviceDependency1 = dm.createServiceDependency().setService(S1.class).setRequired(true);
ServiceDependency serviceDependency2 = dm.createServiceDependency().setService(S2.class).setRequired(true);
Component component1 = dm.createComponent().setImplementation(C0.class).add(serviceDependency1);
Component component2 = dm.createComponent().setImplementation(S1Impl1.class).setInterface(S1.class.getName(), null).add(serviceDependency2);
dm.add(component1);
dm.add(component2);
DependencyGraph graph = DependencyGraph.getGraph(ComponentState.UNREGISTERED, DependencyState.REQUIRED_UNAVAILABLE);
assertEquals(2, graph.getAllComponents().size());
assertEquals(2, graph.getAllDependencies().size());
List<MissingDependency> missingDependencies = graph.getMissingDependencies("service");
assertEquals(1, missingDependencies.size());
assertEquals(S2.class.getName(), missingDependencies.get(0).getName());
assertTrue(graph.getMissingDependencies("configuration").isEmpty());
assertTrue(graph.getMissingDependencies("bundle").isEmpty());
assertTrue(graph.getMissingDependencies("resource").isEmpty());
}
Aggregations