Search in sources :

Example 61 with Ensure

use of org.apache.felix.dm.itest.util.Ensure in project felix by apache.

the class BundleDependencyAnnotationTest method testBundleAdapterServiceAnnotation.

/**
 * Tests a Bundle Adapter, which adapts the dependency manager bundle to a "ServiceInterface" service.
 * @throws Throwable
 */
public void testBundleAdapterServiceAnnotation() throws Throwable {
    Ensure e = new Ensure();
    ServiceRegistration sr = register(e, BundleDependencyAnnotation.ENSURE_ADAPTER);
    e.waitForStep(3, 10000);
    e.ensure();
    sr.unregister();
}
Also used : Ensure(org.apache.felix.dm.itest.util.Ensure) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 62 with Ensure

use of org.apache.felix.dm.itest.util.Ensure 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");
    }
}
Also used : ConfigurableComponentWithDynamicExtraConfiguration(org.apache.felix.dm.runtime.itest.components.ConfigurationDependencyAnnotation.ConfigurableComponentWithDynamicExtraConfiguration) Hashtable(java.util.Hashtable) IOException(java.io.IOException) Ensure(org.apache.felix.dm.itest.util.Ensure) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 63 with Ensure

use of org.apache.felix.dm.itest.util.Ensure 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");
    }
}
Also used : Hashtable(java.util.Hashtable) ConfigurableComponent(org.apache.felix.dm.runtime.itest.components.ConfigurationDependencyAnnotation.ConfigurableComponent) IOException(java.io.IOException) Ensure(org.apache.felix.dm.itest.util.Ensure) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 64 with Ensure

use of org.apache.felix.dm.itest.util.Ensure 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);
}
Also used : Ensure(org.apache.felix.dm.itest.util.Ensure) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 65 with Ensure

use of org.apache.felix.dm.itest.util.Ensure 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();
}
Also used : Ensure(org.apache.felix.dm.itest.util.Ensure) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

Ensure (org.apache.felix.dm.itest.util.Ensure)135 Component (org.apache.felix.dm.Component)90 DependencyManager (org.apache.felix.dm.DependencyManager)90 ServiceRegistration (org.osgi.framework.ServiceRegistration)42 Hashtable (java.util.Hashtable)32 Dictionary (java.util.Dictionary)8 URL (java.net.URL)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ResourceHandler (org.apache.felix.dm.ResourceHandler)5 IOException (java.io.IOException)4 Dependency (org.apache.felix.dm.Dependency)4 ServiceDependency (org.apache.felix.dm.ServiceDependency)4 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)4 ArrayList (java.util.ArrayList)2 ForkJoinPool (java.util.concurrent.ForkJoinPool)2 TimeUnit (java.util.concurrent.TimeUnit)2 ComponentStateListener (org.apache.felix.dm.ComponentStateListener)2 TestBase (org.apache.felix.dm.itest.util.TestBase)2 Bundle (org.osgi.framework.Bundle)2