Search in sources :

Example 11 with ComponentDeclaration

use of org.apache.felix.dm.ComponentDeclaration in project felix by apache.

the class FELIX4158_DependencyDeclarationTest method testBundleDependencyDeclarationWithFilter.

public void testBundleDependencyDeclarationWithFilter() throws MalformedURLException {
    DependencyManager m = getDM();
    Component c = m.createComponent().setImplementation(new Object()).add(m.createBundleDependency().setStateMask(Bundle.ACTIVE).setFilter("(DependencyManager-Component=*)"));
    ComponentDeclaration cd = c.getComponentDeclaration();
    ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
    Assert.assertNotNull(cdds);
    Assert.assertNotNull(cdds.length == 1);
    Assert.assertEquals(cdds[0].getName(), "active (DependencyManager-Component=*)");
    Assert.assertNotNull(cdds[0].getSimpleName());
    Assert.assertEquals(cdds[0].getSimpleName(), "active");
    Assert.assertNotNull(cdds[0].getFilter());
    Assert.assertEquals(cdds[0].getFilter(), "(DependencyManager-Component=*)");
    m.clear();
}
Also used : ComponentDeclaration(org.apache.felix.dm.ComponentDeclaration) DependencyManager(org.apache.felix.dm.DependencyManager) ComponentDependencyDeclaration(org.apache.felix.dm.ComponentDependencyDeclaration) Component(org.apache.felix.dm.Component)

Example 12 with ComponentDeclaration

use of org.apache.felix.dm.ComponentDeclaration in project felix by apache.

the class FELIX4158_DependencyDeclarationTest method testBundleDependencyDeclaration.

public void testBundleDependencyDeclaration() throws MalformedURLException {
    DependencyManager m = getDM();
    Component c = m.createComponent().setImplementation(new Object()).add(m.createBundleDependency());
    ComponentDeclaration cd = c.getComponentDeclaration();
    ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
    Assert.assertNotNull(cdds);
    Assert.assertNotNull(cdds.length == 1);
    Assert.assertEquals(cdds[0].getName(), "active installed resolved");
    Assert.assertNotNull(cdds[0].getSimpleName());
    Assert.assertEquals(cdds[0].getSimpleName(), "active installed resolved");
    Assert.assertNull(cdds[0].getFilter());
    m.clear();
}
Also used : ComponentDeclaration(org.apache.felix.dm.ComponentDeclaration) DependencyManager(org.apache.felix.dm.DependencyManager) ComponentDependencyDeclaration(org.apache.felix.dm.ComponentDependencyDeclaration) Component(org.apache.felix.dm.Component)

Example 13 with ComponentDeclaration

use of org.apache.felix.dm.ComponentDeclaration in project felix by apache.

the class FELIX4158_DependencyDeclarationTest method testBundleDependencyDeclarationWithMask.

public void testBundleDependencyDeclarationWithMask() throws MalformedURLException {
    DependencyManager m = getDM();
    Component c = m.createComponent().setImplementation(new Object()).add(m.createBundleDependency().setStateMask(Bundle.ACTIVE | Bundle.RESOLVED));
    ComponentDeclaration cd = c.getComponentDeclaration();
    ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
    Assert.assertNotNull(cdds);
    Assert.assertNotNull(cdds.length == 1);
    Assert.assertEquals(cdds[0].getName(), "active resolved");
    Assert.assertNotNull(cdds[0].getSimpleName());
    Assert.assertEquals(cdds[0].getSimpleName(), "active resolved");
    Assert.assertNull(cdds[0].getFilter());
    m.clear();
}
Also used : ComponentDeclaration(org.apache.felix.dm.ComponentDeclaration) DependencyManager(org.apache.felix.dm.DependencyManager) ComponentDependencyDeclaration(org.apache.felix.dm.ComponentDependencyDeclaration) Component(org.apache.felix.dm.Component)

Example 14 with ComponentDeclaration

use of org.apache.felix.dm.ComponentDeclaration in project felix by apache.

the class FELIX4158_DependencyDeclarationTest method testServiceDependencyDeclaration.

public void testServiceDependencyDeclaration() {
    DependencyManager m = getDM();
    Component c = m.createComponent().setImplementation(new Object()).add(m.createServiceDependency().setService(LogService.class, "(foo=bar)"));
    ComponentDeclaration cd = c.getComponentDeclaration();
    ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
    Assert.assertNotNull(cdds);
    Assert.assertNotNull(cdds.length == 1);
    Assert.assertEquals(cdds[0].getName(), "org.osgi.service.log.LogService (foo=bar)");
    Assert.assertEquals(cdds[0].getSimpleName(), "org.osgi.service.log.LogService");
    Assert.assertNotNull(cdds[0].getFilter());
    Assert.assertEquals(cdds[0].getFilter(), "(foo=bar)");
    m.clear();
}
Also used : ComponentDeclaration(org.apache.felix.dm.ComponentDeclaration) DependencyManager(org.apache.felix.dm.DependencyManager) ComponentDependencyDeclaration(org.apache.felix.dm.ComponentDependencyDeclaration) Component(org.apache.felix.dm.Component) LogService(org.osgi.service.log.LogService)

Example 15 with ComponentDeclaration

use of org.apache.felix.dm.ComponentDeclaration in project felix by apache.

the class FELIX4158_DependencyDeclarationTest method testConfigurationDependencyDeclaration.

public void testConfigurationDependencyDeclaration() {
    DependencyManager m = getDM();
    Component c = m.createComponent().setImplementation(new Object()).add(m.createConfigurationDependency().setPid("foo"));
    ComponentDeclaration cd = c.getComponentDeclaration();
    ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
    Assert.assertNotNull(cdds);
    Assert.assertNotNull(cdds.length == 1);
    Assert.assertEquals(cdds[0].getName(), "foo");
    Assert.assertEquals(cdds[0].getSimpleName(), "foo");
    Assert.assertNull(cdds[0].getFilter());
    m.clear();
}
Also used : ComponentDeclaration(org.apache.felix.dm.ComponentDeclaration) DependencyManager(org.apache.felix.dm.DependencyManager) ComponentDependencyDeclaration(org.apache.felix.dm.ComponentDependencyDeclaration) Component(org.apache.felix.dm.Component)

Aggregations

ComponentDeclaration (org.apache.felix.dm.ComponentDeclaration)18 Component (org.apache.felix.dm.Component)13 DependencyManager (org.apache.felix.dm.DependencyManager)12 ComponentDependencyDeclaration (org.apache.felix.dm.ComponentDependencyDeclaration)8 DependencyGraph (org.apache.felix.dm.diagnostics.DependencyGraph)6 CircularDependency (org.apache.felix.dm.diagnostics.CircularDependency)4 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ServiceDependency (org.apache.felix.dm.ServiceDependency)2 MissingDependency (org.apache.felix.dm.diagnostics.MissingDependency)2 URL (java.net.URL)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 Descriptor (org.apache.felix.service.command.Descriptor)1 Bundle (org.osgi.framework.Bundle)1 Filter (org.osgi.framework.Filter)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 LogService (org.osgi.service.log.LogService)1