use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ComponentFactoryAnnotationTest method testServiceFactory.
public void testServiceFactory() {
ServiceRegistration sr = register(m_ensure, ComponentFactoryAnnotation.ENSURE);
DependencyManager m = new DependencyManager(context);
// Wait for the factory.
m.add(m.createComponent().setImplementation(this).add(m.createServiceDependency().setService(ComponentFactory.class, "(" + Component.FACTORY_NAME + "=" + ComponentFactoryAnnotation.FACTORY + ")").setRequired(true).setCallbacks("bindFactory", null)));
// Check if the test.annotation components have been initialized orderly
m_ensure.waitForStep(10, 5000);
m.clear();
sr.unregister();
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ConfigurationDependencyAnnotationTest method testConfigurationDependencyWithAnotherExtraDynamicConfigurationAnnotation.
/**
* Tests a Component two ConfigurationDependency (the second one is "instance bound"
* and its pid is declared from the init method).
*/
@SuppressWarnings({ "serial", "rawtypes", "unchecked" })
public void testConfigurationDependencyWithAnotherExtraDynamicConfigurationAnnotation() throws Throwable {
Ensure e = new Ensure();
ServiceRegistration sr = register(e, ConfigurableComponentWithDynamicExtraConfiguration.ENSURE);
ConfigurationAdmin cm = (ConfigurationAdmin) context.getService(context.getServiceReference(ConfigurationAdmin.class.getName()));
try {
org.osgi.service.cm.Configuration cf = cm.getConfiguration(ConfigurableComponentWithDynamicExtraConfiguration.class.getName(), null);
cf.update(new Hashtable() {
{
put("foo", "bar");
// Pid of the second Configuration Dependency.
put("dynamicPid", "dynamicPid");
}
});
org.osgi.service.cm.Configuration extraCf = cm.getConfiguration("dynamicPid", null);
extraCf.update(new Hashtable() {
{
put("foo2", "bar2");
}
});
e.waitForStep(4, MAXWAIT);
cf.delete();
extraCf.delete();
e.waitForStep(5, MAXWAIT);
e.ensure();
sr.unregister();
} catch (IOException err) {
err.printStackTrace();
Assert.fail("can't create factory configuration");
}
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ConfigurationDependencyAnnotationTest method testConfigurationDependencyAnnotation.
/**
* Tests the ConfigurationDependency annotation.
*/
@SuppressWarnings({ "serial", "rawtypes", "unchecked" })
public void testConfigurationDependencyAnnotation() throws Throwable {
Ensure e = new Ensure();
ServiceRegistration sr = register(e, ConfigurableComponent.ENSURE);
ConfigurationAdmin cm = (ConfigurationAdmin) context.getService(context.getServiceReference(ConfigurationAdmin.class.getName()));
try {
org.osgi.service.cm.Configuration cf = cm.getConfiguration(ConfigurableComponent.class.getName(), null);
cf.update(new Hashtable() {
{
put("foo", "bar");
}
});
e.waitForStep(1, MAXWAIT);
cf.delete();
e.waitForStep(3, MAXWAIT);
e.ensure();
sr.unregister();
} catch (IOException err) {
err.printStackTrace();
Assert.fail("can't create factory configuration");
}
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ConfigurationProxyTest method testConfigurationProxy.
/**
* Validates ServiceDependency method signatures.
*/
public void testConfigurationProxy() {
Ensure e = new Ensure();
ServiceRegistration sr = register(e, ConfigurationProxy.ENSURE_CONFIG_DEPENDENCY);
e.waitForStep(1, 5000);
sr.unregister();
e.waitForStep(3, 5000);
}
use of org.osgi.framework.ServiceRegistration in project felix by apache.
the class ExtraServicePropertiesTest method testExtraServiceProperties.
/**
* Tests if a Service can provide its service properties from its start method.
*/
public void testExtraServiceProperties() {
Ensure e = new Ensure();
ServiceRegistration sr = register(e, ExtraServiceProperties.ENSURE);
e.waitForStep(2, 10000);
sr.unregister();
}
Aggregations