use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class FELIX2696_ConfigurationAndServiceDependencyTest method testComponentWithRequiredConfigurationAndServicePropertyPropagation.
public void testComponentWithRequiredConfigurationAndServicePropertyPropagation() {
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 ConfigurationConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true)).add(m.createConfigurationDependency().setPid(PID));
Component s2 = m.createComponent().setImplementation(new ConfigurationCreator(e)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
Component s3 = m.createComponent().setInterface(ServiceInterface.class.getName(), null).setImplementation(DependentServiceProvider.class);
m.add(s1);
m.add(s2);
m.add(s3);
e.waitForStep(2, 5000);
warn("removing s3");
m.remove(s3);
warn("readding s3");
m.add(s3);
// after adding the required dependency again, the issue in FELIX-2696 means that the
// updated() method is not invoked for the new instance, and init() is, so our step
// count will only go up to 3 (not 4) causing this test to fail
e.waitForStep(4, 5000);
m.remove(s3);
m.remove(s2);
m.remove(s1);
e.waitForStep(5, 5000);
}
use of org.apache.felix.dm.DependencyManager in project felix by apache.
the class FELIX4158_DependencyDeclarationTest method testResourceDependencyDeclarationWithFilter.
public void testResourceDependencyDeclarationWithFilter() {
DependencyManager m = getDM();
Component c = m.createComponent().setImplementation(new Object()).add(m.createResourceDependency().setFilter("(&(path=/path/to/*.txt)(host=localhost))"));
ComponentDeclaration cd = c.getComponentDeclaration();
ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
Assert.assertNotNull(cdds);
Assert.assertNotNull(cdds.length == 1);
Assert.assertEquals(cdds[0].getName(), ("(&(path=/path/to/*.txt)(host=localhost))"));
Assert.assertNull(cdds[0].getSimpleName());
Assert.assertNotNull(cdds[0].getFilter());
Assert.assertEquals(cdds[0].getFilter(), "(&(path=/path/to/*.txt)(host=localhost))");
m.clear();
}
use of org.apache.felix.dm.DependencyManager 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();
}
use of org.apache.felix.dm.DependencyManager 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();
}
use of org.apache.felix.dm.DependencyManager 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();
}
Aggregations