Delete old tests.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1480617 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/api/pom.xml b/ipojo/tests/api/pom.xml
deleted file mode 100644
index 1f974e7..0000000
--- a/ipojo/tests/api/pom.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <groupId>ipojo.tests</groupId>
- <artifactId>org.apache.felix.ipojo.tests.api</artifactId>
- <packaging>jar</packaging>
- <version>${ipojo.api.snapshot}</version>
- <name>org.apache.felix.ipojo.tests.api</name>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.api</artifactId>
- <version>${ipojo.api.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version> <!-- TODO Revert to release once released -->
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- </dependency>
-
- <!-- For external handler management -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.whiteboard</artifactId>
- </dependency>
-
- <!--
- Pax Exam API:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.1.0</version>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.1.0</version>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-</project>
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/CompositeTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/CompositeTest.java
deleted file mode 100644
index 64cc3ed..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/CompositeTest.java
+++ /dev/null
@@ -1,275 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.api.Dependency;
-import org.apache.felix.ipojo.api.PrimitiveComponentType;
-import org.apache.felix.ipojo.api.Service;
-import org.apache.felix.ipojo.api.composite.CompositeComponentType;
-import org.apache.felix.ipojo.api.composite.ExportedService;
-import org.apache.felix.ipojo.api.composite.ImportedService;
-import org.apache.felix.ipojo.api.composite.Instance;
-import org.apache.felix.ipojo.api.composite.InstantiatedService;
-import org.example.service.Foo;
-import org.example.service.impl.FooImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-
-@RunWith( JUnit4TestRunner.class )
-public class CompositeTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.composite").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.api").version(asInProject())
- )
- );
- return opt;
- }
-
- @Test
- public void createACompositeWithcontainedInstance() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- PrimitiveComponentType cons = createAConsumer();
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp1")
- .addInstance(new Instance(prov.getFactory().getName()))
- .addInstance(new Instance(cons.getFactory().getName()));
-
- ComponentInstance ci = type.createInstance();
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
-
- // Stop cons
- cons.stop();
- assertThat("ci is invalid", ci.getState(), is(ComponentInstance.INVALID));
-
- // Restart cons
- cons.start();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createACompositeWithAnInstantiatedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- prov.start();
- PrimitiveComponentType cons = createAConsumer();
-
- ServiceReference[] refs = osgi.getServiceReferences(Factory.class.getName(),
- "(component.providedServiceSpecifications=" + Foo.class.getName() +")");
- assertThat(refs.length, is(not(0)));
-
- Factory factory = (Factory) osgi.getServiceObject(refs[0]);
- System.out.println(factory.getComponentDescription().getDescription());
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp2")
- .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()))
- .addInstance(new Instance(cons.getFactory().getName()));
-
- ComponentInstance ci = type.createInstance();
-
- System.out.println(ci.getInstanceDescription().getDescription());
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
-
- // Stop prov
- prov.stop();
- assertThat("ci is invalid", ci.getState(), is(ComponentInstance.INVALID));
-
- // Restart prov
- prov.start();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createACompositeWithAnOptionalInstantiatedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- prov.start();
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp3")
- .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()).setOptional(true));
-
- ComponentInstance ci = type.createInstance();
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
-
- // Stop prov
- prov.stop();
- assertThat("ci is valid - 1", ci.getState(), is(ComponentInstance.VALID));
-
- // Restart prov
- prov.start();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createACompositeWithAnImportedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- prov.createInstance();
- PrimitiveComponentType cons = createAConsumer();
-
- ServiceReference[] refs = osgi.getServiceReferences(Factory.class.getName(),
- "(component.providedServiceSpecifications=" + Foo.class.getName() +")");
- assertThat(refs.length, is(not(0)));
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp2")
- .addSubService(new ImportedService().setSpecification(Foo.class.getName()))
- .addInstance(new Instance(cons.getFactory().getName()));
-
- ComponentInstance ci = type.createInstance();
-
- System.out.println(ci.getInstanceDescription().getDescription());
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
-
- // Stop prov
- prov.stop();
- assertThat("ci is invalid", ci.getState(), is(ComponentInstance.INVALID));
-
- // Restart prov
- prov.start();
- prov.createInstance();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createACompositeWithAnOptionalImportedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- prov.createInstance();
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp3")
- .addSubService(new ImportedService().setSpecification(Foo.class.getName()).setOptional(true));
-
- ComponentInstance ci = type.createInstance();
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
-
- // Stop prov
- prov.stop();
- assertThat("ci is valid - 1", ci.getState(), is(ComponentInstance.VALID));
-
- // Restart prov
- prov.start();
- prov.createInstance();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createACompositeWithExportingAService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Define the component types
- PrimitiveComponentType prov = createAProvider();
- prov.start();
- PrimitiveComponentType cons = createAConsumer();
- ComponentInstance c = cons.createInstance();
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("compExport")
- .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()))
- .addService(new ExportedService().setSpecification(Foo.class.getName()));
-
- ComponentInstance ci = type.createInstance();
-
- assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
- assertThat("c is valid", c.getState(), is(ComponentInstance.VALID));
-
-
- // Stop prov
- prov.stop();
- assertThat("ci is invalid", ci.getState(), is(ComponentInstance.INVALID));
- assertThat("c is invalid", c.getState(), is(ComponentInstance.INVALID));
-
-
- // Restart prov
- prov.start();
- assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));
- assertThat("c is valid - 2", c.getState(), is(ComponentInstance.VALID));
-
-
- }
-
- private PrimitiveComponentType createAProvider() {
- return new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(FooImpl.class.getName())
- .setPublic(true)
- .addService(new Service()); // Provide the FooService
- }
-
- private PrimitiveComponentType createAConsumer() {
- return new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .addDependency(new Dependency().setField("myFoo"))
- .setValidateMethod("start");
- }
-
-
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/ExternalHandlerTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/ExternalHandlerTest.java
deleted file mode 100644
index 9c3dcf7..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/ExternalHandlerTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.api.PrimitiveComponentType;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.example.service.impl.HostImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-
-
-
-@RunWith( JUnit4TestRunner.class )
-public class ExternalHandlerTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.whiteboard").version(asInProject())
- )
- );
- return opt;
- }
-
- @Test
- public void createAHost() throws Exception {
- PrimitiveComponentType type = createAWhiteboardHost();
- ComponentInstance ci = type.createInstance();
- assertThat (ci.getState(), is (ComponentInstance.VALID));
- HandlerDescription hd = ci.getInstanceDescription().getHandlerDescription(Whiteboard.NAMESPACE + ":" + Whiteboard.NAME);
- assertThat (hd, is (notNullValue()));
- }
-
- @Test
- public void createDoubleHost() throws Exception {
- PrimitiveComponentType type = createASecondWhiteboardHost();
- ComponentInstance ci = type.createInstance();
- assertThat (ci.getState(), is (ComponentInstance.VALID));
- HandlerDescription hd = ci.getInstanceDescription().getHandlerDescription(Whiteboard.NAMESPACE + ":" + Whiteboard.NAME);
- assertThat (hd, is (notNullValue()));
- }
-
- private PrimitiveComponentType createAWhiteboardHost() {
- return new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(HostImpl.class.getName())
- .addHandler(new Whiteboard()
- .onArrival("arrival")
- .onDeparture("departure")
- .setFilter("(foo=foo)")
- );
- }
-
- private PrimitiveComponentType createASecondWhiteboardHost() {
- return new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(HostImpl.class.getName())
- .addHandler(new Whiteboard()
- .onArrival("arrival")
- .onDeparture("departure")
- .setFilter("(foo=foo)")
- )
- .addHandler(new Whiteboard()
- .onArrival("arrival")
- .onDeparture("departure")
- .setFilter("(foo=bar)")
- .onModification("modification")
- );
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/IPOJOHelper.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/IPOJOHelper.java
deleted file mode 100644
index 8943cbe..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/IPOJOHelper.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.tests.api;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-/**
- * iPOJO Helper.
- * This helper helps getting {@link Factory}, and managing
- * {@link ComponentInstance}.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class IPOJOHelper {
-
- /**
- * The bundle context.
- */
- private BundleContext m_context;
-
-
- /**
- * List of instances.
- */
- private List<ComponentInstance> m_instances;
-
- /**
- * Creates a IPOJOHelper.
- * @param tc the OSGi Test Case
- */
- public IPOJOHelper(BundleContext context) {
- m_context = context;
- m_instances = new ArrayList<ComponentInstance>();
- }
-
- /**
- * Disposes created instances.
- * @see org.apache.felix.ipojo.junit4osgi.Helper#dispose()
- */
- public void dispose() {
- for (int i = 0; i < m_instances.size(); i++) {
- ((ComponentInstance) m_instances.get(i)).dispose();
- }
- m_instances.clear();
- }
-
- /**
- * Gets a created instance from the instance name.
- * @param name the instance name.
- * @return the created {@link ComponentInstance} or <code>null</code>
- * if the instance was not created during the session.
- */
- public ComponentInstance getInstanceByName(String name) {
- for (int i = 0; i < m_instances.size(); i++) {
- if (((ComponentInstance) m_instances.get(i)).getInstanceName()
- .equals(name)) {
- return (ComponentInstance) m_instances.get(i);
- }
- }
- return null;
- }
-
- /**
- * Creates a new component instance with the given name (and empty
- * configuration), from the factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, String instanceName) {
-
- // Create the instance configuration
- Properties configuration = new Properties();
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(bundle, factoryName, configuration);
- }
-
- /**
- * Creates a new component instance with the given configuration, from the
- * factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param configuration the configuration of the component instance to
- * create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, Dictionary configuration) {
-
- // Retrieve the component factory.
- Factory fact = getFactory(bundle, factoryName);
-
- if (fact == null) {
- // Factory not found...
- throw new IllegalArgumentException(
- "Cannot find the component factory (" + factoryName
- + ") in the specified bundle ("
- + bundle.getSymbolicName() + ").");
- }
-
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Cannot create the component instance with the given configuration:"
- + e.getMessage());
- }
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, String instanceName, Dictionary configuration) {
-
- // Add the instance name to the configuration
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(bundle, factoryName, configuration);
- }
-
- /**
- * Creates a new component instance with the given name (and an empty
- * configuration), from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- String instanceName) {
-
- // Create the instance configuration
- Properties configuration = new Properties();
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(serviceContext, factoryName,
- configuration);
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- Dictionary configuration) {
-
- // Retrieve the component factory.
- Factory fact = getFactory(serviceContext, factoryName);
-
- if (fact == null) {
- // Factory not found...
- throw new IllegalArgumentException(
- "Cannot find the component factory (" + factoryName
- + ") in the specified service context.");
- }
-
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Cannot create the component instance with the given configuration: "
- + e.getMessage());
- }
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- String instanceName, Dictionary configuration) {
-
- // Add the instance name to the configuration
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(serviceContext, factoryName,
- configuration);
- }
-
- /**
- * Creates a new component instance with the given name (and empty
- * configuration), from the factory specified in the local bundle.
- *
- * @param factoryName the name of the component factory, defined in the
- * local bundle.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- String instanceName) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, instanceName);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with the given configuration, from the
- * factory specified in the local bundle.
- *
- * @param factoryName the name of the component factory, in the local
- * bundle.
- * @param configuration the configuration of the component instance to
- * create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- Dictionary configuration) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, configuration);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with no configuration, from the factory
- * specified in the local bundle.
- *
- * @param factoryName the name of the component factory, in the local
- * bundle.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, (Dictionary) null);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given bundle.
- *
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- String instanceName, Dictionary configuration) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, instanceName, configuration);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Returns the component factory with the given name in the local bundle.
- *
- * @param factoryName the name of the factory to retrieve.
- * @return the component factory with the given name in the local bundle, or
- * {@code null} if not found.
- */
- public Factory getFactory(String factoryName) {
- return getFactory(m_context.getBundle(), factoryName);
- }
-
- /**
- * Returns the handler factory with the given name in the local bundle.
- *
- * @param factoryName the name of the handler factory to retrieve.
- * @return the handler factory with the given name in the local bundle, or
- * {@code null} if not found.
- */
- public HandlerFactory getHandlerFactory(String factoryName) {
- return getHandlerFactory(m_context.getBundle(), factoryName);
- }
-
- /**
- * Returns the metadata description of the component defined in this bundle.
- *
- * @param component the name of the locally defined component.
- * @return the metadata description of the component with the given name,
- * defined in this given bundle, or {@code null} if not found.
- */
- public Element getMetadata(String component) {
- return getMetadata(m_context.getBundle(), component);
- }
-
- /**
- * Returns the component factory with the given name in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the defined factory.
- * @return the component factory with the given name in the given bundle, or
- * {@code null} if not found.
- */
- public static Factory getFactory(Bundle bundle, String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the component factories services in the bundle.
- refs = bundle.getBundleContext().getServiceReferences(
- Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs != null) {
- return (Factory) bundle.getBundleContext().getService(refs[0]);
- }
-
- // Factory not found...
- return null;
-
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get the component factory services: "
- + e.getMessage());
- }
- }
-
- /**
- * Returns the component factory with the given name, registered in the
- * given service context.
- *
- * @param serviceContext the service context in which the factory service is
- * defined.
- * @param factoryName the name of the factory.
- * @return the component factory with the given name, registered in the
- * given service context.
- */
- public static Factory getFactory(ServiceContext serviceContext,
- String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the component factories services in the service
- // context.
- refs = serviceContext.getServiceReferences(Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs != null) {
- return (Factory) serviceContext.getService(refs[0]);
- }
- return null;
-
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : "
- + e.getMessage());
- return null;
- }
- }
-
- /**
- * Returns the handler factory with the given name in the given bundle.
- *
- * @param bundle the bundle from which the handler factory is defined.
- * @param factoryName the name of the handler factory to retrieve.
- * @return the handler factory with the given name in the given bundle, or
- * {@code null} if not found.
- */
- public static HandlerFactory getHandlerFactory(Bundle bundle,
- String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the handler factories services in the bundle.
- refs = bundle.getBundleContext().getServiceReferences(
- HandlerFactory.class.getName(),
- "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName
- + ")");
- if (refs != null) {
- return (HandlerFactory) bundle.getBundleContext().getService(
- refs[0]);
- }
-
- // Factory not found...
- return null;
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get the handler factory services: "
- + e.getMessage());
- }
- }
-
- /**
- * Returns the metadata description of the component with the given name,
- * defined in the given bundle.
- *
- * @param bundle the bundle from which the component is defined.
- * @param component the name of the defined component.
- * @return the metadata description of the component with the given name,
- * defined in the given bundle, or {@code null} if not found.
- */
- public static Element getMetadata(Bundle bundle, String component) {
-
- // Retrieves the component description from the bundle's manifest.
- String elem = (String) bundle.getHeaders().get("iPOJO-Components");
- if (elem == null) {
- throw new IllegalArgumentException(
- "Cannot find iPOJO-Components descriptor in the specified bundle ("
- + bundle.getSymbolicName()
- + "). Not an iPOJO bundle.");
- }
-
- // Parses the retrieved description and find the component with the
- // given name.
- try {
- Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
- Element[] childs = element.getElements("component");
- for (int i = 0; i < childs.length; i++) {
- String name = childs[i].getAttribute("name");
- String clazz = childs[i].getAttribute("classname");
- if (name != null && name.equalsIgnoreCase(component)) {
- return childs[i];
- }
- if (clazz.equalsIgnoreCase(component)) {
- return childs[i];
- }
- }
-
- // Component not found...
- return null;
-
- } catch (ParseException e) {
- throw new IllegalStateException(
- "Cannot parse the components from specified bundle ("
- + bundle.getSymbolicName() + "): " + e.getMessage());
- }
- }
-
- /**
- * Returns the service object of a service registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which the service is
- * searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the specified bundle, offering the
- * specified interface and matching the given filter.
- */
- public static Object getServiceObject(ServiceContext serviceContext,
- String itf, String filter) {
- ServiceReference ref = getServiceReference(serviceContext, itf, filter);
- if (ref != null) {
- return serviceContext.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the specified bundle, offering
- * the specified interface and matching the given filter.
- */
- public static Object[] getServiceObjects(ServiceContext serviceContext,
- String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = serviceContext.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference registered in the specified service context,
- * offering the specified interface and matching the given filter.
- * If no service is found, {@code null} is returned.
- */
- public static ServiceReference getServiceReference(
- ServiceContext serviceContext, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs.length != 0) {
- return refs[0];
- } else {
- // No service found
- return null;
- }
- }
-
- /**
- * Returns the service reference of the service registered in the specified
- * service context, offering the specified interface and having the given
- * persistent ID.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service registered in the specified service context, offering
- * the specified interface and having the given persistent ID.
- */
- public static ServiceReference getServiceReferenceByPID(
- ServiceContext serviceContext, String itf, String pid) {
- String filter = "(" + "service.pid" + "=" + pid + ")";
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- throw new IllegalStateException(
- "A service lookup by PID returned several providers ("
- + refs.length + ")" + " for " + itf + " with pid="
- + pid);
- }
- }
-
- /**
- * Returns the service reference of all the services registered in the
- * specified service context, offering the specified interface and matching
- * the given filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references registered in the specified service
- * context, offering the specified interface and matching the given
- * filter. If no service matches, an empty array is returned.
- */
- public static ServiceReference[] getServiceReferences(
- ServiceContext serviceContext, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- // Get all the service references
- refs = serviceContext.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get service references: " + e.getMessage());
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- /**
- * Returns the service reference of a service registered in the specified
- * service context, offering the specified interface and having the given
- * name.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service registered in the specified service context, offering
- * the specified interface and having the given name.
- */
- public static ServiceReference getServiceReferenceByName(
- ServiceContext serviceContext, String itf, String name) {
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- return getServiceReference(serviceContext, itf, filter);
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailable(ServiceContext sc, String itf) {
- ServiceReference ref = getServiceReference(sc, itf, null);
- return ref != null;
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @param name the service provider name
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailableByName(ServiceContext sc,
- String itf, String name) {
- ServiceReference ref = getServiceReferenceByName(sc, itf, name);
- return ref != null;
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @param pid the pid of the service
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailableByPID(ServiceContext sc,
- String itf, String pid) {
- ServiceReference ref = getServiceReferenceByPID(sc, itf, pid);
- return ref != null;
- }
-
- /**
- * Returns the service reference of a service provided by the specified
- * bundle, offering the specified interface and having the given name.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given name.
- */
- public static ServiceReference getServiceReferenceByName(Bundle bundle,
- String itf, String name) {
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- return OSGiHelper.getServiceReference(bundle, itf, filter);
- }
-
- /**
- * Returns the service reference of a service provided by the local bundle,
- * offering the specified interface and having the given name.
- *
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given name.
- */
- public ServiceReference getServiceReferenceByName(String itf, String name) {
- return getServiceReferenceByName(m_context.getBundle(), itf, name);
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @param name the service provider name
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailableByName(String itf, String name) {
- ServiceReference ref = getServiceReferenceByName(itf, name);
- return ref != null;
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/OSGiHelper.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/OSGiHelper.java
deleted file mode 100644
index 7d6e9ad..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/OSGiHelper.java
+++ /dev/null
@@ -1,456 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import static org.junit.Assert.fail;
-
-
-public class OSGiHelper {
-
- /**
- * The bundle context.
- */
- private BundleContext context;
-
- /**
- * List of get references.
- */
- private List<ServiceReference> m_references = new ArrayList<ServiceReference>();
-
- public OSGiHelper(BundleContext context) {
- this.context = context;
- }
-
- public void dispose() {
- // Unget services
- for (int i = 0; i < m_references.size(); i++) {
- context.ungetService((ServiceReference) m_references.get(i));
- }
- m_references.clear();
- }
-
- /**
- * Gets the Bundle Context.
- * @return the bundle context.
- */
- public BundleContext getContext() {
- return context;
- }
-
- /**
- * Returns the service object of a service provided by the specified bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the specified bundle, offering the
- * specified interface and matching the given filter.
- */
- public static Object getServiceObject(Bundle bundle, String itf,
- String filter) {
- ServiceReference ref = getServiceReference(bundle, itf, filter);
- if (ref != null) {
- return bundle.getBundleContext().getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the specified bundle, offering
- * the specified interface and matching the given filter.
- */
- public static Object[] getServiceObjects(Bundle bundle, String itf,
- String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bundle.getBundleContext().getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the specified bundle, offering
- * the specified interface and matching the given filter. If no
- * service is found, {@code null} is returned.
- */
- public static ServiceReference getServiceReference(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs.length != 0) {
- return refs[0];
- } else {
- // No service found
- return null;
- }
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailable(String itf) {
- ServiceReference ref = getServiceReference(itf, null);
- return ref != null;
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @param pid the service pid
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailableByPID(String itf, String pid) {
- ServiceReference ref = getServiceReferenceByPID(itf, pid);
- return ref != null;
- }
-
- /**
- * Returns the service reference of the service provided by the specified
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given persistent ID.
- */
- public static ServiceReference getServiceReferenceByPID(Bundle bundle,
- String itf, String pid) {
- String filter = "(" + "service.pid" + "=" + pid + ")";
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- throw new IllegalStateException(
- "A service lookup by PID returned several providers ("
- + refs.length + ")" + " for " + itf + " with pid="
- + pid);
- }
- }
-
- /**
- * Returns the service reference of all the services provided in the
- * specified bundle, offering the specified interface and matching the given
- * filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the specified bundle,
- * offering the specified interface and matching the given filter.
- * If no service matches, an empty array is returned.
- */
- public static ServiceReference[] getServiceReferences(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- // Get all the service references
- refs = bundle.getBundleContext().getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get service references: " + e.getMessage());
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- /**
- * Returns the service object of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object getServiceObject(String itf, String filter) {
- ServiceReference ref = getServiceReference(itf, filter);
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service object associated with this service reference.
- *
- * @param ref service reference
- * @return the service object.
- */
- public Object getServiceObject(ServiceReference ref) {
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object[] getServiceObjects(String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- m_references.add(refs[i]);
- list[i] = context.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf, String filter) {
- return getServiceReference(context.getBundle(), itf, filter);
- }
-
- /**
- * Returns the service reference of a service provided offering the
- * specified interface.
- *
- * @param itf the interface provided by the searched service.
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf) {
- return getServiceReference(context.getBundle(), itf, null);
- }
-
- /**
- * Returns the service reference of the service provided by the local
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the local bundle, offering the specified
- * interface and having the given persistent ID.
- */
- public ServiceReference getServiceReferenceByPID(String itf, String pid) {
- return getServiceReferenceByPID(context.getBundle(), itf, pid);
- }
-
- /**
- * Returns the service reference of all the services provided in the local
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the local bundle, offering
- * the specified interface and matching the given filter. If no
- * service matches, an empty array is returned.
- */
- public ServiceReference[] getServiceReferences(String itf, String filter) {
- return getServiceReferences(context.getBundle(), itf, filter);
- }
-
- /**
- * Gets the package admin exposed by the framework.
- * Fails if the package admin is not available.
- * @return the package admin service.
- */
- public PackageAdmin getPackageAdmin() {
- PackageAdmin pa = (PackageAdmin) getServiceObject(PackageAdmin.class.getName(), null);
- if (pa == null) {
- fail("No package admin available");
- }
- return pa;
- }
-
- /**
- * Refresh the packages.
- * Fails if the package admin service is not available.
- */
- public void refresh() {
- getPackageAdmin().refreshPackages(null);
- }
-
- /**
- * Waits for a service. Fails on timeout.
- * If timeout is set to 0, it sets the timeout to 10s.
- * @param itf the service interface
- * @param filter the filter
- * @param timeout the timeout
- */
- public void waitForService(String itf, String filter, long timeout) {
- if (timeout == 0) {
- timeout = 10000; // Default 10 secondes.
- }
- ServiceReference[] refs = getServiceReferences(itf, filter);
- long begin = System.currentTimeMillis();
- if (refs.length != 0) {
- return;
- } else {
- while(refs.length == 0) {
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // Interrupted
- }
- long now = System.currentTimeMillis();
-
- if ((now - begin) > timeout) {
- fail("Timeout ... no services matching with the request after " + timeout + "ms");
- }
- refs = getServiceReferences(itf, filter);
- }
- }
- }
-
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @return the installed bundle
- */
- public Bundle installBundle(String url) {
- try {
- return context.installBundle(url);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @param stream input stream containing the bundle
- * @return the installed bundle
- */
- public Bundle installBundle(String url, InputStream stream) {
- try {
- return context.installBundle(url, stream);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url) {
- Bundle bundle = installBundle(url);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @param stream input stream containing the bundle
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url, InputStream stream) {
- Bundle bundle = installBundle(url, stream);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Get the bundle by its id.
- * @param bundleId the bundle id.
- * @return the bundle with the given id.
- */
- public Bundle getBundle(long bundleId) {
- return context.getBundle(bundleId);
- }
-
- /**
- * Gets a bundle by its symbolic name.
- * Fails if no bundle matches.
- * @param name the symbolic name of the bundle
- * @return the bundle object.
- */
- public Bundle getBundle(String name) {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (name.equals(bundles[i].getSymbolicName())) {
- return bundles[i];
- }
- }
- fail("No bundles with the given symbolic name " + name);
- return null; // should not happen
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java
deleted file mode 100644
index 469a348..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.api.Dependency;
-import org.apache.felix.ipojo.api.PrimitiveComponentType;
-import org.apache.felix.ipojo.api.Service;
-import org.apache.felix.ipojo.api.SingletonComponentType;
-import org.example.service.Foo;
-import org.example.service.impl.FooImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-
-
-@RunWith( JUnit4TestRunner.class )
-public class PrimitiveComponentTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.api").version(asInProject())
- )
- );
- return opt;
- }
-
- @Test
- public void createAServiceProvider() throws Exception {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
-
- PrimitiveComponentType type = createAProvider();
- ci = type.createInstance();
- assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
- ServiceReference ref = ipojo.getServiceReferenceByName(Foo.class
- .getName(), ci.getInstanceName());
- assertThat(ref, is(notNullValue()));
-
- }
-
- @Test
- public void killTheFactory() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
-
- PrimitiveComponentType type = createAProvider();
- ci = type.createInstance();
- assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
- ServiceReference ref = ipojo.getServiceReferenceByName(Foo.class
- .getName(), ci.getInstanceName());
- assertThat(ref, is(notNullValue()));
- type.stop();
- assertThat("Ci is disposed", ci.getState(),
- is(ComponentInstance.DISPOSED));
- ref = ipojo.getServiceReferenceByName(Foo.class.getName(), ci
- .getInstanceName());
- assertThat(ref, is(nullValue()));
-
- }
-
- @Test
- public void createAServiceCons() throws Exception {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
-
- PrimitiveComponentType type = createAConsumer();
- ci = type.createInstance();
- assertThat("Ci is invalid", ci.getState(),
- is(ComponentInstance.INVALID));
-
- }
-
- @Test
- public void createBoth() throws Exception {
- ComponentInstance cons = createAConsumer().createInstance();
- // cons is invalid
- assertThat("cons is invalid", cons.getState(), is(ComponentInstance.INVALID));
-
- ComponentInstance prov = createAProvider().createInstance();
- assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
- assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));
-
- }
-
- @Test
- public void createTwoCons() throws Exception {
- ComponentInstance cons1 = createAConsumer().createInstance();
- // cons is invalid
- assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));
-
- ComponentInstance prov = createAProvider().createInstance();
- assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
- assertThat("cons is valid", cons1.getState(), is(ComponentInstance.VALID));
-
- ComponentInstance cons2 = createAnOptionalConsumer().createInstance();
-
- assertThat("cons2 is valid", cons2.getState(), is(ComponentInstance.VALID));
-
- prov.stop();
- assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));
- assertThat("cons2 is valid", cons2.getState(), is(ComponentInstance.VALID));
- }
-
- private PrimitiveComponentType createAProvider() {
- return new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(FooImpl.class.getName())
- .addService(new Service()); // Provide the FooService
- }
-
- private PrimitiveComponentType createAConsumer() {
- return new SingletonComponentType()
- .setBundleContext(context)
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .addDependency(new Dependency().setField("myFoo"))
- .setValidateMethod("start");
- }
-
- private PrimitiveComponentType createAnOptionalConsumer() {
- return new SingletonComponentType()
- .setBundleContext(context)
- .setComponentTypeName("cons.optional")
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .addDependency(new Dependency().setField("myFoo").setOptional(true))
- .setValidateMethod("start");
- }
-
-
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java
deleted file mode 100644
index 732fa4d..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.api.Dependency;
-import org.apache.felix.ipojo.api.PrimitiveComponentType;
-import org.apache.felix.ipojo.api.Service;
-import org.apache.felix.ipojo.api.SingletonComponentType;
-import org.example.service.Foo;
-import org.example.service.impl.FooImpl;
-import org.example.service.impl.MyComponentImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-
-
-@RunWith( JUnit4TestRunner.class )
-public class SingletonComponentTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.api").version(asInProject())
- )
- );
- return opt;
- }
-
- @Test
- public void createAServiceProvider() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException
- {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
-
- SingletonComponentType type = createAProvider();
- ci = type.create();
- assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
- ServiceReference ref = ipojo.getServiceReferenceByName(Foo.class
- .getName(), ci.getInstanceName());
- assertThat(ref, is(notNullValue()));
- type.disposeInstance(ci);
-
- }
-
- @Test
- public void killTheFactory() throws Exception {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
- SingletonComponentType type = createAProvider();
- ci = type.create();
- assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
- ServiceReference ref = ipojo.getServiceReferenceByName(Foo.class
- .getName(), ci.getInstanceName());
- assertThat(ref, is(notNullValue()));
- type.stop();
- assertThat("Ci is disposed", ci.getState(),
- is(ComponentInstance.DISPOSED));
- ref = ipojo.getServiceReferenceByName(Foo.class.getName(), ci
- .getInstanceName());
- assertThat(ref, is(nullValue()));
- }
-
- @Test
- public void createAServiceCons() throws Exception {
- assertThat( context, is( notNullValue() ) );
- ComponentInstance ci = null;
-
- SingletonComponentType type = createAConsumer();
- ci = type.create();
- assertThat("Ci is invalid", ci.getState(),
- is(ComponentInstance.INVALID));
- type.stop();
- }
-
- @Test
- public void createBoth() throws Exception {
- SingletonComponentType consFactory = createAConsumer();
- ComponentInstance cons = consFactory.create();
- // cons is invalid
- assertThat("cons is invalid", cons.getState(), is(ComponentInstance.INVALID));
-
- SingletonComponentType provFactory = createAProvider();
- ComponentInstance prov = provFactory.create();
- assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
- assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));
- consFactory.stop();
- provFactory.stop();
- }
-
- @Test
- public void createTwoCons() throws Exception {
- SingletonComponentType consFactory = createAConsumer();
- ComponentInstance cons1 = createAConsumer().create();
- // cons is invalid
- assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));
-
- ComponentInstance prov = createAProvider().create();
- assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
- assertThat("cons is valid", cons1.getState(), is(ComponentInstance.VALID));
-
- ComponentInstance cons2 = createAnOptionalConsumer().create();
-
- assertThat("cons2 is valid", cons2.getState(), is(ComponentInstance.VALID));
-
- prov.stop();
- assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));
- assertThat("cons2 is valid", cons2.getState(), is(ComponentInstance.VALID));
- }
-
- @Test
- @Ignore // TODO Why is this ignored ?
- public void setObject() throws Exception {
- ComponentInstance cons = createAConsumer().setObject(new MyComponentImpl(5)).create();
- // cons is invalid
- assertThat("cons is invalid", cons.getState(), is(ComponentInstance.INVALID));
-
- ComponentInstance prov = createAProvider().create();
- assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
- assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));
-
- }
-
- private SingletonComponentType createAProvider() {
- PrimitiveComponentType type = new SingletonComponentType()
- .setBundleContext(context)
- .setClassName(FooImpl.class.getName())
- .addService(new Service()); // Provide the FooService
-
- return (SingletonComponentType) type;
- }
-
- private SingletonComponentType createAConsumer() {
- PrimitiveComponentType type = new SingletonComponentType()
- .setBundleContext(context)
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .setComponentTypeName("singleton.cons")
- .addDependency(new Dependency().setField("myFoo"))
- .setValidateMethod("start");
-
- return (SingletonComponentType) type;
- }
-
- private SingletonComponentType createAnOptionalConsumer() {
- PrimitiveComponentType type = new SingletonComponentType()
- .setBundleContext(context)
- .setClassName(MyComponentImpl.class.getName())
- .addDependency(new Dependency().setField("myFoo").setOptional(true))
- .setComponentTypeName("singleton.optional.consumer")
- .setValidateMethod("start");
-
- return (SingletonComponentType) type;
-
- }
-
-
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/Whiteboard.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/Whiteboard.java
deleted file mode 100644
index 17bce48..0000000
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/Whiteboard.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.apache.felix.ipojo.tests.api;
-
-import org.apache.felix.ipojo.api.HandlerConfiguration;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Whiteboard implements HandlerConfiguration {
-
- public static final String NAME = "wbp";
-
- public static final String NAMESPACE = "org.apache.felix.ipojo.whiteboard";
-
- private String arrival;
-
- private String departure;
-
- private String modification;
-
- private String filter;
-
- public Whiteboard onArrival(String method) {
- arrival = method;
- return this;
- }
-
- public Whiteboard onDeparture(String method) {
- departure = method;
- return this;
- }
-
- public Whiteboard onModification(String method) {
- modification = method;
- return this;
- }
-
- public Whiteboard setFilter(String fil) {
- filter = fil;
- return this;
- }
-
- public Element getElement() {
- ensureValidity();
- // Create the root element.
- Element element = new Element(NAME, NAMESPACE);
- // Mandatory attributes
- element.addAttribute(new Attribute("onArrival", arrival));
- element.addAttribute(new Attribute("onDeparture", departure));
- element.addAttribute(new Attribute("filter", filter));
-
- // Optional attribute
- if (modification != null) {
- element.addAttribute(new Attribute("onModification", modification));
- }
-
- return element;
- }
-
- private void ensureValidity() {
- if (arrival == null) {
- throw new IllegalStateException("The whiteboard pattern configuration must have a onArrival method");
- }
- if (departure == null) {
- throw new IllegalStateException("The whiteboard pattern configuration must have a onDeparture method");
- }
- if (filter == null) {
- throw new IllegalStateException("The whiteboard pattern configuration must have a filter");
- }
-
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/BarService.java b/ipojo/tests/api/src/test/java/org/example/service/BarService.java
deleted file mode 100644
index c00a51d..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/BarService.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.example.service;
-
-public interface BarService {
-
- public void doSomethingWithBar();
-
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/Foo.java b/ipojo/tests/api/src/test/java/org/example/service/Foo.java
deleted file mode 100644
index ea18955..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/Foo.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.example.service;
-
-public interface Foo {
-
-
- public void doSomething();
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/MyService.java b/ipojo/tests/api/src/test/java/org/example/service/MyService.java
deleted file mode 100644
index abf4884..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/MyService.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.example.service;
-
-public interface MyService {
- double compute(double value);
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/impl/FooImpl.java b/ipojo/tests/api/src/test/java/org/example/service/impl/FooImpl.java
deleted file mode 100644
index 69b2c62..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/impl/FooImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.example.service.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.example.service.Foo;
-
-public class FooImpl implements Foo {
-
- // private List<String> m_list = new ArrayList<String>();
-
- public void doSomething() {
- // Do something...
- System.out.println("Hello World !");
- }
-
- public FooImpl(String s) {
- _setIM(s);
- }
-
- public void _setIM(String s) {
-
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/impl/HostImpl.java b/ipojo/tests/api/src/test/java/org/example/service/impl/HostImpl.java
deleted file mode 100644
index 1be1a70..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/impl/HostImpl.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.example.service.impl;
-
-import org.osgi.framework.ServiceReference;
-
-public class HostImpl {
-
- public void arrival(ServiceReference ref) {
-
- }
-
- public void departure(ServiceReference ref) {
-
- }
-
- public void modification(ServiceReference ref) {
-
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/impl/MyComponentImpl.java b/ipojo/tests/api/src/test/java/org/example/service/impl/MyComponentImpl.java
deleted file mode 100644
index 2bb6ab2..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/impl/MyComponentImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.example.service.impl;
-
-import org.example.service.Foo;
-
-public class MyComponentImpl {
-
- private Foo myFoo;
-
- private int anInt;
-
- public MyComponentImpl() {
- anInt = 2;
- }
-
- public MyComponentImpl(int i) {
- anInt = i;
- }
-
- public void start() {
- myFoo.doSomething();
- if (anInt > 0) {
- System.out.println("Set int to " + anInt);
- }
- }
-
-}
diff --git a/ipojo/tests/api/src/test/java/org/example/service/impl/MyServiceImpl.java b/ipojo/tests/api/src/test/java/org/example/service/impl/MyServiceImpl.java
deleted file mode 100644
index efe4c0b..0000000
--- a/ipojo/tests/api/src/test/java/org/example/service/impl/MyServiceImpl.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.example.service.impl;
-
-import org.example.service.MyService;
-
-public class MyServiceImpl implements MyService {
- public double compute(double value) {
- return Math.exp(value * Math.cosh(value));
- }
-}
diff --git a/ipojo/tests/composite/composite-runtime/pom.xml b/ipojo/tests/composite/composite-runtime/pom.xml
deleted file mode 100644
index e8d6b05..0000000
--- a/ipojo/tests/composite/composite-runtime/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Composite Test Suite</name>
- <artifactId>tests.composite</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.composite.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.composite.service, org.apache.felix.ipojo.test.composite.component, org.apache.felix.ipojo.test.composite.util
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.composite.*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.composite.CompositeTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/CompositeTestSuite.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/CompositeTestSuite.java
deleted file mode 100644
index a3bd8df..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/CompositeTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.apache.felix.ipojo.test.composite.infrastructure.InfrastructureTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class CompositeTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("iPOJO Composites Test Suite", bc);
- ots.addTest(InfrastructureTestSuite.suite(bc));
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/Baz2CheckProvider.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/Baz2CheckProvider.java
deleted file mode 100644
index 9fcc4fd..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/Baz2CheckProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class Baz2CheckProvider implements CheckService {
-
- BazService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(fs.foo()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
-
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
- private void voidUnbind() {
- simpleU++;
- }
-
- protected void objectBind(Object o) {
- if(o != null && o instanceof FooService) { objectB++; }
- }
- protected void objectUnbind(Object o) {
- if(o != null && o instanceof FooService) { objectU++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/BazProviderType1.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/BazProviderType1.java
deleted file mode 100644
index fd495e0..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/BazProviderType1.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.BazService;
-
-public class BazProviderType1 implements BazService {
-
- private int m_bar;
- private String m_foo;
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- p.put("foo", m_foo);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckProviderParentClass.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckProviderParentClass.java
deleted file mode 100644
index 2294ba3..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckServiceProvider.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckServiceProvider.java
deleted file mode 100644
index 9a17f1f..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooBarProviderType1.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooBarProviderType1.java
deleted file mode 100644
index 719f235..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooBarProviderType1.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-
-public class FooBarProviderType1 implements FooService, BarService {
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- return new Properties();
- }
-
- public boolean bar() {
- return true;
- }
-
- public Properties getProps() {
- return new Properties();
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderType1.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderType1.java
deleted file mode 100644
index 509e5d1..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderType1.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn.java
deleted file mode 100644
index ec5261b..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.FooService;
-
-public class FooProviderTypeDyn implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
-
- public boolean foo() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn2.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn2.java
deleted file mode 100644
index 757ae24..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/FooProviderTypeDyn2.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.FooService;
-
-public class FooProviderTypeDyn2 implements FooService {
-
- private int intProp = 2;
- private boolean boolProp = true;
- private String strProp = "foo";
- private String[] strAProp = new String[] {"foo", "bar"};
- private int[] intAProp = new int[] {1, 2, 3};
-
- public boolean foo() {
- intAProp = null;
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TataProvider.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TataProvider.java
deleted file mode 100644
index 2607b55..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TataProvider.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.Tata;
-
-
-public class TataProvider implements Tata {
-
- int tata = 0;
- int tataStr = 0;
- int tataStrs = 0;
- int tata_2 = 0;
- int tata_3 = 0;
- int tata1 = 0;
- int tata1_1 = 0;
- int tata5 = 0;
- int tata5_1 = 0;
- int tata5_2 = 0;
- int tataBoolean = 0;
- int tataBooleans = 0;
- int tataByte = 0;
- int tataBytes = 0;
- private int add;
- private int tataShorts;
- private int tataShort;
- private int tataLongs;
- private int tataLong;
- private int tataInts;
- private int tataInt;
- private int tataFloat;
- private int tataFloats;
- private int tataDoubles;
- private int tataDouble;
- private int tataChars;
- private int tataChar;
-
- public Properties getPropsTata() {
- Properties props = new Properties();
- props.put("tata", new Integer(tata));
- props.put("tataStr", new Integer(tataStr));
- props.put("tataStrs", new Integer(tataStrs));
- props.put("tata_2", new Integer(tata_2));
- props.put("tata_3", new Integer(tata_3));
- props.put("tata1", new Integer(tata1));
- props.put("tata1_1", new Integer(tata1_1));
- props.put("tata5", new Integer(tata5));
- props.put("tata5_1", new Integer(tata5_1));
- props.put("tata5_2", new Integer(tata5_2));
- props.put("add", new Integer(add));
- props.put("tataBoolean", new Integer(tataBoolean));
- props.put("tataBoolean", new Integer(tataBoolean));
- props.put("tataByte", new Integer(tataByte));
- props.put("tataBytes", new Integer(tataBytes));
- props.put("tataShort", new Integer(tataShort));
- props.put("tataShorts", new Integer(tataShorts));
- props.put("tataLongs", new Integer(tataLongs));
- props.put("tataLong", new Integer(tataLong));
- props.put("tataInt", new Integer(tataInt));
- props.put("tataInts", new Integer(tataInts));
- props.put("tataFloat", new Integer(tataFloat));
- props.put("tataFloats", new Integer(tataFloats));
- props.put("tataDouble", new Integer(tataDouble));
- props.put("tataDoubles", new Integer(tataDoubles));
- props.put("tataChar", new Integer(tataChar));
- props.put("tataChars", new Integer(tataChars));
- return props;
- }
-
- public void tata() {
- tata++;
- }
-
- public String tataStr() {
- tataStr++;
- return "Tata";
- }
-
- public String[] tataStrs() {
- tataStrs++;
- return new String[] {"T", "A", "T", "A"};
- }
-
- public void tata(int i, int j) {
- tata_2++;
- }
-
- public void tata(String s) {
- tata_3++;
- }
-
- public String tata1(String a) {
- tata1++;
- return a;
- }
-
- public String tata1(char[] a) {
- tata1_1++;
- String s = new String(a);
- return s;
- }
-
- public String tata5(String a, int i) {
- tata5++;
- return a+i;
- }
-
- public String tata5(String[] a, int i) {
- tata5_1++;
- return ""+a.length + i;
- }
-
- public String tata5(String a, int[] i) {
- tata5_2++;
- return a + i.length;
- }
-
- public boolean tataBoolean(boolean b) {
- tataBoolean++;
- return b;
- }
-
- public boolean[] tataBooleans(boolean[] b) {
- tataBooleans++;
- return b;
- }
-
- public byte tataByte(byte b) {
- tataByte++;
- return b;
- }
-
- public byte[] tataBytes(byte[] b) {
- tataBytes++;
- return b;
- }
-
- public char tataChar(char c) {
- tataChar++;
- return c;
- }
-
- public char[] tataChars(char[] c) {
- tataChars++;
- return c;
- }
-
- public double tataDouble(double d) {
- tataDouble++;
- return d;
- }
-
- public double[] tataDoubles(double[] d) {
- tataDoubles++;
- return d;
- }
-
- public float tataFloat(float f) {
- tataFloat++;
- return f;
- }
-
- public float[] tataFloats(float[] f) {
- tataFloats++;
- return f;
- }
-
- public int tataInt(int i) {
- tataInt++;
- return i;
- }
-
- public int[] tataInts(int[] its) {
- tataInts++;
- return its;
- }
-
- public long tataLong(long l) {
- tataLong++;
- return l;
- }
-
- public long[] tataLongs(long[] l) {
- tataLongs++;
- return l;
- }
-
- public short tataShort(short s) {
- tataShort++;
- return s;
- }
-
- public short[] tataShorts(short[] s) {
- tataShorts++;
- return s;
- }
-
- public long add(int i, int j, int k) {
- add++;
- return i + j + k;
- }
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProvider.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProvider.java
deleted file mode 100644
index fb79bc4..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProvider.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.Toto;
-
-
-public class TotoProvider implements Toto {
-
- private int i = 0;
- public static int toto = 0;
- public static int toto_2 = 0;
- public static int toto_3 = 0;
- public static int toto_4 = 0;
- public static int toto1 = 0;
-
- public int count() {
- return i;
- }
-
- public void toto() {
- toto++;
- }
-
- public void toto(int i, int j) {
- toto_2++;
- }
-
- public String toto(String a) {
- toto_3++;
- return a;
- }
-
- public String toto(String[] a) {
- toto_4++;
- return "toto";
- }
-
- public void toto1(String j) {
- i++;
- toto1++;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("i", new Integer(i));
- props.put("toto", new Integer(toto));
- props.put("toto_2", new Integer(toto_2));
- props.put("toto_3", new Integer(toto_3));
- props.put("toto_4", new Integer(toto_4));
- props.put("toto1", new Integer(toto1));
- return props;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProviderGlue.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProviderGlue.java
deleted file mode 100644
index 3ea3a88..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/component/TotoProviderGlue.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.Toto;
-
-
-public class TotoProviderGlue implements Toto {
-
- Toto m_toto;
-
- private int i = 0;
- public static int toto = 0;
- public static int toto_2 = 0;
- public static int toto_3 = 0;
- public static int toto_4 = 0;
- public static int toto1 = 0;
-
- public int count() {
- return i;
- }
-
- public void toto() {
- toto++;
- m_toto.toto();
- }
-
- public void toto(int i, int j) {
- toto_2++;
- m_toto.toto(i, j);
- }
-
- public String toto(String a) {
- toto_3++;
- return a;
- }
-
- public String toto(String[] a) {
- toto_4++;
- return "toto";
- }
-
- public void toto1(String j) {
- i++;
- toto1++;
- m_toto.toto1(j);
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("i", new Integer(i));
- props.put("gtoto", new Integer(toto));
- props.put("gtoto_2", new Integer(toto_2));
- props.put("gtoto_3", new Integer(toto_3));
- props.put("gtoto_4", new Integer(toto_4));
- props.put("gtoto1", new Integer(toto1));
- props.put("glue", "glue");
- Properties p2 = m_toto.getProps();
- props.putAll(p2);
- return props;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/EmptyCompositeTest.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/EmptyCompositeTest.java
deleted file mode 100644
index ea761db..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/EmptyCompositeTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.infrastructure;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
-import org.apache.felix.ipojo.composite.CompositeManager;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-
-public class EmptyCompositeTest extends OSGiTestCase {
-
- public void testEmptyCompositeCreation() {
- Factory factory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
-
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch (Exception e) {
- e.printStackTrace();
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- ComponentTypeDescription cd = ci.getFactory().getComponentDescription();
- assertEquals("Check component type name", cd.getName(), "composite.empty");
-// assertEquals("Check class name (" + cd.getClassName() + ")", cd.getClassName(), "composite");
- assertEquals("Check offered service", cd.getprovidedServiceSpecification().length, 0);
- assertEquals("Check configurable properties", cd.getProperties().length, 0);
-
- CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state (" + id.getState() + ")", id.getState(), ComponentInstance.VALID);
-
- assertEquals("Check contained instance", id.getContainedInstances().length, 0);
-
- assertTrue("Check composite manager", ci instanceof CompositeManager);
- CompositeManager cm = (CompositeManager) ci;
- ServiceContext sc = cm.getServiceContext();
- try {
- assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e.getMessage());
- }
- ci.dispose();
- }
-
- public void testInstanceCreation1() {
- Factory factory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
-
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- assertTrue("Check composite manager", ci instanceof CompositeManager);
- CompositeManager cm = (CompositeManager) ci;
- ServiceContext sc = cm.getServiceContext();
- try {
- assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e.getMessage());
- }
-
- Properties props2 = new Properties();
- props2.put("instance.name","empty2");
- ComponentInstance ci2 = null;
- try {
- ci2 = factory.createComponentInstance(props2, sc);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 1);
- CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
- assertEquals("Check composite instance name", id2.getName(), "empty2");
- assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
-
- ci2.dispose();
- //id = ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 0);
-
- ci.dispose();
- }
-
- public void testInstanceCreation2() {
- Factory factory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
-
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- assertTrue("Check composite manager", ci instanceof CompositeManager);
- CompositeManager cm = (CompositeManager) ci;
- ServiceContext sc = cm.getServiceContext();
- try {
- assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e.getMessage());
- }
-
- Factory factory2 = Utils.getFactoryByName(sc, "composite.empty");
- assertNotNull("Check factory2 not null", factory2);
- Properties props2 = new Properties();
- props2.put("instance.name","empty2");
- ComponentInstance ci2 = null;
- try {
- ci2 = factory2.createComponentInstance(props2);
- } catch(Exception e) {
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 1);
- CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
- assertEquals("Check composite instance name", id2.getName(), "empty2");
- assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
-
- ci2.dispose();
- //id = ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 0);
-
- ci.dispose();
- }
-
- public void testInstanceCreation3() {
- Factory factory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
-
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- assertTrue("Check composite manager", ci instanceof CompositeManager);
- CompositeManager cm = (CompositeManager) ci;
- ServiceContext sc = cm.getServiceContext();
- try {
- assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e.getMessage());
- }
-
- Factory factory2 = Utils.getFactoryByName(sc, "composite.empty");
- assertNotNull("Check factory2 not null", factory2);
- Properties props2 = new Properties();
- props2.put("instance.name","empty2");
- ComponentInstance ci2 = null;
- try {
- ci2 = factory2.createComponentInstance(props2, sc);
- } catch(Exception e) {
- fail("Unacceptable configuration : " + e.getMessage());
- }
-
- CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 1);
- CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];
- assertEquals("Check composite instance name", id2.getName(), "empty2");
- assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id2.getContainedInstances().length, 0);
-
- ci2.dispose();
- //id = ci.getInstanceDescription();
- assertEquals("Check composite instance name", id.getName(), "empty");
- assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);
- assertEquals("Check contained instance", id.getContainedInstances().length, 0);
-
- ci.dispose();
- }
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/FactoryManagementTest.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/FactoryManagementTest.java
deleted file mode 100644
index 3eebd55..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/FactoryManagementTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.infrastructure;
-
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.FactoryStateListener;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-public class FactoryManagementTest extends OSGiTestCase {
-
- private FakeFactory fake1 = new FakeFactory("fake");
- private FakeFactory fake2 = new FakeFactory("fake2");
-
- private Factory emptyFactory;
- private ComponentInstance empty;
-
- private class FakeFactory implements Factory {
-
- private String m_name;
- public FakeFactory(String name) { m_name = name; }
-
- public ComponentInstance createComponentInstance(Dictionary arg0) throws UnacceptableConfiguration { return null; }
- public ComponentInstance createComponentInstance(Dictionary arg0, ServiceContext arg1) throws UnacceptableConfiguration { return null; }
- public Element getDescription() { return null; }
- public String getName() { return m_name; }
- public boolean isAcceptable(Dictionary arg0) { return false; }
- public void reconfigure(Dictionary arg0) throws UnacceptableConfiguration { }
- public void addFactoryStateListener(FactoryStateListener arg0) { }
- public List getMissingHandlers() { return null; }
- public List getRequiredHandlers() { return null; }
- public void removeFactoryStateListener(FactoryStateListener arg0) { }
- public ComponentTypeDescription getComponentDescription() { return null; }
- public String getClassName() { return ""; }
- public int getState() { return Factory.VALID; }
- public BundleContext getBundleContext() { return getContext(); }
- public String getVersion() { return null; }
- public Element getComponentMetadata() { return null; }
-
- }
-
- public void setUp() {
- emptyFactory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty-1");
- try {
- empty = emptyFactory.createComponentInstance(props);
- } catch (Exception e) { fail("Cannot create empty instance " + e.getMessage()); }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testOneLevelExposition() {
- ServiceReference[] parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- ServiceContext sc = Utils.getServiceContext(empty);
- ServiceReference[] internalFactoryReferences = Utils.getServiceReferences(sc, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories", parentsFactoryReferences.length, internalFactoryReferences.length);
-
- for(int i = 0; i < parentsFactoryReferences.length; i++) {
- Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
- assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, internalFactoryReferences, sc));
- }
- }
-
- public void testTwoLevelExposition() {
- ServiceReference[] parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- ServiceContext sc1 = Utils.getServiceContext(empty);
- ServiceReference[] Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
-
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch (Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
- ServiceReference[] Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- for(int i = 0; i < Level1FactoryReferences.length; i++) {
- Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
- assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));
- }
-
- empty2.dispose();
- }
-
- public void testDynamism() {
- ServiceReference[] parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- ServiceContext sc1 = Utils.getServiceContext(empty);
- ServiceReference[] Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
-
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch (Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
- ServiceReference[] Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- for(int i = 0; i < Level1FactoryReferences.length; i++) {
- Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);
- assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));
- }
-
- // Publish fake1
- ServiceRegistration reg1 = getContext().registerService(Factory.class.getName(), fake1, null);
-
- parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- sc1 = Utils.getServiceContext(empty);
- Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
- sc2 = Utils.getServiceContext(empty2);
- Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- // Publish fake2
- ServiceRegistration reg2 = getContext().registerService(Factory.class.getName(), fake2, null);
-
- parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- sc1 = Utils.getServiceContext(empty);
- Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
- sc2 = Utils.getServiceContext(empty2);
- Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- reg1.unregister();
-
- parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- sc1 = Utils.getServiceContext(empty);
- Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
- sc2 = Utils.getServiceContext(empty2);
- Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- reg2.unregister();
-
- parentsFactoryReferences = Utils.getServiceReferences(getContext(), Factory.class.getName(), null);
- sc1 = Utils.getServiceContext(empty);
- Level1FactoryReferences = Utils.getServiceReferences(sc1, Factory.class.getName(), null);
- sc2 = Utils.getServiceContext(empty2);
- Level2FactoryReferences = Utils.getServiceReferences(sc2, Factory.class.getName(), null);
-
- assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);
- assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);
-
- empty2.dispose();
- }
-
- public void testInvocation() {
- ServiceContext sc1 = Utils.getServiceContext(empty);
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch (Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
-
- Factory fact1 = Utils.getFactoryByName(sc2, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props);
- } catch (Exception e) { e.printStackTrace(); fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc2, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2);
- } catch (Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- assertNotNull("Check ref existency", ref);
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
- client.dispose();
- provider.dispose();
- empty2.dispose();
- }
-
-
-
-
- private boolean isExposed(Factory fact, ServiceReference[] refs, ServiceContext sc) {
- for(int i = 0; i < refs.length; i++) {
- Factory f = (Factory) sc.getService(refs[i]);
- if(fact.getName().equals(f.getName())) {
- sc.ungetService(refs[i]);
- return true;
- }
- sc.ungetService(refs[i]);
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/InfrastructureTestSuite.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/InfrastructureTestSuite.java
deleted file mode 100644
index 051ba7b..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/InfrastructureTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.infrastructure;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class InfrastructureTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Service Context Infrastructure Test", bc);
- ots.addTestSuite(ServiceRegistryTest.class);
- ots.addTestSuite(EmptyCompositeTest.class);
- ots.addTestSuite(FactoryManagementTest.class);
- ots.addTestSuite(ServiceRangeTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRangeTest.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRangeTest.java
deleted file mode 100644
index 54f4648..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRangeTest.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.infrastructure;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class ServiceRangeTest extends OSGiTestCase {
-
- private Factory emptyFactory;
- private ComponentInstance empty;
-
-
- public void setUp() {
- emptyFactory = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty-1");
- try {
- empty = emptyFactory.createComponentInstance(props);
- } catch(Exception e) { fail("Cannot create empty instance " + e.getMessage()); }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testLevelOne1() {
- ServiceContext sc2 = Utils.getServiceContext(empty);
-
- Factory fact1 = Utils.getFactoryByName(sc2, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc2, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- provider.dispose();
- client.dispose();
-
- assertNull("Check foo service invisible inside the composite", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible from the context", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- }
-
- public void testLevelOne2() {
- ServiceContext sc2 = Utils.getServiceContext(empty);
-
- Factory fact1 = Utils.getFactoryByName(sc2, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props, sc2);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc2, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2, sc2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- }
-
- public void testLevelOne3() {
- ServiceContext sc2 = Utils.getServiceContext(empty);
-
- Factory fact1 = Utils.getFactoryByName(getContext(), "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props, sc2);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2, sc2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- }
-
- public void testLevelTwo1() {
- ServiceContext sc1 = Utils.getServiceContext(empty);
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
-
- Factory fact1 = Utils.getFactoryByName(sc2, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc2, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- empty2.dispose();
- }
-
- public void testLevelTwo2() {
- ServiceContext sc1 = Utils.getServiceContext(empty);
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
-
- Factory fact1 = Utils.getFactoryByName(sc1, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props, sc2);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc1, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2, sc2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- empty2.dispose();
- }
-
- public void testLevelTwo3() {
- ServiceContext sc1 = Utils.getServiceContext(empty);
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
-
- Factory fact1 = Utils.getFactoryByName(getContext(), "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props, sc2);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2, sc2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- empty2.dispose();
- }
-
- public void testLevelTwo4() {
- ServiceContext sc1 = Utils.getServiceContext(empty);
- Factory fact = Utils.getFactoryByName(sc1, "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty2");
- ComponentInstance empty2 = null;
- try {
- empty2 = fact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate empty2 instance : " + e.getMessage());
- }
-
- ServiceContext sc2 = Utils.getServiceContext(empty2);
-
- Factory fact1 = Utils.getFactoryByName(sc2, "COMPO-SimpleCheckServiceProvider");
- Properties props = new Properties();
- props.put("instance.name","client");
- ComponentInstance client = null;
- try {
- client = fact1.createComponentInstance(props, sc2);
- } catch(Exception e) { fail("Cannot instantiate the client : " + e.getMessage()); }
-
- Factory fact2 = Utils.getFactoryByName(sc2, "COMPO-FooProviderType-1");
- Properties props2 = new Properties();
- props2.put("instance.name","provider");
- ComponentInstance provider = null;
- try {
- provider = fact2.createComponentInstance(props2, sc2);
- } catch(Exception e) {
- fail("Cannot instantiate the provider : " + e.getMessage());
- }
-
- ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());
- CheckService check = (CheckService) sc2.getService(ref);
-
- assertTrue("Check invocation", check.check());
-
- sc2.ungetService(ref);
-
- // Check visibility
- assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- // Check invisibilty
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
-
- client.dispose();
- provider.dispose();
-
- assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));
- assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));
- assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));
- assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));
- try {
- assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e);
- }
- empty2.dispose();
- }
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRegistryTest.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRegistryTest.java
deleted file mode 100644
index 86d96f1..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/infrastructure/ServiceRegistryTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.infrastructure;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.InstanceStateListener;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.context.ServiceRegistry;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-public class ServiceRegistryTest extends OSGiTestCase {
-
- private class svcListener implements ServiceListener {
- public int registration = 0;
- public int unregistration = 0;
- public int modification = 0;
- public void serviceChanged(ServiceEvent ev) {
- if(ev.getType() == ServiceEvent.REGISTERED) { registration++; }
- if(ev.getType() == ServiceEvent.UNREGISTERING) { unregistration++; }
- if(ev.getType() == ServiceEvent.MODIFIED) { modification++; }
- }
- }
-
- private class barProvider implements BarService {
-
- public boolean bar() { return true; }
-
- public Properties getProps() { return null; }
-
- }
-
- private class FakeComponent implements ComponentInstance {
-
- public ComponentTypeDescription getComponentDescription() {
- return null;
- }
-
- public BundleContext getContext() {
- return null;
- }
-
- public ComponentFactory getFactory() {
- return null;
- }
-
- public InstanceDescription getInstanceDescription() {
- return null;
- }
-
- public String getInstanceName() {
- return null;
- }
-
- public int getState() {
- return 0;
- }
-
- public boolean isStarted() {
- return false;
- }
-
- public void reconfigure(Dictionary dictionary) { }
-
- public void start() { }
-
- public void stop() { }
-
- public void dispose() { }
-
- public void addInstanceStateListener(InstanceStateListener arg0) { }
-
- public void removeInstanceStateListener(InstanceStateListener arg0) { }
-
- }
-
- public void testRegistrationAndListener() {
- ComponentInstance im = new FakeComponent();
- ComponentInstance im2 = new FakeComponent();
- ServiceRegistry registry = new ServiceRegistry(getContext());
- assertNotNull("Assert registry not null", registry);
- svcListener all = new svcListener();
- try {
- assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
- registry.addServiceListener(all);
-
- ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), null);
-
- try {
- assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage());
- }
-
- ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);
-
- try {
- assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- assertEquals("Check the number of registration", 2, all.registration);
-
- Properties props = new Properties();
- props.put("foo", "bar");
- reg1.setProperties(props);
- assertEquals("Check the number of modification", 1, all.modification);
-
- reg1.unregister();
- assertEquals("Check the number of unregistration", 1, all.unregistration);
-
- reg2.setProperties(props);
- assertEquals("Check the number of modification", 2, all.modification);
-
- reg2.unregister();
- assertEquals("Check the number of unregistration", 2, all.unregistration);
-
- registry.removeServiceListener(all);
- }
-
- public void testRegistrationAndFilter() {
- ComponentInstance im = new FakeComponent();
- ComponentInstance im2 = new FakeComponent();
- ServiceRegistry registry = new ServiceRegistry(getContext());
- svcListener filtered = new svcListener();
-
- try {
- assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- registry.addServiceListener(filtered, "(foo=bar)");
-
- Properties props = new Properties();
- props.put("foo", "bar");
- ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);
-
- try {
- assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);
-
- try {
- assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- assertEquals("Check the number of registration", 1, filtered.registration);
-
- reg2.setProperties(props);
- assertEquals("Check the number of modification", 1, filtered.modification);
- // Follow the OSGi semantics of filters
-
- reg1.unregister();
- reg2.unregister();
- assertEquals("Check the number of unregistration", 2, filtered.unregistration);
- registry.removeServiceListener(filtered);
- }
-
- public void testGetService() {
- ComponentInstance im = new FakeComponent();
- ComponentInstance im2 = new FakeComponent();
- ServiceRegistry registry = new ServiceRegistry(getContext());
-
- try {
- assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- Properties props = new Properties();
- props.put("foo", "bar");
- ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);
-
- ServiceReference ref = registry.getServiceReference(BarService.class.getName());
- assertNotNull("Check ref not null", ref);
- assertEquals("Test property", ref.getProperty("foo"), "bar");
- BarService bar = (BarService) registry.getService(im2, ref);
- assertTrue("Test invocation", bar.bar());
-
- reg1.unregister();
- ref = registry.getServiceReference(BarService.class.getName());
- assertNull("Check ref null", ref);
- }
-
- public void testGetFilteredService() {
- ComponentInstance im = new FakeComponent();
- ComponentInstance im2 = new FakeComponent();
- ServiceRegistry registry = new ServiceRegistry(getContext());
-
- try {
- assertNull("Check that there is no available service", registry.getServiceReferences(null, null));
- } catch (InvalidSyntaxException e) { fail("Cannot query the registry : " + e.getMessage()); }
-
- Properties props = new Properties();
- props.put("foo", "bar");
- ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);
- ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);
-
- ServiceReference[] ref = null;
- try {
- ref = registry.getServiceReferences(BarService.class.getName(), "(foo=bar)");
- } catch (InvalidSyntaxException e) { fail("Registry query fail : " + e.getMessage()); }
- assertNotNull("Check ref not null", ref);
- assertEquals("Check ref count", ref.length, 1);
- assertEquals("Test property", ref[0].getProperty("foo"), "bar");
- BarService bar = (BarService) registry.getService(im2, ref[0]);
- assertTrue("Test invocation", bar.bar());
-
- ref = null;
- reg1.unregister();
- try {
- ref = registry.getServiceReferences(BarService.class.getName(), "(bar=foo)");
- } catch (InvalidSyntaxException e) { fail("Registry query fail : " + e.getMessage()); }
- assertNull("Check ref null", ref);
-
- reg2.unregister();
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/A123/CheckService2.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/A123/CheckService2.java
deleted file mode 100644
index 1a745a9..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/A123/CheckService2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service.A123;
-
-public interface CheckService2 {
-
- public boolean check();
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BarService.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BarService.java
deleted file mode 100644
index 8b24f04..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BazService.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BazService.java
deleted file mode 100644
index 88b78a1..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/BazService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface BazService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/CheckService.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/CheckService.java
deleted file mode 100644
index 8eb499f..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/FooService.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/FooService.java
deleted file mode 100644
index bbfa2c9..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tata.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tata.java
deleted file mode 100644
index 04fe33d..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tata.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface Tata {
-
- public Properties getPropsTata();
-
- public void tata();
-
- public int tataInt(int i);
- public long tataLong(long l);
- public double tataDouble(double d);
- public char tataChar(char c);
- public boolean tataBoolean(boolean b);
- public short tataShort(short s);
- public float tataFloat(float f);
- public byte tataByte(byte b);
-
- public int[] tataInts(int[] its);
- public long[] tataLongs(long[] l);
- public double[] tataDoubles(double[] d);
- public char[] tataChars(char[] c);
- public boolean[] tataBooleans(boolean[] b);
- public short[] tataShorts(short[] s);
- public float[] tataFloats(float[] f);
- public byte[] tataBytes(byte[] b);
-
- public String tataStr();
- public String[] tataStrs();
-
- public void tata(int i, int j);
- public void tata(String s);
-
- public String tata1(String a);
- public String tata1(char[] a);
-
- public String tata5(String a, int i);
- public String tata5(String[] a, int i);
- public String tata5(String a, int[] i);
-
- public long add(int i, int j, int k);
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tota.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tota.java
deleted file mode 100644
index f7481a4..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Tota.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface Tota {
-
- public static final String specification="specification { " +
- "requires { " +
- "$specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" " +
- "$optional=\"true\" " +
- "$aggregate=\"true\" " +
- "$type=\"service\" " +
- "} }";
-
- public Properties getProps() throws UnsupportedOperationException;;
- public Properties getPropsTata();
-
- public void tata();
-
- public int tataInt(int i);
- public long tataLong(long l);
- public double tataDouble(double d);
- public char tataChar(char c);
- public boolean tataBoolean(boolean b);
- public short tataShort(short s);
- public float tataFloat(float f);
- public byte tataByte(byte b);
-
- public int[] tataInts(int[] its);
- public long[] tataLongs(long[] l);
- public double[] tataDoubles(double[] d);
- public char[] tataChars(char[] c);
- public boolean[] tataBooleans(boolean[] b);
- public short[] tataShorts(short[] s);
- public float[] tataFloats(float[] f);
- public byte[] tataBytes(byte[] b);
-
- public String tataStr();
- public String[] tataStrs();
-
- public void tata(int i, int j);
- public void tata(String s);
-
- public String tata1(String a);
- public String tata1(char[] a);
-
- public String tata5(String a, int i);
- public String tata5(String[] a, int i);
- public String tata5(String a, int[] i);
-
- public long add(int i, int j, int k);
-
- public void toto() throws UnsupportedOperationException;
- public void toto(int i, int j) throws UnsupportedOperationException;
- public String toto(String a) throws UnsupportedOperationException;
-
- public void toto1(String j) throws UnsupportedOperationException;
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Toto.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Toto.java
deleted file mode 100644
index edf6c10..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/service/Toto.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.service;
-
-import java.util.Properties;
-
-public interface Toto {
-
- public Properties getProps();
-
- public void toto();
- public void toto(int i, int j);
- public String toto(String a);
- public String toto(String[] a);
-
- public void toto1(String j);
-
- public int count();
-
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/util/Utils.java b/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/util/Utils.java
deleted file mode 100644
index 89f094f..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/java/org/apache/felix/ipojo/test/composite/util/Utils.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static ServiceContext getServiceContext(ComponentInstance ci) {
- if (ci instanceof CompositeManager) {
- return ((CompositeManager) ci).getServiceContext();
- } else {
- throw new RuntimeException("Cannot get the service context from a non composite instance");
- }
- }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-}
diff --git a/ipojo/tests/composite/composite-runtime/src/main/resources/metadata.xml b/ipojo/tests/composite/composite-runtime/src/main/resources/metadata.xml
deleted file mode 100644
index b7c2ad2..0000000
--- a/ipojo/tests/composite/composite-runtime/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
- org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:comp="org.apache.felix.ipojo.composite"
- xmlns:cs="org.apache.felix.ipojo.test.composite.handler.CheckServiceHandler">
- <!-- Used component type -->
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooProviderType1"
- name="COMPO-FooProviderType-1" architecture="true">
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooProviderType1"
- name="COMPO-FooProviderType-2" architecture="true">
- <provides>
- <property name="int" type="int" value="2" />
- <property name="long" type="long" value="40" />
- <property name="string" type="java.lang.String" value="foo" />
- <property name="strAProp" type="java.lang.String[]"
- value="{foo, bar}" />
- <property name="intAProp" type="int[]" value="{1,2,3}" />
- </provides>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooProviderTypeDyn"
- name="COMPO-FooProviderType-Dyn" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2" />
- <property name="boolean" field="boolProp" value="false" />
- <property name="string" field="strProp" value="foo" />
- <property name="strAProp" field="strAProp"
- value="{foo, bar}" />
- <property name="intAProp" field="intAProp" value="{ 1,2,3}" />
- </provides>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooProviderTypeDyn2"
- name="COMPO-FooProviderType-Dyn2" architecture="true">
- <provides>
- <property name="int" field="intProp" value="4" />
- <property name="boolean" field="boolProp" />
- <property name="string" field="strProp" />
- <property name="strAProp" field="strAProp" />
- <property name="intAProp" field="intAProp"
- value="{1, 2,3 }" />
- </provides>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.CheckServiceProvider"
- name="COMPO-SimpleCheckServiceProvider" architecture="true">
- <requires field="fs" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooBarProviderType1"
- name="COMPO-FooBarProviderType-1" architecture="true">
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooBarProviderType1"
- name="COMPO-FooBarProviderType-2" architecture="true">
- <provides
- specifications="{org.apache.felix.ipojo.test.composite.service.FooService, org.apache.felix.ipojo.test.composite.service.BarService }" />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.composite.component.FooBarProviderType1"
- name="COMPO-FooBarProviderType-3" architecture="true">
- <provides
- specifications="{org.apache.felix.ipojo.test.composite.service.FooService}">
- <property name="baz" type="java.lang.String" value="foo" />
- </provides>
- <provides
- specifications="{org.apache.felix.ipojo.test.composite.service.BarService}">
- <property name="baz" type="java.lang.String" value="bar" />
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.composite.component.BazProviderType1"
- name="BazProviderType">
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.composite.component.TataProvider"
- name="tata">
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.composite.component.TotoProvider"
- name="toto" architecture="true">
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.composite.component.TotoProviderGlue"
- name="totoglue">
- <requires field="m_toto" scope="composite" />
- </component>
-
- <!-- Composite -->
- <comp:composite name="composite.empty" architecture="true">
- </comp:composite>
-
- <component classname="org.apache.felix.ipojo.test.composite.component.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">
- <requires field="fs" scope="composite"/>
- <provides/>
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/composite/import-export/pom.xml b/ipojo/tests/composite/import-export/pom.xml
deleted file mode 100644
index 388c180..0000000
--- a/ipojo/tests/composite/import-export/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Composite (Service Import/Export) Test Suite</name>
- <artifactId>tests.composite.service.import-export</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.composite.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.composite.exporter, org.apache.felix.ipojo.test.composite.importer
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.composite.importer.ImportTestSuite, org.apache.felix.ipojo.test.composite.exporter.ExportTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/ExportTestSuite.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/ExportTestSuite.java
deleted file mode 100644
index d9b84f1..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/ExportTestSuite.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ExportTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Composite Service Exporters Test Suite", bc);
- ots.addTestSuite(SimpleExport.class);
- ots.addTestSuite(OptionalExport.class);
- ots.addTestSuite(MultipleExport.class);
- ots.addTestSuite(OptionalMultipleExport.class);
- ots.addTestSuite(FilteredExport.class);
- ots.setBundleContext(bc);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/FilteredExport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/FilteredExport.java
deleted file mode 100644
index a60b711..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/FilteredExport.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class FilteredExport extends OSGiTestCase {
-
- ComponentInstance export1;
- Factory fooProvider;
- ComponentInstance foo1 = null, foo2 = null;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "BazProviderType");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
-
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to create foos : " + e.getMessage());
- }
-
- foo1.stop();
- foo2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "composite.export.5");
- Properties props = new Properties();
- props.put("instance.name","export");
- try {
- export1 = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Fail to instantiate exporter " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- export1.dispose();
- foo1 = null;
- foo2 = null;
- export1 = null;
- }
-
- public void test1() {
- export1.start();
-
- // Check that no foo service are available
- assertEquals("Check no foo service", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 0);
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.stop();
- assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check invalidity - 5", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 0);
- }
-
- public void test2() {
- export1.start();
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 3", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 5", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke());
- }
-
- public void test3() {
- foo1.start();
- foo2.start();
-
- export1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 2", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 0);
-
- foo2.stop();
- assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 4", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke());
- }
-
- public void test4() {
- foo1.start();
- foo2.start();
-
- export1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
- }
-
-
-
- private boolean isFooServiceProvided() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export1.getInstanceName());
- return ref != null;
- }
-
- private int countFooServiceProvided() {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export1.getInstanceName()+")");
- return refs.length;
- }
-
- private boolean invoke() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export1.getInstanceName());
- if(ref == null) { return false; }
- BazService fs = (BazService) getContext().getService(ref);
- return fs.foo();
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/MultipleExport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/MultipleExport.java
deleted file mode 100644
index 7d452d0..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/MultipleExport.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MultipleExport extends OSGiTestCase {
-
- ComponentInstance export3;
- Factory fooProvider;
- ComponentInstance foo1 = null, foo2 = null;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "BazProviderType");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
-
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to create foos : " + e.getMessage());
- }
-
- foo1.stop();
- foo2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "composite.export.3");
- Properties props = new Properties();
- props.put("instance.name","export");
- try {
- export3 = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Fail to instantiate exporter " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- export3.dispose();
- foo1 = null;
- foo2 = null;
- export3 = null;
- }
-
- public void test1() {
- export3.start();
-
- // Check that no foo service are available
- assertEquals("Check no foo service", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 0);
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke(1));
-
- foo2.start();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 2", invoke(2));
-
- foo1.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3 ("+countFooServiceProvided()+")", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke(1));
-
- foo2.stop();
- assertTrue("Check invalidity - 4", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 5", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke(1));
- }
-
- public void test2() {
- export3.start();
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 2", invoke(2));
-
- foo2.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke(1));
-
- foo1.stop();
- assertTrue("Check invalidity - 4", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 5", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke(1));
- }
-
- public void test3() {
- foo1.start();
- foo2.start();
-
- export3.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 1", invoke(2));
-
- foo1.stop();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke(1));
-
- foo2.stop();
- assertTrue("Check invalidity - 3", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke(1));
- }
-
- public void test4() {
- foo1.start();
- foo2.start();
-
- export3.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 1", invoke(2));
-
- foo2.stop();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke(1));
-
- foo1.stop();
- assertTrue("Check invalidity - 3", export3.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke(1));
- }
-
-
-
- private boolean isFooServiceProvided() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export3.getInstanceName());
- return ref != null;
- }
-
- private int countFooServiceProvided() {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export3.getInstanceName()+")");
- return refs.length;
- }
-
- private boolean invoke() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export3.getInstanceName());
- if(ref == null) { return false; }
- BazService fs = (BazService) getContext().getService(ref);
- getContext().ungetService(ref);
- return fs.foo();
- }
-
- private boolean invoke(int nb) {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export3.getInstanceName()+")");
- if(refs == null) { return false; }
- if (nb > refs.length) { return false; }
- for(int i = 0; i < nb; i++) {
- BazService fs = (BazService) getContext().getService(refs[i]);
- getContext().ungetService(refs[i]);
- if(!fs.foo()) { return false; }
- }
- return true;
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalExport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalExport.java
deleted file mode 100644
index 3879abe..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalExport.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class OptionalExport extends OSGiTestCase {
-
- ComponentInstance export2;
- Factory fooProvider;
- ComponentInstance foo1 = null, foo2 = null;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "BazProviderType");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
-
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to create foos : " + e.getMessage());
- }
-
- foo1.stop();
- foo2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "composite.export.2");
- Properties props = new Properties();
- props.put("instance.name","export");
- try {
- export2 = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Fail to instantiate exporter " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- export2.dispose();
- foo1 = null;
- foo2 = null;
- export2 = null;
- }
-
- public void test1() {
- export2.start();
-
- // Check that no foo service are available
- assertEquals("Check no foo service", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 0);
-
- // Test validity
- assertTrue("Check validity - 0", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 3", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3 ("+countFooServiceProvided()+")", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 4", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 5", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke());
- }
-
- public void test2() {
- export2.start();
-
- // Test invalidity
- assertTrue("Check validity - 0", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 3", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 4", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 5", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke());
- }
-
- public void test3() {
- foo1.start();
- foo2.start();
-
- export2.start();
- assertTrue("Check validity - 1", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 2", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 3", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 4", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke());
- }
-
- public void test4() {
- foo1.start();
- foo2.start();
-
- export2.start();
- assertTrue("Check validity - 1", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 2", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 3", export2.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 4", export2.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke());
- }
-
-
-
- private boolean isFooServiceProvided() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export2.getInstanceName());
- return ref != null;
- }
-
- private int countFooServiceProvided() {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export2.getInstanceName()+")");
- return refs.length;
- }
-
- private boolean invoke() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export2.getInstanceName());
- if(ref == null) { return false; }
- BazService fs = (BazService) getContext().getService(ref);
- return fs.foo();
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalMultipleExport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalMultipleExport.java
deleted file mode 100644
index 9c38800..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/OptionalMultipleExport.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class OptionalMultipleExport extends OSGiTestCase {
-
- ComponentInstance export3;
- Factory fooProvider;
- ComponentInstance foo1 = null, foo2 = null;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "BazProviderType");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
-
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to create foos : " + e.getMessage());
- }
-
- foo1.stop();
- foo2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "composite.export.4");
- Properties props = new Properties();
- props.put("instance.name","export");
- try {
- export3 = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Fail to instantiate exporter " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- export3.dispose();
- foo1 = null;
- foo2 = null;
- export3 = null;
- }
-
- public void test1() {
- export3.start();
-
- // Check that no foo service are available
- assertEquals("Check no foo service", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 0);
-
- // Test invalidity
- assertTrue("Check validity - 0", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke(1));
-
- foo2.start();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 2", invoke(2));
-
- foo1.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3 ("+countFooServiceProvided()+")", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke(1));
-
- foo2.stop();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 5", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke(1));
- }
-
- public void test2() {
- export3.start();
-
- // Test invalidity
- assertTrue("Check validity - 0", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 2", invoke(2));
-
- foo2.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke(1));
-
- foo1.stop();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 5", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke(1));
- }
-
- public void test3() {
- foo1.start();
- foo2.start();
-
- export3.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 1", invoke(2));
-
- foo1.stop();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke(1));
-
- foo2.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke(1));
- }
-
- public void test4() {
- foo1.start();
- foo2.start();
-
- export3.start();
- assertTrue("Check validity - 1", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);
- assertTrue("Check invocation - 1", invoke(2));
-
- foo2.stop();
- assertTrue("Check validity - 2", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke(1));
-
- foo1.stop();
- assertTrue("Check validity - 3", export3.getState() == ComponentInstance.VALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 4", export3.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke(1));
- }
-
-
-
- private boolean isFooServiceProvided() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export3.getInstanceName());
- return ref != null;
- }
-
- private int countFooServiceProvided() {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export3.getInstanceName()+")");
- return refs.length;
- }
-
- private boolean invoke() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export3.getInstanceName());
- if(ref == null) { return false; }
- BazService fs = (BazService) getContext().getService(ref);
- getContext().ungetService(ref);
- return fs.foo();
- }
-
- private boolean invoke(int nb) {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export3.getInstanceName()+")");
- if(refs == null) { return false; }
- if (nb > refs.length) { return false; }
- for(int i = 0; i < nb; i++) {
- BazService fs = (BazService) getContext().getService(refs[i]);
- getContext().ungetService(refs[i]);
- if(!fs.foo()) { return false; }
- }
- return true;
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/SimpleExport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/SimpleExport.java
deleted file mode 100644
index 54418e6..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/exporter/SimpleExport.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.exporter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleExport extends OSGiTestCase {
-
- ComponentInstance export1;
- Factory fooProvider;
- ComponentInstance foo1 = null, foo2 = null;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "BazProviderType");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
-
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to create foos : " + e.getMessage());
- }
-
- foo1.stop();
- foo2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "composite.export.1");
- Properties props = new Properties();
- props.put("instance.name","export");
- try {
- export1 = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Fail to instantiate exporter " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- export1.dispose();
- foo1 = null;
- foo2 = null;
- export1 = null;
- }
-
- public void test1() {
- export1.start();
-
- // Check that no foo service are available
- assertEquals("Check no foo service", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 0);
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 3", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3 ("+countFooServiceProvided()+")", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke());
-
- foo2.stop();
- assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 5", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke());
- }
-
- public void test2() {
- export1.start();
-
- // Test invalidity
- assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 0", isFooServiceProvided());
- assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.start();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 3", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 3", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 5", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 5", isFooServiceProvided());
- assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 5", invoke());
- }
-
- public void test3() {
- foo1.start();
- foo2.start();
-
- export1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo1.stop();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo2.stop();
- assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo1.start();
- assertTrue("Check validity - 4", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke());
- }
-
- public void test4() {
- foo1.start();
- foo2.start();
-
- export1.start();
- assertTrue("Check validity - 1", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 1", isFooServiceProvided());
- assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 1", invoke());
-
- foo2.stop();
- assertTrue("Check validity - 2", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 2", isFooServiceProvided());
- assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 2", invoke());
-
- foo1.stop();
- assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);
- assertFalse("Check providing - 3", isFooServiceProvided());
- assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);
-
- foo2.start();
- assertTrue("Check validity - 4", export1.getState() == ComponentInstance.VALID);
- assertTrue("Check providing - 4", isFooServiceProvided());
- assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);
- assertTrue("Check invocation - 4", invoke());
- }
-
-
-
- private boolean isFooServiceProvided() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export1.getInstanceName());
- return ref != null;
- }
-
- private int countFooServiceProvided() {
- ServiceReference[] refs = Utils.getServiceReferences(getContext(), BazService.class.getName(), "(instance.name="+export1.getInstanceName()+")");
- return refs.length;
- }
-
- private boolean invoke() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), export1.getInstanceName());
- if(ref == null) { return false; }
- BazService fs = (BazService) getContext().getService(ref);
- return fs.foo();
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedFilteredImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedFilteredImport.java
deleted file mode 100644
index c712945..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedFilteredImport.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedFilteredImport extends OSGiTestCase {
-
- ComponentInstance import1;
- Factory fooProvider;
- ComponentInstance foo1, foo2;
-
- public void setUp() {
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.1");
- try {
- import1 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
-
- import1.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import1.dispose();
- foo1 = null;
- foo2 = null;
- import1 = null;
- }
-
- public void testSimple() {
- import1.start();
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo2.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import1.start();
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo2.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedMultipleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedMultipleImport.java
deleted file mode 100644
index f215040..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedMultipleImport.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedMultipleImport extends OSGiTestCase {
-
- ComponentInstance import2;
- Factory fooProvider;
- ComponentInstance foo1, foo2;
-
- public void setUp() {
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.2");
- try {
- import2 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
-
- import2.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import2.dispose();
- foo1 = null;
- foo2 = null;
- import2 = null;
- }
-
- public void testSimple() {
- import2.start();
- //Two providers
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- fs = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation (2)", fs.foo());
- sc.ungetService(refs[1]);
-
- foo1.stop();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);
-
- foo2.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import2.start();
- //Two providers
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- fs = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[1]);
-
- foo2.stop();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalImport.java
deleted file mode 100644
index 38cff7d..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalImport.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedOptionalImport extends OSGiTestCase {
-
- ComponentInstance import3;
- Factory fooProvider;
- ComponentInstance foo1, foo2;
-
- public void setUp() {
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.3");
- try {
- import3 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
-
- import3.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import3.dispose();
- foo1 = null;
- foo2 = null;
- import3 = null;
- }
-
- public void testSimple() {
- import3.start();
- //Two providers
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import3);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.stop();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component validity - 2", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo non-availability inside the composite - 3.1", refs.length, 0);
-
- foo2.start();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import3.start();
- //Two providers
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import3);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo2.stop();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component validity - 2", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 0);
-
- foo1.start();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalMultipleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalMultipleImport.java
deleted file mode 100644
index 3cfa5e5..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedOptionalMultipleImport.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedOptionalMultipleImport extends OSGiTestCase {
-
- ComponentInstance import4;
- Factory fooProvider;
- ComponentInstance foo1, foo2;
-
- public void setUp() {
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.4");
- try {
- import4 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
-
- import4.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import4.dispose();
- foo1 = null;
- foo2 = null;
- import4 = null;
- }
-
- public void testSimple() {
- import4.start();
- //Two providers
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import4);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- fs = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation (2)", fs.foo());
- sc.ungetService(refs[1]);
-
- foo1.stop();
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component validity - 2", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo availability inside the composite - 1", refs.length, 0);
-
- foo2.start();
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import4.start();
- //Two providers
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import4);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- fs = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[1]);
-
- foo2.stop();
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component validity - 2", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo availability inside the composite - 1", refs.length, 0);
-
- foo1.start();
- assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import4);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedSimpleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedSimpleImport.java
deleted file mode 100644
index 82deca3..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/DelayedSimpleImport.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedSimpleImport extends OSGiTestCase {
-
- ComponentInstance import1;
- Factory fooProvider;
- ComponentInstance foo1, foo2;
-
- public void setUp() {
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.1");
- try {
- import1 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
-
- import1.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import1.dispose();
- foo1 = null;
- foo2 = null;
- import1 = null;
- }
-
- public void testSimple() {
- import1.start();
-
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo2.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import1.start();
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo2.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/FilteredImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/FilteredImport.java
deleted file mode 100644
index 761bd41..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/FilteredImport.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class FilteredImport extends OSGiTestCase {
-
- ComponentInstance import1;
- Factory fooProvider;
- Factory fooProvider2;
-
- ComponentInstance foo1, foo2;
-
- public void setUp() {
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.5");
- try {
- import1 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
- import1.stop();
-
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- fooProvider2 = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-2");
- assertNotNull("Check fooProvider availability", fooProvider2);
-
- Properties p1 = new Properties();
- p1.put("instance.name","foo1");
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo1 = fooProvider.createComponentInstance(p1);
- foo2 = fooProvider2.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- foo1.dispose();
- foo2.dispose();
- import1.dispose();
- foo1 = null;
- foo2 = null;
- import1 = null;
- }
-
- public void testSimple() {
- import1.start();
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo2.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
- public void testSimple2() {
- import1.start();
- //Two providers
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo2.stop();
- assertTrue("Test component invalidity - 1", import1.getState() == ComponentInstance.INVALID);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);
-
- foo2.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
- }
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/ImportTestSuite.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/ImportTestSuite.java
deleted file mode 100644
index 2f25b2c..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/ImportTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ImportTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Composite Import Test Suite", bc);
- ots.addTestSuite(SimpleImport.class);
- ots.addTestSuite(DelayedSimpleImport.class);
- ots.addTestSuite(OptionalImport.class);
- ots.addTestSuite(DelayedOptionalImport.class);
- ots.addTestSuite(MultipleImport.class);
- ots.addTestSuite(DelayedMultipleImport.class);
- ots.addTestSuite(OptionalMultipleImport.class);
- ots.addTestSuite(DelayedOptionalMultipleImport.class);
- ots.addTestSuite(FilteredImport.class);
- ots.addTestSuite(DelayedFilteredImport.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/MultipleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/MultipleImport.java
deleted file mode 100644
index 135c6c8..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/MultipleImport.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MultipleImport extends OSGiTestCase {
-
- ComponentInstance import2;
- Factory fooProvider;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.2");
- try {
- import2 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- import2.dispose();
- import2 = null;
- }
-
- public void testSimple() {
- // No provider -> Invalid
- assertTrue("Test component invalidity", import2.getState() == ComponentInstance.INVALID);
-
- ComponentInstance foo = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2 ("+refs.length+")", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- FooService fs2 = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs2.foo());
- sc.ungetService(refs[0]);
- sc.ungetService(refs[1]);
-
- // Stop the second provider
- foo2.dispose();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the foo provider
- foo.stop();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);
-
- foo.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.INVALID);
- }
-
- public void testSimple2() {
- // No provider -> Invalid
- assertTrue("Test component invalidity", import2.getState() == ComponentInstance.INVALID);
-
- ComponentInstance foo1 = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo1 = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2 ("+refs.length+")", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- FooService fs2 = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs2.foo());
- sc.ungetService(refs[0]);
- sc.ungetService(refs[1]);
-
- // Stop the first provider
- foo1.stop();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the second foo provider
- foo2.dispose();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.INVALID);
- }
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalImport.java
deleted file mode 100644
index 985b834..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalImport.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class OptionalImport extends OSGiTestCase {
-
- ComponentInstance import3;
- Factory fooProvider;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.3");
- try {
- import3 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- import3.dispose();
- import3 = null;
- }
-
- public void testSimple() {
- // No provider -> valid
- assertTrue("Test component invalidity", import3.getState() == ComponentInstance.VALID);
-
- ComponentInstance foo = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import3);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.dispose();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the foo provider
- foo.stop();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import3.getState() == ComponentInstance.VALID);
-
- foo.start();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import3.getState() == ComponentInstance.VALID);
- }
-
- public void testSimple2() {
- // No provider -> valid
- assertTrue("Test component invalidity", import3.getState() == ComponentInstance.VALID);
-
- ComponentInstance foo1 = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo1 = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import3);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo1.stop();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the foo provider
- foo2.dispose();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import3.getState() == ComponentInstance.VALID);
-
- foo1.start();
- assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import3);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import3.getState() == ComponentInstance.VALID);
- }
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalMultipleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalMultipleImport.java
deleted file mode 100644
index 4269ef5..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/OptionalMultipleImport.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class OptionalMultipleImport extends OSGiTestCase {
-
- ComponentInstance import2;
- Factory fooProvider;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.4");
- try {
- import2 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- fail("Cannot instantiate the component : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- import2.dispose();
- import2 = null;
- }
-
- public void testSimple() {
- // No provider -> valid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
-
- ComponentInstance foo = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2 ("+refs.length+")", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- FooService fs2 = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs2.foo());
- sc.ungetService(refs[0]);
- sc.ungetService(refs[1]);
-
- // Stop the second provider
- foo2.dispose();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the foo provider
- foo.stop();
-
- // No provider -> valid
- assertTrue("Test component validity - 2", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo non-availability inside the composite - 1", refs.length, 0);
-
- foo.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo.dispose();
- // No provider -> Invalid
- assertTrue("Test component validity - 3", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo non-availability inside the composite - 2", refs.length, 0);
- }
-
- public void testSimple2() {
- // No provider -> Invalid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
-
- ComponentInstance foo1 = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo1 = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import2);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2 ("+refs.length+")", refs.length, 2);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- FooService fs2 = (FooService) sc.getService(refs[1]);
- assertTrue("Test foo invocation", fs2.foo());
- sc.ungetService(refs[0]);
- sc.ungetService(refs[1]);
-
- // Stop the first provider
- foo1.stop();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the second foo provider
- foo2.dispose();
-
- // No provider -> Invalid
- assertTrue("Test component validity - 2", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo non-availability inside the composite - 1", refs.length, 0);
-
- foo1.start();
- assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import2);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertEquals("Test foo non-availability inside the composite - 2", refs.length, 0);
- }
-
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/SimpleImport.java b/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/SimpleImport.java
deleted file mode 100644
index 897d6e7..0000000
--- a/ipojo/tests/composite/import-export/src/main/java/org/apache/felix/ipojo/test/composite/importer/SimpleImport.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.importer;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleImport extends OSGiTestCase {
-
- ComponentInstance import1;
- Factory fooProvider;
-
- public void setUp() {
- fooProvider = Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- assertNotNull("Check fooProvider availability", fooProvider);
-
- Properties p = new Properties();
- p.put("instance.name","importer");
- Factory compFact = Utils.getFactoryByName(getContext(), "composite.requires.1");
- try {
- import1 = compFact.createComponentInstance(p);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate the component : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- import1.dispose();
- import1 = null;
- }
-
- public void testSimple() {
- // No provider -> Invalid
- assertTrue("Test component invalidity - 0 ("+import1.getState()+")", import1.getState() == ComponentInstance.INVALID);
-
- ComponentInstance foo = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity - 1", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the second provider
- foo2.dispose();
- assertTrue("Test component validity - 2", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the foo provider
- foo.stop();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo.start();
- assertTrue("Test component validity - 3", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);
- }
-
- public void testSimple2() {
- // No provider -> Invalid
- assertTrue("Test component invalidity", import1.getState() == ComponentInstance.INVALID);
-
- ComponentInstance foo1 = null;
- Properties p = new Properties();
- p.put("instance.name","foo");
- try {
- foo1 = fooProvider.createComponentInstance(p);
- } catch(Exception e) {
- fail("Fail to instantiate the foo component " + e.getMessage());
- }
-
- ComponentInstance foo2 = null;
- Properties p2 = new Properties();
- p2.put("instance.name","foo2");
- try {
- foo2 = fooProvider.createComponentInstance(p2);
- } catch(Exception e) {
- fail("Fail to instantiate the foo2 component " + e.getMessage());
- }
-
- // The foo service is available => import1 must be valid
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(import1);
- ServiceReference[] refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 1", refs);
- assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);
- FooService fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // Stop the first provider
- foo1.stop();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 2", refs);
- assertEquals("Test foo availability inside the composite - 2.1 ("+refs.length+")", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- // stop the second foo provider
- foo2.dispose();
-
- // No provider -> Invalid
- assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);
-
- foo1.start();
- assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);
- sc = Utils.getServiceContext(import1);
- refs = Utils.getServiceReferences(sc, FooService.class.getName(), null);
- assertNotNull("Test foo availability inside the composite - 3", refs);
- assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);
- fs = (FooService) sc.getService(refs[0]);
- assertTrue("Test foo invocation", fs.foo());
- sc.ungetService(refs[0]);
-
- foo1.dispose();
- // No provider -> Invalid
- assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);
- }
-
-}
diff --git a/ipojo/tests/composite/import-export/src/main/resources/metadata.xml b/ipojo/tests/composite/import-export/src/main/resources/metadata.xml
deleted file mode 100644
index 7924d37..0000000
--- a/ipojo/tests/composite/import-export/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
- org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:comp="org.apache.felix.ipojo.composite"
- xmlns:cs="org.apache.felix.ipojo.test.composite.handler.CheckServiceHandler">
- <comp:composite name="composite.requires.1" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.FooService"
- scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.requires.2" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.FooService"
- aggregate="true" scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.requires.3" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.FooService"
- optional="true" scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.requires.4" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.FooService"
- optional="true" aggregate="true" scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.requires.5" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.FooService"
- filter="(&(int=2)(long=40))" scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.export.1" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" optional="true" filter="(!(instance.name=export))"
- scope="composite" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService" />
- </comp:composite>
-
- <comp:composite name="composite.export.2" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- scope="composite" aggregate="true" optional="true"
- filter="(!(instance.name=export))" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- optional="true" />
- </comp:composite>
-
- <comp:composite name="composite.export.3" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- scope="composite" aggregate="true" optional="true"
- filter="(!(instance.name=export))" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" />
- </comp:composite>
-
- <comp:composite name="composite.export.4" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" optional="true" filter="(!(instance.name=export))"
- scope="composite" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" optional="true" />
- </comp:composite>
-
- <comp:composite name="composite.export.5" architecture="true">
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" optional="true" filter="(!(instance.name=export))"
- scope="composite" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- filter="(instance.name=foo1)" />
- </comp:composite>
-
-</ipojo>
diff --git a/ipojo/tests/composite/service-instance/pom.xml b/ipojo/tests/composite/service-instance/pom.xml
deleted file mode 100644
index e486eb6..0000000
--- a/ipojo/tests/composite/service-instance/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Composite (Service Instance) Test Suite</name>
- <artifactId>tests.composite.service.instance</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.composite.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.composite.instantiator*, org.apache.felix.ipojo.test.composite.instance, org.apache.felix.ipojo.test.instance
- </Private-Package>
- <Export-Package>org.apache.felix.ipojo.test.instance.service</Export-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.composite.instantiator.InstantiatorTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java
deleted file mode 100644
index 3aae2e5..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.apache.felix.ipojo.test.composite.instance;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.composite.CompositeFactory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.apache.felix.ipojo.test.instance.service.Service;
-import org.osgi.framework.ServiceReference;
-
-public class InstanceScopeTest extends OSGiTestCase {
-
- CompositeFactory factory;
- ComponentInstance instance;
-
- public void setUp() {
- factory = (CompositeFactory) Utils.getFactoryByName(getContext(), "SCOPE-scope");
- assertNotNull("Factory", factory);
- try {
- instance = factory.createComponentInstance(null);
- } catch (Exception e) {
- fail("Fail instantiation : " + e.getMessage());
- }
-
-
- }
-
- public void tearDown() {
- instance.dispose();
- instance = null;
- }
-
- public void testScope() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", ref);
- Architecture arch = (Architecture) getContext().getService(ref);
- assertTrue("Validity", arch.getInstanceDescription().getState() == ComponentInstance.VALID);
-
- // Get internal service
- ServiceContext sc = Utils.getServiceContext(instance);
- ServiceReference ref2 = Utils.getServiceReference(sc, CheckService.class.getName(), null);
- assertNotNull("Check CheckService availability", ref2);
- CheckService svc = (CheckService) sc.getService(ref2);
- Properties props = svc.getProps();
- assertEquals("Check props - 1", 1, ((Integer) props.get("1")).intValue());
- assertEquals("Check props - 2", 2, ((Integer) props.get("2")).intValue());
- assertEquals("Check props - 3", 3, ((Integer) props.get("3")).intValue());
-
- }
-
- public void testGlobalUnavailability() {
- ServiceReference ref2 = Utils.getServiceReference(getContext(), Service.class.getName(), null);
- assertNull("Check Service unavailability", ref2);
- }
-
- public void testScopeUnvailability() {
- CompositeFactory factory2 = (CompositeFactory) Utils.getFactoryByName(getContext(), "SCOPE-badscope");
- assertNotNull("Factory", factory2);
- ComponentInstance instance2 = null;
- try {
- instance2 = factory2.createComponentInstance(null);
- } catch (Exception e) {
- fail("Fail instantiation : " + e.getMessage());
- }
- //System.out.println(instance2.getInstanceDescription().getDescription());
-
- assertEquals("Check invalidity", ComponentInstance.INVALID, instance2.getState());
- instance2.dispose();
-
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/SimpleInstance.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/SimpleInstance.java
deleted file mode 100644
index 5b41d74..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/SimpleInstance.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instance;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleInstance extends OSGiTestCase {
-
- private ComponentFactory fooFactory1, fooFactory2;
- private ComponentFactory compoFactory;
- private ComponentInstance empty;
-
-
- public void setUp() {
- fooFactory1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-1");
- fooFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooProviderType-Dyn2");
- compoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.inst.1");
- Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty-X");
- try {
- empty = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the empty composite : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testCreation() {
- Properties props = new Properties();
- props.put("instance.name","under-A");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate under from " + compoFactory.getName() + " -> " + e.getMessage());
- }
-
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailability() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
-
- assertNotNull("Check service availability", sc.getServiceReference(FooService.class.getName()));
- assertEquals("Check service provider", Utils.getServiceReferences(sc, FooService.class.getName(), null).length, 2);
-
- under.dispose();
- }
-
- public void testCreationLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props, sc);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailabilityLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under-X");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
-
- assertNotNull("Check service availability", sc2.getServiceReference(FooService.class.getName()));
- assertEquals("Check service providers", Utils.getServiceReferences(sc2, FooService.class.getName(), null).length, 2);
-
- under.dispose();
- }
-
- public void testFactoryManagement() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- fooFactory1.stop();
- assertTrue("Check instance invalidity - 2", under.getState() == ComponentInstance.INVALID);
-
- fooFactory1.start();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fooFactory2.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
-
- fooFactory2.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fooFactory1.start();
- fooFactory2.start();
- }
-
- public void testFactoryManagementLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- fooFactory1.stop();
- assertTrue("Check instance invalidity - 2", under.getState() == ComponentInstance.INVALID);
-
- fooFactory1.start();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fooFactory2.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
-
- fooFactory2.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fooFactory1.start();
- fooFactory2.start();
- }
-
- public void atestArchitecture() { // TODO fix and reactivate the method.
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compoFactory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- ServiceReference ref = Utils.getServiceReference(getContext(), Architecture.class.getName(), "(architecture.instance=under)");
- assertNotNull("Check architecture availability", ref);
- Architecture arch = (Architecture) getContext().getService(ref);
- CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();
-
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- InstanceDescription[] contained = id.getContainedInstances();
- assertEquals("Check contained instances count (" + contained.length + ")", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReference(getContext(), Architecture.class.getName(), "(architecture.instance=under)");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.INVALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 0);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurableInstantiation.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurableInstantiation.java
deleted file mode 100644
index 510c3a6..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurableInstantiation.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ConfigurableInstantiation extends OSGiTestCase {
-
- private ComponentFactory acceptF;
- private ComponentFactory refuse1F;
- private ComponentFactory refuse2F;
-
- public void setUp() {
- acceptF = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.5-accept");
- refuse1F = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.5-refuse1");
- refuse2F = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.5-refuse2");
-
- }
-
- public void tearDown() { }
-
- public void testAccept() {
- Properties props = new Properties();
- props.put("instance.name","under-A");
- ComponentInstance under = null;
- try {
- under = acceptF.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
-
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- ServiceReference ref = sc.getServiceReference(FooService.class.getName());
- assertNotNull("Check refs not null", ref);
- FooService foo = (FooService) sc.getService(ref);
- Properties p = foo.fooProps();
- boolean b = ((Boolean) p.get("boolProp")).booleanValue();
- String s = (String) p.get("strProp");
- int i = ( (Integer) p.get("intProp")).intValue();
- assertTrue("Test boolean", b);
- assertEquals("Test string", s, "foo");
- //TODO See why it fails...
- //assertEquals("Test int", i, 5); // The code fix to 5.
- under.dispose();
- }
-
- public void testRefuse1() {
- Properties props = new Properties();
- props.put("instance.name","under-ref1");
- ComponentInstance under = null;
- try {
- under = refuse1F.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
-
- assertTrue("Check that under is not valid", under.getState() == ComponentInstance.INVALID);
-
- under.dispose();
- }
-
- public void testRefuse2() {
- Properties props = new Properties();
- props.put("instance.name","under-ref2");
- ComponentInstance under = null;
- try {
- under = refuse2F.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
-
- assertTrue("Check that under is not valid", under.getState() == ComponentInstance.INVALID);
-
- under.dispose();
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurationTest.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurationTest.java
deleted file mode 100644
index bf6923c..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/ConfigurationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class ConfigurationTest extends OSGiTestCase {
-
- private ComponentFactory compositeFactory;
-
- public void setUp() {
- compositeFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "CONF-MySuperComposite");
- }
-
- public void tearDown() {
-
- }
-
- public void testDefaultInstantiation() throws InvalidSyntaxException {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = compositeFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- ServiceReference[] refs = sc.getServiceReferences(FooService.class.getName(), null);
- assertEquals(2, refs.length);
- for (int i = 0; i < refs.length; i++) {
- assertEquals(3, ((Integer) refs[i].getProperty("int")).intValue());
- assertEquals("foo", (String) refs[i].getProperty("string"));
- }
- under.dispose();
- }
-
- public void testConfiguredInstantiation() throws InvalidSyntaxException {
- Properties props = new Properties();
- props.put("instance.name","under");
- props.put("string", "bar");
- props.put("int", "25");
- ComponentInstance under = null;
- try {
- under = compositeFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- ServiceReference[] refs = sc.getServiceReferences(FooService.class.getName(), null);
- assertEquals(2, refs.length);
- for (int i = 0; i < refs.length; i++) {
- assertEquals(25, ((Integer) refs[i].getProperty("int")).intValue());
- assertEquals("bar", (String) refs[i].getProperty("string"));
- }
- under.dispose();
- }
-
-
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java
deleted file mode 100644
index 1ae39b7..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.apache.felix.ipojo.test.composite.instance.InstanceScopeTest;
-import org.apache.felix.ipojo.test.composite.instance.SimpleInstance;
-import org.osgi.framework.BundleContext;
-
-public class InstantiatorTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Composite Service Instantiation Test Suite", bc);
- ots.addTestSuite(SimpleInstantiation.class);
- ots.addTestSuite(OptionalInstantiation.class);
- ots.addTestSuite(MultipleInstantiation.class);
- ots.addTestSuite(OptionalMultipleInstantiation.class);
- ots.addTestSuite(ConfigurableInstantiation.class);
- ots.addTestSuite(SimpleInstance.class);
- ots.addTestSuite(InstanceScopeTest.class);
- ots.addTestSuite(ConfigurationTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/MultipleInstantiation.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/MultipleInstantiation.java
deleted file mode 100644
index 2201507..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/MultipleInstantiation.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MultipleInstantiation extends OSGiTestCase {
-
- private ComponentFactory bar2Factory;
- private ComponentInstance empty;
-
- public void setUp() {
- bar2Factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.2");
- Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
- try {
- empty = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the empty composite : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testCreation() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailability() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));
- int count = Utils.getServiceReferences(sc, BarService.class.getName(), null).length;
- assertEquals("Check service provider number : " + count, count, 3);
-
- under.dispose();
- }
-
- public void testCreationLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailabilityLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 3);
-
- under.dispose();
- }
-
- public void testFactoryManagement() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- ServiceContext sc = Utils.getServiceContext(under);
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 2);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 0);
-
- fact1.start();
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testFactoryManagementLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 2);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 0);
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
- public void testArchitecture() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- Architecture arch = (Architecture) getContext().getService(ref);
- CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();
-
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- InstanceDescription[] contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 3);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.2");
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 2);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.2");
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.2");
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.INVALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 0);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.2");
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.2");
-
- getContext().ungetService(ref);
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalInstantiation.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalInstantiation.java
deleted file mode 100644
index 398c34c..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalInstantiation.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class OptionalInstantiation extends OSGiTestCase {
-
- private ComponentFactory bar1Factory;
- private ComponentInstance empty;
-
- public void setUp() {
- bar1Factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.3");
- Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
- try {
- empty = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the empty composite : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testCreation() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailability() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));
-
- under.dispose();
- }
-
- public void testCreationLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailabilityLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));
-
- under.dispose();
- }
-
- public void testFactoryManagement() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fact3.stop();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- assertNull("Check that no Bar Service is available", sc.getServiceReference(BarService.class.getName()));
-
- fact1.start();
- assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testFactoryManagementLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fact3.stop();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- fact1.start();
- assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testArchitecture() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- Architecture arch = (Architecture) getContext().getService(ref);
- assertNotNull("Check architecture", arch);
- CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- InstanceDescription[] contained = id.getContainedInstances();
- assertNotNull("Check contained not null", contained);
- assertEquals("Check contained instances count ("+contained.length+") - 1", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 0);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");
-
- getContext().ungetService(ref);
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalMultipleInstantiation.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalMultipleInstantiation.java
deleted file mode 100644
index d27643e..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/OptionalMultipleInstantiation.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-
-public class OptionalMultipleInstantiation extends OSGiTestCase {
-
- private ComponentFactory bar2Factory;
- private ComponentInstance empty;
-
- public void setUp() {
- bar2Factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.4");
- assertNotNull("Check bar2factory availability", bar2Factory);
-
- Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty");
- try {
- empty = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the empty composite : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testCreation() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailability() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));
- int count = Utils.getServiceReferences(sc, BarService.class.getName(), null).length;
- assertEquals("Check service provider number : " + count, count, 3);
-
- under.dispose();
- }
-
- public void testCreationLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailabilityLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 3);
-
- under.dispose();
- }
-
- public void testFactoryManagement() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- ServiceContext sc = Utils.getServiceContext(under);
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 2);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
-
- fact3.stop();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 0);
-
- fact1.start();
- assertEquals("Check service provider number", Utils.getServiceReferences(sc, BarService.class.getName(), null).length, 1);
- assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testFactoryManagementLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar2Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 2);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
-
- fact3.stop();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 0);
-
- fact1.start();
- assertTrue("Check instance validity - 5", under.getState() == ComponentInstance.VALID);
- assertEquals("Check service provider number", Utils.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/SimpleInstantiation.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/SimpleInstantiation.java
deleted file mode 100644
index 04f81c4..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/SimpleInstantiation.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.instantiator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.composite.CompositeInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BarService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleInstantiation extends OSGiTestCase {
-
- private ComponentFactory bar1Factory;
- private ComponentInstance empty;
-
- public void setUp() {
- bar1Factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "composite.bar.1");
- Factory fact = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties props = new Properties();
- props.put("instance.name","empty-X");
- try {
- empty = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the empty composite : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- empty.dispose();
- empty = null;
- }
-
- public void testCreation() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailability() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));
-
- under.dispose();
- }
-
- public void testCreationLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- under.dispose();
- }
-
- public void testServiceAvailabilityLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under-X");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
- ServiceContext sc2 = Utils.getServiceContext(under);
- assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));
-
- under.dispose();
- }
-
- public void testFactoryManagement() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testFactoryManagementLevel2() {
- ServiceContext sc = Utils.getServiceContext(empty);
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props, sc);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
- public void testArchitecture() {
- Properties props = new Properties();
- props.put("instance.name","under");
- ComponentInstance under = null;
- try {
- under = bar1Factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate under : " + e.getMessage());
- }
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- Architecture arch = (Architecture) getContext().getService(ref);
- CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();
-
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- InstanceDescription[] contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- ComponentFactory fact1 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-1");
- ComponentFactory fact2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-2");
- ComponentFactory fact3 = (ComponentFactory) Utils.getFactoryByName(getContext(), "COMPO-FooBarProviderType-3");
-
- fact1.stop();
- assertTrue("Check instance validity - 2", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact2.stop();
- assertTrue("Check instance validity - 3", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact3.stop();
- assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.INVALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 0);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- fact1.start();
- assertTrue("Check instance validity - 4", under.getState() == ComponentInstance.VALID);
- ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "under");
- assertNotNull("Check architecture availability", ref);
- arch = (Architecture) getContext().getService(ref);
- //id = arch.getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- contained = id.getContainedInstances();
- assertEquals("Check contained instances count", contained.length, 1);
- assertEquals("Check instance name" , id.getName(), "under");
- assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.1");
-
- under.dispose();
- fact2.start();
- fact3.start();
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java
deleted file mode 100644
index d6abe0a..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.felix.ipojo.test.instance;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.instance.service.Service;
-
-public class ServiceConsumer implements CheckService {
-
- private Service service;
- private Properties props = new Properties();
-
- public ServiceConsumer() {
- props.put("1", new Integer(service.count()));
- props.put("2", new Integer(service.count()));
- props.put("3", new Integer(service.count()));
- }
-
- public boolean check() {
- return service.count() > 0;
- }
-
- public Properties getProps() {
- return props;
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java
deleted file mode 100644
index 7c12a12..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test.instance;
-
-import org.apache.felix.ipojo.test.instance.service.Service;
-
-
-public class ServiceProvider implements Service {
-
- private int i = 0;
-
- public int count() {
- i++;
- return i;
- }
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java
deleted file mode 100644
index 4c64172..0000000
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.instance.service;
-
-public interface Service {
-
- public int count();
-
-}
diff --git a/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml b/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml
deleted file mode 100644
index ede6935..0000000
--- a/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
- org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:comp="org.apache.felix.ipojo.composite"
- xmlns:cs="org.apache.felix.ipojo.test.composite.handler.CheckServiceHandler">
- <comp:composite name="composite.bar.1" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.BarService"/>
- </comp:composite>
-
- <comp:composite name="composite.bar.2" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.BarService" aggregate="true"/>
- </comp:composite>
-
- <comp:composite name="composite.bar.3" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.BarService" optional="true"/>
- </comp:composite>
-
- <comp:composite name="composite.bar.4" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.FooService" aggregate="true" optional="true"/>
- </comp:composite>
-
- <comp:composite name="composite.bar.5-accept" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.FooService">
- <property name="boolean" value="true"/>
- <property name="string" value="foo"/>
- <property name="strAprop" value="{foo, bar, baz}"/>
- <property name="int" value="5"/>
- </subservice>
- </comp:composite>
-
- <comp:composite name="composite.bar.5-refuse1" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.BarService">
- <property name="foo" value="bar"/>
- <property name="boolean" value="true"/>
- <property name="string" value="foo"/>
- <property name="strAprop" value="{foo, bar, baz}"/>
- <property name="int" value="5"/>
- </subservice>
- </comp:composite>
-
- <comp:composite name="composite.bar.5-refuse2" architecture="true">
- <subservice action="instantiate" specification="org.apache.felix.ipojo.test.composite.service.BarService">
- <property name="string" value="foo"/>
- <property name="strAprop" value="{foo, bar, baz}"/>
- </subservice>
- </comp:composite>
-
- <!-- Instance of a specified component -->
- <comp:composite name="composite.inst.1" architecture="true">
- <instance component="COMPO-FooProviderType-1" /> <!-- name="FooProv" -->
- <instance component="COMPO-FooProviderType-Dyn2">
- <property name="boolean" value="true"/>
- <property name="string" value="foo"/>
- <property name="strAProp" value="{a,b,c}"/>
- </instance>
- </comp:composite>
-
- <!-- Scope test -->
- <component name="SCOPE-provider" classname="org.apache.felix.ipojo.test.instance.ServiceProvider">
- <provides/>
- </component>
- <component name="SCOPE-cons" classname="org.apache.felix.ipojo.test.instance.ServiceConsumer">
- <provides/>
- <requires field="service"/>
- </component>
- <comp:composite name="SCOPE-scope">
- <instance component="SCOPE-provider"/>
- <instance component="SCOPE-cons"/>
- </comp:composite>
- <comp:composite name="SCOPE-badscope">
- <instance component="SCOPE-cons"/>
- </comp:composite>
-
- <!-- Instance configuration -->
- <comp:composite name="CONF-MySuperComposite">
- <instance component="COMPO-FooProviderType-2">
- <property name="int" value="3"/>
- </instance>
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.FooService">
- <property name="boolean" value="true"/>
- <property name="string" value="foo"/>
- <property name="strAprop" value="{foo, bar, baz}"/>
- <property name="int" value="3"/>
- </subservice>
- </comp:composite>
-</ipojo>
diff --git a/ipojo/tests/composite/service-providing/pom.xml b/ipojo/tests/composite/service-providing/pom.xml
deleted file mode 100644
index f1069bb..0000000
--- a/ipojo/tests/composite/service-providing/pom.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Composite (Service Providing) Test Suite</name>
- <artifactId>tests.composite.service.providing</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.composite.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.composite.provides, org.apache.felix.ipojo.test.composite.test
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.composite.test.CompositeTest, org.apache.felix.ipojo.test.composite.provides.ProvidesTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/ProvidesTestSuite.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/ProvidesTestSuite.java
deleted file mode 100644
index 413ff58..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/ProvidesTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ProvidesTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Composite Service Providing Test Suite", bc);
- ots.addTestSuite(TestComp0.class);
- ots.addTestSuite(TestComp1.class);
- ots.addTestSuite(TestComp2.class);
- ots.addTestSuite(TestComp3.class);
- ots.addTestSuite(TestComp4.class);
- ots.addTestSuite(TestComp5.class);
- ots.addTestSuite(TestComp6.class);
- ots.addTestSuite(TestComp7.class);
- ots.addTestSuite(TestComp8.class);
-
- return ots;
- }
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java
deleted file mode 100644
index 5e936b3..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.service.Toto;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp0 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
- private ComponentFactory tataFactory2;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create an instance : " + e.getMessage());
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- fail("Cannot create an instance : " + e.getMessage());
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-0");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot create an instance : " + e.getMessage());
- }
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertNotNull("Assert toto service - 1", getContext().getServiceReference(Toto.class.getName()));
- assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 3", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- Integer tataStr = (Integer) props.get("tataStr");
- Integer tataStrs = (Integer) props.get("tataStrs");
- Integer tata_2 = (Integer) props.get("tata_2");
- Integer tata_3 = (Integer) props.get("tata_3");
- Integer tata1 = (Integer) props.get("tata1");
- Integer tata1_1 = (Integer) props.get("tata1_1");
- Integer tata5 = (Integer) props.get("tata5");
- Integer tata5_1 = (Integer) props.get("tata5_1");
- Integer tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 3", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 3", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 4", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);
- assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);
- assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);
- assertEquals("Assert tata1 - 4", tata1.intValue(), 2);
- assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);
- assertEquals("Assert tata5 - 4", tata5.intValue(), 2);
- assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);
- assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);
-
- getContext().ungetService(ref);
- tota = null;
-
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 6", toto.intValue(), 3);
- assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);
- assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);
- assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
- assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 6", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 6", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- totoProv.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
-
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
- private void invokeArrays(Tota tota) {
-
- int[] a = new int[] {1,2,3};
- assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);
-
- long[] b = new long[] {1,2,3};
- assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);
-
- double[] c = new double[] {1,2,3};
- assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);
-
- char[] d = new char[] {'a','b', 'c'};
- assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);
-
- boolean[] e = new boolean[] {true, false};
- assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);
-
- byte[] f = new byte[] {(byte) 1};
- assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);
-
- short[] g = new short[] {(short) 1};
- assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);
-
- float[] h = new float[] {5,6,7};
- assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);
-
- }
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeTata(Tota tota) {
- tota.tata(1,2);
- tota.tata("tototototo");
- }
-
- private void invokeTata1(Tota tota) {
- assertEquals("Assert tata1", tota.tata1("foo"), "foo");
- assertEquals("Assert tata1 - 2", tota.tata1(new char[] {'a','b','c'}), "abc");
- }
-
- private void invokeTata5(Tota tota) {
- assertEquals("Assert tata5 -1", tota.tata5("foo",1), "foo"+1);
- assertEquals("Assert tata5 - 2", tota.tata5(new String[] {"a","b","c"}, 1), "31");
- assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[] {1,2,3}), "foo3");
- }
-
- private void invokeAdd(Tota tota) {
- assertEquals("Assert add", tota.add(1,1,1), 3);
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- invokeArrays(tota);
- invokeStr(tota);
- invokeTata(tota);
- invokeTata1(tota);
- invokeTata5(tota);
- invokeAdd(tota);
- invokeToto(tota);
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp1.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp1.java
deleted file mode 100644
index 17613fc..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp1.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp1 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
- private ComponentFactory tataFactory2;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
-
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-1");
- Properties props2 = new Properties();
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- fail("Cannot create the instance : " + e.getMessage());
- }
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- Integer tataStr = (Integer) props.get("tataStr");
- Integer tataStrs = (Integer) props.get("tataStrs");
- Integer tata_2 = (Integer) props.get("tata_2");
- Integer tata_3 = (Integer) props.get("tata_3");
- Integer tata1 = (Integer) props.get("tata1");
- Integer tata1_1 = (Integer) props.get("tata1_1");
- Integer tata5 = (Integer) props.get("tata5");
- Integer tata5_1 = (Integer) props.get("tata5_1");
- Integer tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 3", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 3", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 4", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);
- assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);
- assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);
- assertEquals("Assert tata1 - 4", tata1.intValue(), 2);
- assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);
- assertEquals("Assert tata5 - 4", tata5.intValue(), 2);
- assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);
- assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);
-
- getContext().ungetService(ref);
- tota = null;
-
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 6", toto.intValue(), 3);
- assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);
- assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);
- assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
- assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 6", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 6", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), under.getInstanceName()));
-
- totoProv.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), under.getInstanceName()));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
-
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
- private void invokeArrays(Tota tota) {
-
- int[] a = new int[] {1,2,3};
- assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);
-
- long[] b = new long[] {1,2,3};
- assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);
-
- double[] c = new double[] {1,2,3};
- assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);
-
- char[] d = new char[] {'a','b', 'c'};
- assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);
-
- boolean[] e = new boolean[] {true, false};
- assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);
-
- byte[] f = new byte[] {(byte) 1};
- assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);
-
- short[] g = new short[] {(short) 1};
- assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);
-
- float[] h = new float[] {5,6,7};
- assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);
-
- }
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeTata(Tota tota) {
- tota.tata(1,2);
- tota.tata("tototototo");
- }
-
- private void invokeTata1(Tota tota) {
- assertEquals("Assert tata1", tota.tata1("foo"), "foo");
- assertEquals("Assert tata1 - 2", tota.tata1(new char[] {'a','b','c'}), "abc");
- }
-
- private void invokeTata5(Tota tota) {
- assertEquals("Assert tata5 -1", tota.tata5("foo",1), "foo"+1);
- assertEquals("Assert tata5 - 2", tota.tata5(new String[] {"a","b","c"}, 1), "31");
- assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[] {1,2,3}), "foo3");
- }
-
- private void invokeAdd(Tota tota) {
- assertEquals("Assert add", tota.add(1,1,1), 3);
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- invokeArrays(tota);
- invokeStr(tota);
- invokeTata(tota);
- invokeTata1(tota);
- invokeTata5(tota);
- invokeAdd(tota);
- invokeToto(tota);
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp2.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp2.java
deleted file mode 100644
index 43e79b7..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp2.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp2 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
- private ComponentFactory tataFactory2;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-2");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
-
- invokeAll(tota);
-
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 4 ("+toto.intValue()+")", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
-
- getContext().ungetService(ref);
- tota = null;
-
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 6 ("+toto.intValue()+")", toto.intValue(), 3);
- assertEquals("Assert toto_2 - 6 ("+toto_2.intValue()+")", toto_2.intValue(), 3);
- assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);
- assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 6", toto_1.intValue(), 4);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- totoProv.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- tota.toto1("foo2");
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- invokeToto(tota);
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp3.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp3.java
deleted file mode 100644
index 41703e5..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp3.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp3 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
- private ComponentFactory tataFactory2;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-3");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
-
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 4 ("+toto.intValue()+")", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 4", toto_1.intValue(), 2);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- getContext().ungetService(ref);
- tota = null;
-
- // Stop the factory
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- totoProv.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAllOpt(tota);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- tataFactory.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- tota.toto1("foo");
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeToto(tota);
- }
-
- private void invokeAllOpt(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeTotoOpt(tota);
- }
-
- private void invokeTotoOpt(Tota tota) {
- try {
- tota.toto();
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
-
- try {
- tota.toto(1,2);
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- tota.toto1("foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp4.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp4.java
deleted file mode 100644
index c5b65af..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp4.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp4 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
- private ComponentFactory tataFactory2;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-4");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void tearDown() {
- tataFactory2.start();
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 4 ("+toto.intValue()+")", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 4", toto_1.intValue(), 2);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- getContext().ungetService(ref);
- tota = null;
-
- // Stop the factory
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- totoProv.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAllOpt(tota);
- // Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- tataFactory.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- tota.toto1("foo");
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeToto(tota);
- }
-
- private void invokeAllOpt(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeTotoOpt(tota);
- }
-
- private void invokeTotoOpt(Tota tota) {
- try {
- tota.toto();
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
-
- try {
- tota.toto(1,2);
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- tota.toto1("foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp5.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp5.java
deleted file mode 100644
index f01dc7a..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp5.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp5 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
- private ComponentFactory tataFactory2;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-5");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot create an instance from comp-5 : " + e.getMessage());
- }
-
- }
-
- public void tearDown() {
- tataFactory2.start();
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 4 ("+toto.intValue()+")", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- getContext().ungetService(ref);
- tota = null;
-
- // Stop the factory
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- totoProv.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAllOpt(tota);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- tataFactory.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
-
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- tota.toto1("foo");
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeToto(tota);
- }
-
- private void invokeAllOpt(Tota tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- invokeTotoOpt(tota);
- }
-
- private void invokeTotoOpt(Tota tota) {
- try {
- tota.toto();
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
-
- try {
- tota.toto(1,2);
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- tota.toto1("foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp6.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp6.java
deleted file mode 100644
index 09edbc6..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp6.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tata;
-import org.apache.felix.ipojo.test.composite.service.Toto;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp6 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
-
- tataFactory.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-6");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- ServiceReference refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- ServiceReference refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNull("Assert no toto service - 1", refToto);
- assertNull("Assert no tata service - 1", refTata);
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNull("Assert no toto service - 2", refToto);
- assertNull("Assert no tata service - 2", refTata);
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNotNull("Assert toto service - 3", refToto);
- assertNotNull("Assert tata service - 3", refTata);
- Toto toto = (Toto) getContext().getService(refToto);
- Tata tata = (Tata) getContext().getService(refTata);
-
- invokeAll(tata);
- invokeToto(toto);
-
- // Check toto
- Properties props = toto.getProps();
- Integer toto_0 = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 3 ("+toto_0.intValue()+")", toto_0.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);
- //Check tata
- props = tata.getPropsTata();
- Integer tata_0 = (Integer) props.get("tata");
- assertEquals("Assert tata - 3", tata_0.intValue(), 1);
-
- getContext().ungetService(refToto);
- getContext().ungetService(refTata);
- toto = null;
- tata = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNotNull("Assert toto service - 4", refToto);
- assertNotNull("Assert tata service - 4", refTata);
-
- toto = (Toto) getContext().getService(refToto);
- tata = (Tata) getContext().getService(refTata);
- invokeAll(tata);
- invokeToto(toto);
-
- // Check toto
- props = toto.getProps();
- toto_0 = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- toto_1 = (Integer) props.get("toto1");
- assertEquals("Assert toto - 4 ("+toto_0.intValue()+")", toto_0.intValue(), 2);
- assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);
- //Check tata
- props = tata.getPropsTata();
- tata_0 = (Integer) props.get("tata");
- assertEquals("Assert tata - 4", tata_0.intValue(), 2);
- getContext().ungetService(refToto);
- getContext().ungetService(refTata);
- toto = null;
- tata = null;
-
- // Stop the factory
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNull("Assert no toto service - 5", refToto);
- assertNull("Assert no tata service - 5", refTata);
-
- totoProv2.stop();
- totoProv.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNotNull("Assert toto service - 6", refToto);
- assertNotNull("Assert tata service - 6", refTata);
- toto = (Toto) getContext().getService(refToto);
- tata = (Tata) getContext().getService(refTata);
-
- invokeAll(tata);
- invokeTotoOpt(toto);
- // Check tata
- props = tata.getPropsTata();
- tata_0 = (Integer) props.get("tata");
- assertEquals("Assert tata - 6", tata_0.intValue(), 1);
- getContext().ungetService(refToto);
- getContext().ungetService(refTata);
- toto = null;
- tata = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- tataFactory.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- refToto = Utils.getServiceReferenceByName(getContext(), Toto.class.getName(), "ff");
- refTata = Utils.getServiceReferenceByName(getContext(), Tata.class.getName(), "ff");
- assertNull("Assert no toto service - 7", refToto);
- assertNull("Assert no tata service - 7", refTata);
-
- under.dispose();
- under = null;
- }
-
- private void invoke(Tata tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
-
- private void invokeStr(Tata tota) {
- tota.tataStr();
- }
-
- private void invokeToto(Toto tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- tota.toto1("foo");
- }
-
- private void invokeAll(Tata tota) {
- invoke(tota);
- //invokeArrays(tota);
- invokeStr(tota);
- //invokeTata(tota);
- //invokeTata1(tota);
- //invokeTata5(tota);
- //invokeAdd(tota);
- }
-
- private void invokeTotoOpt(Toto tota) {
- try {
- tota.toto();
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
-
- try {
- tota.toto(1,2);
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
-
- try {
- tota.toto1("foo");
- fail("UnsupportedOperationException expected");
- } catch(UnsupportedOperationException e) { }
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp7.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp7.java
deleted file mode 100644
index 2e2a2ef..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp7.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp7 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
- private ComponentFactory tataFactory2;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-7");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
- tataFactory.stop();
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- Integer tataStr = (Integer) props.get("tataStr");
- Integer tataStrs = (Integer) props.get("tataStrs");
- Integer tata_2 = (Integer) props.get("tata_2");
- Integer tata_3 = (Integer) props.get("tata_3");
- Integer tata1 = (Integer) props.get("tata1");
- Integer tata1_1 = (Integer) props.get("tata1_1");
- Integer tata5 = (Integer) props.get("tata5");
- Integer tata5_1 = (Integer) props.get("tata5_1");
- Integer tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 3", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 3", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 4", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);
- assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);
- assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);
- assertEquals("Assert tata1 - 4", tata1.intValue(), 2);
- assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);
- assertEquals("Assert tata5 - 4", tata5.intValue(), 2);
- assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);
- assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);
-
- getContext().ungetService(ref);
- tota = null;
-
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- assertEquals("Assert toto - 6", toto.intValue(), 3);
- assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);
- assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);
- assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 6", 1, tata.intValue());
- assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 6", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 6", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- totoProv.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
- private void invokeArrays(Tota tota) {
-
- int[] a = new int[] {1,2,3};
- assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);
-
- long[] b = new long[] {1,2,3};
- assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);
-
- double[] c = new double[] {1,2,3};
- assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);
-
- char[] d = new char[] {'a','b', 'c'};
- assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);
-
- boolean[] e = new boolean[] {true, false};
- assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);
-
- byte[] f = new byte[] {(byte) 1};
- assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);
-
- short[] g = new short[] {(short) 1};
- assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);
-
- float[] h = new float[] {5,6,7};
- assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);
-
- }
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeTata(Tota tota) {
- tota.tata(1,2);
- tota.tata("tototototo");
- }
-
- private void invokeTata1(Tota tota) {
- assertEquals("Assert tata1", tota.tata1("foo"), "foo");
- assertEquals("Assert tata1 - 2", tota.tata1(new char[] {'a','b','c'}), "abc");
- }
-
- private void invokeTata5(Tota tota) {
- assertEquals("Assert tata5 -1", tota.tata5("foo",1), "foo"+1);
- assertEquals("Assert tata5 - 2", tota.tata5(new String[] {"a","b","c"}, 1), "31");
- assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[] {1,2,3}), "foo3");
- }
-
- private void invokeAdd(Tota tota) {
- assertEquals("Assert add", tota.add(1,1,1), 3);
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- invokeArrays(tota);
- invokeStr(tota);
- invokeTata(tota);
- invokeTata1(tota);
- invokeTata5(tota);
- invokeAdd(tota);
- invokeToto(tota);
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp8.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp8.java
deleted file mode 100644
index c11f643..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp8.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.provides;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.component.TotoProvider;
-import org.apache.felix.ipojo.test.composite.component.TotoProviderGlue;
-import org.apache.felix.ipojo.test.composite.service.Tota;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComp8 extends OSGiTestCase {
-
- private ComponentFactory tataFactory;
- private ComponentFactory totoFactory;
- private ComponentFactory tataFactory2;
-
- private ComponentInstance totoProv, totoProv2;
- private ComponentInstance under;
-
- public void setUp() {
- tataFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "tata");
- totoFactory = (ComponentFactory) Utils.getFactoryByName(getContext(), "toto");
- tataFactory2 = (ComponentFactory) Utils.getFactoryByName(getContext(), "comp-6");
- tataFactory2.stop();
-
- Properties props = new Properties();
- props.put("instance.name","toto provider");
- try {
- totoProv = totoFactory.createComponentInstance(props);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Properties props3 = new Properties();
- props3.put("instance.name","toto provider 2");
- try {
- totoProv2 = totoFactory.createComponentInstance(props3);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- totoProv.stop();
- totoProv2.stop();
-
- Factory factory = Utils.getFactoryByName(getContext(), "comp-8");
- Properties props2 = new Properties();
- props2.put("instance.name","ff");
- try {
- under = factory.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- }
- tataFactory.stop();
-
- }
-
- public void tearDown() {
- tataFactory.start();
- totoProv.dispose();
- totoProv = null;
- totoProv2.dispose();
- totoProv2 = null;
- tataFactory2.start();
-
- // Reset counters
- TotoProvider.toto = 0;
- TotoProvider.toto_2 = 0;
- TotoProvider.toto_3 = 0;
- TotoProvider.toto_4 = 0;
- TotoProvider.toto1 = 0;
- TotoProviderGlue.toto = 0;
- TotoProviderGlue.toto_2 = 0;
- TotoProviderGlue.toto_3 = 0;
- TotoProviderGlue.toto_4 = 0;
- TotoProviderGlue.toto1 = 0;
- }
-
- public void testSimple() {
- // Neither factory nor instance
- assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the importer
- totoProv.start();
- assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));
-
- // Start the factory
- tataFactory.start();
- assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));
- ServiceReference ref = getContext().getServiceReference(Tota.class.getName());
- Tota tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- Properties props = tota.getProps();
- Integer toto = (Integer) props.get("toto");
- Integer toto_2 = (Integer) props.get("toto_2");
- Integer toto_3 = (Integer) props.get("toto_3");
- Integer toto_4 = (Integer) props.get("toto_4");
- Integer gtoto = (Integer) props.get("gtoto");
- Integer gtoto_2 = (Integer) props.get("gtoto_2");
- Integer gtoto_3 = (Integer) props.get("gtoto_3");
- Integer gtoto_4 = (Integer) props.get("gtoto_4");
- assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);
- assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);
- assertEquals("Assert toto_3 - 3", toto_3.intValue(), 0);
- assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);
- assertEquals("Assert gtoto - 3 ("+gtoto.intValue()+")", gtoto.intValue(), 1);
- assertEquals("Assert gtoto_2 - 3", gtoto_2.intValue(), 1);
- assertEquals("Assert gtoto_3 - 3", gtoto_3.intValue(), 1);
- assertEquals("Assert gtoto_4 - 3", gtoto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- Integer tata = (Integer) props.get("tata");
- Integer tataStr = (Integer) props.get("tataStr");
- Integer tataStrs = (Integer) props.get("tataStrs");
- Integer tata_2 = (Integer) props.get("tata_2");
- Integer tata_3 = (Integer) props.get("tata_3");
- Integer tata1 = (Integer) props.get("tata1");
- Integer tata1_1 = (Integer) props.get("tata1_1");
- Integer tata5 = (Integer) props.get("tata5");
- Integer tata5_1 = (Integer) props.get("tata5_1");
- Integer tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 3", tata.intValue(), 1);
- assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 3", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 3", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Start a second import
- totoProv2.start();
- assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- gtoto = (Integer) props.get("gtoto");
- gtoto_2 = (Integer) props.get("gtoto_2");
- gtoto_3 = (Integer) props.get("gtoto_3");
- gtoto_4 = (Integer) props.get("gtoto_4");
- assertEquals("Assert toto - 4", toto.intValue(), 2);
- assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);
- assertEquals("Assert toto_3 - 4", toto_3.intValue(), 0);
- assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);
- assertEquals("Assert gtoto - 4 ("+gtoto.intValue()+")", gtoto.intValue(), 2);
- assertEquals("Assert gtoto_2 - 4", gtoto_2.intValue(), 2);
- assertEquals("Assert gtoto_3 - 4", gtoto_3.intValue(), 2);
- assertEquals("Assert gtoto_4 - 4", gtoto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 4", tata.intValue(), 2);
- assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);
- assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);
- assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);
- assertEquals("Assert tata1 - 4", tata1.intValue(), 2);
- assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);
- assertEquals("Assert tata5 - 4", tata5.intValue(), 2);
- assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);
- assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);
-
- getContext().ungetService(ref);
- tota = null;
-
- tataFactory.stop();
- assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);
- assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));
-
- totoProv2.stop();
- tataFactory.start();
- assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);
- assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));
- ref = getContext().getServiceReference(Tota.class.getName());
- tota = (Tota) getContext().getService(ref);
- invokeAll(tota);
- // Check toto
- props = tota.getProps();
- toto = (Integer) props.get("toto");
- toto_2 = (Integer) props.get("toto_2");
- toto_3 = (Integer) props.get("toto_3");
- toto_4 = (Integer) props.get("toto_4");
- gtoto = (Integer) props.get("gtoto");
- gtoto_2 = (Integer) props.get("gtoto_2");
- gtoto_3 = (Integer) props.get("gtoto_3");
- gtoto_4 = (Integer) props.get("gtoto_4");
- assertEquals("Assert toto - 6", toto.intValue(), 3);
- assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);
- assertEquals("Assert toto_3 - 6", toto_3.intValue(), 0);
- assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);
- assertEquals("Assert gtoto - 6 ("+gtoto.intValue()+")", gtoto.intValue(), 3);
- assertEquals("Assert gtoto_2 - 6", gtoto_2.intValue(), 3);
- assertEquals("Assert gtoto_3 - 6", gtoto_3.intValue(), 3);
- assertEquals("Assert gtoto_4 - 6", gtoto_4.intValue(), 0);
- //Check tata
- props = tota.getPropsTata();
- tata = (Integer) props.get("tata");
- tataStr = (Integer) props.get("tataStr");
- tataStrs = (Integer) props.get("tataStrs");
- tata_2 = (Integer) props.get("tata_2");
- tata_3 = (Integer) props.get("tata_3");
- tata1 = (Integer) props.get("tata1");
- tata1_1 = (Integer) props.get("tata1_1");
- tata5 = (Integer) props.get("tata5");
- tata5_1 = (Integer) props.get("tata5_1");
- tata5_2 = (Integer) props.get("tata5_2");
- assertEquals("Assert tata - 6", tata.intValue(), 1);
- assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);
- assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);
- assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);
- assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);
- assertEquals("Assert tata1 - 6", tata1.intValue(), 1);
- assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);
- assertEquals("Assert tata5 - 6", tata5.intValue(), 1);
- assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);
- assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);
- getContext().ungetService(ref);
- tota = null;
-
- // Is arch exposed
- assertNotNull("Test arch", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
-
- totoProv.stop();
-
- assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);
- assertNotNull("Test arch-2", Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "ff"));
- assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));
-
- under.dispose();
- under = null;
- }
-
-
-
- private void invoke(Tota tota) {
- tota.tata();
-
- assertEquals("Assert invoke tataint", tota.tataInt(2), 2);
- assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);
- assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2);
- assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');
- assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));
- assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);
- assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);
- assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5);
-
- }
-
- private void invokeArrays(Tota tota) {
-
- int[] a = new int[] {1,2,3};
- assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);
-
- long[] b = new long[] {1,2,3};
- assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);
-
- double[] c = new double[] {1,2,3};
- assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);
-
- char[] d = new char[] {'a','b', 'c'};
- assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);
-
- boolean[] e = new boolean[] {true, false};
- assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);
-
- byte[] f = new byte[] {(byte) 1};
- assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);
-
- short[] g = new short[] {(short) 1};
- assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);
-
- float[] h = new float[] {5,6,7};
- assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);
-
- }
-
- private void invokeStr(Tota tota) {
- tota.tataStr();
- }
-
- private void invokeTata(Tota tota) {
- tota.tata(1,2);
- tota.tata("tototototo");
- }
-
- private void invokeTata1(Tota tota) {
- assertEquals("Assert tata1", tota.tata1("foo"), "foo");
- assertEquals("Assert tata1 - 2", tota.tata1(new char[] {'a','b','c'}), "abc");
- }
-
- private void invokeTata5(Tota tota) {
- assertEquals("Assert tata5 -1", tota.tata5("foo",1), "foo"+1);
- assertEquals("Assert tata5 - 2", tota.tata5(new String[] {"a","b","c"}, 1), "31");
- assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[] {1,2,3}), "foo3");
- }
-
- private void invokeAdd(Tota tota) {
- assertEquals("Assert add", tota.add(1,1,1), 3);
- }
-
- private void invokeToto(Tota tota) {
- tota.toto();
- assertEquals("Assert toto", tota.toto("foo"), "foo");
- tota.toto(1,2);
- }
-
- private void invokeAll(Tota tota) {
- invoke(tota);
- invokeArrays(tota);
- invokeStr(tota);
- invokeTata(tota);
- invokeTata1(tota);
- invokeTata5(tota);
- invokeAdd(tota);
- invokeToto(tota);
- }
-
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/test/CompositeTest.java b/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/test/CompositeTest.java
deleted file mode 100644
index 4f90fad..0000000
--- a/ipojo/tests/composite/service-providing/src/main/java/org/apache/felix/ipojo/test/composite/test/CompositeTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.composite.test;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.composite.service.BazService;
-import org.apache.felix.ipojo.test.composite.service.CheckService;
-import org.apache.felix.ipojo.test.composite.service.FooService;
-import org.apache.felix.ipojo.test.composite.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class CompositeTest extends OSGiTestCase {
-
- public void testAPI() {
- Factory fact1 = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty-1");
- ComponentInstance empty = null;
- try {
- empty = fact1.createComponentInstance(p);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- ServiceContext sc = Utils.getServiceContext(empty);
-
- Factory fact2 = Utils.getFactoryByName(getContext(), "composite.test.2");
- Properties props2 = new Properties();
- props2.put("instance.name","2"); // 2
- Factory fact3 = Utils.getFactoryByName(getContext(), "composite.test.3");
- Properties props3 = new Properties();
- props3.put("instance.name","3");
- ComponentInstance comp2 = null;
- ComponentInstance comp3 = null;
- try {
- comp2 = fact2.createComponentInstance(props2, sc);
- comp3 = fact3.createComponentInstance(props3, sc);
- } catch(Throwable e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);
- assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);
-
- ServiceReference ref = null;
-
- ref = Utils.getServiceReferenceByName(sc, CheckService.class.getName(), "2"); // 2
-
- assertNotNull("Check ref", ref);
- CheckService cs = (CheckService) sc.getService(ref);
- assertTrue("Check invoke", cs.check());
-
- comp3.dispose();
- comp2.dispose();
- empty.dispose();
- }
-
- public void testInstantiator() {
- String type = "composite.instantiator";
- Factory fact = Utils.getFactoryByName(getContext(), type);
- ComponentInstance ci = null;
- Properties p = new Properties();
- p.put("instance.name","mon_coeur");
- try {
- ci = fact.createComponentInstance(p);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- assertTrue("Check ci", ci.getState() == ComponentInstance.VALID);
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), BazService.class.getName(), "mon_coeur");
- assertNotNull("Check ref",ref);
- BazService bs = (BazService) getContext().getService(ref);
- assertTrue("Check invocation", bs.foo());
- getContext().ungetService(ref);
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "mon_coeur");
- assertNotNull("Check ref 2 ",ref);
- FooService fs = (FooService) getContext().getService(ref);
- assertTrue("Check invocation", fs.foo());
- getContext().ungetService(ref);
- ci.dispose();
- }
-
- public void testAPI2() {
- Factory fact1 = Utils.getFactoryByName(getContext(), "composite.empty");
- Properties p = new Properties();
- p.put("instance.name","empty-2");
- ComponentInstance empty = null;
- try {
- empty = fact1.createComponentInstance(p);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- ServiceContext sc = Utils.getServiceContext(empty);
-
- Factory fact2 = Utils.getFactoryByName(sc, "composite.test.2");
- Properties props2 = new Properties();
- props2.put("instance.name","4");
- Factory fact3 = Utils.getFactoryByName(sc, "composite.test.3");
- Properties props3 = new Properties();
- props3.put("instance.name","5");
- ComponentInstance comp2 = null;
- ComponentInstance comp3 = null;
- try {
- comp2 = fact2.createComponentInstance(props2, sc);
- comp3 = fact3.createComponentInstance(props3, sc);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);
- assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);
-
- ServiceReference ref = null;
-
- ref = Utils.getServiceReferenceByName(sc, CheckService.class.getName(), "4");
-
- assertNotNull("Check ref", ref);
- CheckService cs = (CheckService) sc.getService(ref);
- assertTrue("Check invoke", cs.check());
-
- comp3.dispose();
- comp2.dispose();
- empty.dispose();
- }
-
-
- public void testApplication() {
- Factory factory = Utils.getFactoryByName(getContext(), "composite.test.1");
- ComponentInstance ci = null;
- Properties props = new Properties();
- props.put("instance.name","Test");
- try {
- ci = factory.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot instantiate Test " + e.getMessage());
- }
-
- assertTrue("Check ci state", ci.getState() == ComponentInstance.VALID );
-
- ServiceReference[] refs = null;
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=Test)");
- } catch (InvalidSyntaxException e) {
- fail("Invalid filter : " + e.getMessage());
- }
- assertNotNull("Check refs not null", refs);
- CheckService cs = (CheckService) getContext().getService(refs[0]);
-
- assertTrue("Check invocation", cs.check());
- ci.dispose();
-
- }
-
-}
diff --git a/ipojo/tests/composite/service-providing/src/main/resources/metadata.xml b/ipojo/tests/composite/service-providing/src/main/resources/metadata.xml
deleted file mode 100644
index 4df6a9e..0000000
--- a/ipojo/tests/composite/service-providing/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
- org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:comp="org.apache.felix.ipojo.composite">
- <comp:composite name="composite.test.3" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- aggregate="true" filter="(factory.name=BazProviderType)" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService" />
- </comp:composite>
-
- <comp:composite name="composite.test.2" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.CheckService"
- filter="(factory.name=Baz2CheckProvider)" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.CheckService" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- scope="composite" />
- </comp:composite>
-
- <comp:composite name="composite.test.1" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- filter="(factory.name=composite.test.3)" />
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.CheckService"
- filter="(factory.name=composite.test.2)" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.CheckService" />
- </comp:composite>
-
- <comp:composite name="composite.instantiator" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.BazService"
- filter="(factory.name=composite.test.3)" />
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.FooService" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.BazService" />
- <comp:provides action="export"
- specification="org.apache.felix.ipojo.test.composite.service.FooService" />
- </comp:composite>
-
- <!-- Test composition provides -->
-
- <comp:composite name="comp-0" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota" />
- </comp:composite>
-
- <comp:composite name="comp-1" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota">
- <delegation method="tataInt" policy="One" />
- <delegation method="toto1" policy="All" />
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-2" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata"
- aggregate="true" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto"
- aggregate="true" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota">
- <delegation method="tataInt" policy="One" />
- <delegation method="toto1" policy="All" />
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-3" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto"
- optional="true" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota">
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-4" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto"
- optional="true" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota">
- <delegation method="tataInt" policy="One" />
- <delegation method="toto1" policy="All" />
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-5" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata"
- aggregate="true" />
- <!-- <subservice action="import" specification="org.apache.felix.ipojo.test.comp:composite.service.Toto" aggregate ="true" optional="true"/> -->
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota">
- <delegation method="tataInt" policy="One" />
- <delegation method="toto1" policy="All" />
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-6" architecture="true">
- <subservice action="instantiate"
- specification="org.apache.felix.ipojo.test.composite.service.Tata"
- aggregate="true" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto"
- aggregate="true" optional="true" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Toto">
- <delegation method="toto1" policy="All" />
- </comp:provides>
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tata">
- <delegation method="tataInt" policy="One" />
- </comp:provides>
- </comp:composite>
-
- <comp:composite name="comp-7" architecture="true">
- <instance component="tata" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota" />
- </comp:composite>
-
- <comp:composite name="comp-8" architecture="true">
- <instance component="tata" />
- <instance component="totoglue" />
- <subservice action="import"
- specification="org.apache.felix.ipojo.test.composite.service.Toto" />
- <comp:provides action="implement"
- specification="org.apache.felix.ipojo.test.composite.service.Tota" />
- </comp:composite>
-</ipojo>
diff --git a/ipojo/tests/core/annotations/pom.xml b/ipojo/tests/core/annotations/pom.xml
deleted file mode 100644
index d1a0a71..0000000
--- a/ipojo/tests/core/annotations/pom.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Annotations Test Suite</name>
- <artifactId>tests.core.annotations</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>1.6.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>
- <version>${ipojo.eah.snapshot}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.eventadmin</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.annotations.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*, foo
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.annotations.AnnotationsTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/annotations/src/main/java/foo/Foo.java b/ipojo/tests/core/annotations/src/main/java/foo/Foo.java
deleted file mode 100644
index aa8d383..0000000
--- a/ipojo/tests/core/annotations/src/main/java/foo/Foo.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package foo;
-
-
-/**
- * Creates a simple annotation to create the processing of non-matching
- * annotations
- */
-public @interface Foo {
- String bar();
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/foo/RGB.java b/ipojo/tests/core/annotations/src/main/java/foo/RGB.java
deleted file mode 100644
index ec43bc7..0000000
--- a/ipojo/tests/core/annotations/src/main/java/foo/RGB.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package foo;
-
-/**
- * Checks the enum support in custom handler.
- */
-public enum RGB {
-
- RED, GREEN, BLUE
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java b/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
deleted file mode 100644
index 553ae17..0000000
--- a/ipojo/tests/core/annotations/src/main/java/foo/ipojo/IPOJOFoo.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package foo.ipojo;
-
-
-import foo.RGB;
-
-/**
- * Creates a simple annotation to create the processing of matching
- * annotations
- */
-public @interface IPOJOFoo {
- String bar();
-
- RGB rgb() default RGB.BLUE;
-
- RGB[] colors() default {};
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AggregateDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AggregateDependency.java
deleted file mode 100644
index 5aa2568..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AggregateDependency.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class AggregateDependency extends OSGiTestCase {
-
- private Element[] deps;
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.AggregateDependency");
- deps = meta.getElements("requires");
- }
-
-
- public void testCallbackBind() {
- Element dep = getDependencyById(deps, "Bar");
- String opt = dep.getAttribute("aggregate");
- assertEquals("Check aggregate", "true", opt);
- }
-
- public void testCallbackUnbind() {
- Element dep = getDependencyById(deps, "Baz");
- String opt = dep.getAttribute("aggregate");
- assertEquals("Check aggregate", "true", opt);
- }
-
- public void testBindOnly() {
- Element dep = getDependencyById(deps, "bindonly");
- String opt = dep.getAttribute("aggregate");
- assertEquals("Check aggregate", "true", opt);
- }
-
- public void testUnbindOnly() {
- Element dep = getDependencyById(deps, "unbindonly");
- String opt = dep.getAttribute("aggregate");
- assertEquals("Check aggregate", "true", opt);
- }
-
-
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
- private String getBind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("bind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
- private String getUnbind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("unbind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
deleted file mode 100644
index 3d7f922..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class AnnotationsTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Annotations Test Suite", bc);
- ots.addTestSuite(ServiceProdiving.class);
- ots.addTestSuite(LifecycleController.class);
- ots.addTestSuite(LifecycleCallbacks.class);
- ots.addTestSuite(Properties.class);
- ots.addTestSuite(Architecture.class);
- ots.addTestSuite(Factory.class);
- ots.addTestSuite(Dependency.class);
- ots.addTestSuite(OptionalDependency.class);
- ots.addTestSuite(AggregateDependency.class);
- ots.addTestSuite(PolicyDependency.class);
- ots.addTestSuite(FilteredDependency.class);
- ots.addTestSuite(RankedDependency.class);
-
- // External handler annotations
- ots.addTestSuite(TemporalDependencies.class);
- ots.addTestSuite(JMX.class);
- ots.addTestSuite(WhiteBoard.class);
- ots.addTestSuite(Extender.class);
- ots.addTestSuite(EventAdmin.class);
-
- ots.addTestSuite(CustomAnnotations.class);
-
- // Instantiate
- ots.addTestSuite(Instantiate.class);
-
- return ots;
- }
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Architecture.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Architecture.java
deleted file mode 100644
index 9996972..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Architecture.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Architecture extends OSGiTestCase {
-
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
-
- public void testArch() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Arch");
- String arch = meta.getAttribute("architecture");
- assertNotNull("Architecture exists ", arch);
- assertEquals("Architecture value", "true", arch);
- }
-
- public void testNoArch() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NoArch");
- String arch = meta.getAttribute("architecture");
- assertNotNull("Architecture exists ", arch);
- assertEquals("Architecture value", "false", arch);
- }
-
-
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
deleted file mode 100644
index 9e852cd..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/CustomAnnotations.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-/**
- * Checks the support of the custom annotation handlinig.
- */
-public class CustomAnnotations extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testThatCustomAnnotationAreCorrectlyAdded() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.CustomAnnotationWithEnum");
- Element[] ann = meta.getElements("IPOJOFoo", "foo.ipojo");
- assertNotNull("Annotation exists ", ann);
- }
-
- public void testThatCustomAnnotationAreSupportingEnums() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.CustomAnnotationWithEnum");
- Element[] ann = meta.getElements("IPOJOFoo", "foo.ipojo");
- assertNotNull("Annotation exists ", ann);
- Element element = ann[0];
- // Simple value
- assertEquals("RED", element.getAttribute("rgb"));
- // Array (FELIX-3508).
- assertEquals("{BLUE,RED}", element.getAttribute("colors"));
- }
-
-
-
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
deleted file mode 100644
index 2bd64dc..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Dependency extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testDependencyDeclaration() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Dependency");
- Element[] deps = meta.getElements("requires");
-
- // Check fs
- Element dep = getDependencyById(deps, "fs");
- String field = dep.getAttribute("field");
- String id = dep.getAttribute("id");
- String bind = getBind(dep);
- String unbind = getUnbind(dep);
- assertNotNull("Check fs field", field);
- assertEquals("Check fs field", "fs", field);
- assertNull("Check fs bind", bind);
- assertNull("Check fs unbind", unbind);
- assertNull("Check fs id", id);
-
- // Check bar
- dep = getDependencyById(deps, "Bar");
- field = dep.getAttribute("field");
- id = dep.getAttribute("id");
- bind = getBind(dep);
- unbind = getUnbind(dep);
- assertNull("Check bar field", field);
- assertEquals("Check bar bind", "bindBar", bind);
- assertEquals("Check bar unbind", "unbindBar", unbind);
- assertEquals("Check bar id", "Bar", id);
-
- // Check baz
- dep = getDependencyById(deps, "Baz");
- field = dep.getAttribute("field");
- id = dep.getAttribute("id");
- bind = getBind(dep);
- unbind = getUnbind(dep);
- assertNull("Check baz field", field);
- assertEquals("Check baz bind", "bindBaz", bind);
- assertEquals("Check baz unbind", "unbindBaz", unbind);
- assertEquals("Check baz id", "Baz", id);
-
- // Check fs2
- dep = getDependencyById(deps, "fs2");
- field = dep.getAttribute("field");
- id = dep.getAttribute("id");
- bind = getBind(dep);
- unbind = getUnbind(dep);
- assertNotNull("Check fs2 field", field);
- assertEquals("Check fs2 field", "fs2", field);
- assertEquals("Check fs2 bind", "bindFS2", bind);
- assertEquals("Check fs2 unbind", "unbindFS2", unbind);
-
- // Check fs2inv
- dep = getDependencyById(deps, "fs2inv");
- field = dep.getAttribute("field");
- id = dep.getAttribute("id");
- bind = getBind(dep);
- unbind = getUnbind(dep);
- assertNotNull("Check fs2inv field", field);
- assertEquals("Check fs2 field", "fs2inv", field);
- assertEquals("Check fs2 bind", "bindFS2Inv", bind);
- assertEquals("Check fs2 unbind", "unbindFS2Inv", unbind);
- assertEquals("Check fs2 id", "inv", id);
-
- // Check mod
- dep = getDependencyById(deps, "mod");
- id = dep.getAttribute("id");
- bind = getBind(dep);
- unbind = getUnbind(dep);
- String mod = getModified(dep);
- assertEquals("Check mod bind", "bindMod", bind);
- assertEquals("Check mod unbind", "unbindMod", unbind);
- assertEquals("Check mod modified", "modifiedMod", mod);
- assertEquals("Check mod id", "mod", id);
-
- // Check not proxied
- dep = getDependencyById(deps, "notproxied");
- assertEquals("Check not proxied", "false", dep.getAttribute("proxy"));
- }
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
- private String getBind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("bind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
- private String getUnbind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("unbind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
- private String getModified(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("modified")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java
deleted file mode 100644
index 0993fa0..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/EventAdmin.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class EventAdmin extends OSGiTestCase {
- String type = "org.apache.felix.ipojo.test.scenarios.component.event.PubSub";
- String deprecated = "org.apache.felix.ipojo.test.scenarios.component.event.PubSubDeprecated";
- String publishes = "org.apache.felix.ipojo.test.scenarios.component.event.PubSubWithPublishes";
-
- String namespace = "org.apache.felix.ipojo.handlers.event";
-
- Element component;
- Element componentDeprecated;
- Element componentWithPublishes;
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- component = helper.getMetadata(type);
- componentDeprecated = helper.getMetadata(deprecated);
- componentWithPublishes = helper.getMetadata(publishes);
- assertNotNull("Check component", component);
- assertNotNull("Check deprecated", componentDeprecated);
- assertNotNull("Check publishes", componentWithPublishes);
-
- }
-
- public void tearDown() {
- component = null;
- componentDeprecated = null;
- componentWithPublishes = null;
- }
-
- public void testP1() {
- //P1, synchronous
- Element elem = getElementByName("p1");
- checkPublisher(elem);
- assertNull("Check topics", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher1", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("dataKey"));
- }
-
- public void testP1WithPublishes() {
- //P1, synchronous
- Element elem = getPublishesByName("p1");
- checkPublishes(elem);
- assertNull("Check topics", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher1", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("dataKey"));
- }
-
- public void testP1Deprecated() {
- //P1, synchronous
- Element elem = getDeprecatedElementByName("p1");
- checkPublisher(elem);
- assertNull("Check topics", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher1", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("data_key"));
- }
-
- public void testP2() {
- //name="p2", synchronous=false, topics="foo,bar", data_key="data"
- Element elem = getElementByName("p2");
- checkPublisher(elem);
- assertEquals("Check topics (" + elem.getAttribute("topics")+")", "foo,bar", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "false", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher2", elem.getAttribute("field"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
- }
-
- public void testP2WithPublishes() {
- //name="p2", synchronous=false, topics="foo,bar", data_key="data"
- Element elem = getPublishesByName("p2");
- checkPublishes(elem);
- assertEquals("Check topics (" + elem.getAttribute("topics")+")", "foo,bar", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "false", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher2", elem.getAttribute("field"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
- }
-
- public void testP2Deprecated() {
- //name="p2", synchronous=false, topics="foo,bar", data_key="data"
- Element elem = getDeprecatedElementByName("p2");
- checkPublisher(elem);
- assertEquals("Check topics (" + elem.getAttribute("topics")+")", "foo,bar", elem.getAttribute("topics"));
- assertEquals("Check synchronous", "false", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher2", elem.getAttribute("field"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("data_key"));
- }
-
- public void testP3() {
- //name="p3", synchronous=true, topics="bar"
- Element elem = getElementByName("p3");
- checkPublisher(elem);
- assertEquals("Check topics", "bar" ,elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher3", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("dataKey"));
- }
-
- public void testWithPublishesP3() {
- //name="p3", synchronous=true, topics="bar"
- Element elem = getPublishesByName("p3");
- checkPublishes(elem);
- assertEquals("Check topics", "bar" ,elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher3", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("dataKey"));
- }
-
- public void testP3Deprecated() {
- //name="p3", synchronous=true, topics="bar"
- Element elem = getDeprecatedElementByName("p3");
- checkPublisher(elem);
- assertEquals("Check topics", "bar" ,elem.getAttribute("topics"));
- assertEquals("Check synchronous", "true", elem.getAttribute("synchronous"));
- assertEquals("Check field", "publisher3", elem.getAttribute("field"));
- assertNull("Check data_key", elem.getAttribute("data_key"));
- }
-
- public void testS1() {
- //name="s1", data_key="data"
- Element elem = getElementByName("s1");
- checkSubscriber(elem);
- assertNull("Check topics",elem.getAttribute("topics"));
- assertEquals("Check method", "receive1", elem.getAttribute("method"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
- assertNull("Check data_type", elem.getAttribute("dataType"));
- assertNull("Check filter", elem.getAttribute("filter"));
- }
-
- public void testS1Deprecated() {
- //name="s1", data_key="data"
- Element elem = getDeprecatedElementByName("s1");
- checkSubscriber(elem);
- assertNull("Check topics",elem.getAttribute("topics"));
- assertEquals("Check method", "receive1", elem.getAttribute("method"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("data_key"));
- assertNull("Check data_type", elem.getAttribute("data_type"));
- assertNull("Check filter", elem.getAttribute("filter"));
- }
-
- public void testS2() {
- //name="s2", topics="foo,bar", filter="(foo=true)"
- Element elem = getElementByName("s2");
- checkSubscriber(elem);
- assertEquals("Check topics", "foo,bar", elem.getAttribute("topics"));
- assertEquals("Check method", "receive2", elem.getAttribute("method"));
- assertNull("Check data_key" ,elem.getAttribute("dataKey"));
- assertNull("Check data_type", elem.getAttribute("dataType"));
- assertEquals("Check filter","(foo=true)" , elem.getAttribute("filter"));
- }
-
- public void testS2Deprecated() {
- //name="s2", topics="foo,bar", filter="(foo=true)"
- Element elem = getDeprecatedElementByName("s2");
- checkSubscriber(elem);
- assertEquals("Check topics", "foo,bar", elem.getAttribute("topics"));
- assertEquals("Check method", "receive2", elem.getAttribute("method"));
- assertNull("Check data_key" ,elem.getAttribute("data_key"));
- assertNull("Check data_type", elem.getAttribute("data_type"));
- assertEquals("Check filter","(foo=true)" , elem.getAttribute("filter"));
- }
-
- public void testS3() {
- //name="s3", topics="foo", data_key="data", data_type="java.lang.String"
- Element elem = getElementByName("s3");
- checkSubscriber(elem);
- assertEquals("Check topics", "foo", elem.getAttribute("topics"));
- assertEquals("Check method", "receive3", elem.getAttribute("method"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("dataKey"));
- assertEquals("Check data_type", "java.lang.String", elem.getAttribute("dataType"));
- assertNull("Check filter", elem.getAttribute("filter"));
- }
-
- public void testS3Deprecated() {
- //name="s3", topics="foo", data_key="data", data_type="java.lang.String"
- Element elem = getDeprecatedElementByName("s3");
- checkSubscriber(elem);
- assertEquals("Check topics", "foo", elem.getAttribute("topics"));
- assertEquals("Check method", "receive3", elem.getAttribute("method"));
- assertEquals("Check data_key", "data" ,elem.getAttribute("data_key"));
- assertEquals("Check data_type", "java.lang.String", elem.getAttribute("data_type"));
- assertNull("Check filter", elem.getAttribute("filter"));
- }
-
-
-
- public Element getElementByName(String name) {
- Element [] elems = component.getElements();
- for (int i = 0; i < elems.length; i++) {
- if (elems[i].containsAttribute("name") && elems[i].getAttribute("name").equals(name)) {
- return elems[i];
- }
- }
- return null;
- }
-
- public Element getPublishesByName(String name) {
- Element [] elems = componentWithPublishes.getElements();
- for (int i = 0; i < elems.length; i++) {
- if (elems[i].containsAttribute("name") && elems[i].getAttribute("name").equals(name)) {
- return elems[i];
- }
- }
- return null;
- }
-
- public Element getDeprecatedElementByName(String name) {
- Element [] elems = componentDeprecated.getElements();
- for (int i = 0; i < elems.length; i++) {
- if (elems[i].containsAttribute("name") && elems[i].getAttribute("name").equals(name)) {
- return elems[i];
- }
- }
- return null;
- }
-
- public void checkSubscriber(Element elem) {
- assertNotNull("Can't check subscriber : null element",elem);
- String ns = elem.getNameSpace();
- String nm = elem.getName();
- assertEquals("Elem is not a subscriber : bad namespace", namespace, ns);
- assertEquals("Elem is not a subscriber : bad name", "subscriber", nm);
-
- }
-
- public void checkPublisher(Element elem) {
- assertNotNull("Can't check publisher : null element",elem);
- String ns = elem.getNameSpace();
- String nm = elem.getName();
- assertEquals("Elem is not a publisher : bad namespace", namespace, ns);
- assertEquals("Elem is not a publisher : bad name", "publisher", nm);
- }
-
- public void checkPublishes(Element elem) {
- assertNotNull("Can't check publisher : null element",elem);
- String ns = elem.getNameSpace();
- String nm = elem.getName();
- assertEquals("Elem is not a publisher : bad namespace", namespace, ns);
- assertEquals("Elem is not a publisher : bad name", "publishes", nm);
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Extender.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Extender.java
deleted file mode 100644
index 9f8a418..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Extender.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Extender extends OSGiTestCase {
-
- String type = "org.apache.felix.ipojo.test.scenarios.component.extender.Extender";
- String namespace = "org.apache.felix.ipojo.extender";
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testMetadata() {
- Element meta = helper.getMetadata(type);
- assertNotNull("Check meta", meta);
- Element[] ext = meta.getElements("extender", namespace);
- assertEquals("Check size", 1, ext.length);
- String extension = ext[0].getAttribute("extension");
- String onArr = ext[0].getAttribute("onArrival");
- String onDep = ext[0].getAttribute("onDeparture");
-
- assertEquals("Check extension", "foo", extension);
- assertEquals("Check onArrival", "onArrival", onArr);
- assertEquals("Check onDeparture", "onDeparture", onDep);
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java
deleted file mode 100644
index 0d696d1..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Factory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Factory extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testArchDeprecated() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryDeprecated");
- String fact = meta.getAttribute("public");
- String name = meta.getAttribute("name");
- assertNotNull("Factory exists ", fact);
- assertEquals("Factory value", "true", fact);
- assertNotNull("Name exists ", name);
- assertEquals("Name value", "org.apache.felix.ipojo.test.scenarios.component.FactoryDeprecated", name);
- }
-
- public void testArch() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Factory");
- String fact = meta.getAttribute("public");
- String name = meta.getAttribute("name");
- assertNotNull("Factory exists ", fact);
- assertEquals("Factory value", "true", fact);
- assertNotNull("Name exists ", name);
- assertEquals("Name value", "factory", name);
- }
-
- public void testNoArch() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NoFactory");
- String fact = meta.getAttribute("public");
- String name = meta.getAttribute("name");
- assertNotNull("Factory exists ", fact);
- assertEquals("Factory value", "false", fact);
- assertNotNull("Name exists ", name);
- assertEquals("Name value", "nofactory", name);
- }
-
- public void testFactoryMethod() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryMethod");
- String method = meta.getAttribute("factory-method");
- assertNotNull("Method exists ", method);
- assertEquals("Method value", "create", method);
- }
-
- public void testFactoryMethodDeprecated() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryMethodDeprecated");
- String method = meta.getAttribute("factory-method");
- assertNotNull("Method exists ", method);
- assertEquals("Method value", "create", method);
- }
-
- public void testVersion() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ComponentTypeVersion");
- String version = meta.getAttribute("version");
- assertNotNull("Version exist", version);
- assertEquals("Version value", "1.0.0", version);
- }
-
- public void testNoVersion() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FactoryMethod");
- String version = meta.getAttribute("version");
- assertNull("No Version", version);
- }
-
-
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/FilteredDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/FilteredDependency.java
deleted file mode 100644
index 8db422c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/FilteredDependency.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class FilteredDependency extends OSGiTestCase {
-
- private Element[] deps ;
- private Element[] froms;
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FilteredDependency");
- deps = meta.getElements("requires");
-
- Element meta2 = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.FromDependency");
- froms = meta2.getElements("requires");
- }
-
- public void testField() {
- Element dep = getDependencyById(deps, "fs");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testCallbackBind() {
- Element dep = getDependencyById(deps, "Bar");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testCallbackUnbind() {
- Element dep = getDependencyById(deps, "Baz");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testBoth() {
- Element dep = getDependencyById(deps, "inv");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testBindOnly() {
- Element dep = getDependencyById(deps, "bindonly");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testUnbindOnly() {
- Element dep = getDependencyById(deps, "unbindonly");
- String opt = dep.getAttribute("filter");
- assertEquals("Check filter", "(foo=bar)", opt);
- }
-
- public void testFromField() {
- Element dep = getDependencyById(froms, "fs");
- String from = dep.getAttribute("from");
- assertEquals("Check from", "X", from);
- }
-
- public void testFromBind() {
- Element dep = getDependencyById(froms, "fs2");
- String from = dep.getAttribute("from");
- assertEquals("Check from", "X", from);
- }
-
- public void testFromUnbind() {
- Element dep = getDependencyById(froms, "inv");
- String from = dep.getAttribute("from");
- assertEquals("Check from", "X", from);
- }
-
- public void testNoFrom() {
- Element dep = getDependencyById(froms, "Bar");
- String from = dep.getAttribute("from");
- assertNull("Check from", from);
- }
-
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
deleted file mode 100644
index 67c2e8f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class Instantiate extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testInstantiateSimple() {
- Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple");
- assertNotNull(meta);
- assertEquals(1, meta.length);
- assertNull(meta[0].getAttribute("name"));
- assertEquals(0, meta[0].getElements().length);
- }
-
- public void testInstantiateWithName() {
- // Check instance tag
- Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateWithName");
- assertNotNull(meta);
- assertEquals(1, meta.length);
- assertNotNull(meta[0].getAttribute("name"));
- assertEquals("myInstantiatedInstance", meta[0].getAttribute("name"));
- assertEquals(0, meta[0].getElements().length);
- }
-
- public void testInstanceCreation() throws InvalidSyntaxException {
- String in = "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple-0";
- ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(),
- in);
- assertNotNull(ref);
- }
-
- public void testInstanceCreationWithName() {
- String in = "myInstantiatedInstance";
- ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(),
- in);
- assertNotNull(ref);
- }
-
- /**
- * Returns the instance metadatas of the component with the given name,
- * defined in the given bundle.
- *
- * @param bundle the bundle from which the component is defined.
- * @param component the name of the defined component.
- * @return the list of instance metadata of the component with the given name,
- * defined in the given bundle, or {@code null} if not found.
- */
- public static Element[] getInstanceMetadata(Bundle bundle, String component) {
-
- // Retrieves the component description from the bundle's manifest.
- String elem = (String) bundle.getHeaders().get("iPOJO-Components");
- if (elem == null) {
- throw new IllegalArgumentException(
- "Cannot find iPOJO-Components descriptor in the specified bundle ("
- + bundle.getSymbolicName()
- + "). Not an iPOJO bundle.");
- }
-
- // Parses the retrieved description and find the component with the
- // given name.
- List<Element> list = new ArrayList<Element>();
- try {
- Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
- Element[] childs = element.getElements("instance");
- for (int i = 0; i < childs.length; i++) {
- String name = childs[i].getAttribute("component");
- if (name != null && name.equalsIgnoreCase(component)) {
- list.add(childs[i]);
- }
- }
-
- if (list.isEmpty()) {
- // Component not found...
- return null;
- } else {
- return (Element[]) list.toArray(new Element[list.size()]);
- }
-
- } catch (ParseException e) {
- throw new IllegalStateException(
- "Cannot parse the components from specified bundle ("
- + bundle.getSymbolicName() + "): " + e.getMessage());
- }
- }
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
deleted file mode 100644
index 7da4390..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/JMX.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class JMX extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testDeprecated() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.jmx.JMXDeprecated");
- /*
- * org.apache.felix.ipojo.handlers.jmx:config domain="my-domain" usesmosgi="false"
- org.apache.felix.ipojo.handlers.jmx:property field="m_foo" name="prop" rights="w" notification="true"
- org.apache.felix.ipojo.handlers.jmx:method description="get the foo prop" method="getFoo"
- org.apache.felix.ipojo.handlers.jmx:method description="set the foo prop" method="setFoo"
- */
-
- Element[] ele = meta.getElements("config", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("ele not null", ele);
- assertEquals("Ele size", 1, ele.length);
- String domain = ele[0].getAttribute("domain");
- String mosgi = ele[0].getAttribute("usesmosgi");
- assertEquals("domain", "my-domain", domain);
- assertEquals("mosgi", "false", mosgi);
-
- Element[] props = ele[0].getElements("property", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("props not null", props);
- assertEquals("props size", 1, props.length);
-
- Element[] methods = ele[0].getElements("method", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("methods not null", methods);
- assertEquals("methods size", 2, methods.length);
- }
-
- public void test() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.jmx.JMXSimple");
- /*
- * org.apache.felix.ipojo.handlers.jmx:config domain="my-domain" usesmosgi="false"
- org.apache.felix.ipojo.handlers.jmx:property field="m_foo" name="prop" rights="w" notification="true"
- org.apache.felix.ipojo.handlers.jmx:method description="get the foo prop" method="getFoo"
- org.apache.felix.ipojo.handlers.jmx:method description="set the foo prop" method="setFoo"
- */
-
- Element[] ele = meta.getElements("config", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("ele not null", ele);
- assertEquals("Ele size", 1, ele.length);
- String domain = ele[0].getAttribute("domain");
- String mosgi = ele[0].getAttribute("usesmosgi");
- assertEquals("domain", "my-domain", domain);
- assertEquals("mosgi", "false", mosgi);
-
- Element[] props = ele[0].getElements("JMXProperty", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("props not null", props);
- assertEquals("props size", 1, props.length);
-
- Element[] methods = ele[0].getElements("JMXMethod", "org.apache.felix.ipojo.handlers.jmx");
- assertNotNull("methods not null", methods);
- assertEquals("methods size", 2, methods.length);
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleCallbacks.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleCallbacks.java
deleted file mode 100644
index 554de91..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleCallbacks.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class LifecycleCallbacks extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testCallbacks() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Lifecycle");
- Element[] cbs = meta.getElements("callback");
- assertNotNull("Callbacks exists ", cbs);
- assertEquals("Callbacks count ", 2, cbs.length);
-
- Element elem = getCallbackByMethodName(cbs, "start");
- assertEquals("Check start method", "start", elem.getAttribute("method"));
- assertEquals("Check start transition", "validate", elem.getAttribute("transition"));
-
- elem = getCallbackByMethodName(cbs, "stop");
- assertEquals("Check stop method", "stop", elem.getAttribute("method"));
- assertEquals("Check stop transition", "invalidate", elem.getAttribute("transition"));
- }
-
- public void testImmediate() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Immediate");
- assertNotNull("Immediate attribute", meta.getAttribute("immediate"));
- assertEquals("Immediate attribute value", "true", meta.getAttribute("immediate"));
- }
-
- public void testNoImmediate() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NoImmediate");
- assertNotNull("Immediate attribute", meta.getAttribute("immediate"));
- assertEquals("Immediate attribute value", "false", meta.getAttribute("immediate"));
- }
-
- private Element getCallbackByMethodName(Element[] cbs, String method) {
- for (int i = 0; i < cbs.length; i++) {
- String met = cbs[i].getAttribute("method");
- if (met != null && met.equalsIgnoreCase(method)) {
- return cbs[i];
- }
- }
- fail("Cannot found the callback with the method " + method);
- return null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleController.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleController.java
deleted file mode 100644
index 95a60ac..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/LifecycleController.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class LifecycleController extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testLFC() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Lifecycle");
- Element[] ctrls = meta.getElements("controller");
- assertNotNull("Controller exists ", ctrls);
- Element ctrl = ctrls[0];
- assertNotNull("Field", ctrl.getAttribute("field"));
- assertEquals("Field", "lfc", ctrl.getAttribute("field"));
- }
-
-
-
-}
-
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/OptionalDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/OptionalDependency.java
deleted file mode 100644
index 7e9b970..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/OptionalDependency.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.scenarios.component.ProvidesSimple;
-
-public class OptionalDependency extends OSGiTestCase {
-
- private Element[] deps ;
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.OptionalDependency");
- deps = meta.getElements("requires");
- }
-
- public void testField() {
- Element dep = getDependencyById(deps, "fs");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testFieldNoOptional() {
- Element dep = getDependencyById(deps, "fs2");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "false", opt);
- }
-
- public void testCallbackBind() {
- Element dep = getDependencyById(deps, "Bar");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testCallbackUnbind() {
- Element dep = getDependencyById(deps, "Baz");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testBoth() {
- Element dep = getDependencyById(deps, "inv");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testBindOnly() {
- Element dep = getDependencyById(deps, "bindonly");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testUnbindOnly() {
- Element dep = getDependencyById(deps, "unbindonly");
- String opt = dep.getAttribute("optional");
- assertEquals("Check optionality", "true", opt);
- }
-
- public void testNullable() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NullableDependency");
- Element[] deps = meta.getElements("requires");
- Element fs = getDependencyById(deps, "fs");
- String nullable = fs.getAttribute("nullable");
- assertNotNull("Check nullable", nullable);
- assertEquals("Check nullable value", "true", nullable);
- }
-
- public void testNoNullable() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NullableDependency");
- Element[] deps = meta.getElements("requires");
- Element fs = getDependencyById(deps, "fs2");
- String nullable = fs.getAttribute("nullable");
- assertNotNull("Check nullable", nullable);
- assertEquals("Check nullable value", "false", nullable);
- }
-
- public void testDefaultImplmentation() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.DefaultImplementationDependency");
- Element[] deps = meta.getElements("requires");
- Element fs = getDependencyById(deps, "fs");
- String di = fs.getAttribute("default-implementation");
- assertNotNull("Check DI", di);
- assertEquals("Check DI value", ProvidesSimple.class.getName(), di);
- }
-
-
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/PolicyDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/PolicyDependency.java
deleted file mode 100644
index 0850190..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/PolicyDependency.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class PolicyDependency extends OSGiTestCase {
-
- private Element[] deps ;
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PolicyDependency");
- deps = meta.getElements("requires");
- }
-
- public void testField() {
- Element dep = getDependencyById(deps, "fs");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
- public void testFieldDPpolicy() {
- Element dep = getDependencyById(deps, "fs2");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "dynamic-priority", opt);
- }
-
- public void testCallbackBind() {
- Element dep = getDependencyById(deps, "Bar");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
- public void testCallbackUnbind() {
- Element dep = getDependencyById(deps, "Baz");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
- public void testBoth() {
- Element dep = getDependencyById(deps, "inv");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
- public void testBindOnly() {
- Element dep = getDependencyById(deps, "bindonly");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
- public void testUnbindOnly() {
- Element dep = getDependencyById(deps, "unbindonly");
- String opt = dep.getAttribute("policy");
- assertEquals("Check policy", "static", opt);
- }
-
-
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Properties.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Properties.java
deleted file mode 100644
index 6bd310d..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Properties.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class Properties extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testProperties() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Properties");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- Element[] props = prov.getElements("property");
- assertEquals("Number of properties", props.length, 5);
- //Foo
- Element foo = getPropertyByName(props, "foo");
- assertEquals("Check foo field", "m_foo", foo.getAttribute("field"));
- assertEquals("Check foo name", "foo", foo.getAttribute("name"));
- //Bar
- Element bar = getPropertyByName(props, "bar");
- assertEquals("Check bar field", "bar", bar.getAttribute("field"));
- assertEquals("Check bar value", "4", bar.getAttribute("value"));
- //Boo
- Element boo = getPropertyByName(props, "boo");
- assertEquals("Check boo field", "boo", boo.getAttribute("field"));
- assertEquals("Check boo method", "setboo", boo.getAttribute("method"));
- //Baa
- Element baa = getPropertyByName(props, "baa");
- assertEquals("Check baa field", "m_baa", baa.getAttribute("field"));
- assertEquals("Check baa name", "baa", baa.getAttribute("name"));
- assertEquals("Check baa method", "setbaa", baa.getAttribute("method"));
- assertEquals("Check mandatory", "true", baa.getAttribute("mandatory"));
-
-
- //Bar
- Element baz = getPropertyByName(props, "baz");
- assertEquals("Check baz method", "setbaz", baz.getAttribute("method"));
- assertEquals("Check baz name", "baz", baz.getAttribute("name"));
- }
-
- public void testAbsentPropagation() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Properties");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("propagation");
- assertNull("Propagation", att);
- }
-
- public void testPropagation() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Propagation");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("propagation");
- assertNotNull("Propagation", att);
- assertEquals("Propagation value", "true", att);
- }
-
- public void testNoPropagation() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.NoPropagation");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("propagation");
- assertNotNull("Propagation", att);
- assertEquals("Propagation value", "false", att);
- }
-
- public void testPID() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ManagedServicePID");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNotNull("PID", att);
- assertEquals("PID Value", "MyPID", att);
- }
-
- public void testAbsentPID() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.Properties");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNull("PID", att);
- }
-
- public void testPropagationAndPID() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PropagationandPID");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNotNull("PID", att);
- assertEquals("PID Value", "MyPID", att);
- att = prov.getAttribute("propagation");
- assertNotNull("Propagation", att);
- assertEquals("Propagation value", "true", att);
- }
-
- public void testPIDAndPropagation() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PIDandPropagation");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNotNull("PID", att);
- assertEquals("PID Value", "MyPID", att);
- att = prov.getAttribute("propagation");
- assertNotNull("Propagation", att);
- assertEquals("Propagation value", "true", att);
- }
-
- public void testUpdatedAndPID() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.UpdatedWithManagedService");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNotNull("PID", att);
- assertEquals("PID Value", "MyPID", att);
-
- att = prov.getAttribute("updated");
- assertNotNull("att", att);
- assertEquals("Updated Value", "after", att);
- }
-
- public void testUpdatedAndProperties() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.UpdatedWithProperties");
- Element[] provs = meta.getElements("properties");
- assertNotNull("Properties exists ", provs);
- Element prov = provs[0];
- String att = prov.getAttribute("pid");
- assertNull("PID", att);
-
- att = prov.getAttribute("updated");
- assertNotNull("att", att);
- assertEquals("Updated Value", "after", att);
- }
-
- private Element getPropertyByName(Element[] props, String name) {
- for (int i = 0; i < props.length; i++) {
- String na = props[i].getAttribute("name");
- String field = props[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return props[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return props[i];
- }
- }
- fail("Property " + name + " not found");
- return null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/RankedDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/RankedDependency.java
deleted file mode 100644
index 6ddb3fa..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/RankedDependency.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.scenarios.component.MyComparator;
-
-public class RankedDependency extends OSGiTestCase {
-
- private Element[] deps ;
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.RankedDependency");
- deps = meta.getElements("requires");
- }
-
- public void testField() {
- Element dep = getDependencyById(deps, "fs");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
- public void testCallbackBind() {
- Element dep = getDependencyById(deps, "Bar");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
- public void testCallbackUnbind() {
- Element dep = getDependencyById(deps, "Baz");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
- public void testBoth() {
- Element dep = getDependencyById(deps, "inv");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
- public void testBindOnly() {
- Element dep = getDependencyById(deps, "bindonly");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
- public void testUnbindOnly() {
- Element dep = getDependencyById(deps, "unbindonly");
- String opt = dep.getAttribute("comparator");
- assertEquals("Check comparator", MyComparator.class.getName(), opt);
- }
-
-
-
- private Element getDependencyById(Element[] deps, String name) {
- for (int i = 0; i < deps.length; i++) {
- String na = deps[i].getAttribute("id");
- String field = deps[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return deps[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return deps[i];
- }
- }
- fail("Dependency " + name + " not found");
- return null;
- }
-
- private String getBind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("bind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
- private String getUnbind(Element dep) {
- Element[] elem = dep.getElements("callback");
- for (int i = 0; elem != null && i < elem.length; i++) {
- if (elem[i].getAttribute("type").equalsIgnoreCase("unbind")) {
- return elem[i].getAttribute("method");
- }
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java
deleted file mode 100644
index edcd7ef..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import java.util.List;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ParseUtils;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-public class ServiceProdiving extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testProvidesSimple() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesSimple");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- }
-
- public void testProvidesDouble() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesDouble");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- }
-
- public void testProvidesTriple() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesTriple");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- Element prov = provs[0];
- String itfs = prov.getAttribute("specifications");
- List list = ParseUtils.parseArraysAsList(itfs);
- assertTrue("Provides CS ", list.contains(CheckService.class.getName()));
- }
-
- public void testProvidesQuatro() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesQuatro");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- Element prov = provs[0];
- String itfs = prov.getAttribute("specifications");
- List list = ParseUtils.parseArraysAsList(itfs);
- assertTrue("Provides CS ", list.contains(CheckService.class.getName()));
- assertTrue("Provides Foo ", list.contains(FooService.class.getName()));
- }
-
- public void testProperties() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesProperties");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- Element prov = provs[0];
- Element[] props = prov.getElements("property");
- assertEquals("Number of properties", props.length, 5);
- //Foo
- Element foo = getPropertyByName(props, "foo");
- assertEquals("Check foo field", "m_foo", foo.getAttribute("field"));
- assertEquals("Check foo name", "foo", foo.getAttribute("name"));
- //Bar
- Element bar = getPropertyByName(props, "bar");
- assertEquals("Check bar field", "bar", bar.getAttribute("field"));
- assertEquals("Check bar value", "4", bar.getAttribute("value"));
- assertEquals("Check mandatory value", "true", bar.getAttribute("mandatory"));
- //Boo
- Element boo = getPropertyByName(props, "boo");
- assertEquals("Check boo field", "boo", boo.getAttribute("field"));
- //Baa
- Element baa = getPropertyByName(props, "baa");
- assertEquals("Check baa field", "m_baa", baa.getAttribute("field"));
- assertEquals("Check baa name", "baa", baa.getAttribute("name"));
-
- //Bar
- Element baz = getPropertyByName(props, "baz");
- assertEquals("Check baz field", "m_baz", baz.getAttribute("field"));
- assertEquals("Check baz name", "baz", baz.getAttribute("name"));
- }
-
- public void testStaticProperties() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.ProvidesStaticProperties");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- Element prov = provs[0];
- Element[] props = prov.getElements("property");
- assertEquals("Number of properties", props.length, 9);
- //Prop1
- Element foo = getPropertyByName(props, "prop1");
- assertNull(foo.getAttribute("field"));
- assertEquals("prop1", foo.getAttribute("value"));
-
- //Prop2
- Element prop2 = getPropertyByName(props, "prop2");
- assertNull(prop2.getAttribute("field"));
- assertNull(prop2.getAttribute("value"));
-
- // Props
- Element prop = getPropertyByName(props, "props");
- assertNull(prop.getAttribute("field"));
- assertEquals("{prop1, prop2}", prop.getAttribute("value"));
-
- // Mandatory
- Element mandatory = getPropertyByName(props, "mandatory1");
- assertNull(mandatory.getAttribute("field"));
- assertNull(mandatory.getAttribute("value"));
- assertEquals("true", mandatory.getAttribute("mandatory"));
-
- //Bar
- Element bar = getPropertyByName(props, "bar");
- assertEquals("Check bar field", "bar", bar.getAttribute("field"));
- assertEquals("Check bar value", "4", bar.getAttribute("value"));
- assertEquals("Check mandatory value", "true", bar.getAttribute("mandatory"));
- //Boo
- Element boo = getPropertyByName(props, "boo");
- assertEquals("Check boo field", "boo", boo.getAttribute("field"));
- //Baa
- Element baa = getPropertyByName(props, "baa");
- assertEquals("Check baa field", "m_baa", baa.getAttribute("field"));
- assertEquals("Check baa name", "baa", baa.getAttribute("name"));
-
- //Bar
- Element baz = getPropertyByName(props, "baz");
- assertEquals("Check baz field", "m_baz", baz.getAttribute("field"));
- assertEquals("Check baz name", "baz", baz.getAttribute("name"));
- }
-
- public void testServiceController() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PSServiceController");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- System.out.println(provs[0].toString());
- assertNotNull(provs[0].getElements("controller"));
- assertEquals(1, provs[0].getElements("controller").length);
- assertEquals("false", provs[0].getElements("controller")[0].getAttribute("value"));
- }
-
- public void testServiceControllerWithSpecification() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PSServiceControllerSpec");
- Element[] provs = meta.getElements("provides");
- assertNotNull("Provides exists ", provs);
- System.out.println(provs[0].toString());
- assertNotNull(provs[0].getElements("controller"));
- assertEquals(2, provs[0].getElements("controller").length);
- assertEquals("false", provs[0].getElements("controller")[0].getAttribute("value"));
- assertEquals(FooService.class.getName(), provs[0].getElements("controller")[0].getAttribute("specification"));
- }
-
- private Element getPropertyByName(Element[] props, String name) {
- for (int i = 0; i < props.length; i++) {
- String na = props[i].getAttribute("name");
- String field = props[i].getAttribute("field");
- if (na != null && na.equalsIgnoreCase(name)) {
- return props[i];
- }
- if (field != null && field.equalsIgnoreCase(name)) {
- return props[i];
- }
- }
- fail("Property " + name + " not found");
- return null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/TemporalDependencies.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/TemporalDependencies.java
deleted file mode 100644
index 353c910..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/TemporalDependencies.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class TemporalDependencies extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testSimple() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalSimple");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
- String to = provs[0].getAttribute("timeout");
- assertNull("No timeout", to);
- String oto = provs[0].getAttribute("onTimeout");
- assertNull("No onTimeout", oto);
- }
-
- public void testTemporal() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.Temporal");
- Element[] provs = meta.getElements("temporal", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
- String to = provs[0].getAttribute("timeout");
- assertNull("No timeout", to);
- String oto = provs[0].getAttribute("onTimeout");
- assertNull("No onTimeout", oto);
- }
-
- public void testDI() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithDI");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String oto = provs[0].getAttribute("onTimeout");
- assertEquals("onTimeout is the DI", "org.apache.felix.ipojo.test.scenarios.component.ProvidesSimple", oto);
-
- }
-
- public void testEmptyArray() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithEmptyArray");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String oto = provs[0].getAttribute("onTimeout");
- assertEquals("onTimeout is empty-array", "empty-array", oto);
-
- }
-
- public void testNull() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithNull");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String oto = provs[0].getAttribute("onTimeout");
- assertEquals("onTimeout is null", "null", oto);
-
- }
-
- public void testNullable() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithNullable");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String oto = provs[0].getAttribute("onTimeout");
- assertEquals("onTimeout is nullable", "nullable", oto);
-
- }
-
- public void testFilter() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithFilter");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String filter = provs[0].getAttribute("filter");
- assertEquals("Filter", "(vendor=clement)", filter);
-
- }
-
- public void testTimeout() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalWithTimeout");
- Element[] provs = meta.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- String field = provs[0].getAttribute("field");
- assertNotNull("Field not null", field);
- assertEquals("Field is fs", "fs", field);
-
- String to = provs[0].getAttribute("timeout");
- assertEquals("Check timeout", "100", to);
-
- }
-
- public void testSimpleCollection() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalCollection");
- Element dep = getElementPerField(meta, "fs1");
- String spec = dep.getAttribute("specification");
- assertNotNull("Specification not null", spec);
- assertEquals("Check specification", "org.apache.felix.ipojo.test.scenarios.annotations.service.FooService", spec);
- }
-
- public void testCollectionWithTimeout() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalCollection");
- Element dep = getElementPerField(meta, "fs2");
- String spec = dep.getAttribute("specification");
- assertNotNull("Specification not null", spec);
- assertEquals("Check specification", "org.apache.felix.ipojo.test.scenarios.annotations.service.FooService", spec);
- String to = dep.getAttribute("timeout");
- assertEquals("Check timeout", "300", to);
- }
-
- public void testCollectionWithPolicy() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalCollection");
- Element dep = getElementPerField(meta, "fs3");
- String spec = dep.getAttribute("specification");
- assertNotNull("Specification not null", spec);
- assertEquals("Check specification", "org.apache.felix.ipojo.test.scenarios.annotations.service.FooService", spec);
- String to = dep.getAttribute("ontimeout");
- assertEquals("Check policy", "empty", to);
- }
-
- public void testCollectionWithProxy() {
- Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.temporal.TemporalCollection");
- Element dep = getElementPerField(meta, "fs4");
- String spec = dep.getAttribute("specification");
- assertNotNull("Specification not null", spec);
- assertEquals("Check specification", "org.apache.felix.ipojo.test.scenarios.annotations.service.FooService", spec);
- String proxy = dep.getAttribute("proxy");
- assertEquals("Check proxy", "true", proxy);
- }
-
- private Element getElementPerField(Element elem, String field) {
- Element[] provs = elem.getElements("requires", "org.apache.felix.ipojo.handler.temporal");
- assertNotNull("Temporal exists ", provs);
- for (int i = 0; i < provs.length; i++) {
- if (provs[i].getAttribute("field").equals(field)) {
- return provs[i];
- }
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/WhiteBoard.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/WhiteBoard.java
deleted file mode 100644
index 418364f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/WhiteBoard.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.annotations;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class WhiteBoard extends OSGiTestCase {
-
- String typeWI = "org.apache.felix.ipojo.test.scenarios.component.whiteboard.WhiteBoardWIModification";
- String typeWO = "org.apache.felix.ipojo.test.scenarios.component.whiteboard.WhiteBoardWOModification";
- String typeWhiteboards = "org.apache.felix.ipojo.test.scenarios.component.whiteboard.WhiteBoards";
- String namespace = "org.apache.felix.ipojo.whiteboard";
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void testMetadataWithOnModification() {
- Element meta = helper.getMetadata(typeWI);
- assertNotNull("Check meta", meta);
- Element[] ext = meta.getElements("wbp", namespace);
- assertEquals("Check size", 1, ext.length);
- String filter = ext[0].getAttribute("filter");
- String onArr = ext[0].getAttribute("onArrival");
- String onDep = ext[0].getAttribute("onDeparture");
- String onMod = ext[0].getAttribute("onModification");
-
-
- assertEquals("Check filter", "(foo=true)", filter);
- assertEquals("Check onArrival", "onArrival", onArr);
- assertEquals("Check onDeparture", "onDeparture", onDep);
- assertEquals("Check onModification", "onModification", onMod);
-
- }
-
- public void testMetadataWithoutOnModification() {
- Element meta = helper.getMetadata(typeWO);
- assertNotNull("Check meta", meta);
- Element[] ext = meta.getElements("wbp", namespace);
- assertEquals("Check size", 1, ext.length);
- String filter = ext[0].getAttribute("filter");
- String onArr = ext[0].getAttribute("onArrival");
- String onDep = ext[0].getAttribute("onDeparture");
- String onMod = ext[0].getAttribute("onModification");
-
-
- assertEquals("Check filter", "(foo=true)", filter);
- assertEquals("Check onArrival", "onArrival", onArr);
- assertEquals("Check onDeparture", "onDeparture", onDep);
- assertNull("Check onModification", onMod);
-
- }
-
- public void testWhiteboards() {
- Element meta = helper.getMetadata(typeWhiteboards);
- assertNotNull("Check meta", meta);
- Element[] ext = meta.getElements("whiteboards", namespace);
- assertEquals("Check size", 1, ext.length);
-
- // Two sub-element
- Element[] wbps = ext[0].getElements("wbp", namespace);
- assertEquals("Check size", 2, wbps.length);
-
- String filter = wbps[0].getAttribute("filter");
- String onArr = wbps[0].getAttribute("onArrival");
- String onDep = wbps[0].getAttribute("onDeparture");
- String onMod = wbps[0].getAttribute("onModification");
-
- assertEquals("Check filter", "(foo=true)", filter);
- assertEquals("Check onArrival", "onArrival", onArr);
- assertEquals("Check onDeparture", "onDeparture", onDep);
- assertNull("Check onModification", onMod);
-
- filter = wbps[1].getAttribute("filter");
- onArr = wbps[1].getAttribute("onArrival");
- onDep = wbps[1].getAttribute("onDeparture");
- onMod = wbps[1].getAttribute("onModification");
-
- assertEquals("Check filter", "(foo=true)", filter);
- assertEquals("Check onArrival", "onArrival", onArr);
- assertEquals("Check onDeparture", "onDeparture", onDep);
- assertEquals("Check onModification", "onModification", onMod);
- }
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/BarService.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/BarService.java
deleted file mode 100644
index ac52244..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/CheckService.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/CheckService.java
deleted file mode 100644
index 7eb16a7..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ChildInterface.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ChildInterface.java
deleted file mode 100644
index f35b4f9..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ChildInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-public interface ChildInterface extends ParentInterface1, ParentInterface2 {
-
- public void processChild();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/FooService.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/FooService.java
deleted file mode 100644
index c542725..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface1.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface1.java
deleted file mode 100644
index 05680f9..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-public interface ParentInterface1 extends ParentParentInterface {
-
- public void processParent1();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface2.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface2.java
deleted file mode 100644
index 7553397..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentInterface2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-public interface ParentInterface2 {
-
- public void processParent2();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentParentInterface.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentParentInterface.java
deleted file mode 100644
index 85eff5e..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/ParentParentInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.annotations.service;
-
-public interface ParentParentInterface {
-
- public void processParentParent();
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/AggregateDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/AggregateDependency.java
deleted file mode 100644
index cfc5ddd..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/AggregateDependency.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Unbind;
-
-@Component
-public class AggregateDependency {
-
- @Unbind(aggregate=true)
- public void unbindBar() { }
- @Bind
- public void bindBar() { }
-
- @Unbind
- public void unbindBaz() { }
- @Bind(aggregate=true)
- public void bindBaz() { }
-
- @Unbind(aggregate=true, id="unbindonly")
- public void unbind() { }
-
- @Bind(aggregate=true, id="bindonly")
- public void bind() { }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Arch.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Arch.java
deleted file mode 100644
index 0ac0e1a..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Arch.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(architecture=true)
-public class Arch {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComponentTypeVersion.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComponentTypeVersion.java
deleted file mode 100644
index a1b08ed..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComponentTypeVersion.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-
-@Component(version="1.0.0")
-public class ComponentTypeVersion {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
deleted file mode 100644
index 5a10c2e..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CustomAnnotationWithEnum.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import foo.RGB;
-import foo.ipojo.IPOJOFoo;
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component
-@IPOJOFoo(bar="bar", rgb = RGB.RED, colors = {RGB.BLUE, RGB.RED})
-public class CustomAnnotationWithEnum {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DefaultImplementationDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DefaultImplementationDependency.java
deleted file mode 100644
index b43540a..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DefaultImplementationDependency.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class DefaultImplementationDependency {
-
- @Requires(defaultimplementation=ProvidesSimple.class, optional=true)
- public FooService fs;
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
deleted file mode 100644
index 17d8d19..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Modified;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class Dependency {
-
- @Requires
- public FooService fs;
-
- @Unbind
- public void unbindBar() {
-
- }
-
- @Bind
- public void bindBar() {
-
- }
-
- @Unbind
- public void unbindBaz() {
-
- }
-
- @Bind
- public void bindBaz() {
-
- }
-
-
- @Requires
- public FooService fs2;
-
- @Bind(id="fs2")
- public void bindFS2() {
-
- }
-
- @Unbind(id="fs2")
- public void unbindFS2() {
-
- }
-
- @Requires(id="inv")
- public FooService fs2inv;
-
- @Bind(id="inv")
- public void bindFS2Inv() {
-
- }
-
- @Unbind(id="inv")
- public void unbindFS2Inv() {
-
- }
-
- @Bind(id="mod")
- public void bindMod() {
-
- }
-
- @Unbind(id="mod")
- public void unbindMod() {
-
- }
-
- @Modified(id="mod")
- public void modifiedMod() {
-
- }
-
-
- @Requires(proxy=false, id="notproxied")
- FooService myFoo;
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java
deleted file mode 100644
index 801f798..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Factory.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(name="factory", publicFactory=true)
-public class Factory {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java
deleted file mode 100644
index bb3e17a..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryDeprecated.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(public_factory=true)
-public class FactoryDeprecated {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java
deleted file mode 100644
index baa47a5..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethod.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(factoryMethod="create")
-public class FactoryMethod {
-
- public static FactoryMethod create() {
- return new FactoryMethod();
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java
deleted file mode 100644
index 3f763dd..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FactoryMethodDeprecated.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(factory_method="create")
-public class FactoryMethodDeprecated {
-
- public static FactoryMethodDeprecated create() {
- return new FactoryMethodDeprecated();
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FilteredDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FilteredDependency.java
deleted file mode 100644
index d064ec3..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FilteredDependency.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class FilteredDependency {
-
- @Requires(filter="(foo=bar)")
- public FooService fs;
-
- @Unbind(filter="(foo=bar)")
- public void unbindBar() { }
- @Bind
- public void bindBar() { }
-
- @Unbind
- public void unbindBaz() { }
- @Bind(filter="(foo=bar)")
- public void bindBaz() { }
-
- @Requires(id="inv")
- public FooService fs2inv;
- @Bind(id="inv", filter="(foo=bar)")
- public void bindFS2Inv() { }
- @Unbind(id="inv")
- public void unbindFS2Inv() { }
-
- @Unbind(filter="(foo=bar)", id="unbindonly")
- public void unbind() { }
-
- @Bind(filter="(foo=bar)", id="bindonly")
- public void bind() { }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FromDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FromDependency.java
deleted file mode 100644
index 673830b..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FromDependency.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class FromDependency {
-
- @Requires(from="X")
- public FooService fs;
-
- @Unbind
- public void unbindBar() {
-
- }
-
- @Bind
- public void bindBar() {
-
- }
-
- @Unbind(from="both")
- public void unbindBaz() {
-
- }
-
- @Bind(from="both")
- public void bindBaz() {
-
- }
-
-
- @Requires
- public FooService fs2;
-
- @Bind(id="fs2", from="X")
- public void bindFS2() {
-
- }
-
- @Unbind(id="fs2")
- public void unbindFS2() {
-
- }
-
- @Requires(id="inv")
- public FooService fs2inv;
-
- @Bind(id="inv")
- public void bindFS2Inv() {
-
- }
-
- @Unbind(id="inv", from="X")
- public void unbindFS2Inv() {
-
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Immediate.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Immediate.java
deleted file mode 100644
index db0f161..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Immediate.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(immediate=true)
-public class Immediate {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateSimple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateSimple.java
deleted file mode 100644
index 57e4b12..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateSimple.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Instantiate;
-
-
-@Instantiate
-@Component
-public class InstantiateSimple {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateWithName.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateWithName.java
deleted file mode 100644
index 76e3e39..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InstantiateWithName.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Instantiate;
-
-
-@Instantiate(name="myInstantiatedInstance")
-@Component
-public class InstantiateWithName {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Lifecycle.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Lifecycle.java
deleted file mode 100644
index dc28af1..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Lifecycle.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Controller;
-import org.apache.felix.ipojo.annotations.Invalidate;
-import org.apache.felix.ipojo.annotations.Validate;
-
-@Component
-public class Lifecycle {
- @Controller
- boolean lfc;
-
- @Validate
- public void start() {
-
- }
-
- @Invalidate
- public void stop() {
-
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ManagedServicePID.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ManagedServicePID.java
deleted file mode 100644
index 66bf0c1..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ManagedServicePID.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(managedservice="MyPID")
-public class ManagedServicePID implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MyComparator.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MyComparator.java
deleted file mode 100644
index 085390f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MyComparator.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Comparator;
-
-public class MyComparator implements Comparator {
-
- public int compare(Object o1, Object o2) {
- return 0;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoAnnotation.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoAnnotation.java
deleted file mode 100644
index 8e24846..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoAnnotation.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class NoAnnotation {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoArch.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoArch.java
deleted file mode 100644
index 4b5f1a3..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoArch.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(architecture=false)
-public class NoArch {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoFactory.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoFactory.java
deleted file mode 100644
index d8e15b2..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoFactory.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(name="nofactory", public_factory=false)
-public class NoFactory {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoImmediate.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoImmediate.java
deleted file mode 100644
index 54d1021..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoImmediate.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component(immediate=false)
-public class NoImmediate {
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoPropagation.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoPropagation.java
deleted file mode 100644
index f1003a0..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoPropagation.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(propagation=false)
-public class NoPropagation implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableDependency.java
deleted file mode 100644
index 7a5b5de..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableDependency.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class NullableDependency {
-
- @Requires(nullable=true)
- public FooService fs;
-
- @Requires(nullable=false)
- public FooService fs2;
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyFoo.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyFoo.java
deleted file mode 100644
index 9431df9..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyFoo.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import foo.Foo;
-
-@Foo(bar="bar")
-public class OnlyFoo {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyiPOJOFoo.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyiPOJOFoo.java
deleted file mode 100644
index 6230887..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OnlyiPOJOFoo.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import foo.ipojo.IPOJOFoo;
-
-@IPOJOFoo(bar="bar")
-public class OnlyiPOJOFoo {
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OptionalDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OptionalDependency.java
deleted file mode 100644
index 3ce2b08..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/OptionalDependency.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class OptionalDependency {
-
- @Requires(optional=true)
- public FooService fs;
-
- @Requires(optional=false)
- public FooService fs2;
-
- @Unbind(optional=true)
- public void unbindBar() { }
- @Bind
- public void bindBar() { }
-
- @Unbind
- public void unbindBaz() { }
- @Bind(optional=true)
- public void bindBaz() { }
-
- @Requires(id="inv")
- public FooService fs2inv;
- @Bind(id="inv", optional=true)
- public void bindFS2Inv() { }
- @Unbind(id="inv")
- public void unbindFS2Inv() { }
-
- @Unbind(optional=true, id="unbindonly")
- public void unbind() { }
-
- @Bind(optional=true, id="bindonly")
- public void bind() { }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PIDandPropagation.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PIDandPropagation.java
deleted file mode 100644
index 168439f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PIDandPropagation.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(managedservice="MyPID", propagation=true)
-public class PIDandPropagation implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java
deleted file mode 100644
index 13b905c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.annotations.ServiceController;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {FooService.class, BarService.class})
-public class PSServiceController implements FooService, BarService {
-
- @ServiceController(value=false)
- public boolean controller;
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceControllerSpec.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceControllerSpec.java
deleted file mode 100644
index 80e6540..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceControllerSpec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.annotations.ServiceController;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {FooService.class, BarService.class})
-public class PSServiceControllerSpec implements FooService, BarService {
-
- @ServiceController(value=false, specification=FooService.class)
- public boolean controller1;
-
- @ServiceController(value=true)
- public boolean controller2;
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PolicyDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PolicyDependency.java
deleted file mode 100644
index d4c1213..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PolicyDependency.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class PolicyDependency {
-
- @Requires(policy="static")
- public FooService fs;
-
- @Requires(policy="dynamic-priority")
- public FooService fs2;
-
- @Unbind(policy="static")
- public void unbindBar() { }
- @Bind
- public void bindBar() { }
-
- @Unbind
- public void unbindBaz() { }
- @Bind(policy="static")
- public void bindBaz() { }
-
- @Requires(id="inv")
- public FooService fs2inv;
- @Bind(id="inv", policy="static")
- public void bindFS2Inv() { }
- @Unbind(id="inv")
- public void unbindFS2Inv() { }
-
- @Unbind(policy="static", id="unbindonly")
- public void unbind() { }
-
- @Bind(policy="static", id="bindonly")
- public void bind() { }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Propagation.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Propagation.java
deleted file mode 100644
index 51caaf6..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Propagation.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(propagation=true)
-public class Propagation implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropagationandPID.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropagationandPID.java
deleted file mode 100644
index 7c6287f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropagationandPID.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(managedservice="MyPID", propagation=true)
-public class PropagationandPID implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Properties.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Properties.java
deleted file mode 100644
index 0737138..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Properties.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class Properties implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5", mandatory=true)
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesDouble.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesDouble.java
deleted file mode 100644
index 56c06e9..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesDouble.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides
-public class ProvidesDouble implements FooService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesProperties.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesProperties.java
deleted file mode 100644
index a1de405..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesProperties.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.annotations.ServiceProperty;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {FooService.class, BarService.class})
-public class ProvidesProperties implements FooService, BarService {
-
- @ServiceProperty(name = "foo")
- public int m_foo = 0;
-
- @ServiceProperty(value = "4", mandatory=true)
- public int bar;
-
- @ServiceProperty(name="baz")
- int m_baz;
-
- @ServiceProperty
- public int boo;
-
- @ServiceProperty(name="baa", value="5")
- public int m_baa;
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesQuatro.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesQuatro.java
deleted file mode 100644
index 49d2f02..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesQuatro.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {FooService.class, CheckService.class})
-public class ProvidesQuatro implements FooService, BarService, CheckService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
- public boolean check() {
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesSimple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesSimple.java
deleted file mode 100644
index 56e877c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesSimple.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {FooService.class, BarService.class})
-public class ProvidesSimple implements FooService, BarService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesStaticProperties.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesStaticProperties.java
deleted file mode 100644
index c9e02f2..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesStaticProperties.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.annotations.ServiceProperty;
-import org.apache.felix.ipojo.annotations.StaticServiceProperty;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(
- specifications= {FooService.class, BarService.class},
- properties= {
- @StaticServiceProperty(name="prop1", value="prop1", type="java.lang.String"),
- @StaticServiceProperty(name="prop2", type="java.lang.String"),
- @StaticServiceProperty(name="props", value="{prop1, prop2}", type="string[]"),
- @StaticServiceProperty(name="mandatory1", mandatory=true, type="string")
- })
-public class ProvidesStaticProperties implements FooService, BarService {
-
- @ServiceProperty(name = "foo")
- public int m_foo = 0;
-
- @ServiceProperty(value = "4", mandatory=true)
- public int bar;
-
- @ServiceProperty(name="baz")
- int m_baz;
-
- @ServiceProperty
- public int boo;
-
- @ServiceProperty(name="baa", value="5")
- public int m_baa;
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesTriple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesTriple.java
deleted file mode 100644
index c6fbe89..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ProvidesTriple.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-@Provides(specifications= {CheckService.class})
-public class ProvidesTriple implements FooService, BarService, CheckService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public Properties getProps() {
- return null;
- }
-
- public boolean check() {
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedDependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedDependency.java
deleted file mode 100644
index 5d84262..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedDependency.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.annotations.Bind;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Unbind;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class RankedDependency {
-
- @Requires(comparator = MyComparator.class)
- public FooService fs;
-
- @Unbind(comparator = MyComparator.class)
- public void unbindBar() {
- }
-
- @Bind
- public void bindBar() {
- }
-
- @Unbind
- public void unbindBaz() {
- }
-
- @Bind(comparator = MyComparator.class)
- public void bindBaz() {
- }
-
- @Requires(id = "inv")
- public FooService fs2inv;
-
- @Bind(id = "inv", comparator = MyComparator.class)
- public void bindFS2Inv() {
- }
-
- @Unbind(id = "inv")
- public void unbindFS2Inv() {
- }
-
- @Unbind(comparator = MyComparator.class, id = "unbindonly")
- public void unbind() {
- }
-
- @Bind(comparator = MyComparator.class, id = "bindonly")
- public void bind() {
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithManagedService.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithManagedService.java
deleted file mode 100644
index 108f772..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithManagedService.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.annotations.Updated;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component(managedservice="MyPID")
-public class UpdatedWithManagedService implements FooService, BarService {
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5")
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
- @Updated
- public void after(Dictionary conf) {
- // ...
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithProperties.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithProperties.java
deleted file mode 100644
index 7d56c44..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/UpdatedWithProperties.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Property;
-import org.apache.felix.ipojo.annotations.Updated;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-
-@Component
-public class UpdatedWithProperties implements FooService, BarService {
-
- @Updated
- public void after(Dictionary dict) {
- // ...
- }
-
- @Property(name="foo")
- public int m_foo = 0;
-
- @Property(value = "4")
- public int bar;
-
- @Property
- public void setboo(int boo) {
-
- }
-
- @Property
- public void setbaz(int baz) {
-
- }
-
- @Property
- public int boo;
-
- @Property(name="baa")
- public int m_baa;
-
- @Property(value="5", mandatory=true)
- public void setbaa(int baa) {
-
- }
-
- public boolean foo() {
- return false;
- }
-
- public java.util.Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean bar() {
- return false;
- }
-
- public java.util.Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/error/AbstractClass.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/error/AbstractClass.java
deleted file mode 100644
index 4cc792c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/error/AbstractClass.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.error;
-
-import org.apache.felix.ipojo.annotations.Requires;
-
-public abstract class AbstractClass {
-
- @Requires
- private Runnable run;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSub.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSub.java
deleted file mode 100644
index ac75616..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSub.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.event;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.event.Subscriber;
-import org.osgi.service.event.Event;
-
-
-@Component
-public class PubSub {
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p1", synchronous=true)
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1;
-
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p2", synchronous=false, topics="foo,bar", dataKey="data")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2;
-
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p3", synchronous=true, topics="bar")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3;
-
- @Subscriber(name="s1", dataKey="data")
- public void receive1(Object foo) {
- // Nothing
- }
-
- @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)")
- public void receive2(Event foo) {
- // Nothing
- }
-
-
- @Subscriber(name="s3", topics="foo", dataKey="data", dataType="java.lang.String")
- public void receive3(String foo) {
- // Nothing
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubDeprecated.java
deleted file mode 100644
index 618f6ff..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubDeprecated.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.event;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.event.Subscriber;
-import org.osgi.service.event.Event;
-
-
-@Component
-public class PubSubDeprecated {
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p1", synchronous=true)
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1;
-
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p2", synchronous=false, topics="foo,bar", data_key="data")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2;
-
- @org.apache.felix.ipojo.handlers.event.Publisher(name="p3", synchronous=true, topics="bar")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3;
-
- @Subscriber(name="s1", data_key="data")
- public void receive1(Object foo) {
- // Nothing
- }
-
- @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)")
- public void receive2(Event foo) {
- // Nothing
- }
-
-
- @Subscriber(name="s3", topics="foo", data_key="data", data_type="java.lang.String")
- public void receive3(String foo) {
- // Nothing
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java
deleted file mode 100644
index a40eb7e..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/event/PubSubWithPublishes.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.event;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.event.Publishes;
-import org.apache.felix.ipojo.handlers.event.Subscriber;
-import org.osgi.service.event.Event;
-
-
-@Component
-public class PubSubWithPublishes {
- @Publishes(name="p1", synchronous=true)
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher1;
-
- @Publishes(name="p2", synchronous=false, topics="foo,bar", dataKey="data")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher2;
-
- @Publishes(name="p3", synchronous=true, topics="bar")
- org.apache.felix.ipojo.handlers.event.publisher.Publisher publisher3;
-
- @Subscriber(name="s1", dataKey="data")
- public void receive1(Object foo) {
- // Nothing
- }
-
- @Subscriber(name="s2", topics="foo,bar", filter="(foo=true)")
- public void receive2(Event foo) {
- // Nothing
- }
-
-
- @Subscriber(name="s3", topics="foo", dataKey="data", dataType="java.lang.String")
- public void receive3(String foo) {
- // Nothing
- }
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/extender/Extender.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/extender/Extender.java
deleted file mode 100644
index 230388a..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/extender/Extender.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.extender;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.osgi.framework.Bundle;
-
-
-@Component
-@org.apache.felix.ipojo.extender.Extender(extension="foo", onArrival="onArrival", onDeparture="onDeparture")
-public class Extender {
-
- public void onArrival(Bundle bundle, String foo) {
- // nothing
- }
-
- public void onDeparture(Bundle bundle) {
- // nothing
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
deleted file mode 100644
index ab374b0..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXDeprecated.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.jmx;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.jmx.Config;
-import org.apache.felix.ipojo.handlers.jmx.Method;
-import org.apache.felix.ipojo.handlers.jmx.Property;
-
-@Component
-@Config(domain="my-domain", usesMOSGi=false)
-public class JMXDeprecated {
-
- @Property(name="prop", notification=true, rights="w")
- String m_foo;
-
- @Method(description="set the foo prop")
- public void setFoo(String mes) {
- System.out.println("Set foo to " + mes);
- m_foo = mes;
- }
-
- @Method(description="get the foo prop")
- public String getFoo() {
- return m_foo;
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
deleted file mode 100644
index 675dc40..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.jmx;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.jmx.Config;
-import org.apache.felix.ipojo.handlers.jmx.JMXMethod;
-import org.apache.felix.ipojo.handlers.jmx.JMXProperty;
-
-@Component
-@Config(domain="my-domain", usesMOSGi=false)
-public class JMXSimple {
-
- @JMXProperty(name="prop", notification=true, rights="w")
- String m_foo;
-
- @JMXMethod(description="set the foo prop")
- public void setFoo(String mes) {
- System.out.println("Set foo to " + mes);
- m_foo = mes;
- }
-
- @JMXMethod(description="get the foo prop")
- public String getFoo() {
- return m_foo;
- }
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/Temporal.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/Temporal.java
deleted file mode 100644
index c2b9d5c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/Temporal.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class Temporal {
-
- @org.apache.felix.ipojo.handler.temporal.Temporal
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalCollection.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalCollection.java
deleted file mode 100644
index 3a1143c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalCollection.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import java.util.Collection;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-
-@Component
-public class TemporalCollection {
-
- @Requires(specification="org.apache.felix.ipojo.test.scenarios.annotations.service.FooService")
- private Collection fs1;
-
- @Requires(specification="org.apache.felix.ipojo.test.scenarios.annotations.service.FooService", timeout=300)
- private Collection fs2;
-
- @Requires(onTimeout="empty", specification="org.apache.felix.ipojo.test.scenarios.annotations.service.FooService")
- private Collection fs3;
-
- @Requires(proxy=true, specification="org.apache.felix.ipojo.test.scenarios.annotations.service.FooService")
- private Collection fs4;
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalSimple.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalSimple.java
deleted file mode 100644
index a235c0b..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalSimple.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalSimple {
-
- @Requires
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithDI.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithDI.java
deleted file mode 100644
index e4c44a9..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithDI.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithDI {
-
- @Requires(onTimeout="org.apache.felix.ipojo.test.scenarios.component.ProvidesSimple")
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithEmptyArray.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithEmptyArray.java
deleted file mode 100644
index 695b69c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithEmptyArray.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithEmptyArray {
-
- @Requires(onTimeout="empty-array")
- private FooService fs[];
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithFilter.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithFilter.java
deleted file mode 100644
index f73bb7c..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithFilter.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithFilter {
-
- @Requires(filter="(vendor=clement)")
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNull.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNull.java
deleted file mode 100644
index 2baf722..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNull.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithNull {
-
- @Requires(onTimeout="null")
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNullable.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNullable.java
deleted file mode 100644
index eb4a595..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithNullable.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithNullable {
-
- @Requires(onTimeout="nullable")
- private FooService fs;
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithTimeout.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithTimeout.java
deleted file mode 100644
index 06d71b4..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/temporal/TemporalWithTimeout.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.temporal;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handler.temporal.Requires;
-import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
-
-@Component
-public class TemporalWithTimeout {
-
- @Requires(timeout=100)
- private FooService fs;
-
-
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWIModification.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWIModification.java
deleted file mode 100644
index 840d899..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWIModification.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.whiteboard;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.osgi.framework.ServiceReference;
-
-@Component
-@org.apache.felix.ipojo.whiteboard.Wbp(filter="(foo=true)",
- onArrival="onArrival",
- onDeparture="onDeparture",
- onModification="onModification")
-public class WhiteBoardWIModification {
-
- public void onArrival(ServiceReference ref) {
- // nothing
- }
-
- public void onDeparture(ServiceReference ref) {
- // nothing
- }
-
- public void onModification(ServiceReference ref) {
- // nothing
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWOModification.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWOModification.java
deleted file mode 100644
index 1424db1..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoardWOModification.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.whiteboard;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.osgi.framework.ServiceReference;
-
-@Component
-@org.apache.felix.ipojo.whiteboard.Wbp(filter="(foo=true)", onArrival="onArrival", onDeparture="onDeparture")
-public class WhiteBoardWOModification {
-
- public void onArrival(ServiceReference ref) {
- // nothing
- }
-
- public void onDeparture(ServiceReference ref) {
- // nothing
- }
-
-}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoards.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoards.java
deleted file mode 100644
index 540837f..0000000
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/whiteboard/WhiteBoards.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.whiteboard;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.whiteboard.Whiteboards;
-import org.apache.felix.ipojo.whiteboard.Wbp;
-import org.osgi.framework.ServiceReference;
-
-@Component
-@Whiteboards(whiteboards={
- @Wbp(filter="(foo=true)", onArrival="onArrival", onDeparture="onDeparture"),
- @Wbp(filter="(foo=true)", onArrival="onArrival", onDeparture="onDeparture", onModification="onModification")
- })
-public class WhiteBoards {
-
- public void onArrival(ServiceReference ref) {
- // nothing
- }
-
- public void onDeparture(ServiceReference ref) {
- // nothing
- }
-
- public void onModification(ServiceReference ref) {
- // nothing
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/pom.xml b/ipojo/tests/core/bad-configurations/pom.xml
deleted file mode 100644
index 0f0e9a4..0000000
--- a/ipojo/tests/core/bad-configurations/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Bad Configurations Test Suite</name>
- <artifactId>tests.core.bad.configurations</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.bad.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.bad.BadTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
deleted file mode 100644
index 58cd15d..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-
-public class BadFactories extends OSGiTestCase {
-
- private Element getElementFactoryWithNoClassName() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("name", "noclassname"));
- return elem;
- }
-
- private Element getElementHandlerFactoryWithNoClassName() {
- Element elem = new Element("handler", "");
- elem.addAttribute(new Attribute("name", "noclassname"));
- return elem;
- }
-
- private Element getElementHandlerFactoryWithNoName() {
- Element elem = new Element("handler", "");
- elem.addAttribute(new Attribute("className", "noclassname"));
- return elem;
- }
-
- public void testBadFactory() {
- try {
- new ComponentFactory(getContext(), getElementFactoryWithNoClassName());
- fail("A factory with no class name must be rejected");
- } catch (ConfigurationException e) {
- // OK.
- }
- }
-
- public void testBadHandlerFactory1() {
- try {
- new HandlerManagerFactory(getContext(), getElementHandlerFactoryWithNoClassName());
- fail("An handler factory with no class name must be rejected");
- } catch (ConfigurationException e) {
- // OK.
- }
- }
-
- public void testBadHandlerFactory2() {
- try {
- new HandlerManagerFactory(getContext(), getElementHandlerFactoryWithNoName());
- fail("An handler factory with no name must be rejected");
- } catch (ConfigurationException e) {
- // OK.
- }
- }
-
- public void testCreationOnBadConstructor() {
- Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadConstructor");
- ComponentInstance ci;
- try {
- // Change in Felix-966, now throws a runtime exception
- ci = factory.createComponentInstance(null);
- //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());
- ci.dispose();
- fail("Exception expected");
- } catch (Throwable e) {
- //fail("Exception unexpected : " + e.getMessage());
- // OK
- }
- }
-
- public void testCreationOnBadFactory() {
- Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadFactory");
- ComponentInstance ci;
- try {
- // Change in Felix-966, now throw a runtime exception
- ci = factory.createComponentInstance(null);
- //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());
- ci.dispose();
- fail("Exception expected");
- } catch (Throwable e) {
- //fail("Exception unexpected : " + e.getMessage());
- //OK
- }
- }
-
- public void testCreationOnBadFactory2() {
- Factory factory = Utils.getFactoryByName(getContext(), "BAD-BadFactory2");
- ComponentInstance ci;
- try {
- // Change in Felix-966, now throw a runtime exception
- ci = factory.createComponentInstance(null);
- //assertEquals("Check ci create error", ComponentInstance.STOPPED, ci.getState());
- ci.dispose();
- fail("Exception expected");
- } catch (Throwable e) {
- //fail("Exception unexpected : " + e.getMessage());
- //Ok
- }
- }
-
- public void testNoManipulationMetadata() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", "org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"));
- try {
- ComponentFactory fact = new ComponentFactory(getContext(), elem);
- fact.stop();
- fail("A factory with no manipulation metadata must be rejected");
- } catch (ConfigurationException e) {
- // OK.
- }
- }
-
-
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCCallback.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCCallback.java
deleted file mode 100644
index 2749e30..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCCallback.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-
-public class BadLFCCallback extends OSGiTestCase {
-
- private String clazz = "org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService";
- private String type = "BAD-CallbackCheckService";
- private Element manipulation;
- private Properties props;
-
- public void setUp() {
- manipulation = getManipulationForComponent();
- props = new Properties();
- props.put("instance.name","BAD");
- }
-
-
- private Element getNothing() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getNoTransition() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- callback.addAttribute(new Attribute("method", "start"));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getNoMethod() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- callback.addAttribute(new Attribute("transition", "validate"));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadMethod() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- callback.addAttribute(new Attribute("transition", "validate"));
- callback.addAttribute(new Attribute("method", "start_")); // Missing method.
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadMethod2() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- callback.addAttribute(new Attribute("transition", "invalidate"));
- callback.addAttribute(new Attribute("method", "stop_")); // Missing method.
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadTransition() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("callback", "");
- callback.addAttribute(new Attribute("method", "start"));
- callback.addAttribute(new Attribute("transition", "validate_"));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getManipulationForComponent() {
- String header = (String) getContext().getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getManipulationForComponent(elem, type);
- assertNotNull("Check manipulation metadata not null for " + type, manip);
- return manip;
- }
-
- private Element getManipulationForComponent(Element metadata, String comp_name) {
- Element[] comps = metadata.getElements("component");
- for(int i = 0; i < comps.length; i++) {
- if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- }
- return null;
- }
-
- public void testNothing() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNothing());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A lifecycle callback with a missing method and transition must be rejected " + cf);
- } catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testNoTransition() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNoTransition());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A lifecycle callback with a missing transition must be rejected " + cf);
- } catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testNoMethod() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNoMethod());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A lifecycle callback with a missing method must be rejected " + cf);
- }catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadMethod() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadMethod());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- if (ci.isStarted()) {
- fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);
- }
- ci.dispose();
- cf.stop();
- } catch (ConfigurationException e) {
- //The check does not happen in the configure method.
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadMethod2() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadMethod2());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.stop();
- if (ci.isStarted()) {
- fail("A lifecycle callback with a bad method must be rejected (instance stills valid)" + cf);
- }
- ci.dispose();
- cf.stop();
- } catch (ConfigurationException e) {
- //The check does not happen in the configure method.
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadTransition() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadTransition());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A lifecycle callback with a bad transition must be rejected " + cf);
- } catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java
deleted file mode 100644
index 3089aa3..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadLFCController.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-
-public class BadLFCController extends OSGiTestCase {
-
- private String clazz = "org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest";
-
- private Element getNoFieldController() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element controller = new Element("controller", "");
- elem.addElement(controller);
- return elem;
- }
-
- private Element getBadFieldController() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element controller = new Element("controller", "");
- controller.addAttribute(new Attribute("field", "controller")); // Missing field
- elem.addElement(controller);
- elem.addElement(getManipulationForComponent("BAD-lcTest"));
- return elem;
- }
-
- private Element getManipulationForComponent(String comp_name) {
- String header = (String) getContext().getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getManipulationForComponent(elem, comp_name);
- assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
- return manip;
- }
-
- private Element getManipulationForComponent(Element metadata, String comp_name) {
- Element[] comps = metadata.getElements("component");
- for(int i = 0; i < comps.length; i++) {
- if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- }
- return null;
- }
-
- public void testNoField() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNoFieldController());
- cf.start();
- cf.stop();
- fail("A lifecycle controller with a missing field must be rejected " + cf);
- } catch (Exception e) {
- // OK
- }
- }
-
- public void testBadField() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadFieldController());
- cf.start();
- cf.stop();
- fail("A lifecycle controller with a bad field must be rejected " + cf);
- } catch (Exception e) {
- // OK
- }
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java
deleted file mode 100644
index 63bcc87..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadServiceDependencies.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.apache.felix.ipojo.test.scenarios.bad.service.BarService;
-
-public class BadServiceDependencies extends OSGiTestCase {
-
- private String clazz = "org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider";
- private String type = "BAD-BothCheckServiceProvider";
- private Element manipulation;
- private Properties props;
-
- public void setUp() {
- manipulation = getManipulationForComponent();
- props = new Properties();
- props.put("instance.name","BAD");
- }
-
-
- private Element getNothing() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getNoField() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("filter", "(foo=bar)"));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadField() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("field", "BAD_FIELD")); // missing field.
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadFilter() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("field", "fs"));
- callback.addAttribute(new Attribute("filter", "(foo=bar)&(bar=foo)")); // Incorrect filter
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadFrom() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("field", "fs"));
- callback.addAttribute(new Attribute("from", "ba(d&_")); // Incorrect from
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadType() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("field", "fs"));
- callback.addAttribute(new Attribute("interface", BarService.class.getName()));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
- private Element getBadAggregate() {
- Element elem = new Element("component", "");
- elem.addAttribute(new Attribute("classname", clazz));
-
- Element callback = new Element("requires", "");
- callback.addAttribute(new Attribute("field", "fs"));
- callback.addAttribute(new Attribute("aggregate", "true"));
- elem.addElement(callback);
- elem.addElement(manipulation);
- return elem;
- }
-
-
- private Element getManipulationForComponent() {
- String header = (String) getContext().getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parse(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getManipulationForComponent(elem, type);
- assertNotNull("Check manipulation metadata not null for " + type, manip);
- return manip;
- }
-
- private Element getManipulationForComponent(Element metadata, String comp_name) {
- Element[] comps = metadata.getElements("component");
- for(int i = 0; i < comps.length; i++) {
- if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- }
- return null;
- }
-
- public void testNothing() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNothing());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with neither field and method must be rejected " + cf);
- } catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testNoField() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getNoField());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with neither field and method must be rejected " + cf);
- } catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadField() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadField());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with a bad field must be rejected " + cf);
- }catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadFilter() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadFilter());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with a bad filter must be rejected " + cf);
- }catch (ConfigurationException e) {
- //OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadFrom() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadFrom());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with a bad from must be rejected " + cf);
- }catch (ConfigurationException e) {
- //OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
-
- public void testBadType() {
- try {
- ComponentFactory cf = new ComponentFactory(getContext(), getBadType());
- cf.start();
- ComponentInstance ci = cf.createComponentInstance(props);
- ci.dispose();
- cf.stop();
- fail("A service requirement with a bad type must be rejected " + cf);
- }catch (ConfigurationException e) {
- // OK
- } catch (UnacceptableConfiguration e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- } catch (MissingHandlerException e) {
- fail("Unexpected exception when creating an instance : " + e.getMessage());
- }
- }
- }
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java
deleted file mode 100644
index 71d7db0..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class BadTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Bad configuration test suite", bc);
- ots.addTestSuite(BadFactories.class);
- ots.addTestSuite(BadLFCController.class);
- ots.addTestSuite(BadLFCCallback.class);
- ots.addTestSuite(BadServiceDependencies.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java
deleted file mode 100644
index e3d8b8b..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java
deleted file mode 100644
index f9e7e2d..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java
deleted file mode 100644
index cdebe3f..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.bad.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/BadConstructors.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/BadConstructors.java
deleted file mode 100644
index 74c6159..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/BadConstructors.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class BadConstructors {
-
- public BadConstructors() {
- throw new Error("BAD");
- }
-
- public BadConstructors(int i) {
- // DO NOTHING
- }
-
- public static BadConstructors createBad() {
- throw new RuntimeException("BAD");
- }
-
- public static BadConstructors createBad2(int o) {
- return new BadConstructors(o);
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java
deleted file mode 100644
index 86b9679..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.bad.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
-
-public class CallbackCheckService extends ParentClass implements CheckService {
-
- int i = 0;
-
- FooService fs;
-
- public static CallbackCheckService singleton;
-
- public static int count = 0;
-
- private static CallbackCheckService singleton() {
- if (singleton == null) {
- count++;
- singleton = new CallbackCheckService();
- }
- return singleton;
- }
-
- public static CallbackCheckService several() {
- count++;
- return new CallbackCheckService();
- }
-
- private void start() {
- i++;
- }
-
- protected void stop() {
- i++;
- }
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties p = new Properties();
- p.put("int", new Integer(i));
- p.put("count", new Integer(count));
- return p;
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
deleted file mode 100644
index 05d9f31..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index 71b5e77..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.bad.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.bad.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
deleted file mode 100644
index 8cef49f..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.bad.service.CheckService;
-
-public class LifecycleControllerTest implements CheckService {
-
- private boolean m_state = true;
- private String m_conf;
-
- public void setConf(String newConf) {
- if (newConf.equals("foo")) {
- m_state = true;
- } else {
- m_state = false;
- }
- }
-
- public boolean check() {
- return m_state;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("conf", m_conf);
- props.put("state", new Boolean(m_state));
- return props;
- }
-}
-
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
deleted file mode 100644
index f7fb580..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass {
-
- public void parentStart() {
-
- }
-
- public void parentStop() {
-
- }
-
- protected String[] strings;
-
- protected String string;
-
- protected int upStrings;
-
- protected int upString;
-
- public void updateStrings(String[] bb) {
- strings = bb;
- upStrings++;
- }
-
- public void updateString(String bb) {
- string = bb;
- upString++;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 5d33264..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-//import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/bad-configurations/src/main/resources/metadata.xml b/ipojo/tests/core/bad-configurations/src/main/resources/metadata.xml
deleted file mode 100644
index 9dca0d9..0000000
--- a/ipojo/tests/core/bad-configurations/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<ipojo>
- <!-- No XSD as this file violates the format -->
- <component
- className="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- name="BAD-CallbackCheckService" architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
- name="BAD-lcTest">
- <provides />
- <controller field="m_state" />
- <properties>
- <property name="conf" field="m_conf" method="setConf" />
- </properties>
- </component>
-
- <component
- className="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="BAD-BothCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Bad constructors -->
- <component
- className="org.apache.felix.ipojo.test.scenarios.component.BadConstructors"
- name="BAD-BadConstructor"
- immediate="true"
- />
-
- <component
- className="org.apache.felix.ipojo.test.scenarios.component.BadConstructors"
- factory-method="createBad"
- name="BAD-BadFactory"
- immediate="true"
- />
-
- <component
- className="org.apache.felix.ipojo.test.scenarios.component.BadConstructors"
- factory-method="createBad2"
- name="BAD-BadFactory2"
- immediate="true"
- />
-</ipojo>
diff --git a/ipojo/tests/core/configadmin/pom.xml b/ipojo/tests/core/configadmin/pom.xml
deleted file mode 100644
index c484331..0000000
--- a/ipojo/tests/core/configadmin/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Configuration Admin Management Test Suite</name>
- <artifactId>tests.core.configadmin</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.configadmin.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.configadmin.ConfigurationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableFooProvider.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableFooProvider.java
deleted file mode 100644
index 693ff1b..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableFooProvider.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configadmin.service.FooService;
-
-public class ConfigurableFooProvider implements FooService {
-
- private String message; // Configurable property
- private int invokeCount = 0;
-
- public void setMessage(String message) {
- System.err.println("=== Set message to " + message);
- this.message = message;
- invokeCount++;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties props = new Properties();
- if (message == null) {
- props.put("message", "NULL");
- } else {
- props.put("message", message);
- }
- props.put("count", new Integer(invokeCount));
- return props;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return invokeCount;
- }
-
- public int getInt() {
- return invokeCount;
- }
-
- public long getLong() {
- return invokeCount;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationMonitor.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationMonitor.java
deleted file mode 100644
index 403e61a..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationMonitor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import junit.framework.Assert;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
-
-public class ConfigurationMonitor implements ConfigurationListener {
-
- private String waitForEvent;
- private boolean detected;
- private ServiceRegistration reg;
-
- public synchronized void configurationEvent(ConfigurationEvent arg0) {
- System.out.println(arg0.getPid() + " reconfiguration received");
- if (waitForEvent != null) {
- if (arg0.getPid().equals(waitForEvent)) {
- detected = true;
- }
- }
- }
-
- public ConfigurationMonitor(BundleContext bc) {
- reg = bc.registerService(ConfigurationListener.class.getName(), this, null);
- }
-
- public void stop() {
- reg.unregister();
- reg = null;
- }
-
- public void waitForEvent(String pid, String mes) {
- waitForEvent = pid;
- detected = false;
- long begin = System.currentTimeMillis();
- long duration = 0;
- while( ! detected) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // Interrupted
- }
- long end = System.currentTimeMillis();
- duration = end - begin;
- if (duration > 10000) {
- Assert.fail(mes + " -> Timeout when waiting for a reconfiguration of " + pid);
- }
- }
- System.out.println("Reconfiguration detected of " + pid);
- waitForEvent = null;
- detected = false;
- }
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationTestSuite.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationTestSuite.java
deleted file mode 100644
index 5e01b33..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ConfigurationTestSuite.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ConfigurationTestSuite {
-
- public static long UPDATE_WAIT_TIME = 2000;
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Configuration Admin Test Suite", bc);
- ots.addTestSuite(ManagedServiceFactoryTestForServices.class);
- ots.addTestSuite(ManagedServiceFactoryTestForImmediate.class);
- ots.addTestSuite(ManagedServiceTestForImmediate.class);
- ots.addTestSuite(ManagedServiceTestForService.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForImmediate.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForImmediate.java
deleted file mode 100644
index 01f9590..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForImmediate.java
+++ /dev/null
@@ -1,378 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configadmin.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ManagedServiceFactoryTestForImmediate extends OSGiTestCase {
-
- private ComponentFactory factory;
- private ConfigurationAdmin admin;
-
- public void setUp() {
- factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "CA-ImmConfigurableProvider");
- admin = (ConfigurationAdmin) Utils.getServiceObject(getContext(), ConfigurationAdmin.class.getName(), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ImmConfigurableProvider)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void tearDown() {
- try {
- Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ImmConfigurableProvider)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- admin = null;
-
-
- }
-
- public void testCreationAndReconfiguration() {
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ImmConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 2, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testCreationAndReconfiguration2() {
- //The reconfiguration happens before the service invocation
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ImmConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
- System.out.println("PID : " + pid);
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object -2", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- //Invoke
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 2, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testDelayedCreationAndReconfiguration() {
- factory.stop();
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ImmConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- assertNull("check no instance", Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")"));
-
- factory.start();
-
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- //assertEquals("Assert count", 2, count);
- // This test was removed as the result can be 3.
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testDelayedCreationAndReconfiguration2() {
- factory.stop();
- //The reconfiguration happens before the service invocation
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ImmConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- assertNull("check no instance", Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")"));
-
- factory.start();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check object -1", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- //Invoke
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 2, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForServices.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForServices.java
deleted file mode 100644
index 3429f96..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceFactoryTestForServices.java
+++ /dev/null
@@ -1,382 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configadmin.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ManagedServiceFactoryTestForServices extends OSGiTestCase {
-
- private ComponentFactory factory;
- private ConfigurationAdmin admin;
-
- public void setUp() {
- factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "CA-ConfigurableProvider");
- admin = (ConfigurationAdmin) Utils.getServiceObject(getContext(), ConfigurationAdmin.class.getName(), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ConfigurableProvider)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void tearDown() {
- try {
- Configuration[] configurations = admin.listConfigurations("(service.factoryPid=CA-ConfigurableProvider)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- admin = null;
-
-
- }
-
- public void testCreationAndReconfiguration() {
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
- System.out.println("PID : " + pid);
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- Utils.waitForService(getContext(), FooService.class.getName(), "(instance.name="+pid+")");
-
- ServiceReference refx = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNotNull("Check refx", refx);
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNotNull("Check fs", fs);
-
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
-
- Dictionary p2 = configuration.getProperties();
- p2.put("message", "message2");
- try {
- System.err.println("The configuration will be updated with message2");
-
- configuration.update(p2);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- System.err.println("The configuration should be updated with message2");
-
- fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 2, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testCreationAndReconfiguration2() {
- //The reconfiguration happens before the service invocation
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object -2", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- //Invoke
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testDelayedCreationAndReconfiguration() {
- factory.stop();
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- assertNull("check no instance", Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")"));
-
- factory.start();
-
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- Utils.waitForService(getContext(), FooService.class.getName(), "(instance.name="+pid+")");
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
-
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- System.out.println("===");
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- System.out.println("===");
-
- fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 2, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
- public void testDelayedCreationAndReconfiguration2() {
- factory.stop();
- //The reconfiguration happens before the service invocation
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("CA-ConfigurableProvider", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- props.put("message", "message");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
- System.out.println("PID : " + pid);
-
- assertNull("check no instance", Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")"));
-
- factory.start();
-
-
- // The instance should be created, wait for the architecture service
- Utils.waitForService(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
- Architecture architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- props.put("message", "message2");
- try {
- configuration.update(props);
- // Update the configuration ...
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- //architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Check no object -2", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- //Invoke
- FooService fs = (FooService) Utils.getServiceObject(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- // architecture = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- assertEquals("Assert Message", "message2", mes);
- assertEquals("Assert count", 1, count);
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);
-
- try {
- configuration.delete();
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReference(getContext(), FooService.class.getName(), "(instance.name=" + pid + ")");
- assertNull("Check unavailability", ref);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForImmediate.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForImmediate.java
deleted file mode 100644
index 67e944f..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForImmediate.java
+++ /dev/null
@@ -1,365 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configadmin.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ManagedServiceTestForImmediate extends OSGiTestCase {
-
- private String factNameImm = "CA-ImmConfigurableProvider";
- private String msp = "foo";
-
- private ComponentFactory factImm;
-
- private ConfigurationAdmin admin;
-
- ConfigurationMonitor listener;
-
-
- public void setUp() {
- factImm = (ComponentFactory) Utils.getFactoryByName(getContext(), factNameImm);
- admin = (ConfigurationAdmin) Utils.getServiceObject(getContext(), ConfigurationAdmin.class.getName(), null);
- assertNotNull("Check configuration admin availability", admin);
- cleanConfigurationAdmin();
- listener = new ConfigurationMonitor(getContext());
- }
-
- public void tearDown() {
- listener.stop();
- cleanConfigurationAdmin();
- admin = null;
- }
-
- private void cleanConfigurationAdmin() {
- try {
- Configuration[] configurations = admin.listConfigurations("(service.pid=" + msp + ")");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void testFactoryCreationAndReconfiguration() {
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factImm.createComponentInstance(props);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message", mes);
- assertEquals("Check count", 1, count);
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- //Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- listener.waitForEvent(configuration.getPid(), "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message2", mes);
- assertEquals("Check count", 2, count);
-
- instance.dispose();
-
- }
-
- public void testMSFCreationAndReconfiguration() {
- Configuration conf = null;
- try {
- conf = admin.createFactoryConfiguration(factNameImm);
- Dictionary props = conf.getProperties();
- if (props == null) {
- props = new Properties();
- }
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- conf.update(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME); // Wait for the creation.
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
-
- Architecture arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message", mes);
- assertEquals("Check count", 1, count);
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- //Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- listener.waitForEvent(configuration.getPid(), "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- if (mes.equals("message")) {
- System.out.println("Warning, configuration not yet applied");
- assertEquals("Check count - W", 1, count);
- } else {
- assertEquals("Check message", "message2", mes);
- assertEquals("Check count", 2, count);
- }
-
- try {
- conf.delete();
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- }
-
- public void testCreationAndReconfiguration2() {
- // The configuration exists before the instance creation.
-
- //Update
- Configuration configuration = null;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factImm.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- // int count1 = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message - 1 (" + mes +")", "message2", mes); // Already reconfigured.
- // assertEquals("Check count", 2, count); // Two : 1) "message" on immediate, "message2" on the reconfiguration,
- // not necessary as the property can be set before the immediate instance creation
-
- instance.dispose();
-
- //Reconfiguration
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message3");
- configuration.update(prc);
- listener.waitForEvent(msp, "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // Recreation of the instance.
- props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- instance = null;
- try {
- instance = factImm.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME * 2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- // int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message already reconfigured", "message3", mes); // Already reconfigured.
- //assertEquals("Check count", count1 + 1, count); // message before the reconfiguration, message3 after the reconfiguration
-
- instance.dispose();
-
-
- }
-
- public void testCreationAndReconfiguration3() {
- // The configuration exists before the instance creation.
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- listener.waitForEvent(msp, "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factImm.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- // int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message2", mes); // Already reconfigured.
- //assertEquals("Check count", 1, count);
-
- //Reconfiguration
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message3");
- configuration.update(prc);
- //Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- listener.waitForEvent(msp, "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- instance.dispose();
-
- // Recreation of the instance.
- props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- instance = null;
- try {
- instance = factImm.createComponentInstance(props);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- // count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message3", mes); // Already reconfigured.
- // assertEquals("Check count", 1, count);
-
- instance.dispose();
-
-
- }
-
-
-
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForService.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForService.java
deleted file mode 100644
index 42e0202..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ManagedServiceTestForService.java
+++ /dev/null
@@ -1,368 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configadmin;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configadmin.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ManagedServiceTestForService extends OSGiTestCase {
-
- private String factNameSvc = "CA-ConfigurableProvider";
- private String msp = "foo";
-
- private ComponentFactory factSvc;
-
- private ConfigurationAdmin admin;
-
- ConfigurationMonitor listener;
-
-
- public void setUp() {
- factSvc = (ComponentFactory) Utils.getFactoryByName(getContext(), factNameSvc);
- admin = (ConfigurationAdmin) Utils.getServiceObject(getContext(), ConfigurationAdmin.class.getName(), null);
- assertNotNull("Check configuration admin availability", admin);
- cleanConfigurationAdmin();
- listener = new ConfigurationMonitor(getContext());
- }
-
- public void tearDown() {
- listener.stop();
- cleanConfigurationAdmin();
- admin = null;
- }
-
- private void cleanConfigurationAdmin() {
- try {
- Configuration[] configurations = admin.listConfigurations("(service.pid=" + msp + ")");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void testFactoryCreationAndReconfiguration() {
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factSvc.createComponentInstance(props);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message", mes);
- assertEquals("Check count", 1, count);
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- if (mes.equals("message")) {
- System.out.println("Warning, configuration not yet applied");
- assertEquals("Check count - W", 1, count);
- } else {
- assertEquals("Check message", "message2", mes);
- assertEquals("Check count", 2, count);
- }
-
- instance.dispose();
-
- }
-
- public void testMSFCreationAndReconfiguration() {
- Configuration conf = null;
- try {
- conf = admin.createFactoryConfiguration(factNameSvc);
- Dictionary props = conf.getProperties();
- if (props == null) {
- props = new Properties();
- }
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- conf.update(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME); // Wait for the creation.
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
-
- Architecture arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message", mes);
- assertEquals("Check count", 1, count);
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), conf.getPid());
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- // arch = (Architecture) Utils.getServiceObject(getContext(), org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
- if (mes.equals("message")) {
- System.out.println("Warning, configuration not yet applied");
- assertEquals("Check count - W", 1, count);
- } else {
- assertEquals("Check message", "message2", mes);
- assertEquals("Check count", 2, count);
- }
-
- try {
- conf.delete();
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- }
-
- public void testCreationAndReconfiguration2() {
- // The configuration exists before the instance creation.
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- listener.waitForEvent(msp, "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factSvc.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message2", mes); // Already reconfigured.
- assertEquals("Check count", 1, count);
-
- instance.dispose();
-
- //Reconfiguration
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message3");
- configuration.update(prc);
- listener.waitForEvent(msp, "2");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // Recreation of the instance.
- props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- instance = null;
- try {
- instance = factSvc.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message3", mes); // Already reconfigured.
- assertEquals("Check count", 1, count);
-
- instance.dispose();
-
-
- }
-
- public void testCreationAndReconfiguration3() {
- // The configuration exists before the instance creation.
-
- //Update
- Configuration configuration;
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message2");
- configuration.update(prc);
- listener.waitForEvent(msp, "1");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- Properties props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- ComponentInstance instance = null;
- try {
- instance = factSvc.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- FooService fs = (FooService) getContext().getService(ref);
- Properties p = fs.fooProps();
- String mes = p.getProperty("message");
- int count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message2", mes); // Already reconfigured.
- assertEquals("Check count", 1, count);
-
- //Reconfiguration
- try {
- configuration = admin.getConfiguration(msp);
- Dictionary prc = configuration.getProperties();
- if (prc == null) {
- prc = new Properties();
- }
- prc.put("message", "message3");
- configuration.update(prc);
- listener.waitForEvent(msp, "2");
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- instance.dispose();
-
- // Recreation of the instance.
- props = new Properties();
- props.put("managed.service.pid", msp);
- props.put("message", "message");
- instance = null;
- try {
- instance = factSvc.createComponentInstance(props);
- Thread.sleep(ConfigurationTestSuite.UPDATE_WAIT_TIME);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertNotNull("FS availability", ref);
-
- fs = (FooService) getContext().getService(ref);
- p = fs.fooProps();
- mes = p.getProperty("message");
- count = ((Integer) p.get("count")).intValue();
- assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) instance.getInstanceDescription()).getCreatedObjects().length);
- assertEquals("Check message", "message3", mes); // Already reconfigured.
- assertEquals("Check count", 1, count);
-
- instance.dispose();
-
-
- }
-
-
-
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/CheckService.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/CheckService.java
deleted file mode 100644
index 6b9cfa0..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configadmin.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/FooService.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/FooService.java
deleted file mode 100644
index 94abc61..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configadmin.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index c45c079..0000000
--- a/ipojo/tests/core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
- public static void waitForService(BundleContext context, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(context, itf, filter);
- int count = 0;
- if (refs.length != 0) {
- return;
- } else {
- while(refs.length == 0) {
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // Interrupted
- }
- count++;
- if (count == 100) {
- throw new RuntimeException("Timeout ... no services match with " + filter);
- }
- refs = getServiceReferences(context, itf, filter);
- }
- }
- }
-
-}
diff --git a/ipojo/tests/core/configadmin/src/main/resources/metadata.xml b/ipojo/tests/core/configadmin/src/main/resources/metadata.xml
deleted file mode 100644
index 09134da..0000000
--- a/ipojo/tests/core/configadmin/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd" xmlns="org.apache.felix.ipojo">
- <component classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableFooProvider"
- name="CA-ConfigurableProvider">
- <provides></provides>
- <properties>
- <property name="message" method="setMessage"/>
- </properties>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableFooProvider"
- immediate="true"
- name="CA-ImmConfigurableProvider">
- <provides></provides>
- <properties>
- <property name="message" method="setMessage"/>
- </properties>
- </component>
-
-
-
-</ipojo>
diff --git a/ipojo/tests/core/configuration/pom.xml b/ipojo/tests/core/configuration/pom.xml
deleted file mode 100644
index c7c1c22..0000000
--- a/ipojo/tests/core/configuration/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Configuration Management Test Suite</name>
- <artifactId>tests.core.configuration</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.configuration.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.configuration.ConfigurationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <!-- Test -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/configuration/src/main/ipojo/metadata.xml b/ipojo/tests/core/configuration/src/main/ipojo/metadata.xml
deleted file mode 100644
index 05e233c..0000000
--- a/ipojo/tests/core/configuration/src/main/ipojo/metadata.xml
+++ /dev/null
@@ -1,250 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="CONFIG-FooProviderType-Conf" architecture="true">
- <provides />
- <properties propagation="false">
- <property name="int" field="intProp" value="2" />
- <property name="boolean" field="boolProp" value="false" />
- <property name="string" field="strProp" value="foo" />
- <property name="strAProp" field="strAProp"
- value="{foo, bar}" />
- <property name="intAProp" field="intAProp" value="{1,2, 3}" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="CONFIG-FooProviderType-ConfNoValue" architecture="true">
- <provides />
- <properties propagation="false">
- <property name="int" field="intProp"/>
- <property name="boolean" field="boolProp"/>
- <property name="string" field="strProp"/>
- <property name="strAProp" field="strAProp"/>
- <property name="intAProp" field="intAProp"/>
- </properties>
- </component>
-
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="CONFIG-FooProviderType-3" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
- <!-- Configuration Management Test -->
- <component name="CONFIG-FieldConfigurableCheckService"
- classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
- architecture="true">
- <provides />
- <properties propagation="true">
- <property field="b" />
- <property field="s" />
- <property field="i" />
- <property field="l" />
- <property field="d" />
- <property field="f" />
- <property field="c" />
- <property field="bool" />
- <property field="bs" />
- <property field="ss" />
- <property field="is" />
- <property field="ls" />
- <property field="ds" />
- <property field="fs" />
- <property field="cs" />
- <property field="bools" />
- <property field="string" />
- <property field="strings" />
- </properties>
- </component>
-
- <component name="CONFIG-BothConfigurableCheckService"
- classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
- architecture="true">
- <provides />
- <properties propagation="true">
- <property field="b" method="updateB" />
- <property field="s" method="updateS" />
- <property field="i" method="updateI" />
- <property field="l" method="updateL" />
- <property field="d" method="updateD" />
- <property field="f" method="updateF" />
- <property field="c" method="updateC" />
- <property field="bool" method="updateBool" />
- <property field="bs" method="updateBs" />
- <property field="ss" method="updateSs" />
- <property field="is" method="updateIs" />
- <property field="ls" method="updateLs" />
- <property field="ds" method="updateDs" />
- <property field="fs" method="updateFs" />
- <property field="cs" method="updateCs" />
- <property field="bools" method="updateBools" />
- <property field="string" method="updateString" />
- <property field="strings" method="updateStrings" />
- </properties>
- </component>
-
- <component name="CONFIG-MethodConfigurableCheckService"
- classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
- architecture="true">
- <provides />
- <properties propagation="true">
- <property method="updateB" name="b" />
- <property method="updateS" name="s" />
- <property method="updateI" name="i" />
- <property method="updateL" name="l" />
- <property method="updateD" name="d" />
- <property method="updateF" name="f" />
- <property method="updateC" name="c" />
- <property method="updateBool" name="bool" />
- <property method="updateBs" name="bs" />
- <property method="updateSs" name="ss" />
- <property method="updateIs" name="is" />
- <property method="updateLs" name="ls" />
- <property method="updateDs" name="ds" />
- <property method="updateFs" name="fs" />
- <property method="updateCs" name="cs" />
- <property method="updateBools" name="bools" />
- <property method="updateString" name="string" />
- <property method="updateStrings" name="strings" />
- </properties>
- </component>
-
- <component name="CONFIG-ParentMethodConfigurableCheckService"
- classname="org.apache.felix.ipojo.test.scenarios.component.ParentConfigurableCheckServiceProvider"
- architecture="true">
- <provides />
- <properties propagation="true">
- <property method="updateB" name="b" />
- <property method="updateS" name="s" />
- <property method="updateI" name="i" />
- <property method="updateL" name="l" />
- <property method="updateD" name="d" />
- <property method="updateF" name="f" />
- <property method="updateC" name="c" />
- <property method="updateBool" name="bool" />
- <property method="updateBs" name="bs" />
- <property method="updateSs" name="ss" />
- <property method="updateIs" name="is" />
- <property method="updateLs" name="ls" />
- <property method="updateDs" name="ds" />
- <property method="updateFs" name="fs" />
- <property method="updateCs" name="cs" />
- <property method="updateBools" name="bools" />
- <property method="updateString" name="string" type="string" />
- <property method="updateStrings" name="strings"
- type="java.lang.String[]" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="CONFIG-FooProviderType-4" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true" pid="FooProvider-3">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ComplexConfiguration">
- <provides>
- <property name="array" field="m_array"/>
- <property name="complex-array" field="m_complexArray"/>
- <property name="list" field="m_list"/>
- <property name="complex-list" field="m_complexList"/>
- <property name="map" field="m_map"/>
- <property name="complex-map" field="m_complexMap"/>
- <property name="dict" field="m_dict"/>
- <property name="empty-array" type="String[]"/>
- <property name="empty-map" type="java.util.HashMap"/>
- <property name="empty-list" type="java.util.List"/>
- </provides>
- <properties>
- <property name="array" field="m_array"/>
- <property name="complex-array" field="m_complexArray"/>
- <property name="list" field="m_list"/>
- <property name="complex-list" field="m_complexList"/>
- <property name="map" field="m_map"/>
- <property name="complex-map" field="m_complexMap"/>
- <property name="dict" field="m_dict"/>
- </properties>
- </component>
-
- <instance component="org.apache.felix.ipojo.test.scenarios.component.ComplexConfiguration" name="complex">
- <property name="array" type="array">
- <property value="a"/>
- <property value="b"/>
- </property>
- <property name="list" type="list">
- <property value="a"/>
- <property value="b"/>
- </property>
- <property name="dict" type="dictionary">
- <property name="a" value="a"/>
- <property name="b" value="b"/>
- </property>
- <property name="map" type="map">
- <property name="a" value="a"/>
- <property name="b" value="b"/>
- </property>
- <property name="complex-array" type="array">
- <property type="list">
- <property value="a"/>
- <property value="b"/>
- </property>
- <property type="list">
- <property value="c"/>
- <property value="d"/>
- </property>
- </property>
- <property name="complex-list" type="list">
- <property type="list">
- <property value="a"/>
- <property value="b"/>
- </property>
- <property type="list">
- <property value="c"/>
- <property value="d"/>
- </property>
- </property>
- <property name="complex-map" type="map">
- <property name="a" type="list">
- <property value="a"/>
- <property value="b"/>
- </property>
- <property name="b" type="list">
- <property value="c"/>
- <property value="d"/>
- </property>
- </property>
- <property name="empty-array" type="array"/>
- <property name="empty-list" type="list"/>
- <property name="empty-map" type="map"/>
- </instance>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.PropertyModifier">
- <provides>
- <property field="classes"/>
- </provides>
- <properties>
- <property method="setClasses" name="cls"/>
- </properties>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/configuration/src/main/ipojo/updated.xml b/ipojo/tests/core/configuration/src/main/ipojo/updated.xml
deleted file mode 100644
index 45fd9b7..0000000
--- a/ipojo/tests/core/configuration/src/main/ipojo/updated.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <!-- updated -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="CONFIG-FooProviderType-ConfUpdated" architecture="true">
- <provides />
- <properties updated="updated">
- <property name="int" field="intProp" value="2" />
- <property name="boolean" field="boolProp" value="false" />
- <property name="string" field="strProp" value="foo" />
- <property name="strAProp" field="strAProp"
- value="{foo, bar}" />
- <property name="intAProp" field="intAProp" value="{1,2, 3}" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="CONFIG-FooProviderType-ConfNoValueUpdated" architecture="true">
- <provides />
- <properties updated="updated">
- <property name="int" field="intProp"/>
- <property name="boolean" field="boolProp"/>
- <property name="string" field="strProp"/>
- <property name="strAProp" field="strAProp"/>
- <property name="intAProp" field="intAProp"/>
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="CONFIG-FooProviderType-4Updated" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true" pid="FooProvider-3" updated="updated">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"
- name="CONFIG-FooProviderType-4Updated2" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true" pid="FooProvider-3" updated="updated">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="CONFIG-FooProviderType-3Updated" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true" updated="updated">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"
- name="CONFIG-FooProviderType-3Updated2" architecture="true">
- <provides>
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- <property name="baz" type="java.lang.String" />
- </provides>
- <properties propagation="true" updated="updated">
- <property name="foo" field="m_foo" />
- <property name="bar" field="m_bar" />
- </properties>
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
deleted file mode 100644
index 11bf266..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index 5b2494e..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComplexConfiguration.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComplexConfiguration.java
deleted file mode 100644
index f460048..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ComplexConfiguration.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-
-public class ComplexConfiguration implements CheckService {
-
- private List m_list;
- private Map m_map;
- private Dictionary m_dict;
- private String[] m_array;
-
- private List m_complexList;
- private Map m_complexMap;
- private Object[] m_complexArray;
-
- public boolean check() {
- return true;
- }
-
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("list", m_list);
- props.put("map", m_map);
- props.put("dict", m_dict);
- props.put("array", m_array);
- props.put("complex-list", m_complexList);
- props.put("complex-map", m_complexMap);
- props.put("complex-array", m_complexArray);
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java
deleted file mode 100644
index bf9d3c7..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-
-public class ConfigurableCheckServiceProvider implements CheckService {
-
- // Integer types
- byte b;
- short s;
- int i;
- long l;
-
- // Floatting types
- double d;
- float f;
-
- // Character
- char c;
-
- // Boolean
- boolean bool;
-
- // Integer arrays
- byte[] bs;
- short[] ss;
- int[] is;
- long[] ls;
-
- double[] ds;
- float[] fs;
-
- char[] cs;
-
- boolean[] bools;
-
- String string;
- String[] strings;
-
- int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools, upString, upStrings;
-
-
- public boolean check() {
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("b", new Byte(b));
- props.put("s", new Short(s));
- props.put("i", new Integer(i));
- props.put("l", new Long(l));
- props.put("d", new Double(d));
- props.put("f", new Float(f));
- props.put("c", new Character(c));
- props.put("bool", new Boolean(bool));
-
- if (bs != null) {
- props.put("bs", bs);
- }
- if (ss != null) {
- props.put("ss", ss);
- }
- if (is != null) {
- props.put("is", is);
- }
- if (ls != null) {
- props.put("ls", ls);
- }
- if (ds != null) {
- props.put("ds", ds);
- }
- if (fs != null) {
- props.put("fs", fs);
- }
- if (cs != null) {
- props.put("cs", cs);
- }
- if (bools != null) {
- props.put("bools", bools);
- }
-
- props.put("upb", new Integer(upB));
- props.put("ups", new Integer(upS));
- props.put("upi", new Integer(upI));
- props.put("upl", new Integer(upL));
- props.put("upd", new Integer(upD));
- props.put("upf", new Integer(upF));
- props.put("upc", new Integer(upC));
- props.put("upbool", new Integer(upBool));
-
- props.put("upbs", new Integer(upBs));
- props.put("upss", new Integer(upSs));
- props.put("upis", new Integer(upIs));
- props.put("upls", new Integer(upLs));
- props.put("upds", new Integer(upDs));
- props.put("upfs", new Integer(upFs));
- props.put("upcs", new Integer(upCs));
- props.put("upbools", new Integer(upBools));
-
- if (string != null) {
- props.put("string", string);
- }
- if (string != null) {
- props.put("strings", strings);
- }
-
- props.put("upstring", new Integer(upString));
- props.put("upstrings", new Integer(upStrings));
-
- return props;
- }
-
- public void updateB(byte bb) {
- b = bb;
- upB++;
- }
-
- public void updateS(short bb) {
- s = bb;
- upS++;
- }
-
- public void updateI(int bb) {
- i = bb;
- upI++;
- }
-
- public void updateL(long bb) {
- l = bb;
- upL++;
- }
-
- public void updateD(double bb) {
- d = bb;
- upD++;
- }
-
- public void updateF(float bb) {
- f = bb;
- upF++;
- }
-
- public void updateC(char bb) {
- c = bb;
- upC++;
- }
-
- public void updateBool(boolean bb) {
- bool = bb;
- upBool++;
- }
-
- public void updateBs(byte[] bb) {
- bs = bb;
- upBs++;
- }
-
- public void updateSs(short[] bb) {
- ss = bb;
- upSs++;
- }
-
- public void updateIs(int[] bb) {
- is = bb;
- upIs++;
- }
-
- public void updateLs(long[] bb) {
- ls = bb;
- upLs++;
- }
-
- public void updateDs(double[] bb) {
- ds = bb;
- upDs++;
- }
-
- public void updateFs(float[] bb) {
- fs = bb;
- upFs++;
- }
-
- public void updateCs(char[] bb) {
- cs = bb;
- upCs++;
- }
-
- public void updateBools(boolean[] bb) {
- bools = bb;
- upBools++;
- }
-
- public void updateStrings(String[] bb) {
- strings = bb;
- upStrings++;
- }
-
- public void updateString(String bb) {
- string = bb;
- upString++;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 03ccbfc..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private int updated;
- private Dictionary lastupdated;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
-
- p.put("updated", new Integer(updated));
- if (lastupdated != null) {
- p.put("lastupdated", lastupdated);
- }
-
-
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
- public void updated(Dictionary props) {
- updated++;
- lastupdated = props;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java
deleted file mode 100644
index 62db9c2..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType2 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static int count = 0;
-
- private int updated;
-
-
- public FooProviderType2(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
-
- p.put("updated", new Integer(updated));
-
-
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType2(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
- public void updated() {
- updated++;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
deleted file mode 100644
index 9ec08de..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-
-public class FooProviderTypeDyn implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
- private int updated;
- private Dictionary lastUpdate;
-
- public boolean foo() {
- intProp = 3;
- boolProp = true;
- if(strProp == null || strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- if (strProp != null) {
- p.put("strProp", strProp);
- }
- if (strAProp != null) {
- p.put("strAProp", strAProp);
- }
- if (intAProp != null) {
- p.put("intAProp", intAProp);
- }
-
- p.put("updated", new Integer(updated));
- if (lastUpdate != null) {
- p.put("lastupdated", lastUpdate);
- }
-
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- public void updated(Dictionary props) {
- updated++;
- lastUpdate = props;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
deleted file mode 100644
index f7fb580..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass {
-
- public void parentStart() {
-
- }
-
- public void parentStop() {
-
- }
-
- protected String[] strings;
-
- protected String string;
-
- protected int upStrings;
-
- protected int upString;
-
- public void updateStrings(String[] bb) {
- strings = bb;
- upStrings++;
- }
-
- public void updateString(String bb) {
- string = bb;
- upString++;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java
deleted file mode 100644
index 1dc7212..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-
-public class ParentConfigurableCheckServiceProvider extends ParentClass implements CheckService {
-
- // Integer types
- byte b;
- short s;
- int i;
- long l;
-
- // Floatting types
- double d;
- float f;
-
- // Character
- char c;
-
- // Boolean
- boolean bool;
-
- // Integer arrays
- byte[] bs;
- short[] ss;
- int[] is;
- long[] ls;
-
- double[] ds;
- float[] fs;
-
- char[] cs;
-
- boolean[] bools;
-
- //String string;
- //String[] strings;
-
- int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools/*, upString, upStrings*/;
-
-
- public boolean check() {
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("b", new Byte(b));
- props.put("s", new Short(s));
- props.put("i", new Integer(i));
- props.put("l", new Long(l));
- props.put("d", new Double(d));
- props.put("f", new Float(f));
- props.put("c", new Character(c));
- props.put("bool", new Boolean(bool));
-
- props.put("bs", bs);
- props.put("ss", ss);
- props.put("is", is);
- props.put("ls", ls);
- props.put("ds", ds);
- props.put("fs", fs);
- props.put("cs", cs);
- props.put("bools", bools);
-
- props.put("upb", new Integer(upB));
- props.put("ups", new Integer(upS));
- props.put("upi", new Integer(upI));
- props.put("upl", new Integer(upL));
- props.put("upd", new Integer(upD));
- props.put("upf", new Integer(upF));
- props.put("upc", new Integer(upC));
- props.put("upbool", new Integer(upBool));
-
- props.put("upbs", new Integer(upBs));
- props.put("upss", new Integer(upSs));
- props.put("upis", new Integer(upIs));
- props.put("upls", new Integer(upLs));
- props.put("upds", new Integer(upDs));
- props.put("upfs", new Integer(upFs));
- props.put("upcs", new Integer(upCs));
- props.put("upbools", new Integer(upBools));
-
- props.put("string", string);
- props.put("strings", strings);
- props.put("upstring", new Integer(upString));
- props.put("upstrings", new Integer(upStrings));
-
- return props;
- }
-
- public void updateB(byte bb) {
- b = bb;
- upB++;
- }
-
- public void updateS(short bb) {
- s = bb;
- upS++;
- }
-
- public void updateI(int bb) {
- i = bb;
- upI++;
- }
-
- public void updateL(long bb) {
- l = bb;
- upL++;
- }
-
- public void updateD(double bb) {
- d = bb;
- upD++;
- }
-
- public void updateF(float bb) {
- f = bb;
- upF++;
- }
-
- public void updateC(char bb) {
- c = bb;
- upC++;
- }
-
- public void updateBool(boolean bb) {
- bool = bb;
- upBool++;
- }
-
- public void updateBs(byte[] bb) {
- bs = bb;
- upBs++;
- }
-
- public void updateSs(short[] bb) {
- ss = bb;
- upSs++;
- }
-
- public void updateIs(int[] bb) {
- is = bb;
- upIs++;
- }
-
- public void updateLs(long[] bb) {
- ls = bb;
- upLs++;
- }
-
- public void updateDs(double[] bb) {
- ds = bb;
- upDs++;
- }
-
- public void updateFs(float[] bb) {
- fs = bb;
- upFs++;
- }
-
- public void updateCs(char[] bb) {
- cs = bb;
- upCs++;
- }
-
- public void updateBools(boolean[] bb) {
- bools = bb;
- upBools++;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropertyModifier.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropertyModifier.java
deleted file mode 100644
index a127ddd..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PropertyModifier.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.osgi.framework.BundleContext;
-
-public class PropertyModifier implements CheckService {
-
- private Class[] classes;
- private BundleContext context;
-
- PropertyModifier(BundleContext bc) {
- context = bc;
- }
-
- public boolean check() {
- return classes != null;
- }
-
- public void setClasses(String[] classes) throws ClassNotFoundException {
- Class[] cls = new Class[classes.length];
- for (int i = 0; i < classes.length; i++) {
- try {
- cls[i] = context.getBundle().loadClass(classes[i]);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- throw e;
- }
- }
-
- this.classes = cls;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("classes", classes);
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
deleted file mode 100644
index a41448c..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-
-public class ArchitectureTest extends OSGiTestCase {
-
- /**
- * Instance where the ManagedServicePID is provided by the component type.
- */
- ComponentInstance instance1;
- /**
- * Instance where the ManagedServicePID is provided by the instance.
- */
- ComponentInstance instance2;
-
- /**
- * Instance without configuration.
- */
- ComponentInstance instance3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-4";
- Properties p = new Properties();
- p.put("instance.name","instance");
- p.put("foo", "foo");
- p.put("bar", "2");
- p.put("baz", "baz");
- instance1 = Utils.getComponentInstance(getContext(), type, p);
- assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
-
- type = "CONFIG-FooProviderType-3";
- Properties p1 = new Properties();
- p1.put("instance.name","instance-2");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- p1.put("managed.service.pid", "instance");
- instance2 = Utils.getComponentInstance(getContext(), type, p1);
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance1 = null;
- instance2 = null;
- }
-
- public void testArchitectureForInstance1() {
- Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(), "(architecture.instance=instance)");
- assertNotNull(arch);
-
- // Test on String representation.
- String desc = arch.getInstanceDescription().getDescription().toString();
- assertTrue(desc.contains("managed.service.pid=\"FooProvider-3\""));
-
- // Test on handler description
- ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
- assertNotNull(hd);
-
- assertEquals(2, hd.getProperties().length);
- assertEquals("FooProvider-3", hd.getManagedServicePid());
-
- }
-
- public void testArchitectureForInstance2() {
- Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(), "(architecture.instance=instance-2)");
- assertNotNull(arch);
-
- // Test on String representation.
- String desc = arch.getInstanceDescription().getDescription().toString();
- assertTrue(desc.contains("managed.service.pid=\"instance\""));
-
- // Test on handler description
- ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
- assertNotNull(hd);
-
- assertEquals(2, hd.getProperties().length);
- assertEquals("instance", hd.getManagedServicePid());
-
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
deleted file mode 100644
index 8bff9b3..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ConfigurationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Configuration Test Suite", bc);
- ots.addTestSuite(SimpleProperties.class);
- ots.addTestSuite(DynamicallyConfigurableProperties.class);
- ots.addTestSuite(TestFieldProperties.class);
- ots.addTestSuite(TestMethodProperties.class);
- ots.addTestSuite(TestBothProperties.class);
- ots.addTestSuite(TestSuperMethodProperties.class);
- ots.addTestSuite(ManagedServiceConfigurableProperties.class);
- ots.addTestSuite(TestComplexProperties.class);
- ots.addTestSuite(TestPropertyModifier.class);
- ots.addTestSuite(UpdatedMethod.class);
- ots.addTestSuite(UpdatedMethodAndManagedServiceFactory.class);
- ots.addTestSuite(UpdatedMethodAndManagedService.class);
- ots.addTestSuite(UpdatedNoArgMethodAndManagedService.class);
- ots.addTestSuite(UpdatedNoArgMethodAndManagedServiceFactory.class);
- ots.addTestSuite(ArchitectureTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java
deleted file mode 100644
index 4610f9d..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class DynamicallyConfigurableProperties extends OSGiTestCase {
-
- ComponentInstance instance, instance2;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-3";
-
- Properties p1 = new Properties();
- p1.put("instance.name","instance");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- instance = Utils.getComponentInstance(getContext(), type, p1);
-
- Properties p2 = new Properties();
- p2.put("instance.name","instance2");
-
- instance2 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance2 = null;
- instance = null;
- }
-
- public void testStatic() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
- getContext().ungetService(msRef);
- }
-
- public void testStaticNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
- getContext().ungetService(msRef);
- }
-
- public void testDynamic() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
-
- public void testDynamicString() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", "0");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testPropagation() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "foo");
- conf.put("bar", new Integer(2));
- conf.put("propagated1", "propagated");
- conf.put("propagated2", new Integer(1));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
- String prop1 = (String) fooRef.getProperty("propagated1");
- assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
- Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "zab");
- assertEquals("Check propagated1 equality", prop1, "propagated");
- assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
- getContext().ungetService(msRef);
- }
-
- public void testPropagationNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "foo");
- conf.put("bar", new Integer(2));
- conf.put("propagated1", "propagated");
- conf.put("propagated2", new Integer(1));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
- String prop1 = (String) fooRef.getProperty("propagated1");
- assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
- Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "zab");
- assertEquals("Check propagated1 equality", prop1, "propagated");
- assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
- getContext().ungetService(msRef);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
deleted file mode 100644
index 92997b2..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-
-public class ManagedServiceConfigurableProperties extends OSGiTestCase {
-
- /**
- * Instance where the ManagedServicePID is provided by the component type.
- */
- ComponentInstance instance1;
- /**
- * Instance where the ManagedServicePID is provided by the instance.
- */
- ComponentInstance instance2;
-
- /**
- * Instance without configuration.
- */
- ComponentInstance instance3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-4";
- Properties p = new Properties();
- p.put("instance.name","instance");
- p.put("foo", "foo");
- p.put("bar", "2");
- p.put("baz", "baz");
- instance1 = Utils.getComponentInstance(getContext(), type, p);
- assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
-
- type = "CONFIG-FooProviderType-3";
- Properties p1 = new Properties();
- p1.put("instance.name","instance-2");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- p1.put("managed.service.pid", "instance");
- instance2 = Utils.getComponentInstance(getContext(), type, p1);
-
- type = "CONFIG-FooProviderType-3";
- Properties p2 = new Properties();
- p2.put("instance.name","instance-3");
- p2.put("managed.service.pid", "instance-3");
- instance3 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- }
-
- public void testStaticInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
- getContext().ungetService(msRef);
- }
-
- public void testStaticInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedService availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testStaticInstance3() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- // No values ... no properties.
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
- assertNotNull("Check ManagedService availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicInstance3() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- // No values ... no properties.
- assertEquals("Check foo equality", fooP, null);
- assertEquals("Check bar equality", barP, null);
- assertEquals("Check baz equality", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicStringInstance1() {
- assertEquals("Check instance1 state", ComponentInstance.VALID,instance1.getState());
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality - 1", fooP, "foo");
- assertEquals("Check bar equality - 1", barP, new Integer(2));
- assertEquals("Check baz equality - 1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedService availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", "0");
- assertEquals("Check instance1 state (2)", ComponentInstance.VALID,instance1.getState());
- ManagedService ms = (ManagedService) getContext().getService(msRef);
-
- PrimitiveHandler ph = (PrimitiveHandler) ms;
- assertSame("Check the correct instance", ph.getInstanceManager(), instance1);
-
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
- assertEquals("Check instance1 state (3)", ComponentInstance.VALID,instance1.getState());
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality - 2", fooP, "oof");
- assertEquals("Check bar equality - 2", barP, new Integer(0));
- assertEquals("Check baz equality - 2", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicStringInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedService availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", "0");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testPropagationInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedService availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "foo");
- conf.put("bar", new Integer(2));
- conf.put("propagated1", "propagated");
- conf.put("propagated2", new Integer(1));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
- String prop1 = (String) fooRef.getProperty("propagated1");
- assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
- Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "zab");
- assertEquals("Check propagated1 equality", prop1, "propagated");
- assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
- getContext().ungetService(msRef);
- }
-
- public void testPropagationInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedService availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "foo");
- conf.put("bar", new Integer(2));
- conf.put("propagated1", "propagated");
- conf.put("propagated2", new Integer(1));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
- String prop1 = (String) fooRef.getProperty("propagated1");
- assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
- Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "zab");
- assertEquals("Check propagated1 equality", prop1, "propagated");
- assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
- getContext().ungetService(msRef);
- }
-
- public void testPropagationInstance3() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, null);
- assertEquals("Check bar equality", barP, null);
- assertEquals("Check baz equality", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
- assertNotNull("Check ManagedService availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "foo");
- conf.put("bar", new Integer(2));
- conf.put("propagated1", "propagated");
- conf.put("propagated2", new Integer(1));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
- String prop1 = (String) fooRef.getProperty("propagated1");
- assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
- Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "zab");
- assertEquals("Check propagated1 equality", prop1, "propagated");
- assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
- getContext().ungetService(msRef);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java
deleted file mode 100644
index 9803664..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleProperties extends OSGiTestCase {
-
- ComponentInstance fooProvider1;
- ComponentInstance fooProvider2;
- ComponentInstance fooProvider3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-Conf";
-
- Properties p1 = new Properties();
- p1.put("instance.name","FooProvider-1");
- fooProvider1 = Utils.getComponentInstance(getContext(), type, p1);
-
- Properties p2 = new Properties();
- p2.put("instance.name","FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("boolean", new Boolean(false));
- p2.put("string", new String("bar"));
- p2.put("strAProp", new String[] {"bar", "foo"});
- p2.put("intAProp", new int[] {1, 2, 3});
- fooProvider2 = Utils.getComponentInstance(getContext(), type, p2);
-
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- fooProvider3 = Utils.getComponentInstance(getContext(), "CONFIG-FooProviderType-ConfNoValue", p3);
- }
-
- public void tearDown() {
- fooProvider1.dispose();
- fooProvider2.dispose();
- fooProvider3.dispose();
- fooProvider1 = null;
- fooProvider2 = null;
- fooProvider3 = null;
- }
-
- public void testComponentTypeConfiguration() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check FooService availability", ref);
- FooService fs = (FooService) getContext().getService(ref);
- Properties toCheck = fs.fooProps();
-
- Integer intProp = (Integer) toCheck.get("intProp");
- Boolean boolProp = (Boolean) toCheck.get("boolProp");
- String strProp = (String) toCheck.get("strProp");
- String[] strAProp = (String[]) toCheck.get("strAProp");
- int[] intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity (1)", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1) : " + strAProp[i] + " != " + v[i]); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1) : " + intAProp[i] + " != " + v2[i]); }
- }
-
- // change the field value
- assertTrue("Invoke the fs service", fs.foo());
- toCheck = fs.fooProps();
-
-
- // Re-check the property (change)
- intProp = (Integer) toCheck.get("intProp");
- boolProp = (Boolean) toCheck.get("boolProp");
- strProp = (String) toCheck.get("strProp");
- strAProp = (String[]) toCheck.get("strAProp");
- intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality (2) ("+intProp+")", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity (2)", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
- }
- assertNotNull("Check intAProp not nullity (2)", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2) : " + intAProp[i] + " != " + v2[i]); }
- }
-
- fs = null;
- getContext().ungetService(ref);
- }
-
- public void testInstanceConfiguration() {
- ServiceReference sr = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "FooProvider-2");
- assertNotNull("Check the availability of the FS service", sr);
-
- FooService fs = (FooService) getContext().getService(sr);
- Properties toCheck = fs.fooProps();
-
- // Check service properties
- Integer intProp = (Integer) toCheck.get("intProp");
- Boolean boolProp = (Boolean) toCheck.get("boolProp");
- String strProp = (String) toCheck.get("strProp");
- String[] strAProp = (String[]) toCheck.get("strAProp");
- int[] intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", boolProp, new Boolean(false));
- assertEquals("Check strProp equality", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"bar", "foo"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
-
- assertTrue("invoke fs", fs.foo());
- toCheck = fs.fooProps();
-
- // Re-check the property (change)
- intProp = (Integer) toCheck.get("intProp");
- boolProp = (Boolean) toCheck.get("boolProp");
- strProp = (String) toCheck.get("strProp");
- strAProp = (String[]) toCheck.get("strAProp");
- intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(3));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fs = null;
- getContext().ungetService(sr);
- }
-
- public void testNoValue() {
- ServiceReference sr = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- FooService fs = (FooService) getContext().getService(sr);
- Properties toCheck = fs.fooProps();
-
- // Check service properties
- Integer intProp = (Integer) toCheck.get("intProp");
- Boolean boolProp = (Boolean) toCheck.get("boolProp");
- String strProp = (String) toCheck.get("strProp");
- String[] strAProp = (String[]) toCheck.get("strAProp");
- int[] intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(false));
- assertEquals("Check strProp equality", strProp, null);
- assertNull("Check strAProp nullity", strAProp);
- assertNull("Check intAProp nullity", intAProp);
-
- assertTrue("invoke fs", fs.foo());
- toCheck = fs.fooProps();
-
- // Re-check the property (change)
- intProp = (Integer) toCheck.get("intProp");
- boolProp = (Boolean) toCheck.get("boolProp");
- strProp = (String) toCheck.get("strProp");
- strAProp = (String[]) toCheck.get("strAProp");
- intAProp = (int[]) toCheck.get("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(3));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fs = null;
- getContext().ungetService(sr);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java
deleted file mode 100644
index 899a3e5..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestBothProperties extends OSGiTestCase {
-
- ComponentInstance instance, instance2;
-
-
- public void setUp() {
- Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-BothConfigurableCheckService");
- Properties props = new Properties();
- props.put("instance.name","under-test");
- props.put("b", "1");
- props.put("s", "1");
- props.put("i", "1");
- props.put("l", "1");
- props.put("d", "1");
- props.put("f", "1");
- props.put("c", "a");
- props.put("bool", "true");
- props.put("bs", "{1,2,3}");
- props.put("ss", "{1,2,3}");
- props.put("is", "{1,2,3}");
- props.put("ls", "{1,2,3}");
- props.put("ds", "{1,2,3}");
- props.put("fs", "{1,2,3}");
- props.put("cs", "{a,b,c}");
- props.put("bools", "{true,true,true}");
- props.put("string", "foo");
- props.put("strings", "{foo, bar, baz}");
-
- try {
- instance = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the under-test instance : " + e.getMessage());
- }
-
- try {
- instance2 = fact.createComponentInstance(null);
- } catch(Exception e) {
- fail("Cannot create the under-test instance2 : " + e.getMessage());
- }
-
-
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance = null;
- instance2 = null;
- }
-
- public void testConfigurationPrimitive() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
- Integer upb = (Integer) props.get("upb");
- Integer ups = (Integer) props.get("ups");
- Integer upi = (Integer) props.get("upi");
- Integer upl = (Integer) props.get("upl");
- Integer upd = (Integer) props.get("upd");
- Integer upf = (Integer) props.get("upf");
- Integer upc = (Integer) props.get("upc");
- Integer upbool = (Integer) props.get("upbool");
-
- assertEquals("Check upb", upb, new Integer(1));
- assertEquals("Check ups", ups, new Integer(1));
- assertEquals("Check upi", upi, new Integer(1));
- assertEquals("Check upl", upl, new Integer(1));
- assertEquals("Check upd", upd, new Integer(1));
- assertEquals("Check upf", upf, new Integer(1));
- assertEquals("Check upc", upc, new Integer(1));
- assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- upb = (Integer) props.get("upb");
- ups = (Integer) props.get("ups");
- upi = (Integer) props.get("upi");
- upl = (Integer) props.get("upl");
- upd = (Integer) props.get("upd");
- upf = (Integer) props.get("upf");
- upc = (Integer) props.get("upc");
- upbool = (Integer) props.get("upbool");
-
- assertEquals("2) Check upb", upb, new Integer(2));
- assertEquals("2) Check ups", ups, new Integer(2));
- assertEquals("2) Check upi", upi, new Integer(2));
- assertEquals("2) Check upl", upl, new Integer(2));
- assertEquals("2) Check upd", upd, new Integer(2));
- assertEquals("2) Check upf", upf, new Integer(2));
- assertEquals("2) Check upc", upc, new Integer(2));
- assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
- Integer upb = (Integer) props.get("upb");
- Integer ups = (Integer) props.get("ups");
- Integer upi = (Integer) props.get("upi");
- Integer upl = (Integer) props.get("upl");
- Integer upd = (Integer) props.get("upd");
- Integer upf = (Integer) props.get("upf");
- Integer upc = (Integer) props.get("upc");
- Integer upbool = (Integer) props.get("upbool");
-
- assertEquals("Check upb", upb, new Integer(1));
- assertEquals("Check ups", ups, new Integer(1));
- assertEquals("Check upi", upi, new Integer(1));
- assertEquals("Check upl", upl, new Integer(1));
- assertEquals("Check upd", upd, new Integer(1));
- assertEquals("Check upf", upf, new Integer(1));
- assertEquals("Check upc", upc, new Integer(1));
- assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- upb = (Integer) props.get("upb");
- ups = (Integer) props.get("ups");
- upi = (Integer) props.get("upi");
- upl = (Integer) props.get("upl");
- upd = (Integer) props.get("upd");
- upf = (Integer) props.get("upf");
- upc = (Integer) props.get("upc");
- upbool = (Integer) props.get("upbool");
-
- assertEquals("2) Check upb", upb, new Integer(2));
- assertEquals("2) Check ups", ups, new Integer(2));
- assertEquals("2) Check upi", upi, new Integer(2));
- assertEquals("2) Check upl", upl, new Integer(2));
- assertEquals("2) Check upd", upd, new Integer(2));
- assertEquals("2) Check upf", upf, new Integer(2));
- assertEquals("2) Check upc", upc, new Integer(2));
- assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArrays() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
- Integer upb = (Integer) props.get("upbs");
- Integer ups = (Integer) props.get("upss");
- Integer upi = (Integer) props.get("upis");
- Integer upl = (Integer) props.get("upls");
- Integer upd = (Integer) props.get("upds");
- Integer upf = (Integer) props.get("upfs");
- Integer upc = (Integer) props.get("upcs");
- Integer upbool = (Integer) props.get("upbools");
-
- assertEquals("Check upb", upb, new Integer(1));
- assertEquals("Check ups", ups, new Integer(1));
- assertEquals("Check upi", upi, new Integer(1));
- assertEquals("Check upl", upl, new Integer(1));
- assertEquals("Check upd", upd, new Integer(1));
- assertEquals("Check upf", upf, new Integer(1));
- assertEquals("Check upc", upc, new Integer(1));
- assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- upb = (Integer) props.get("upbs");
- ups = (Integer) props.get("upss");
- upi = (Integer) props.get("upis");
- upl = (Integer) props.get("upls");
- upd = (Integer) props.get("upds");
- upf = (Integer) props.get("upfs");
- upc = (Integer) props.get("upcs");
- upbool = (Integer) props.get("upbools");
-
- assertEquals("2) Check upb", upb, new Integer(2));
- assertEquals("2) Check ups", ups, new Integer(2));
- assertEquals("2) Check upi", upi, new Integer(2));
- assertEquals("2) Check upl", upl, new Integer(2));
- assertEquals("2) Check upd", upd, new Integer(2));
- assertEquals("2) Check upf", upf, new Integer(2));
- assertEquals("2) Check upc", upc, new Integer(2));
- assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArraysString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
- Integer upb = (Integer) props.get("upbs");
- Integer ups = (Integer) props.get("upss");
- Integer upi = (Integer) props.get("upis");
- Integer upl = (Integer) props.get("upls");
- Integer upd = (Integer) props.get("upds");
- Integer upf = (Integer) props.get("upfs");
- Integer upc = (Integer) props.get("upcs");
- Integer upbool = (Integer) props.get("upbools");
-
- assertEquals("Check upb", upb, new Integer(1));
- assertEquals("Check ups", ups, new Integer(1));
- assertEquals("Check upi", upi, new Integer(1));
- assertEquals("Check upl", upl, new Integer(1));
- assertEquals("Check upd", upd, new Integer(1));
- assertEquals("Check upf", upf, new Integer(1));
- assertEquals("Check upc", upc, new Integer(1));
- assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- upb = (Integer) props.get("upbs");
- ups = (Integer) props.get("upss");
- upi = (Integer) props.get("upis");
- upl = (Integer) props.get("upls");
- upd = (Integer) props.get("upds");
- upf = (Integer) props.get("upfs");
- upc = (Integer) props.get("upcs");
- upbool = (Integer) props.get("upbools");
-
- assertEquals("2) Check upb", upb, new Integer(2));
- assertEquals("2) Check ups", ups, new Integer(2));
- assertEquals("2) Check upi", upi, new Integer(2));
- assertEquals("2) Check upl", upl, new Integer(2));
- assertEquals("2) Check upd", upd, new Integer(2));
- assertEquals("2) Check upf", upf, new Integer(2));
- assertEquals("2) Check upc", upc, new Integer(2));
- assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationObj() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
- Integer upString = (Integer) props.get("upstring");
- Integer upStrings = (Integer) props.get("upstrings");
-
- assertEquals("Check upString", upString, new Integer(1));
- assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
- upString = (Integer) props.get("upstring");
- upStrings = (Integer) props.get("upstrings");
-
- assertEquals("2) Check upstring", upString, new Integer(2));
- assertEquals("2) Check upstrings", upStrings, new Integer(2));
- }
-
- public void testConfigurationObjString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
- Integer upString = (Integer) props.get("upstring");
- Integer upStrings = (Integer) props.get("upstrings");
-
- assertEquals("Check upString", upString, new Integer(1));
- assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
- upString = (Integer) props.get("upstring");
- upStrings = (Integer) props.get("upstrings");
-
- assertEquals("2) Check upstring", upString, new Integer(2));
- assertEquals("2) Check upstrings", upStrings, new Integer(2));
- }
-
- private void reconfigure(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", new Byte("2"));
- props2.put("s", new Short("2"));
- props2.put("i", new Integer("2"));
- props2.put("l", new Long("2"));
- props2.put("d", new Double("2"));
- props2.put("f", new Float("2"));
- props2.put("c", new Character('b'));
- props2.put("bool", new Boolean(false));
- props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
- props2.put("ss", new short[]{(short)3,(short)2,(short)1});
- props2.put("is", new int[]{3,2,1});
- props2.put("ls", new long[]{3,2,1});
- props2.put("ds", new double[]{3,2,1});
- props2.put("fs", new float[]{3,2,1});
- props2.put("cs", new char[]{'c','b','a'});
- props2.put("bools", new boolean[]{false,false,false});
- props2.put("string", "bar");
- props2.put("strings", new String[]{"baz", "bar", "foo"});
-
- ci.reconfigure(props2);
- }
-
- private void reconfigureString(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", "2");
- props2.put("s", "2");
- props2.put("i", "2");
- props2.put("l", "2");
- props2.put("d", "2");
- props2.put("f", "2");
- props2.put("c", "b");
- props2.put("bool", "false");
- props2.put("bs", "{3, 2,1}");
- props2.put("ss", "{3, 2,1}");
- props2.put("is", "{3, 2,1}");
- props2.put("ls", "{3, 2,1}");
- props2.put("ds", "{3, 2,1}");
- props2.put("fs", "{3, 2,1}");
- props2.put("cs", "{c, b , a}");
- props2.put("bools", "{false,false,false}");
- props2.put("string", "bar");
- props2.put("strings", "{baz, bar, foo}");
-
- ci.reconfigure(props2);
- }
-
- public void testConfigurationPrimitiveNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("0"));
- assertEquals("Check s", s, new Short("0"));
- assertEquals("Check i", i, new Integer("0"));
- assertEquals("Check l", l, new Long("0"));
- assertEquals("Check d", d, new Double("0"));
- assertEquals("Check f", f, new Float("0"));
- assertEquals("Check c", c, new Character((char) 0));
- assertEquals("Check bool", bool, new Boolean(false));
-
- Integer upb = (Integer) props.get("upb");
- Integer ups = (Integer) props.get("ups");
- Integer upi = (Integer) props.get("upi");
- Integer upl = (Integer) props.get("upl");
- Integer upd = (Integer) props.get("upd");
- Integer upf = (Integer) props.get("upf");
- Integer upc = (Integer) props.get("upc");
- Integer upbool = (Integer) props.get("upbool");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- upb = (Integer) props.get("upb");
- ups = (Integer) props.get("ups");
- upi = (Integer) props.get("upi");
- upl = (Integer) props.get("upl");
- upd = (Integer) props.get("upd");
- upf = (Integer) props.get("upf");
- upc = (Integer) props.get("upc");
- upbool = (Integer) props.get("upbool");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- //assertEquals("2) Check upbool", upbool, new Integer(1)); // TODO Why 0 ???
-
- }
-
- public void testConfigurationPrimitiveArraysNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertNull("Check b nullity", b);
- assertNull("Check s nullity", s);
- assertNull("Check i nullity", i);
- assertNull("Check l nullity", l);
- assertNull("Check d nullity", d);
- assertNull("Check f nullity", f);
- assertNull("Check c nullity", c);
- assertNull("Check bool nullity", bool);
-
- Integer upb = (Integer) props.get("upbs");
- Integer ups = (Integer) props.get("upss");
- Integer upi = (Integer) props.get("upis");
- Integer upl = (Integer) props.get("upls");
- Integer upd = (Integer) props.get("upds");
- Integer upf = (Integer) props.get("upfs");
- Integer upc = (Integer) props.get("upcs");
- Integer upbool = (Integer) props.get("upbools");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- upb = (Integer) props.get("upbs");
- ups = (Integer) props.get("upss");
- upi = (Integer) props.get("upis");
- upl = (Integer) props.get("upls");
- upd = (Integer) props.get("upds");
- upf = (Integer) props.get("upfs");
- upc = (Integer) props.get("upcs");
- upbool = (Integer) props.get("upbools");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- assertEquals("2) Check upbool", upbool, new Integer(1));
-
- }
-
- public void testConfigurationObjNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, null);
- assertEquals("Check strings", ss, null);
-
-
- Integer upString = (Integer) props.get("upstring");
- Integer upStrings = (Integer) props.get("upstrings");
-
- assertEquals("Check upString", upString, new Integer(0));
- assertEquals("Check upStrings", upStrings, new Integer(0));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
- upString = (Integer) props.get("upstring");
- upStrings = (Integer) props.get("upstrings");
-
- assertEquals("2) Check upstring", upString, new Integer(1));
- assertEquals("2) Check upstrings", upStrings, new Integer(1));
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestComplexProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestComplexProperties.java
deleted file mode 100644
index dc33f52..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestComplexProperties.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestComplexProperties extends OSGiTestCase {
-
- private ServiceReference m_ref;
- private CheckService m_check;
-
- public void setUp() {
- m_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "complex");
- assertNotNull("Complex service availability", m_ref);
- m_check = (CheckService) getContext().getService(m_ref);
- }
-
- public void tearDown() {
- m_check = null;
- getContext().ungetService(m_ref);
- }
-
- public void testArray() {
- String[] array = (String[]) m_check.getProps().get("array");
- assertEquals("Array size", 2, array.length);
- assertEquals("Array[0]", "a", array[0]);
- assertEquals("Array[1]", "b", array[1]);
- }
-
- public void testList() {
- List list = (List) m_check.getProps().get("list");
- assertEquals("List size", 2, list.size());
- assertEquals("List[0]", "a", list.get(0));
- assertEquals("List[1]", "b", list.get(1));
- }
-
- public void testMap() {
- Map map = (Map) m_check.getProps().get("map");
- assertEquals("Map size", 2, map.size());
- assertEquals("Map[a]", "a", map.get("a"));
- assertEquals("Map[b]", "b", map.get("b"));
- }
-
- public void testDictionary() {
- Dictionary dict = (Dictionary) m_check.getProps().get("dict");
- assertEquals("Map size", 2, dict.size());
- assertEquals("Map[a]", "a", dict.get("a"));
- assertEquals("Map[b]", "b", dict.get("b"));
- }
-
- public void testComplexArray() {
- Object[] array = (Object[]) m_check.getProps().get("complex-array");
- assertEquals("Array size", 2, array.length);
- assertTrue("Array[0] type", array[0] instanceof List);
- assertTrue("Array[1] type", array[1] instanceof List);
- List list = (List) array[0];
- assertEquals("List size", 2, list.size());
- assertEquals("List[0]", "a", list.get(0));
- assertEquals("List[1]", "b", list.get(1));
- list = (List) array[1];
- assertEquals("List size - 2", 2, list.size());
- assertEquals("List[0] - 2", "c", list.get(0));
- assertEquals("List[1] - 2", "d", list.get(1));
- }
-
- public void testComplexList() {
- List list = (List) m_check.getProps().get("complex-list");
- assertEquals("List size", 2, list.size());
- assertTrue("List[0] type", list.get(0) instanceof List);
- assertTrue("List[1] type", list.get(1) instanceof List);
- List list1 = (List) list.get(0);
- assertEquals("List size - 1", 2, list1.size());
- assertEquals("List[0] - 1", "a", list1.get(0));
- assertEquals("List[1] - 1", "b", list1.get(1));
- list1 = (List) list.get(1);
- assertEquals("List size - 2", 2, list1.size());
- assertEquals("List[0] - 2", "c", list1.get(0));
- assertEquals("List[1] - 2", "d", list1.get(1));
- }
-
- public void testComplexMap() {
- Map map = (Map) m_check.getProps().get("complex-map");
- assertEquals("List size", 2, map.size());
- assertTrue("List[0] type", map.get("a") instanceof List);
- assertTrue("List[1] type", map.get("b") instanceof List);
- List list = (List) map.get("a");
- assertEquals("List size - 1", 2, list.size());
- assertEquals("List[0] - 1", "a", list.get(0));
- assertEquals("List[1] - 1", "b", list.get(1));
- list = (List) map.get("b");
- assertEquals("List size - 2", 2, list.size());
- assertEquals("List[0] - 2", "c", list.get(0));
- assertEquals("List[1] - 2", "d", list.get(1));
- }
-
- public void testServiceArray() {
- String[] array = (String[]) m_ref.getProperty("array");
- assertEquals("Array size", 2, array.length);
- assertEquals("Array[0]", "a", array[0]);
- assertEquals("Array[1]", "b", array[1]);
- }
-
- public void testServiceList() {
- List list = (List) m_ref.getProperty("list");
- assertEquals("List size", 2, list.size());
- assertEquals("List[0]", "a", list.get(0));
- assertEquals("List[1]", "b", list.get(1));
- }
-
- public void testServiceMap() {
- Map map = (Map) m_ref.getProperty("map");
- assertEquals("Map size", 2, map.size());
- assertEquals("Map[a]", "a", map.get("a"));
- assertEquals("Map[b]", "b", map.get("b"));
- }
-
- public void testServiceDictionary() {
- Dictionary dict = (Dictionary) m_ref.getProperty("dict");
- assertEquals("Map size", 2, dict.size());
- assertEquals("Map[a]", "a", dict.get("a"));
- assertEquals("Map[b]", "b", dict.get("b"));
- }
-
- public void testServiceComplexArray() {
- Object[] array = (Object[]) m_ref.getProperty("complex-array");
- assertEquals("Array size", 2, array.length);
- assertTrue("Array[0] type", array[0] instanceof List);
- assertTrue("Array[1] type", array[1] instanceof List);
- List list = (List) array[0];
- assertEquals("List size", 2, list.size());
- assertEquals("List[0]", "a", list.get(0));
- assertEquals("List[1]", "b", list.get(1));
- list = (List) array[1];
- assertEquals("List size - 2", 2, list.size());
- assertEquals("List[0] - 2", "c", list.get(0));
- assertEquals("List[1] - 2", "d", list.get(1));
- }
-
- public void testServiceComplexList() {
- List list = (List) m_ref.getProperty("complex-list");
- assertEquals("List size", 2, list.size());
- assertTrue("List[0] type", list.get(0) instanceof List);
- assertTrue("List[1] type", list.get(1) instanceof List);
- List list1 = (List) list.get(0);
- assertEquals("List size - 1", 2, list1.size());
- assertEquals("List[0] - 1", "a", list1.get(0));
- assertEquals("List[1] - 1", "b", list1.get(1));
- list1 = (List) list.get(1);
- assertEquals("List size - 2", 2, list1.size());
- assertEquals("List[0] - 2", "c", list1.get(0));
- assertEquals("List[1] - 2", "d", list1.get(1));
- }
-
- public void testServiceComplexMap() {
- Map map = (Map) m_ref.getProperty("complex-map");
- assertEquals("List size", 2, map.size());
- assertTrue("List[0] type", map.get("a") instanceof List);
- assertTrue("List[1] type", map.get("b") instanceof List);
- List list = (List) map.get("a");
- assertEquals("List size - 1", 2, list.size());
- assertEquals("List[0] - 1", "a", list.get(0));
- assertEquals("List[1] - 1", "b", list.get(1));
- list = (List) map.get("b");
- assertEquals("List size - 2", 2, list.size());
- assertEquals("List[0] - 2", "c", list.get(0));
- assertEquals("List[1] - 2", "d", list.get(1));
- }
-
- public void testServiceEmptyArray() {
- String[] array = (String[]) m_ref.getProperty("empty-array");
- assertEquals("Array size", 0, array.length);
- }
-
- public void testServiceEmptyList() {
- List list = (List) m_ref.getProperty("empty-list");
- assertEquals("List size", 0, list.size());
- }
-
- public void testServiceEmptyMap() {
- Map map = (Map) m_ref.getProperty("empty-map");
- assertEquals("Map size", 0, map.size());
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java
deleted file mode 100644
index 0339b3f..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestFieldProperties extends OSGiTestCase {
-
- ComponentInstance instance;
- ComponentInstance instance2;
-
- public void setUp() {
- Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-FieldConfigurableCheckService");
- Properties props = new Properties();
- props.put("instance.name","under-test");
- props.put("b", "1");
- props.put("s", "1");
- props.put("i", "1");
- props.put("l", "1");
- props.put("d", "1");
- props.put("f", "1");
- props.put("c", "a");
- props.put("bool", "true");
- props.put("bs", "{1,2,3}");
- props.put("ss", "{1,2,3}");
- props.put("is", "{1,2,3}");
- props.put("ls", "{1,2,3}");
- props.put("ds", "{1,2,3}");
- props.put("fs", "{1,2,3}");
- props.put("cs", "{a,b,c}");
- props.put("bools", "{true,true,true}");
- props.put("string", "foo");
- props.put("strings", "{foo, bar, baz}");
-
- try {
- instance = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the under-test instance : " + e.getMessage());
- }
-
- try {
- instance2 = fact.createComponentInstance(null);
- } catch (Exception e) {
- e.printStackTrace();
- fail("Cannot create the instance : " + e.getMessage());
-
- }
-
-
-
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance = null;
- instance2 = null;
- }
-
- public void testConfigurationPrimitive() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- }
-
- public void testConfigurationPrimitiveNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("0"));
- assertEquals("Check s", s, new Short("0"));
- assertEquals("Check i", i, new Integer("0"));
- assertEquals("Check l", l, new Long("0"));
- assertEquals("Check d", d, new Double("0"));
- assertEquals("Check f", f, new Float("0"));
- assertEquals("Check c", c, new Character((char) 0));
- assertEquals("Check bool", bool, new Boolean(false));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- }
-
- public void testConfigurationPrimitiveString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- }
-
- public void testConfigurationPrimitiveStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("0"));
- assertEquals("Check s", s, new Short("0"));
- assertEquals("Check i", i, new Integer("0"));
- assertEquals("Check l", l, new Long("0"));
- assertEquals("Check d", d, new Double("0"));
- assertEquals("Check f", f, new Float("0"));
- assertEquals("Check c", c, new Character((char) 0));
- assertEquals("Check bool", bool, new Boolean(false));
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- }
-
- public void testConfigurationPrimitiveArrays() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- }
-
- public void testConfigurationPrimitiveArraysNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertNull("Check b nullity", b);
- assertNull("Check s nullity", s);
- assertNull("Check i nullity", i);
- assertNull("Check l nullity", l);
- assertNull("Check d nullity", d);
- assertNull("Check f nullity", f);
- assertNull("Check c nullity", c);
- assertNull("Check bool nullity", bool);
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- }
-
- public void testConfigurationPrimitiveArraysString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- }
-
- public void testConfigurationPrimitiveArraysStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertNull("Check b nullity", b);
- assertNull("Check s nullity", s);
- assertNull("Check i nullity", i);
- assertNull("Check l nullity", l);
- assertNull("Check d nullity", d);
- assertNull("Check f nullity", f);
- assertNull("Check c nullity", c);
- assertNull("Check bool nullity", bool);
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- }
-
- public void testConfigurationObj() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
- }
-
- public void testConfigurationObjNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, null);
- assertEquals("Check strings", ss, null);
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
- }
-
- public void testConfigurationObjString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
- }
-
- public void testConfigurationObjStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, null);
- assertEquals("Check strings", ss, null);
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
- }
-
- private void reconfigure(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", new Byte("2"));
- props2.put("s", new Short("2"));
- props2.put("i", new Integer("2"));
- props2.put("l", new Long("2"));
- props2.put("d", new Double("2"));
- props2.put("f", new Float("2"));
- props2.put("c", new Character('b'));
- props2.put("bool", new Boolean(false));
- props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
- props2.put("ss", new short[]{(short)3,(short)2,(short)1});
- props2.put("is", new int[]{3,2,1});
- props2.put("ls", new long[]{3,2,1});
- props2.put("ds", new double[]{3,2,1});
- props2.put("fs", new float[]{3,2,1});
- props2.put("cs", new char[]{'c','b','a'});
- props2.put("bools", new boolean[]{false,false,false});
- props2.put("string", "bar");
- props2.put("strings", new String[]{"baz", "bar", "foo"});
-
- ci.reconfigure(props2);
- }
-
- private void reconfigureString(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", "2");
- props2.put("s", "2");
- props2.put("i", "2");
- props2.put("l", "2");
- props2.put("d", "2");
- props2.put("f", "2");
- props2.put("c", "b");
- props2.put("bool", "false");
- props2.put("bs", "{3, 2,1}");
- props2.put("ss", "{3, 2,1}");
- props2.put("is", "{3, 2,1}");
- props2.put("ls", "{3, 2,1}");
- props2.put("ds", "{3, 2,1}");
- props2.put("fs", "{3, 2,1}");
- props2.put("cs", "{c, b , a}");
- props2.put("bools", "{false,false,false}");
- props2.put("string", "bar");
- props2.put("strings", "{baz, bar, foo}");
-
- ci.reconfigure(props2);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
deleted file mode 100644
index c4a6f8d..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
+++ /dev/null
@@ -1,1618 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestMethodProperties extends OSGiTestCase {
-
- ComponentInstance instance;
-
- ComponentInstance instance2;
-
- ComponentInstance instance3;
-
- public void setUp() {
- Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-MethodConfigurableCheckService");
- Properties props = new Properties();
- props.put("instance.name","under-test");
- props.put("b", "1");
- props.put("s", "1");
- props.put("i", "1");
- props.put("l", "1");
- props.put("d", "1");
- props.put("f", "1");
- props.put("c", "a");
- props.put("bool", "true");
- props.put("bs", "{1,2,3}");
- props.put("ss", "{1,2,3}");
- props.put("is", "{1,2,3}");
- props.put("ls", "{1,2,3}");
- props.put("ds", "{1,2,3}");
- props.put("fs", "{1,2,3}");
- props.put("cs", "{a,b,c}");
- props.put("bools", "{true,true,true}");
- props.put("string", "foo");
- props.put("strings", "{foo, bar, baz}");
-
- try {
- instance = fact.createComponentInstance(props);
- } catch(Exception e) {
- fail("Cannot create the under-test instance : " + e.getMessage());
- }
-
- Properties props2 = new Properties();
- props2.put("instance.name","under-test-2");
- props2.put("b", new Byte("1"));
- props2.put("s", new Short("1"));
- props2.put("i", new Integer("1"));
- props2.put("l", new Long("1"));
- props2.put("d", new Double("1"));
- props2.put("f", new Float("1"));
- props2.put("c", new Character('a'));
- props2.put("bool", new Boolean(true));
- props2.put("bs", new byte[] {1,2,3});
- props2.put("ss", new short[] {1,2,3});
- props2.put("is", new int[] {1,2,3});
- props2.put("ls", new long[] {1,2,3});
- props2.put("ds", new double[] {1,2,3});
- props2.put("fs", new float[] {1,2,3});
- props2.put("cs", new char[] {'a','b','c'});
- props2.put("bools", new boolean[] {true,true,true});
- props2.put("string", "foo");
- props2.put("strings", new String[] {"foo", "bar", "baz"});
-
- try {
- instance2 = fact.createComponentInstance(props2);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot create the under-test instance 2 : " + e.getMessage());
- }
-
- try {
- instance3 = fact.createComponentInstance(null);
- } catch(Exception e) {
- e.printStackTrace();
- fail("Cannot create the under-test instance 3 : " + e.getMessage());
- }
-
-
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance3.dispose();
- instance = null;
- instance2 = null;
- instance3 = null;
- }
-
- public void testConfigurationPrimitive() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-//
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArrays() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArraysString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationObj() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigure(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- public void testConfigurationObjString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigureString(instance);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- public void testConfigurationPrimitive2() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitive2String() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArrays2() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArrays2String() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationObj2() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigure(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- public void testConfigurationObj2String() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigureString(instance2);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- private void reconfigure(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", new Byte("2"));
- props2.put("s", new Short("2"));
- props2.put("i", new Integer("2"));
- props2.put("l", new Long("2"));
- props2.put("d", new Double("2"));
- props2.put("f", new Float("2"));
- props2.put("c", new Character('b'));
- props2.put("bool", new Boolean(false));
- props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
- props2.put("ss", new short[]{(short)3,(short)2,(short)1});
- props2.put("is", new int[]{3,2,1});
- props2.put("ls", new long[]{3,2,1});
- props2.put("ds", new double[]{3,2,1});
- props2.put("fs", new float[]{3,2,1});
- props2.put("cs", new char[]{'c','b','a'});
- props2.put("bools", new boolean[]{false,false,false});
- props2.put("string", "bar");
- props2.put("strings", new String[]{"baz", "bar", "foo"});
-
- ci.reconfigure(props2);
- }
-
- private void reconfigureString(ComponentInstance ci) {
- Properties props2 = new Properties();
- props2.put("b", "2");
- props2.put("s", "2");
- props2.put("i", "2");
- props2.put("l", "2");
- props2.put("d", "2");
- props2.put("f", "2");
- props2.put("c", "b");
- props2.put("bool", "false");
- props2.put("bs", "{3, 2,1}");
- props2.put("ss", "{3, 2,1}");
- props2.put("is", "{3, 2,1}");
- props2.put("ls", "{3, 2,1}");
- props2.put("ds", "{3, 2,1}");
- props2.put("fs", "{3, 2,1}");
- props2.put("cs", "{c, b , a}");
- props2.put("bools", "{false,false,false}");
- props2.put("string", "bar");
- props2.put("strings", "{baz, bar, foo}");
-
- ci.reconfigure(props2);
- }
-
- public void testConfigurationPrimitiveNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("0"));
- assertEquals("Check s", s, new Short("0"));
- assertEquals("Check i", i, new Integer("0"));
- assertEquals("Check l", l, new Long("0"));
- assertEquals("Check d", d, new Double("0"));
- assertEquals("Check f", f, new Float("0"));
- assertEquals("Check c", c, new Character((char) 0));
- assertEquals("Check bool", bool, new Boolean("false"));
-
- Integer upb = (Integer) props.get("upb");
- Integer ups = (Integer) props.get("ups");
- Integer upi = (Integer) props.get("upi");
- Integer upl = (Integer) props.get("upl");
- Integer upd = (Integer) props.get("upd");
- Integer upf = (Integer) props.get("upf");
- Integer upc = (Integer) props.get("upc");
- Integer upbool = (Integer) props.get("upbool");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
- reconfigure(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- upb = (Integer) props.get("upb");
- ups = (Integer) props.get("ups");
- upi = (Integer) props.get("upi");
- upl = (Integer) props.get("upl");
- upd = (Integer) props.get("upd");
- upf = (Integer) props.get("upf");
- upc = (Integer) props.get("upc");
- upbool = (Integer) props.get("upbool");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- assertEquals("2) Check upbool", upbool, new Integer(1));
-
- }
-
- public void testConfigurationPrimitiveStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("0"));
- assertEquals("Check s", s, new Short("0"));
- assertEquals("Check i", i, new Integer("0"));
- assertEquals("Check l", l, new Long("0"));
- assertEquals("Check d", d, new Double("0"));
- assertEquals("Check f", f, new Float("0"));
- assertEquals("Check c", c, new Character((char) 0));
- assertEquals("Check bool", bool, new Boolean("false"));
-
- Integer upb = (Integer) props.get("upb");
- Integer ups = (Integer) props.get("ups");
- Integer upi = (Integer) props.get("upi");
- Integer upl = (Integer) props.get("upl");
- Integer upd = (Integer) props.get("upd");
- Integer upf = (Integer) props.get("upf");
- Integer upc = (Integer) props.get("upc");
- Integer upbool = (Integer) props.get("upbool");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
- reconfigureString(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
- upb = (Integer) props.get("upb");
- ups = (Integer) props.get("ups");
- upi = (Integer) props.get("upi");
- upl = (Integer) props.get("upl");
- upd = (Integer) props.get("upd");
- upf = (Integer) props.get("upf");
- upc = (Integer) props.get("upc");
- upbool = (Integer) props.get("upbool");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- assertEquals("2) Check upbool", upbool, new Integer(1));
-
- }
-
- public void testConfigurationPrimitiveArraysNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertNull("Check b nullity", b);
- assertNull("Check s nullity", s);
- assertNull("Check i nullity", i);
- assertNull("Check l nullity", l);
- assertNull("Check d nullity", d);
- assertNull("Check f nullity", f);
- assertNull("Check c nullity", c);
- assertNull("Check bool nullity", bool);
-
- Integer upb = (Integer) props.get("upbs");
- Integer ups = (Integer) props.get("upss");
- Integer upi = (Integer) props.get("upis");
- Integer upl = (Integer) props.get("upls");
- Integer upd = (Integer) props.get("upds");
- Integer upf = (Integer) props.get("upfs");
- Integer upc = (Integer) props.get("upcs");
- Integer upbool = (Integer) props.get("upbools");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
- reconfigure(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- upb = (Integer) props.get("upbs");
- ups = (Integer) props.get("upss");
- upi = (Integer) props.get("upis");
- upl = (Integer) props.get("upls");
- upd = (Integer) props.get("upds");
- upf = (Integer) props.get("upfs");
- upc = (Integer) props.get("upcs");
- upbool = (Integer) props.get("upbools");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- assertEquals("2) Check upbool", upbool, new Integer(1));
-
- }
-
- public void testConfigurationPrimitiveArraysStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertNull("Check b nullity", b);
- assertNull("Check s nullity", s);
- assertNull("Check i nullity", i);
- assertNull("Check l nullity", l);
- assertNull("Check d nullity", d);
- assertNull("Check f nullity", f);
- assertNull("Check c nullity", c);
- assertNull("Check bool nullity", bool);
-
- Integer upb = (Integer) props.get("upbs");
- Integer ups = (Integer) props.get("upss");
- Integer upi = (Integer) props.get("upis");
- Integer upl = (Integer) props.get("upls");
- Integer upd = (Integer) props.get("upds");
- Integer upf = (Integer) props.get("upfs");
- Integer upc = (Integer) props.get("upcs");
- Integer upbool = (Integer) props.get("upbools");
-
- assertEquals("Check upb", upb, new Integer(0));
- assertEquals("Check ups", ups, new Integer(0));
- assertEquals("Check upi", upi, new Integer(0));
- assertEquals("Check upl", upl, new Integer(0));
- assertEquals("Check upd", upd, new Integer(0));
- assertEquals("Check upf", upf, new Integer(0));
- assertEquals("Check upc", upc, new Integer(0));
- assertEquals("Check upbool", upbool, new Integer(0));
-
-
- reconfigureString(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
- upb = (Integer) props.get("upbs");
- ups = (Integer) props.get("upss");
- upi = (Integer) props.get("upis");
- upl = (Integer) props.get("upls");
- upd = (Integer) props.get("upds");
- upf = (Integer) props.get("upfs");
- upc = (Integer) props.get("upcs");
- upbool = (Integer) props.get("upbools");
-
- assertEquals("2) Check upb", upb, new Integer(1));
- assertEquals("2) Check ups", ups, new Integer(1));
- assertEquals("2) Check upi", upi, new Integer(1));
- assertEquals("2) Check upl", upl, new Integer(1));
- assertEquals("2) Check upd", upd, new Integer(1));
- assertEquals("2) Check upf", upf, new Integer(1));
- assertEquals("2) Check upc", upc, new Integer(1));
- assertEquals("2) Check upbool", upbool, new Integer(1));
-
- }
-
- public void testConfigurationObjNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, null);
- assertEquals("Check strings", ss, null);
-
-
- Integer upString = (Integer) props.get("upstring");
- Integer upStrings = (Integer) props.get("upstrings");
-
- assertEquals("Check upString", upString, new Integer(0));
- assertEquals("Check upStrings", upStrings, new Integer(0));
-
- reconfigure(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
- upString = (Integer) props.get("upstring");
- upStrings = (Integer) props.get("upstrings");
-
- assertEquals("2) Check upString", upString, new Integer(1));
- assertEquals("2) Check upStrings", upStrings, new Integer(1));
- }
-
- public void testConfigurationObjStringNoValue() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, null);
- assertEquals("Check strings", ss, null);
-
-
- Integer upString = (Integer) props.get("upstring");
- Integer upStrings = (Integer) props.get("upstrings");
-
- assertEquals("Check upString", upString, new Integer(0));
- assertEquals("Check upStrings", upStrings, new Integer(0));
-
- reconfigureString(instance3);
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
- upString = (Integer) props.get("upstring");
- upStrings = (Integer) props.get("upstrings");
-
- assertEquals("2) Check upString", upString, new Integer(1));
- assertEquals("2) Check upStrings", upStrings, new Integer(1));
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestPropertyModifier.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestPropertyModifier.java
deleted file mode 100644
index 47ddc81..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestPropertyModifier.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestPropertyModifier extends OSGiTestCase {
-
- public void testPropertyModifier() {
- ComponentInstance ci = null;
- Factory factory = Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.PropertyModifier");
- Properties props = new Properties();
- props.put("cls", new String[] {FooService.class.getName()});
- try {
- ci = factory.createComponentInstance(props);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), ci.getInstanceName());
- assertNotNull("Check ref", ref);
-
- // Check the service property
- // Not exposed here:
- assertNull("Classes -0", ref.getProperty("classes"));
-
- CheckService check = (CheckService) getContext().getService(ref);
- assertTrue(check.check());
-
- // Property exposed now.
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), ci.getInstanceName());
- Class[] str = (Class[]) ref.getProperty("classes");
- assertEquals("Classes size", 1, str.length);
- assertEquals("Classes[0]", FooService.class.getName(), str[0].getName());
-
- Properties p = check.getProps();
- Class[] str2 = (Class[]) p.get("classes");
- assertEquals("Classes size -2", 1, str2.length);
- assertEquals("Classes[0] -2", FooService.class.getName(), str2[0].getName());
-
- Properties props2 = new Properties();
- props2.put("cls", new String[] {FooService.class.getName(), CheckService.class.getName()});
- try {
- ci.reconfigure(props2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- // Check the service property
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), ci.getInstanceName());
- assertNotNull("Check ref", ref);
- str = (Class[]) ref.getProperty("classes");
- assertEquals("Classes size -3", 2, str.length);
- assertEquals("Classes[0] -3", FooService.class.getName(), str[0].getName());
- assertEquals("Classes[1] -3", CheckService.class.getName(), str[1].getName());
-
-
- check = (CheckService) getContext().getService(ref);
- p = check.getProps();
- str2 = (Class[]) p.get("classes");
- assertEquals("Classes size -4", 2, str2.length);
- assertEquals("Classes[0] -4", FooService.class.getName(), str2[0].getName());
- assertEquals("Classes[1] -4", CheckService.class.getName(), str2[1].getName());
-
- ci.dispose();
- getContext().ungetService(ref);
-
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java
deleted file mode 100644
index fc5ce65..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TestSuperMethodProperties extends OSGiTestCase {
-
- ComponentInstance instance;
-
- public void setUp() {
- Factory fact = Utils.getFactoryByName(getContext(), "CONFIG-ParentMethodConfigurableCheckService");
- Properties props = new Properties();
- props.put("instance.name","under-test");
- props.put("b", "1");
- props.put("s", "1");
- props.put("i", "1");
- props.put("l", "1");
- props.put("d", "1");
- props.put("f", "1");
- props.put("c", "a");
- props.put("bool", "true");
- props.put("bs", "{1,2,3}");
- props.put("ss", "{1,2,3}");
- props.put("is", "{1,2,3}");
- props.put("ls", "{1,2,3}");
- props.put("ds", "{1,2,3}");
- props.put("fs", "{1,2,3}");
- props.put("cs", "{a,b,c}");
- props.put("bools", "{true,true,true}");
- props.put("string", "foo");
- props.put("strings", "{foo, bar, baz}");
-
- try {
- instance = fact.createComponentInstance(props);
- } catch (Exception e) {
- fail("Cannot create the under-test instance : " + e.getMessage());
- }
-
-
- }
-
- public void tearDown() {
- instance.dispose();
- instance = null;
- }
-
- public void testConfigurationPrimitive() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- Byte b = (Byte) props.get("b");
- Short s = (Short) props.get("s");
- Integer i = (Integer) props.get("i");
- Long l = (Long) props.get("l");
- Double d = (Double) props.get("d");
- Float f = (Float) props.get("f");
- Character c = (Character) props.get("c");
- Boolean bool = (Boolean) props.get("bool");
-
- assertEquals("Check b", b, new Byte("1"));
- assertEquals("Check s", s, new Short("1"));
- assertEquals("Check i", i, new Integer("1"));
- assertEquals("Check l", l, new Long("1"));
- assertEquals("Check d", d, new Double("1"));
- assertEquals("Check f", f, new Float("1"));
- assertEquals("Check c", c, new Character('a'));
- assertEquals("Check bool", bool, new Boolean("true"));
-
-// Integer upb = (Integer) props.get("upb");
-// Integer ups = (Integer) props.get("ups");
-// Integer upi = (Integer) props.get("upi");
-// Integer upl = (Integer) props.get("upl");
-// Integer upd = (Integer) props.get("upd");
-// Integer upf = (Integer) props.get("upf");
-// Integer upc = (Integer) props.get("upc");
-// Integer upbool = (Integer) props.get("upbool");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (Byte) props.get("b");
- s = (Short) props.get("s");
- i = (Integer) props.get("i");
- l = (Long) props.get("l");
- d = (Double) props.get("d");
- f = (Float) props.get("f");
- c = (Character) props.get("c");
- bool = (Boolean) props.get("bool");
-
- assertEquals("2) Check b ("+b+")", b, new Byte("2"));
- assertEquals("2) Check s", s, new Short("2"));
- assertEquals("2) Check i", i, new Integer("2"));
- assertEquals("2) Check l", l, new Long("2"));
- assertEquals("2) Check d", d, new Double("2"));
- assertEquals("2) Check f", f, new Float("2"));
- assertEquals("2) Check c", c, new Character('b'));
- assertEquals("2) Check bool", bool, new Boolean("false"));
-
-// upb = (Integer) props.get("upb");
-// ups = (Integer) props.get("ups");
-// upi = (Integer) props.get("upi");
-// upl = (Integer) props.get("upl");
-// upd = (Integer) props.get("upd");
-// upf = (Integer) props.get("upf");
-// upc = (Integer) props.get("upc");
-// upbool = (Integer) props.get("upbool");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArrays() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigure();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationPrimitiveArraysString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- byte[] b = (byte[]) props.get("bs");
- short[] s = (short[]) props.get("ss");
- int[] i = (int[]) props.get("is");
- long[] l = (long[]) props.get("ls");
- double[] d = (double[]) props.get("ds");
- float[] f = (float[]) props.get("fs");
- char[] c = (char[]) props.get("cs");
- boolean[] bool = (boolean[]) props.get("bools");
-
- assertEquals("Check b 0", b[0], 1);
- assertEquals("Check b 1", b[1], 2);
- assertEquals("Check b 2", b[2], 3);
- assertEquals("Check s 0", s[0], 1);
- assertEquals("Check s 1", s[1], 2);
- assertEquals("Check s 2", s[2], 3);
- assertEquals("Check i 0", i[0], 1);
- assertEquals("Check i 1", i[1], 2);
- assertEquals("Check i 2", i[2], 3);
- assertEquals("Check l 0", l[0], 1);
- assertEquals("Check l 1", l[1], 2);
- assertEquals("Check l 2", l[2], 3);
- assertEquals("Check d 0", d[0], 1);
- assertEquals("Check d 1", d[1], 2);
- assertEquals("Check d 2", d[2], 3);
- assertEquals("Check f 0", f[0], 1);
- assertEquals("Check f 1", f[1], 2);
- assertEquals("Check f 2", f[2], 3);
- assertEquals("Check c 0", c[0], 'a');
- assertEquals("Check c 1", c[1], 'b');
- assertEquals("Check c 2", c[2], 'c');
- assertTrue("Check bool 0", bool[0]);
- assertTrue("Check bool 1", bool[0]);
- assertTrue("Check bool 2", bool[0]);
-
-// Integer upb = (Integer) props.get("upbs");
-// Integer ups = (Integer) props.get("upss");
-// Integer upi = (Integer) props.get("upis");
-// Integer upl = (Integer) props.get("upls");
-// Integer upd = (Integer) props.get("upds");
-// Integer upf = (Integer) props.get("upfs");
-// Integer upc = (Integer) props.get("upcs");
-// Integer upbool = (Integer) props.get("upbools");
-//
-// assertEquals("Check upb", upb, new Integer(1));
-// assertEquals("Check ups", ups, new Integer(1));
-// assertEquals("Check upi", upi, new Integer(1));
-// assertEquals("Check upl", upl, new Integer(1));
-// assertEquals("Check upd", upd, new Integer(1));
-// assertEquals("Check upf", upf, new Integer(1));
-// assertEquals("Check upc", upc, new Integer(1));
-// assertEquals("Check upbool", upbool, new Integer(1));
-
- reconfigureString();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- b = (byte[]) props.get("bs");
- s = (short[]) props.get("ss");
- i = (int[]) props.get("is");
- l = (long[]) props.get("ls");
- d = (double[]) props.get("ds");
- f = (float[]) props.get("fs");
- c = (char[]) props.get("cs");
- bool = (boolean[]) props.get("bools");
-
- assertEquals("2) Check b 0", b[0], 3);
- assertEquals("2) Check b 1", b[1], 2);
- assertEquals("2) Check b 2", b[2], 1);
- assertEquals("2) Check s 0", s[0], 3);
- assertEquals("2) Check s 1", s[1], 2);
- assertEquals("2) Check s 2", s[2], 1);
- assertEquals("2) Check i 0", i[0], 3);
- assertEquals("2) Check i 1", i[1], 2);
- assertEquals("2) Check i 2", i[2], 1);
- assertEquals("2) Check l 0", l[0], 3);
- assertEquals("2) Check l 1", l[1], 2);
- assertEquals("2) Check l 2", l[2], 1);
- assertEquals("2) Check d 0", d[0], 3);
- assertEquals("2) Check d 1", d[1], 2);
- assertEquals("2) Check d 2", d[2], 1);
- assertEquals("2) Check f 0", f[0], 3);
- assertEquals("2) Check f 1", f[1], 2);
- assertEquals("2) Check f 2", f[2], 1);
- assertEquals("2) Check c 0", c[0], 'c');
- assertEquals("2) Check c 1", c[1], 'b');
- assertEquals("2) Check c 2", c[2], 'a');
- assertFalse("2) Check bool 0", bool[0]);
- assertFalse("2) Check bool 1", bool[0]);
- assertFalse("2) Check bool 2", bool[0]);
-
-// upb = (Integer) props.get("upbs");
-// ups = (Integer) props.get("upss");
-// upi = (Integer) props.get("upis");
-// upl = (Integer) props.get("upls");
-// upd = (Integer) props.get("upds");
-// upf = (Integer) props.get("upfs");
-// upc = (Integer) props.get("upcs");
-// upbool = (Integer) props.get("upbools");
-//
-// assertEquals("2) Check upb", upb, new Integer(2));
-// assertEquals("2) Check ups", ups, new Integer(2));
-// assertEquals("2) Check upi", upi, new Integer(2));
-// assertEquals("2) Check upl", upl, new Integer(2));
-// assertEquals("2) Check upd", upd, new Integer(2));
-// assertEquals("2) Check upf", upf, new Integer(2));
-// assertEquals("2) Check upc", upc, new Integer(2));
-// assertEquals("2) Check upbool", upbool, new Integer(2));
-
- }
-
- public void testConfigurationObj() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigure();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- public void testConfigurationObjString() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- CheckService check = (CheckService) getContext().getService(ref);
- Properties props = check.getProps();
-
- String s = (String) props.get("string");
- String[] ss = (String[]) props.get("strings");
-
- assertEquals("Check string", s, "foo");
- assertEquals("Check strings 0", ss[0], "foo");
- assertEquals("Check strings 1", ss[1], "bar");
- assertEquals("Check strings 2", ss[2], "baz");
-
-// Integer upString = (Integer) props.get("upstring");
-// Integer upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("Check upString", upString, new Integer(1));
-// assertEquals("Check upStrings", upStrings, new Integer(1));
-
- reconfigureString();
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Test check service availability", ref);
- check = (CheckService) getContext().getService(ref);
- props = check.getProps();
-
- s = (String) props.get("string");
- ss = (String[]) props.get("strings");
-
- assertEquals("2) Check string", s, "bar");
- assertEquals("2) Check strings 0", ss[0], "baz");
- assertEquals("2) Check strings 1", ss[1], "bar");
- assertEquals("2) Check strings 2", ss[2], "foo");
-
-// upString = (Integer) props.get("upstring");
-// upStrings = (Integer) props.get("upstrings");
-//
-// assertEquals("2) Check upString", upString, new Integer(2));
-// assertEquals("2) Check upStrings", upStrings, new Integer(2));
- }
-
- private void reconfigure() {
- Properties props2 = new Properties();
- props2.put("instance.name","under-test");
- props2.put("b", new Byte("2"));
- props2.put("s", new Short("2"));
- props2.put("i", new Integer("2"));
- props2.put("l", new Long("2"));
- props2.put("d", new Double("2"));
- props2.put("f", new Float("2"));
- props2.put("c", new Character('b'));
- props2.put("bool", new Boolean(false));
- props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
- props2.put("ss", new short[]{(short)3,(short)2,(short)1});
- props2.put("is", new int[]{3,2,1});
- props2.put("ls", new long[]{3,2,1});
- props2.put("ds", new double[]{3,2,1});
- props2.put("fs", new float[]{3,2,1});
- props2.put("cs", new char[]{'c','b','a'});
- props2.put("bools", new boolean[]{false,false,false});
- props2.put("string", "bar");
- props2.put("strings", new String[]{"baz", "bar", "foo"});
-
- instance.reconfigure(props2);
- }
-
- private void reconfigureString() {
- Properties props2 = new Properties();
- props2.put("instance.name","under-test");
- props2.put("b", "2");
- props2.put("s", "2");
- props2.put("i", "2");
- props2.put("l", "2");
- props2.put("d", "2");
- props2.put("f", "2");
- props2.put("c", "b");
- props2.put("bool", "false");
- props2.put("bs", "{3, 2,1}");
- props2.put("ss", "{3, 2,1}");
- props2.put("is", "{3, 2,1}");
- props2.put("ls", "{3, 2,1}");
- props2.put("ds", "{3, 2,1}");
- props2.put("fs", "{3, 2,1}");
- props2.put("cs", "{c, b , a}");
- props2.put("bools", "{false,false,false}");
- props2.put("string", "bar");
- props2.put("strings", "{baz, bar, foo}");
-
- instance.reconfigure(props2);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethod.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethod.java
deleted file mode 100644
index a204deb..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethod.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class UpdatedMethod extends OSGiTestCase {
-
- ComponentInstance fooProvider1;
- ComponentInstance fooProvider2;
- ComponentInstance fooProvider3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-ConfUpdated";
-
- Properties p1 = new Properties();
- p1.put("instance.name","FooProvider-1");
- fooProvider1 = Utils.getComponentInstance(getContext(), type, p1);
-
- Properties p2 = new Properties();
- p2.put("instance.name","FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("boolean", new Boolean(false));
- p2.put("string", new String("bar"));
- p2.put("strAProp", new String[] {"bar", "foo"});
- p2.put("intAProp", new int[] {1, 2, 3});
- fooProvider2 = Utils.getComponentInstance(getContext(), type, p2);
-
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- fooProvider3 = Utils.getComponentInstance(getContext(), "CONFIG-FooProviderType-ConfNoValueUpdated", p3);
- }
-
- public void tearDown() {
- fooProvider1.dispose();
- fooProvider2.dispose();
- fooProvider3.dispose();
- fooProvider1 = null;
- fooProvider2 = null;
- fooProvider3 = null;
- }
-
- public void testComponentTypeConfiguration() {
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check FooService availability", ref);
- FooService fs = (FooService) getContext().getService(ref);
- Properties toCheck = fs.fooProps();
-
- Integer intProp = (Integer) toCheck.get("intProp");
- Boolean boolProp = (Boolean) toCheck.get("boolProp");
- String strProp = (String) toCheck.get("strProp");
- String[] strAProp = (String[]) toCheck.get("strAProp");
- int[] intAProp = (int[]) toCheck.get("intAProp");
-
- // Check updated
- Integer updated = (Integer) toCheck.get("updated");
- Dictionary dict = (Dictionary) toCheck.get("lastupdated");
-
- assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity (1)", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1) : " + strAProp[i] + " != " + v[i]); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1) : " + intAProp[i] + " != " + v2[i]); }
- }
-
- assertEquals("updated count ", 1, updated.intValue());
- assertEquals("Last updated", 5, dict.size());
-
- // change the field value
- assertTrue("Invoke the fs service", fs.foo());
- toCheck = fs.fooProps();
-
-
- // Re-check the property (change)
- intProp = (Integer) toCheck.get("intProp");
- boolProp = (Boolean) toCheck.get("boolProp");
- strProp = (String) toCheck.get("strProp");
- strAProp = (String[]) toCheck.get("strAProp");
- intAProp = (int[]) toCheck.get("intAProp");
-
- // Check updated
- updated = (Integer) toCheck.get("updated");
- dict = (Dictionary) toCheck.get("lastupdated");
-
- assertEquals("Check intProp equality (2) ("+intProp+")", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity (2)", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
- }
- assertNotNull("Check intAProp not nullity (2)", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2) : " + intAProp[i] + " != " + v2[i]); }
- }
-
- // This does not reconfigure...
- assertEquals("updated count -2 ", 1, updated.intValue());
- assertEquals("Last update - 2", 5, dict.size());
-
- fs = null;
- getContext().ungetService(ref);
- }
-
- public void testNoValue() {
- ServiceReference sr = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- FooService fs = (FooService) getContext().getService(sr);
- Properties toCheck = fs.fooProps();
-
- // Check service properties
- Integer intProp = (Integer) toCheck.get("intProp");
- Boolean boolProp = (Boolean) toCheck.get("boolProp");
- String strProp = (String) toCheck.get("strProp");
- String[] strAProp = (String[]) toCheck.get("strAProp");
- int[] intAProp = (int[]) toCheck.get("intAProp");
-
- // Check updated
- Integer updated = (Integer) toCheck.get("updated");
- Dictionary dict = (Dictionary) toCheck.get("lastupdated");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(false));
- assertEquals("Check strProp equality", strProp, null);
- assertNull("Check strAProp nullity", strAProp);
- assertNull("Check intAProp nullity", intAProp);
-
- assertEquals("updated count ", 1, updated.intValue());
- assertEquals("Last update", 0, dict.size());
-
- assertTrue("invoke fs", fs.foo());
- toCheck = fs.fooProps();
-
- // Re-check the property (change)
- intProp = (Integer) toCheck.get("intProp");
- boolProp = (Boolean) toCheck.get("boolProp");
- strProp = (String) toCheck.get("strProp");
- strAProp = (String[]) toCheck.get("strAProp");
- intAProp = (int[]) toCheck.get("intAProp");
-
- updated = (Integer) toCheck.get("updated");
- dict = (Dictionary) toCheck.get("lastupdated");
-
- assertEquals("Check intProp equality", intProp, new Integer(3));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fs = null;
- getContext().ungetService(sr);
- }
-
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedService.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedService.java
deleted file mode 100644
index 0c78e26..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedService.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-
-public class UpdatedMethodAndManagedService extends OSGiTestCase {
-
- /**
- * Instance where the ManagedServicePID is provided by the component type.
- */
- ComponentInstance instance1;
- /**
- * Instance where the ManagedServicePID is provided by the instance.
- */
- ComponentInstance instance2;
-
- /**
- * Instance without configuration.
- */
- ComponentInstance instance3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-4Updated";
- Properties p = new Properties();
- p.put("instance.name","instance");
- p.put("foo", "foo");
- p.put("bar", "2");
- p.put("baz", "baz");
- instance1 = Utils.getComponentInstance(getContext(), type, p);
- assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
-
- type = "CONFIG-FooProviderType-3Updated";
- Properties p1 = new Properties();
- p1.put("instance.name","instance-2");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- p1.put("managed.service.pid", "instance");
- instance2 = Utils.getComponentInstance(getContext(), type, p1);
-
- type = "CONFIG-FooProviderType-3Updated";
- Properties p2 = new Properties();
- p2.put("instance.name","instance-3");
- p2.put("managed.service.pid", "instance-3");
- instance3 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- }
-
- public void testStaticInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- context.ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testStaticInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedService availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
- dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated -1", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
- dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
-
- }
-
- public void testDynamicInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
- dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedServiceFactory.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedServiceFactory.java
deleted file mode 100644
index f9289c7..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedMethodAndManagedServiceFactory.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class UpdatedMethodAndManagedServiceFactory extends OSGiTestCase {
-
- ComponentInstance instance, instance2;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-3Updated";
-
- Properties p1 = new Properties();
- p1.put("instance.name","instance");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- instance = Utils.getComponentInstance(getContext(), type, p1);
-
- Properties p2 = new Properties();
- p2.put("instance.name","instance2");
-
- instance2 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance2 = null;
- instance = null;
- }
-
- public void testStatic() {
-
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- System.out.println("Dictionary : " + dict);
- assertEquals("Check last updated", 3, dict.size()); // foo bar and baz as a service prooperties.
-
- getContext().ungetService(msRef);
-
- }
-
- public void testStaticNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- getContext().ungetService(msRef);
- }
-
- public void testDynamic() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
-
- public void testDynamicString() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", "0");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
- Dictionary dict = (Dictionary) fs.fooProps().get("lastupdated");
-
- assertEquals("Check updated", 1, updated.intValue());
- assertEquals("Check last updated", 3, dict.size());
-
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedService.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedService.java
deleted file mode 100644
index c44236b..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedService.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
-
-public class UpdatedNoArgMethodAndManagedService extends OSGiTestCase {
-
- /**
- * Instance where the ManagedServicePID is provided by the component type.
- */
- ComponentInstance instance1;
- /**
- * Instance where the ManagedServicePID is provided by the instance.
- */
- ComponentInstance instance2;
-
- /**
- * Instance without configuration.
- */
- ComponentInstance instance3;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-4Updated2";
- Properties p = new Properties();
- p.put("instance.name","instance");
- p.put("foo", "foo");
- p.put("bar", "2");
- p.put("baz", "baz");
- instance1 = Utils.getComponentInstance(getContext(), type, p);
- assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
-
- type = "CONFIG-FooProviderType-3Updated2";
- Properties p1 = new Properties();
- p1.put("instance.name","instance-2");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- p1.put("managed.service.pid", "instance");
- instance2 = Utils.getComponentInstance(getContext(), type, p1);
-
- type = "CONFIG-FooProviderType-3Updated2";
- Properties p2 = new Properties();
- p2.put("instance.name","instance-3");
- p2.put("managed.service.pid", "instance-3");
- instance3 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- }
-
- public void testStaticInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
- assertEquals("Check updated", 1, updated.intValue());
-
- context.ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testStaticInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedService availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicInstance1() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Re-check props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated -1", 1, updated.intValue());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
-
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
-
- }
-
- public void testDynamicInstance2() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedService ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- conf.put("baz", "zab2");
- conf.put("foo", "oof2");
- conf.put("bar", new Integer(0));
- ms = (ManagedService) getContext().getService(msRef);
- try {
- ms.updated(conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated -2", 2, updated.intValue());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedServiceFactory.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedServiceFactory.java
deleted file mode 100644
index 5067b93..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/UpdatedNoArgMethodAndManagedServiceFactory.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class UpdatedNoArgMethodAndManagedServiceFactory extends OSGiTestCase {
-
- ComponentInstance instance, instance2;
-
- public void setUp() {
- String type = "CONFIG-FooProviderType-3Updated2";
-
- Properties p1 = new Properties();
- p1.put("instance.name","instance");
- p1.put("foo", "foo");
- p1.put("bar", "2");
- p1.put("baz", "baz");
- instance = Utils.getComponentInstance(getContext(), type, p1);
-
- Properties p2 = new Properties();
- p2.put("instance.name","instance2");
-
- instance2 = Utils.getComponentInstance(getContext(), type, p2);
- }
-
- public void tearDown() {
- instance.dispose();
- instance2.dispose();
- instance2 = null;
- instance = null;
- }
-
- public void testStatic() {
-
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, "foo");
- assertEquals("Check bar equality -1", barP, new Integer(2));
- assertEquals("Check baz equality -1", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- getContext().ungetService(msRef);
-
- }
-
- public void testStaticNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("bar", new Integer(2));
- conf.put("foo", "foo");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
- assertEquals("Check foo equality -2", fooP, "foo");
- assertEquals("Check bar equality -2", barP, new Integer(2));
- assertEquals("Check baz equality -2", bazP, "zab");
-
- // Get Service
- FooService fs = (FooService) context.getService(fooRef);
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- getContext().ungetService(msRef);
- }
-
- public void testDynamic() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
- public void testDynamicNoValue() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- Object fooP = fooRef.getProperty("foo");
- Object barP = fooRef.getProperty("bar");
- Object bazP = fooRef.getProperty("baz");
- assertEquals("Check foo equality -1", fooP, null);
- assertEquals("Check bar equality -1", barP, null);
- assertEquals("Check baz equality -1", bazP, null);
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance2.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", new Integer(0));
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance2.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
-
- public void testDynamicString() {
- ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- assertNotNull("Check FS availability", fooRef);
-
- String fooP = (String) fooRef.getProperty("foo");
- Integer barP = (Integer) fooRef.getProperty("bar");
- String bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "foo");
- assertEquals("Check bar equality", barP, new Integer(2));
- assertEquals("Check baz equality", bazP, "baz");
-
- ServiceReference msRef = Utils.getServiceReferenceByName(getContext(), ManagedServiceFactory.class.getName(), instance.getFactory().getName());
- assertNotNull("Check ManagedServiceFactory availability", msRef);
-
- // Configuration of baz
- Properties conf = new Properties();
- conf.put("baz", "zab");
- conf.put("foo", "oof");
- conf.put("bar", "0");
- ManagedServiceFactory ms = (ManagedServiceFactory) getContext().getService(msRef);
- try {
- ms.updated(instance.getInstanceName(), conf);
- } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
- // Recheck props
- fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance.getInstanceName());
- fooP = (String) fooRef.getProperty("foo");
- barP = (Integer) fooRef.getProperty("bar");
- bazP = (String) fooRef.getProperty("baz");
-
- assertEquals("Check foo equality", fooP, "oof");
- assertEquals("Check bar equality", barP, new Integer(0));
- assertEquals("Check baz equality", bazP, "zab");
-
- // Check field value
- FooService fs = (FooService) getContext().getService(fooRef);
- Properties p = fs.fooProps();
- fooP = (String) p.get("foo");
- barP = (Integer) p.get("bar");
-
- assertEquals("Check foo field equality", fooP, "oof");
- assertEquals("Check bar field equality", barP, new Integer(0));
-
- Integer updated = (Integer) fs.fooProps().get("updated");
-
- assertEquals("Check updated", 1, updated.intValue());
-
- getContext().ungetService(fooRef);
- getContext().ungetService(msRef);
- }
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java
deleted file mode 100644
index e8f89b9..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java
deleted file mode 100644
index 7f6a005..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.configuration.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index ca53df4..0000000
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-//import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
-
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
-
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/pom.xml b/ipojo/tests/core/external-handlers/pom.xml
deleted file mode 100644
index 1031e23..0000000
--- a/ipojo/tests/core/external-handlers/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO External Handler Mechanism Test Suite</name>
- <artifactId>tests.core.external.handlers</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.eh.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.eh.ExternalHandlerTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java
deleted file mode 100644
index 7bdcfb0..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.architecture.PropertyDescription;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.scenarios.eh.service.CheckService;
-import org.osgi.framework.ServiceRegistration;
-
-public class CheckServiceHandler extends PrimitiveHandler implements CheckService {
-
- ServiceRegistration sr;
- boolean isValid;
- int changes = 0;
- static final String NAMESPACE = "org.apache.felix.ipojo.test.handler.checkservice";
-
- Properties props = new Properties();
-
- public void configure(Element metadata, Dictionary configuration) {
- Element[] meta = metadata.getElements("check", NAMESPACE);
- if(meta == null) { return; }
- // Get handler props
- props.put("instance.name", configuration.get("instance.name"));
- if(configuration.get("csh.simple") != null) { props.put("Simple", configuration.get("csh.simple")); }
- if(configuration.get("csh.map") != null) {
- Dictionary m = (Dictionary) configuration.get("csh.map");
- if (m.size() > 0) {
- props.put("Map1", m.get("a"));
- props.put("Map2", m.get("b"));
- props.put("Map3", m.get("c"));
- }
- }
- props.put("changes", new Integer(changes));
-
- }
-
- public void initializeComponentFactory(ComponentTypeDescription cd, Element metadata) {
- cd.addProperty(new PropertyDescription("csh.simple", "java.lang.String", null));
- cd.addProperty(new PropertyDescription("csh.map", "java.util.Dictionary", null));
- }
-
- public void start() {
- if(sr == null) {
- sr = getInstanceManager().getContext().registerService(CheckService.class.getName(), this, props);
- }
- isValid = true;
- }
-
- public void stop() {
- isValid = false;
- synchronized(this) {
- if(sr != null) { sr.unregister(); }
- }
- }
-
- public boolean check() {
- if(isValid) { isValid = false;}
- else { isValid = true; }
- return isValid;
- }
-
- public Properties getProps() {
- return props;
- }
-
- public void stateChanged(int state) {
- if (sr != null) {
- changes++;
- props.put("changes", new Integer(changes));
- sr.setProperties(props);
- }
- }
-
- public String getName() {
- return NAMESPACE;
- }
-
- public HandlerDescription getDescription() {
- return new CheckServiceHandlerDescription(this);
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java
deleted file mode 100644
index ade2474..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class CheckServiceHandlerDescription extends HandlerDescription {
-
- public CheckServiceHandlerDescription(Handler h) {
- super(h);
- }
-
- public Element getHandlerInfo() {
- Element elem = super.getHandlerInfo();
- elem.addAttribute(new Attribute("isValid", isValid()+""));
- return elem;
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index b82cf3c..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.eh.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/AutoHandlerTest.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/AutoHandlerTest.java
deleted file mode 100644
index 4445cb8..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/AutoHandlerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.eh;
-
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.component.CheckServiceHandlerDescription;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-
-public class AutoHandlerTest extends OSGiTestCase {
-
- private static final String ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE = "org.apache.felix.ipojo.handler.auto.primitive";
-
- ComponentInstance instance;
-
- ComponentFactory factory;
-
- public void setUp() {
- factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "HANDLER-HandlerTesterWO");
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, "");
- }
-
- public void tearDown() {
- if (instance != null) {
- instance.dispose();
- }
- instance = null;
-
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, "");
-
- }
-
- public void testRequiredHandlerList() {
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, "");
-
- factory.stop();
- factory.restart();
- factory.start();
-
- List list = factory.getRequiredHandlers();
- assertFalse(list.contains("org.apache.felix.ipojo.test.handler.checkservice:check"));
-
- String v = "org.apache.felix.ipojo.test.handler.checkservice:check";
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, v);
-
- factory.stop();
- factory.restart();
- factory.start();
-
- list = factory.getRequiredHandlers();
- assertTrue(list.contains("org.apache.felix.ipojo.test.handler.checkservice:check"));
-
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, "");
-
- }
-
- public void testInstanceCreation() throws Exception {
- String v = "org.apache.felix.ipojo.test.handler.checkservice:check";
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, v);
-
- factory.stop();
- factory.restart();
- factory.start();
-
- instance = factory.createComponentInstance(new Properties());
- assertEquals(ComponentInstance.VALID, instance.getState());
-
- HandlerDescription hd = instance.getInstanceDescription().getHandlerDescription(v);
- assertNotNull(hd);
- assertTrue(hd instanceof CheckServiceHandlerDescription);
-
- System.setProperty(ORG_APACHE_FELIX_IPOJO_HANDLER_AUTO_PRIMITIVE, "");
-
- factory.stop();
- factory.restart();
- factory.start();
- }
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java
deleted file mode 100644
index 4f66028..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.eh;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ExternalHandlerTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("External Handler Test Suite", bc);
- ots.addTestSuite(HandlerTest.class);
- ots.addTestSuite(AutoHandlerTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
deleted file mode 100644
index 1e89772..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.eh;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.eh.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class HandlerTest extends OSGiTestCase {
-
- ComponentInstance instance;
-
- public void setUp() {
- Properties props = new Properties();
- props.put("instance.name","HandlerTest-1");
- props.put("csh.simple", "simple");
- Properties p = new Properties();
- p.put("a", "a");
- p.put("b", "b");
- p.put("c", "c");
- props.put("csh.map", p);
- instance = Utils.getComponentInstance(getContext(), "HANDLER-HandlerTester", props);
- }
-
- public void tearDown() {
- instance.dispose();
- instance = null;
- }
-
- public void testConfiguration1() {
- // Check the availability of CheckService
- String name = "HandlerTest-1";
- ServiceReference sr = null;
- ServiceReference[] refs = null;
- String filter = "("+"instance.name"+"="+name+")";
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), filter);
- } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
- if(refs != null) { sr = refs[0]; }
-
- assertNotNull("Check the check service availability", sr);
-
- CheckService cs = (CheckService) getContext().getService(sr);
- Properties p = cs.getProps();
- assertEquals("Assert 'simple' equality", p.get("Simple"), "simple");
- assertEquals("Assert 'a' equality", p.get("Map1"), "a");
- assertEquals("Assert 'b' equality", p.get("Map2"), "b");
- assertEquals("Assert 'c' equality", p.get("Map3"), "c");
-
- cs = null;
- getContext().ungetService(sr);
- }
-
- public void testConfiguration2() {
- // Check the availability of CheckService
- String name = "HandlerTest-2";
- ServiceReference sr = null;
- ServiceReference[] refs = null;
- String filter = "("+"instance.name"+"="+name+")";
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), filter);
- } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
- if(refs != null) { sr = refs[0]; }
- assertNotNull("Check the check service availability", sr);
-
- CheckService cs = (CheckService) getContext().getService(sr);
- Properties p = cs.getProps();
- assertEquals("Assert 'simple' equality", p.get("Simple"), "Simple");
- assertEquals("Assert 'a' equality", p.get("Map1"), "a");
- assertEquals("Assert 'b' equality", p.get("Map2"), "b");
- assertEquals("Assert 'c' equality", p.get("Map3"), "c");
-
- cs = null;
- getContext().ungetService(sr);
- }
-
-
- public void testConfiguration3() {
- // Check the availability of CheckService
- String name = "HandlerTest-2-empty";
- ServiceReference sr = null;
- ServiceReference[] refs = null;
- String filter = "("+"instance.name"+"="+name+")";
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), filter);
- } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
- if(refs != null) { sr = refs[0]; }
- assertNotNull("Check the check service availability", sr);
-
- CheckService cs = (CheckService) getContext().getService(sr);
- Properties p = cs.getProps();
- assertEquals("Assert 'simple' equality", p.get("Simple"), "Simple");
- assertEquals("Size of p", 3, p.size()); // instance name, simple and changes.
-
- cs = null;
- getContext().ungetService(sr);
- }
-
- public void testLifecycle() {
- // Check the availability of CheckService
- String name = "HandlerTest-1";
- ServiceReference sr = null;
- ServiceReference[] refs = null;
- String filter = "("+"instance.name"+"="+name+")";
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), filter);
- } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
- if(refs != null) { sr = refs[0]; }
- assertNotNull("Check the check service availability", sr);
-
- ServiceReference sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
- Architecture arch = (Architecture) getContext().getService(sr_arch);
-
- assertEquals("Check instance validity - 0", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
-
- CheckService cs = (CheckService) getContext().getService(sr);
- Properties p = cs.getProps();
- Integer changes = (Integer) p.get("changes");
- assertNotNull("Check changes no null", changes);
- assertEquals("Changes changes 1 ("+changes+")", changes.intValue(), 1);
- assertEquals("Check instance validity - 1", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
- cs.check();
- p = cs.getProps();
- changes = (Integer) p.get("changes");
- assertEquals("Changes changes 2 ("+changes+")", changes.intValue(), 2);
- assertEquals("Check instance validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
- cs.check();
- p = cs.getProps();
- changes = (Integer) p.get("changes");
- assertEquals("Changes changes 3 ("+changes+")", changes.intValue(), 3);
- assertEquals("Check instance validity - 3", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
- cs.check();
- p = cs.getProps();
- changes = (Integer) p.get("changes");
- assertEquals("Changes changes 4 ("+changes+")", changes.intValue(), 4);
- assertEquals("Check instance validity - 4", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
-
- cs = null;
- arch = null;
- getContext().ungetService(sr_arch);
- getContext().ungetService(sr);
- }
-
- public void testAvailability() {
- String name = "HandlerTest-1";
- ServiceReference sr = null;
- ServiceReference[] refs = null;
- String filter = "("+"instance.name"+"="+name+")";
- try {
- refs = getContext().getServiceReferences(CheckService.class.getName(), filter);
- } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}
- if(refs != null) { sr = refs[0]; }
- assertNotNull("Check the check service availability", sr);
-
- ServiceReference sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
- Architecture arch = (Architecture) getContext().getService(sr_arch);
- assertEquals("Check validity", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
-
- // Kill the handler factory
- HandlerManagerFactory f = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "check");
- f.stop();
-
- sr = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "HandlerTest-1");
- assertNull("Check the check service unavailability", sr);
-
- sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
- assertNull("Check the architecture unavailability", sr_arch);
-
- // The instance is disposed, restart the handler
- f.start();
-
- Properties props = new Properties();
- props.put("instance.name","HandlerTest-1");
- props.put("csh.simple", "simple");
- Properties p = new Properties();
- p.put("a", "a");
- p.put("b", "b");
- p.put("c", "c");
- props.put("csh.map", p);
- instance = Utils.getComponentInstance(getContext(), "HANDLER-HandlerTester", props);
-
- sr = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "HandlerTest-1");
- assertNotNull("Check the check service availability - 2", sr);
-
- sr_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "HandlerTest-1");
- arch = (Architecture) getContext().getService(sr_arch);
- assertEquals("Check validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java
deleted file mode 100644
index 9239759..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.eh.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java
deleted file mode 100644
index 38d66ff..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.eh.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 0e2375f..0000000
--- a/ipojo/tests/core/external-handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(HandlerFactory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/external-handlers/src/main/resources/metadata.xml b/ipojo/tests/core/external-handlers/src/main/resources/metadata.xml
deleted file mode 100644
index b7da090..0000000
--- a/ipojo/tests/core/external-handlers/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:cs="org.apache.felix.ipojo.test.handler.checkservice">
- <handler
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceHandler"
- name="check"
- namespace="org.apache.felix.ipojo.test.handler.checkservice"
- architecture="false">
- <controller field="isValid" />
- </handler>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="HANDLER-HandlerTester" architecture="true">
- <cs:check />
- </component>
- <instance name="HandlerTest-2" component="HANDLER-HandlerTester">
- <property name="csh.simple" value="Simple" />
- <property name="csh.map">
- <property name="a" value="a" />
- <property name="b" value="b" />
- <property name="c" value="c" />
- </property>
- </instance>
- <instance name="HandlerTest-2-empty" component="HANDLER-HandlerTester">
- <property name="csh.simple" value="Simple" />
- <property name="csh.map">
- <!-- Empty dictionary -->
- </property>
- </instance>
-
- <!-- The handler will be added using the auto handler property -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="HANDLER-HandlerTesterWO" architecture="true">
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/factories/pom.xml b/ipojo/tests/core/factories/pom.xml
deleted file mode 100644
index a648383..0000000
--- a/ipojo/tests/core/factories/pom.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Factories Test Suite</name>
- <artifactId>tests.core.factories</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.factories.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.factories.FactoryTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
deleted file mode 100644
index 7f7f37d..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index fdaf7c1..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
deleted file mode 100644
index 419da2e..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-
-public class FooBarProviderType1 implements FooService, BarService {
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- return new Properties();
- }
-
- public boolean bar() {
- return true;
- }
-
- public Properties getProps() {
- return new Properties();
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 46593da..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
deleted file mode 100644
index 77a1583..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-
-
-public class FooProviderTypeDyn implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
-
- public boolean foo() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java
deleted file mode 100644
index 8cc7d12..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-
-public class FooProviderTypeDyn2 implements FooService {
-
- private int intProp = 2;
- private boolean boolProp = true;
- private String strProp = "foo";
- private String[] strAProp = new String[] {"foo", "bar"};
- private int[] intAProp = new int[] {1, 2, 3};
-
- public boolean foo() {
- intAProp = null;
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ReconfigurableSimpleType.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ReconfigurableSimpleType.java
deleted file mode 100644
index b84c40f..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ReconfigurableSimpleType.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ReconfigurableSimpleType {
-
-
- private String prop; // Property.
-
- private String x; // Property.
-
- boolean controller;
-
- public void start () {
- if (prop == null || prop.equals("KO")) {
- throw new IllegalStateException("Bad Configuration : " + prop);
- }
-
- if (x == null) {
- throw new IllegalStateException("x is null");
- }
-
- System.out.println("OK !!!!");
- }
-
- public void setX(String v) {
- x = v;
- }
-
- public void setProp(String p) {
- prop = p;
- if (prop == null || prop.equals("KO")) {
- controller = false;
- } else {
- controller = true;
- System.out.println("OK !!!!");
- }
- }
-
- public void setController(boolean p) {
- if (p) {
- System.out.println("OK !!!!");
- }
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleType.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleType.java
deleted file mode 100644
index 6938eba..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleType.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class SimpleType {
-
- private boolean m_controller;
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ComponentDesc.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ComponentDesc.java
deleted file mode 100644
index 81bbc9e..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ComponentDesc.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.architecture.PropertyDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.test.scenarios.factories.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Check component type description.
- */
-public class ComponentDesc extends OSGiTestCase {
-
- ServiceReference sr_fooProvider1;
- ServiceReference sr_fooProvider2;
- ServiceReference sr_fooProviderDyn2;
- ServiceReference sr_fooProvider3;
- ServiceReference sr_foobarProvider;
-// ServiceReference sr_simple;
-// ServiceReference sr_optional;
-// ServiceReference sr_multiple;
-// ServiceReference sr_multiple_optional;
-
- Factory fooProvider1;
- Factory fooProvider2;
- Factory fooProviderDyn2;
- Factory fooProvider3;
- Factory foobarProvider;
-// Factory simple;
-// Factory optional;
-// Factory multiple;
-// Factory multiple_optional;
-
- public void setUp() {
- sr_fooProvider1 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-1");
- sr_fooProvider2 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-2");
- sr_fooProviderDyn2 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-Dyn2");
- sr_fooProvider3 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-3");
- sr_foobarProvider = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooBarProviderType-1");
-// sr_simple = Utils.getServiceReferenceByName(context, Factory.class.getName(), "SimpleCheckServiceProvider");
-// sr_optional = Utils.getServiceReferenceByName(context, Factory.class.getName(), "SimpleOptionalCheckServiceProvider");
-// sr_multiple = Utils.getServiceReferenceByName(context, Factory.class.getName(), "SimpleMultipleCheckServiceProvider");
-// sr_multiple_optional = Utils.getServiceReferenceByName(context, Factory.class.getName(), "SimpleOptionalMultipleCheckServiceProvider");
-
- fooProvider1 = (Factory) getContext().getService(sr_fooProvider1);
- fooProvider2 = (Factory) getContext().getService(sr_fooProvider2);
- fooProviderDyn2 = (Factory) getContext().getService(sr_fooProviderDyn2);
- fooProvider3 = (Factory) getContext().getService(sr_fooProvider3);
- foobarProvider = (Factory) getContext().getService(sr_foobarProvider);
-// simple = (Factory) context.getService(sr_simple);
-// optional = (Factory) context.getService(sr_optional);
-// multiple = (Factory) context.getService(sr_multiple);
-// multiple_optional = (Factory) context.getService(sr_multiple_optional);
-
- }
-
- public void tearDown() {
- fooProvider1 = null;
- fooProvider2 = null;
- fooProviderDyn2 = null;
- fooProvider3 = null;
- foobarProvider = null;
-// simple = null;
-// multiple = null;
-// optional = null;
-// multiple_optional = null;
-
- getContext().ungetService(sr_fooProvider1);
- getContext().ungetService(sr_fooProvider2);
- getContext().ungetService(sr_fooProviderDyn2);
- getContext().ungetService(sr_fooProvider3);
- getContext().ungetService(sr_foobarProvider);
-// context.ungetService(sr_simple);
-// context.ungetService(sr_optional);
-// context.ungetService(sr_multiple);
-// context.ungetService(sr_multiple_optional);
- }
-
- /**
- * Check simple providing.
- */
- public void testFooProvider1() {
- // Test SR properties
-// String impl = (String) sr_fooProvider1.getProperty("component.class");
-// assertEquals("Check component.class", impl, "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- String[] specs = (String[]) sr_fooProvider1.getProperty("component.providedServiceSpecifications");
- assertEquals("Check component.providedServiceSpecifications length", specs.length, 1);
- assertEquals("Check component.providedServiceSpecifications", FooService.class.getName(), specs[0]);
-
- PropertyDescription[] pd = (PropertyDescription[]) sr_fooProvider1.getProperty("component.properties");
- assertEquals("Check component.properties length", pd.length, 0);
-
- // Test factory
- assertEquals("Check factory name", fooProvider1.getName(), "Factories-FooProviderType-1");
- Element cd = fooProvider1.getDescription();
-
-// assertEquals("Check implementation class ", cd.getAttribute("implementation-class"), impl);
-
- Element[] specs2 = cd.getElements("provides");
- assertEquals("Check specs length", specs2.length, 1);
- assertEquals("Check specs", FooService.class.getName(), specs2[0].getAttribute("specification"));
-
- Element[] pd2 = cd.getElements("property");
- assertNull("Check props null", pd2);
-
- // Check Description equality
- ComponentTypeDescription desc = (ComponentTypeDescription) sr_fooProvider1.getProperty("component.description");
- assertNotNull("check description equality", desc);
- }
-
- /**
- * Check component properties.
- */
- public void testFooProvider2() {
- // Test SR properties
-// String impl = (String) sr_fooProvider2.getProperty("component.class");
-// assertEquals("Check component.class", impl, "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- String[] specs = (String[]) sr_fooProvider2.getProperty("component.providedServiceSpecifications");
- assertEquals("Check component.providedServiceSpecifications length", specs.length, 1);
- assertEquals("Check component.providedServiceSpecifications", FooService.class.getName(), specs[0]);
-
- PropertyDescription[] pd = (PropertyDescription[]) sr_fooProvider2.getProperty("component.properties");
- assertEquals("Check component.properties length", pd.length, 5);
-
- assertEquals("Check component.properties name [" + 0 + "]", "int", pd[0].getName());
- assertEquals("Check component.properties type [" + 0 + "]", "int", pd[0].getType());
- assertEquals("Check component.properties value [" + 0 + "]", "2", pd[0].getValue());
-
- assertEquals("Check component.properties name [" + 1 + "]", "long", pd[1].getName());
- assertEquals("Check component.properties type [" + 1 + "]", "long", pd[1].getType());
- assertEquals("Check component.properties value [" + 1 + "]", "40", pd[1].getValue());
-
- assertEquals("Check component.properties name [" + 2 + "]", "string", pd[2].getName());
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd[2].getType());
- assertEquals("Check component.properties value [" + 2 + "]", "foo", pd[2].getValue());
-
- assertEquals("Check component.properties name [" + 3 + "]", "strAProp", pd[3].getName());
- assertEquals("Check component.properties type [" + 3 + "]", "java.lang.String[]", pd[3].getType());
-
- assertEquals("Check component.properties name [" + 4 + "]", "intAProp", pd[4].getName());
- assertEquals("Check component.properties type [" + 4 + "]", "int[]", pd[4].getType());
-
- // Test factory
- assertEquals("Check factory name", fooProvider2.getName(), "Factories-FooProviderType-2");
- Element cd = fooProvider2.getDescription();
-
-// assertEquals("Check implementation class ", cd.getAttribute("implementation-class"), impl);
-
- Element[] specs2 = cd.getElements("provides");
- assertEquals("Check specs length", specs2.length, 1);
- assertEquals("Check specs", FooService.class.getName(), specs2[0].getAttribute("specification"));
-
- Element[] pd2 = cd.getElements("property");
- assertEquals("Check props length", pd2.length, 5);
-
- assertEquals("Check component.properties name [" + 0 + "]", "int", pd2[0].getAttribute("name"));
- assertEquals("Check component.properties type [" + 0 + "]", "int", pd2[0].getAttribute("type"));
- assertEquals("Check component.properties value [" + 0 + "]", "2", pd2[0].getAttribute("value"));
-
- assertEquals("Check component.properties name [" + 1 + "]", "long", pd2[1].getAttribute("name"));
- assertEquals("Check component.properties type [" + 1 + "]", "long", pd2[1].getAttribute("type"));
- assertEquals("Check component.properties value [" + 1 + "]", "40", pd2[1].getAttribute("value"));
-
- assertEquals("Check component.properties name [" + 2 + "]", "string", pd2[2].getAttribute("name"));
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd2[2].getAttribute("type"));
- assertEquals("Check component.properties value [" + 2 + "]", "foo", pd2[2].getAttribute("value"));
-
- assertEquals("Check component.properties name [" + 3 + "]", "strAProp", pd2[3].getAttribute("name"));
- assertEquals("Check component.properties type [" + 3 + "]", "java.lang.String[]", pd2[3].getAttribute("type"));
-
- assertEquals("Check component.properties name [" + 4 + "]", "intAProp", pd2[4].getAttribute("name"));
- assertEquals("Check component.properties type [" + 4 + "]", "int[]", pd2[4].getAttribute("type"));
-
- // Check Description equality
- ComponentTypeDescription desc = (ComponentTypeDescription) sr_fooProvider2.getProperty("component.description");
- assertNotNull("check description equality", desc);
-
- // Check that we have the complete metadata
- assertNotNull(fooProvider2.getComponentMetadata());
- }
-
- /**
- * Check component properties (dynamic).
- */
- public void testFooProviderDyn2() {
- // Test SR properties
-// String impl = (String) sr_fooProviderDyn2.getProperty("component.class");
-// assertEquals("Check component.class", impl, "org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn2");
-
- String[] specs = (String[]) sr_fooProviderDyn2.getProperty("component.providedServiceSpecifications");
- assertEquals("Check component.providedServiceSpecifications length", specs.length, 1);
- assertEquals("Check component.providedServiceSpecifications", FooService.class.getName(), specs[0]);
-
- PropertyDescription[] pd = (PropertyDescription[]) sr_fooProviderDyn2.getProperty("component.properties");
- assertEquals("Check component.properties length", pd.length, 5);
-
- assertEquals("Check component.properties name [" + 0 + "]", "int", pd[0].getName());
- assertEquals("Check component.properties type [" + 0 + "]", "int", pd[0].getType());
- assertEquals("Check component.properties value [" + 0 + "]", "4", pd[0].getValue());
-
- assertEquals("Check component.properties name [" + 1 + "]", "boolean", pd[1].getName());
- assertEquals("Check component.properties type [" + 1 + "]", "boolean", pd[1].getType());
-
- assertEquals("Check component.properties name [" + 2 + "]", "string", pd[2].getName());
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd[2].getType());
-
- assertEquals("Check component.properties name [" + 3 + "]", "strAProp", pd[3].getName());
- assertEquals("Check component.properties type [" + 3 + "]", "java.lang.String[]", pd[3].getType());
-
- assertEquals("Check component.properties name [" + 4 + "]", "intAProp", pd[4].getName());
- assertEquals("Check component.properties type [" + 4 + "]", "int[]", pd[4].getType());
-
- // Test factory
- assertEquals("Check factory name", fooProviderDyn2.getName(), "Factories-FooProviderType-Dyn2");
- Element cd = fooProviderDyn2.getDescription();
-
-// assertEquals("Check implementation class ", cd.getAttribute("implementation-class"), impl);
-
- Element[] specs2 = cd.getElements("provides");
- assertEquals("Check specs length", specs2.length, 1);
- assertEquals("Check specs", FooService.class.getName(), specs2[0].getAttribute("specification"));
-
- Element[] pd2 = cd.getElements("property");
- assertEquals("Check props length", pd2.length, 5);
-
- assertEquals("Check component.properties name [" + 0 + "]", "int", pd2[0].getAttribute("name"));
- assertEquals("Check component.properties type [" + 0 + "]", "int", pd2[0].getAttribute("type"));
- assertEquals("Check component.properties value [" + 0 + "]", "4", pd2[0].getAttribute("value"));
-
- assertEquals("Check component.properties name [" + 1 + "]", "boolean", pd2[1].getAttribute("name"));
- assertEquals("Check component.properties type [" + 1 + "]", "boolean", pd2[1].getAttribute("type"));
-
- assertEquals("Check component.properties name [" + 2 + "]", "string", pd2[2].getAttribute("name"));
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd2[2].getAttribute("type"));
-
- assertEquals("Check component.properties name [" + 3 + "]", "strAProp", pd2[3].getAttribute("name"));
- assertEquals("Check component.properties type [" + 3 + "]", "java.lang.String[]", pd2[3].getAttribute("type"));
-
- assertEquals("Check component.properties name [" + 4 + "]", "intAProp", pd2[4].getAttribute("name"));
- assertEquals("Check component.properties type [" + 4 + "]", "int[]", pd2[4].getAttribute("type"));
-
- // Check Description equality
- ComponentTypeDescription desc = (ComponentTypeDescription) sr_fooProviderDyn2.getProperty("component.description");
- assertNotNull("check description equality", desc);
-
- // Check that we have the complete metadata
- assertNotNull(fooProvider2.getComponentMetadata());
- }
-
- /**
- * Check component properties.
- */
- public void testFooProvider3() {
- // Test SR properties
-// String impl = (String) sr_fooProvider3.getProperty("component.class");
-// assertEquals("Check component.class", impl, "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- String[] specs = (String[]) sr_fooProvider3.getProperty("component.providedServiceSpecifications");
- assertEquals("Check component.providedServiceSpecifications length", specs.length, 1);
- assertEquals("Check component.providedServiceSpecifications", FooService.class.getName(), specs[0]);
-
- PropertyDescription[] pd = (PropertyDescription[]) sr_fooProvider3.getProperty("component.properties");
- assertEquals("Check component.properties length (" + pd.length +")", pd.length, 3);
-
- assertEquals("Check component.properties name [" + 0 + "]", "foo", pd[0].getName());
-
- assertEquals("Check component.properties name [" + 1 + "]", "bar", pd[1].getName());
-
- assertEquals("Check component.properties name [" + 2 + "]", "baz", pd[2].getName());
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd[2].getType());
-
- // Test factory
- assertEquals("Check factory name", fooProvider3.getName(), "Factories-FooProviderType-3");
- Element cd = fooProvider3.getDescription();
-
-// assertEquals("Check implementation class ", cd.getAttribute("implementation-class"), impl);
-
- Element[] specs2 = cd.getElements("provides");
- assertEquals("Check specs length", specs2.length, 1);
- assertEquals("Check specs", FooService.class.getName(), specs2[0].getAttribute("specification"));
-
- Element[] pd2 = cd.getElements("property");
- assertEquals("Check props length", pd2.length, 3);
-
- assertEquals("Check component.properties name [" + 0 + "]", "foo", pd2[0].getAttribute("name"));
-
- assertEquals("Check component.properties name [" + 1 + "]", "bar", pd2[1].getAttribute("name"));
-
- assertEquals("Check component.properties name [" + 2 + "]", "baz", pd2[2].getAttribute("name"));
- assertEquals("Check component.properties type [" + 2 + "]", "java.lang.String", pd2[2].getAttribute("type"));
-
- // Check Description equality
- ComponentTypeDescription desc = (ComponentTypeDescription) sr_fooProvider3.getProperty("component.description");
- assertNotNull("check description equality", desc);
- }
-
- /**
- * Test two services provider.
- */
- public void testFooBar() {
- // Test SR properties
-// String impl = (String) sr_foobarProvider.getProperty("component.class");
-// assertEquals("Check component.class", impl, "org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1");
-
- String[] specs = (String[]) sr_foobarProvider.getProperty("component.providedServiceSpecifications");
- assertEquals("Check component.providedServiceSpecifications length", specs.length, 2);
- assertTrue("Check component.providedServiceSpecifications 1", Utils.contains(FooService.class.getName(), specs));
- assertTrue("Check component.providedServiceSpecifications 2", Utils.contains(BarService.class.getName(), specs));
-
- PropertyDescription[] pd = (PropertyDescription[]) sr_foobarProvider.getProperty("component.properties");
- assertEquals("Check component.properties length", pd.length, 0);
-
- // Test factory
- assertEquals("Check factory name", foobarProvider.getName(), "Factories-FooBarProviderType-1");
- Element cd = foobarProvider.getDescription();
-
-// assertEquals("Check implementation class ", cd.getAttribute("implementation-class"), impl);
-
- Element[] specs2 = cd.getElements("provides");
- assertEquals("Check specs length", specs2.length, 2);
- assertTrue("Check specs", containsSpecification(FooService.class.getName(), specs2));
- assertTrue("Check specs", containsSpecification(BarService.class.getName(), specs2));
-
- Element[] pd2 = cd.getElements("property");
- assertNull("Check props null", pd2);
-
- // Check Description equality
- ComponentTypeDescription desc = (ComponentTypeDescription) sr_foobarProvider.getProperty("component.description");
- assertNotNull("check description equality", desc);
-
- // Check that we have the complete metadata
- assertNotNull(foobarProvider.getComponentMetadata());
- }
-
- private boolean containsSpecification(String value, Element[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].containsAttribute("specification") && array[i].getAttribute("specification").equals(value)) {
- return true;
- }
- }
- return false;
- }
-
-
-
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ConfigAdminTest.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ConfigAdminTest.java
deleted file mode 100644
index 07ee24c..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ConfigAdminTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-/**
- * Check configuration admin reconfiguration.
- */
-public class ConfigAdminTest extends OSGiTestCase {
-
- private ManagedServiceFactory getFactoryByName(String pid) {
- ServiceReference[] refs;
- try {
- refs = getContext().getServiceReferences(ManagedServiceFactory.class.getName(), "(service.pid="+pid+")");
- if(refs == null) { return null; }
- return ((org.osgi.service.cm.ManagedServiceFactory) getContext().getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + pid + " : " + e.getMessage());
- return null;
- }
- }
-
- /**
- * Check creation.
- */
- public void testCreation() {
- ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- try {
- f.updated("ok2", p);
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "ok2");
- assertNotNull("Check instance creation", ref);
- f.deleted("ok2");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "ok2");
- assertNull("Check instance deletion", ref);
- } catch (ConfigurationException e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check creation (push String).
- */
- public void testCreationString() {
- ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("int", "3");
- p.put("long", "42");
- p.put("string", "absdir");
- p.put("strAProp", "{a}");
- p.put("intAProp", "{1,2}");
-
- try {
- f.updated("ok2", p);
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "ok2");
- assertNotNull("Check instance creation", ref);
- f.deleted("ok2");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "ok2");
- assertNull("Check instance deletion", ref);
- } catch (ConfigurationException e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check update and delete.
- */
- public void testUpdate() {
- ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- try {
- f.updated("okkkk", p);
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- assertNotNull("Check instance creation", ref);
- p.put("int", new Integer("4"));
- f.updated("okkkk", p);
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- Integer test = (Integer) ref.getProperty("int");
- assertEquals("Check instance modification", 4, test.intValue());
- f.deleted("okkkk");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- assertNull("Check instance deletion", ref);
- } catch (ConfigurationException e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check update and delete.
- * (Push String).
- */
- public void testUpdateString() {
- ManagedServiceFactory f = getFactoryByName("Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("int", "3");
- p.put("long", "42");
- p.put("string", "absdir");
- p.put("strAProp", "{a}");
- p.put("intAProp", "{1,2}");
-
- try {
- f.updated("okkkk", p);
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- assertNotNull("Check instance creation", ref);
- p.put("int", new Integer("4"));
- f.updated("okkkk", p);
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- Integer test = (Integer) ref.getProperty("int");
- assertEquals("Check instance modification", 4, test.intValue());
- f.deleted("okkkk");
- ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), "okkkk");
- assertNull("Check instance deletion", ref);
- } catch (ConfigurationException e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryProps.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryProps.java
deleted file mode 100644
index f18359f..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryProps.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.PropertyDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.factories.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class FactoryProps extends OSGiTestCase {
-
-// public void testImplementationClass() {
-// ServiceReference ref1 = Utils.getServiceReferenceByName(context, Factory.class.getName(), "FooProviderType-1");
-// assertNotNull("The factory is available", ref1);
-// String clazz = (String) ref1.getProperty("component.class");
-// assertEquals("Check the implementation class", clazz, FooProviderType1.class.getName());
-// }
-
- public void testSimpleExposition() {
- ServiceReference ref1 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-1");
- assertNotNull("The factory is available", ref1);
- String[] spec = (String[]) ref1.getProperty("component.providedServiceSpecifications");
- assertEquals("Check array length", spec.length, 1);
- assertEquals("Check spec", spec[0], FooService.class.getName());
- }
-
- public void testDoubleExposition() {
- ServiceReference ref1 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooBarProviderType-1");
- assertNotNull("The factory is available", ref1);
- String[] spec = (String[]) ref1.getProperty("component.providedServiceSpecifications");
- assertEquals("Check array length", spec.length, 2);
- assertContains("Check spec 1", spec, FooService.class.getName());
- assertContains("Check spec 2", spec, BarService.class.getName());
- }
-
- public void testProps() {
- ServiceReference ref1 = Utils.getServiceReferenceByName(getContext(), Factory.class.getName(), "Factories-FooProviderType-Dyn2");
- assertNotNull("The factory is available", ref1);
- PropertyDescription[] pd = (PropertyDescription[]) ref1.getProperty("component.properties");
- assertEquals("Check property list size", pd.length, 5);
-
- //P0
- assertEquals("0) Check name", "int", pd[0].getName());
- assertEquals("0) Check type", "int", pd[0].getType());
- assertEquals("0) Check value", "4", pd[0].getValue());
-
- //P1
- assertEquals("1) Check name", "boolean", pd[1].getName());
- assertEquals("1) Check type", "boolean", pd[1].getType());
- assertNull("1) Check value", pd[1].getValue());
-
- //P2
- assertEquals("2) Check name", "string", pd[2].getName());
- assertEquals("2) Check type", String.class.getName(), pd[2].getType());
- assertNull("2) Check value", pd[2].getValue());
-
- //P3
- assertEquals("3) Check name", "strAProp", pd[3].getName());
- assertEquals("3) Check type", "java.lang.String[]", pd[3].getType());
- assertNull("3) Check value", pd[3].getValue());
-
- //P4
- assertEquals("4) Check name", "intAProp", pd[4].getName());
- assertEquals("4) Check type", "int[]", pd[4].getType());
- }
-
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryTestSuite.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryTestSuite.java
deleted file mode 100644
index 4338ef3..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/FactoryTestSuite.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class FactoryTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Factories Test Suite", bc);
- ots.addTestSuite(ComponentDesc.class);
- ots.addTestSuite(UnacceptableConfigurationTest.class);
- ots.addTestSuite(ConfigAdminTest.class);
- ots.addTestSuite(ObedienceTest.class);
- ots.addTestSuite(FactoryProps.class);
- ots.addTestSuite(ReconfigurationTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ObedienceTest.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ObedienceTest.java
deleted file mode 100644
index c650d5c..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ObedienceTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.factories.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Check that instances are disposed when the factory is stopped.
- */
-public class ObedienceTest extends OSGiTestCase {
-
- public void testObedience() {
- assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
- ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(), "Factories-FooProviderType-1");
- assertNotNull("Check factory existing", factory);
-
- Properties props1 = new Properties();
- props1.put("instance.name","foo1");
- Properties props2 = new Properties();
- props2.put("instance.name","foo2");
-
- ComponentInstance ci1 = null, ci2 = null;
- try {
- ci1 = factory.createComponentInstance(props1);
- ci2 = factory.createComponentInstance(props2);
- } catch(Exception e) {
- fail("Cannot instantiate foo providers : " + e.getMessage());
- }
-
- assertTrue("Check foo1 validity", ci1.getState() == ComponentInstance.VALID);
- assertTrue("Check foo2 validity", ci2.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check foo service", getContext().getServiceReference(FooService.class.getName()));
- assertEquals("Check the number of Foo", Utils.getServiceReferences(getContext(), FooService.class.getName(), null).length, 2);
-
- factory.stop();
-
- assertTrue("Check foo1 invalidity ("+ci1.getState()+")", ci1.getState() == ComponentInstance.DISPOSED);
- assertTrue("Check foo2 invalidity ("+ci1.getState()+")", ci2.getState() == ComponentInstance.DISPOSED);
-
- assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
-
- factory.start();
- assertNull("Check no foo service", getContext().getServiceReference(FooService.class.getName()));
- }
-
- public void testDisposeAfterFactoryInvalidation() {
- ComponentFactory cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
- assertNotNull("Check factory availability -1", cf);
- assertEquals("Check factory state -1", Factory.VALID, cf.getState());
-
- ServiceReference ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
- assertNotNull("Check Architecture availability -1", ref_arch);
-
- HandlerManagerFactory hf = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
- assertNotNull("Check handler availability -1", hf);
- assertEquals("Check handler state -1", Factory.VALID, hf.getState());
-
- // Stop the handler
- hf.stop();
- HandlerManagerFactory hf2 = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
- assertNull("Check handler availability -2", hf2);
-
- // Check the factory invalidity
- cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
- assertNotNull("Check factory availability -2", cf);
- assertEquals("Check factory state -2", Factory.INVALID, cf.getState());
-
- // Check the instance disparition
- ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
- assertNull("Check Architecture availability -1", ref_arch);
-
- // Restart the handler
- hf.start();
- hf2 = (HandlerManagerFactory) Utils.getHandlerFactoryByName(getContext(), "controller");
- assertNotNull("Check handler availability -3", hf2);
-
- // Check the factory state
- cf = (ComponentFactory) Utils.getFactoryByName(getContext(), "org.apache.felix.ipojo.test.scenarios.component.SimpleType");
- assertNotNull("Check factory availability -3", cf);
- assertEquals("Check factory state -3", Factory.VALID, cf.getState());
-
-
- // Check the instance re-creation
- ref_arch = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), "SimpleInstance");
- assertNotNull("Check Architecture availability -3", ref_arch);
-
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ReconfigurationTest.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ReconfigurationTest.java
deleted file mode 100644
index 08edfe0..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/ReconfigurationTest.java
+++ /dev/null
@@ -1,335 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-public class ReconfigurationTest extends OSGiTestCase {
-
- private ConfigurationAdmin admin;
-
- public void setUp() {
- admin = (ConfigurationAdmin) Utils.getServiceObject(getContext(), ConfigurationAdmin.class.getName(), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations(
- "(service.factoryPid=org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void tearDown() {
- try {
- Configuration[] configurations = admin.listConfigurations(
- "(service.factoryPid=org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType)");
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- admin = null;
-
-
- }
-
- public void testRevalidationOnReconfiguration() {
- ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType");
-
- // First inject a configuration triggering an exception of the validate method.
- Properties props = new Properties();
- props.put("prop", "KO");
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch (UnacceptableConfiguration e) {
- e.printStackTrace();
- } catch (MissingHandlerException e) {
- e.printStackTrace();
- } catch (ConfigurationException e) {
- e.printStackTrace();
- }
-
- assertNotNull(ci);
- assertEquals("instance invalid", ComponentInstance.STOPPED, ci.getState());
-
- // Reconfigure
- props = new Properties();
- props.put("prop", "OK");
-
- ci.reconfigure(props);
-
- assertNotNull(ci);
- assertEquals("instance valid", ComponentInstance.VALID, ci.getState());
- }
-
- public static long UPDATE_WAIT_TIME = 2000;
-
- public void testRevalidationOnReconfigurationUsingConfigAdmin() throws InvalidSyntaxException {
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType", null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- // First inject a configuration triggering an exception of the validate method.
- props.put("prop", "KO");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- Assert.assertNull("No architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
-
-
- // Reconfigure
- props = new Properties();
- props.put("prop", "OK");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
- Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
- }
-
- public void testRevalidationOnReconfigurationWithController() {
- ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType2");
-
- // First inject a configuration triggering an exception of the validate method.
- Properties props = new Properties();
- props.put("prop", "KO");
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch (UnacceptableConfiguration e) {
- e.printStackTrace();
- } catch (MissingHandlerException e) {
- e.printStackTrace();
- } catch (ConfigurationException e) {
- e.printStackTrace();
- }
-
- assertNotNull(ci);
- assertEquals("instance invalid", ComponentInstance.INVALID, ci.getState()); // Controller effect.
-
- // Reconfigure
- props = new Properties();
- props.put("prop", "OK");
-
- ci.reconfigure(props);
-
- assertNotNull(ci);
- assertEquals("instance valid", ComponentInstance.VALID, ci.getState());
- }
-
- public void testRevalidationOnReconfigurationUsingConfigAdminAndController() throws InvalidSyntaxException {
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType2",
- null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- // First inject a configuration triggering an exception of the validate method.
- props.put("prop", "KO");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- // Invalid ... controller effect
- Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
- Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- Assert.assertEquals("Is invalid ?", ComponentInstance.INVALID, arch.getInstanceDescription().getState());
-
- // Reconfigure
- props = new Properties();
- props.put("prop", "OK");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
- arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
- }
-
- public void testRevalidationOnReconfigurationOfTheController() {
- ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType3");
-
- // First inject a configuration triggering an exception of the validate method.
- Properties props = new Properties();
- props.put("controller", "false");
- ComponentInstance ci = null;
- try {
- ci = factory.createComponentInstance(props);
- } catch (UnacceptableConfiguration e) {
- e.printStackTrace();
- } catch (MissingHandlerException e) {
- e.printStackTrace();
- } catch (ConfigurationException e) {
- e.printStackTrace();
- }
-
- assertNotNull(ci);
- assertEquals("instance invalid", ComponentInstance.INVALID, ci.getState()); // Controller effect.
-
- // Reconfigure
- props = new Properties();
- props.put("controller", "true");
-
- ci.reconfigure(props);
-
- assertNotNull(ci);
- assertEquals("instance valid", ComponentInstance.VALID, ci.getState());
- }
-
- public void testRevalidationOnReconfigurationUsingConfigAdminOfTheController() throws InvalidSyntaxException {
- Configuration configuration = null;
- try {
- configuration = admin.createFactoryConfiguration("org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType3",
- null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- Dictionary props = configuration.getProperties();
- if(props == null) {
- props = new Properties();
- }
- // First inject a configuration triggering an exception of the validate method.
- props.put("controller", "false");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- String pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- // Invalid ... controller effect
- Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
- Architecture arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- Assert.assertEquals("Is invalid ?", ComponentInstance.INVALID, arch.getInstanceDescription().getState());
-
- // Reconfigure
- props = new Properties();
- props.put("controller", "true");
-
- try {
- configuration.update(props);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- pid = configuration.getPid();
-
- // Wait for the processing of the first configuration.
- try {
- Thread.sleep(UPDATE_WAIT_TIME);
- } catch (InterruptedException e1) {
- fail(e1.getMessage());
- }
-
- Assert.assertNotNull("architecture", getContext().getServiceReferences(Architecture.class.getName(), "(architecture.instance="+pid+")"));
- arch = (Architecture) Utils.getServiceObject(getContext(), Architecture.class.getName(), "(architecture.instance="+pid+")");
-
- Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
- }
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/UnacceptableConfigurationTest.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/UnacceptableConfigurationTest.java
deleted file mode 100644
index 9c7ba67..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/UnacceptableConfigurationTest.java
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-
-/**
- * Test unacceptable configuration.
- */
-public class UnacceptableConfigurationTest extends OSGiTestCase {
-
- /**
- * Configuration without the name property.
- */
- public void testWithoutName() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("an acceptable configuration is refused : " + e.getMessage());
- e.printStackTrace();
- }
-
- }
-
- /**
- * Configuration without the name property.
- */
- public void testWithoutNameOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2opt");
-
- Properties p = new Properties();
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { fail("an acceptable configuration is refused : " + e.getMessage()); }
-
- }
-
- /**
- * Empty configuration.
- */
- public void testEmptyConfiguration() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
- Properties p = new Properties();
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Empty configuration.
- */
- public void testEmptyConfigurationOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2opt");
- Properties p = new Properties();
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Empty configuration (just the name).
- */
- public void testEmptyConfiguration2() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
- Properties p = new Properties();
- p.put("instance.name","ko");
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { return; }
-
- fail("An unacceptable configuration is accepted");
- }
-
- /**
- * Empty configuration (just the name).
- */
- public void testEmptyConfiguration2opt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
- Properties p = new Properties();
- p.put("instance.name","ko");
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is refused");
- }
-
- }
-
- /**
- * Null configuration (accept).
- */
- public void testNull() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(null);
- ci.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Null configuration (accept).
- */
- public void testNullOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2opt");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(null);
- ci.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Null configuration (fail).
- */
- public void testNull2() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(null);
- ci.dispose();
- } catch(Exception e) { return; }
-
- fail("An unacceptable configuration is accepted");
- }
-
- /**
- * Null configuration (success).
- */
- public void testNull2Opt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(null);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is refused");
- }
-
-
- }
-
- /**
- * Check static properties.
- */
- public void testStaticOK() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check static properties.
- */
- public void testStaticOKopt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check dynamic properties.
- */
- public void testDynamicOK() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- e.printStackTrace();
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
-
- /**
- * Check dynamic properties.
- */
- public void testDynamicOKopt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dynopt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- e.printStackTrace();
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
-
- p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- e.printStackTrace();
- fail("An acceptable configuration is rejected (2) : " + e.getMessage());
- }
- }
-
- /**
- * Check inconsistent types.
- */
- public void testDynamicBadType() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check inconsistent types.
- */
- public void testDynamicBadTypeOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dynopt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("long", new Long(42));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
-
- p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected (2) : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration (with overriding).
- */
- public void testDynamicComplete() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration (with overriding).
- */
- public void testDynamicCompleteOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
-
-
- p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected (2) : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration.
- */
- public void testDynamicJustEnough() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration.
- */
- public void testDynamicJustEnoughOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
-
- p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("strAProp", new String[] {"a"});
-
- ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration.
- */
- public void testDynamicMix() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration.
- */
- public void testDynamicMixOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
-
- p = new Properties();
- p.put("instance.name","ok");
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check uncomplete configuration.
- */
- public void testDynamicUncomplete() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { return; }
-
- fail("An unacceptable configuration is accepted");
- }
-
- /**
- * Check uncomplete configuration.
- */
- public void testDynamicUncompleteOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
-
-
- }
-
- /**
- * Check good configuration (more properties).
- */
- public void testDynamicMore() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
- p.put("tralala", "foo");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check good configuration (more properties).
- */
- public void testDynamicMoreOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
- p.put("tralala", "foo");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check properties affecting services and component.
- */
- public void testDoubleProps() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
- p.put("boolean", new Boolean(false));
- p.put("string", "toto");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check properties affecting services and component.
- */
- public void testDoublePropsOpt() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-Dyn2opt");
-
- Properties p = new Properties();
- p.put("instance.name","ok");
- p.put("int", new Integer(3));
- p.put("boolean", new Boolean(true));
- p.put("string", "absdir");
- p.put("strAProp", new String[] {"a"});
- p.put("intAProp", new int[] {1,2});
- p.put("boolean", new Boolean(false));
- p.put("string", "toto");
-
- ComponentInstance ci = null;
- try {
- ci = f.createComponentInstance(p);
- ci.dispose();
- } catch(Exception e) {
- fail("An acceptable configuration is rejected : " + e.getMessage());
- }
- }
-
- /**
- * Check instance name unicity.
- */
- public void testUnicity1() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- ComponentInstance ci1,ci2, ci3 = null;
- try {
- ci1 = f.createComponentInstance(null);
- ci2 = f.createComponentInstance(null);
- ci3 = f.createComponentInstance(null);
- assertNotEquals("Check name ci1, ci2", ci1.getInstanceName(), ci2.getInstanceName());
- assertNotEquals("Check name ci1, ci3", ci1.getInstanceName(), ci3.getInstanceName());
- assertNotEquals("Check name ci3, ci2", ci3.getInstanceName(), ci2.getInstanceName());
- ci1.dispose();
- ci2.dispose();
- ci3.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Check instance name unicity.
- */
- public void testUnicity2() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- ComponentInstance ci1,ci2, ci3 = null;
- try {
- Properties p1 = new Properties();
- p1.put("instance.name","name1");
- ci1 = f.createComponentInstance(p1);
- Properties p2 = new Properties();
- p2.put("instance.name","name2");
- ci2 = f.createComponentInstance(p2);
- Properties p3 = new Properties();
- p3.put("instance.name","name3");
- ci3 = f.createComponentInstance(p3);
- assertNotEquals("Check name ci1, ci2", ci1.getInstanceName(), ci2.getInstanceName());
- assertNotEquals("Check name ci1, ci3", ci1.getInstanceName(), ci3.getInstanceName());
- assertNotEquals("Check name ci3, ci2", ci3.getInstanceName(), ci2.getInstanceName());
- ci1.dispose();
- ci2.dispose();
- ci3.dispose();
- } catch(Exception e) { fail("An acceptable configuration is refused"); }
- }
-
- /**
- * Check instance name unicity.
- */
- public void testUnicity3() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
-
- ComponentInstance ci1 = null,ci2 = null;
- try {
- Properties p1 = new Properties();
- p1.put("instance.name","name1");
- ci1 = f.createComponentInstance(p1);
- Properties p2 = new Properties();
- p2.put("instance.name","name1");
- ci2 = f.createComponentInstance(p2);
- assertNotEquals("Check name ci1, ci2", ci1.getInstanceName(), ci2.getInstanceName());
- ci1.dispose();
- ci2.dispose();
- } catch(Exception e) {
- ci1.dispose();
- return; }
-
- fail("An unacceptable configuration is acceptable");
- }
-
- /**
- * Check instance name unicity.
- */
- public void testUnicity4() {
- Factory f = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-2");
- Factory f2 = Utils.getFactoryByName(getContext(), "Factories-FooProviderType-1");
-
- ComponentInstance ci1 = null,ci2 = null;
- try {
- Properties p1 = new Properties();
- p1.put("instance.name","name1");
- ci1 = f.createComponentInstance(p1);
- Properties p2 = new Properties();
- p2.put("instance.name","name1");
- ci2 = f2.createComponentInstance(p2);
- assertNotEquals("Check name ci1, ci2", ci1.getInstanceName(), ci2.getInstanceName());
- ci1.dispose();
- ci2.dispose();
- } catch(Exception e) {
- ci1.dispose();
- return; }
-
- fail("An unacceptable configuration is acceptable");
- }
-
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/BarService.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/BarService.java
deleted file mode 100644
index e29c179..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/CheckService.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/CheckService.java
deleted file mode 100644
index 3fd1e2f..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/FooService.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/FooService.java
deleted file mode 100644
index 9ba67c9..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/factories/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.factories.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 8fa2fda..0000000
--- a/ipojo/tests/core/factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(HandlerFactory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
- public static void waitForService(BundleContext context, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(context, itf, filter);
- int count = 0;
- if (refs.length != 0) {
- return;
- } else {
- while(refs.length == 0) {
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // Interrupted
- }
- count++;
- if (count == 100) {
- throw new RuntimeException("Timeout ... no services match with " + filter);
- }
- refs = getServiceReferences(context, itf, filter);
- }
- }
- }
-
-}
diff --git a/ipojo/tests/core/factories/src/main/resources/metadata.xml b/ipojo/tests/core/factories/src/main/resources/metadata.xml
deleted file mode 100644
index cd72f96..0000000
--- a/ipojo/tests/core/factories/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <!-- Simple provider -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Factories-FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Provider providing 2 services -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
- name="Factories-FooBarProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Provider with dynamic property -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="Factories-FooProviderType-Dyn" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2" mandatory="true"/>
- <property name="boolean" field="boolProp" value="false" mandatory="true"/>
- <property name="string" field="strProp" value="foo" mandatory="true"/>
- <property name="strAProp" field="strAProp"
- value="{foo, bar}" mandatory="true"/>
- <property name="intAProp" field="intAProp" value="{ 1,2,3}" mandatory="true"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="Factories-FooProviderType-Dynopt" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2"/>
- <property name="boolean" field="boolProp" value="false"/>
- <property name="string" field="strProp" value="foo"/>
- <property name="strAProp" field="strAProp"
- value="{foo, bar}"/>
- <property name="intAProp" field="intAProp" value="{ 1,2,3}"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Factories-FooProviderType-2" architecture="true">
- <provides>
- <property name="int" type="int" value="2" mandatory="true" />
- <property name="long" type="long" value="40" mandatory="true"/>
- <property name="string" type="java.lang.String" value="foo" mandatory="true"/>
- <property name="strAProp" type="java.lang.String[]"
- value="{foo, bar}" mandatory="true" />
- <property name="intAProp" type="int[]" value="{1,2,3}" mandatory="true"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Factories-FooProviderType-2opt" architecture="true">
- <provides>
- <property name="int" type="int" value="2"/>
- <property name="long" type="long" value="40"/>
- <property name="string" type="java.lang.String" value="foo"/>
- <property name="strAProp" type="java.lang.String[]"
- value="{foo, bar}" />
- <property name="intAProp" type="int[]" value="{1,2,3}"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn2"
- name="Factories-FooProviderType-Dyn2" architecture="true">
- <provides>
- <property name="int" field="intProp" value="4" mandatory="true"/>
- <property name="boolean" field="boolProp" mandatory="true"/>
- <property name="string" field="strProp" mandatory="true"/>
- <property name="strAProp" field="strAProp" mandatory="true"/>
- <property name="intAProp" field="intAProp"
- value="{1, 2,3 }" mandatory="true"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn2"
- name="Factories-FooProviderType-Dyn2opt" architecture="true">
- <provides>
- <property name="int" field="intProp" value="4" />
- <property name="boolean" field="boolProp"/>
- <property name="string" field="strProp"/>
- <property name="strAProp" field="strAProp"/>
- <property name="intAProp" field="intAProp"
- value="{1, 2,3 }"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Factories-FooProviderType-3" architecture="true">
- <provides>
- <property name="foo" field="m_foo" mandatory="true"/>
- <property name="bar" field="m_bar" mandatory="true"/>
- <property name="baz" type="java.lang.String" mandatory="true"/>
- </provides>
- <properties propagation="true">
- <property name="foo" field="m_foo" mandatory="true"/>
- <property name="bar" field="m_bar" mandatory="true"/>
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Factories-FooProviderType-3opt" architecture="true">
- <provides>
- <property name="foo" field="m_foo"/>
- <property name="bar" field="m_bar"/>
- <property name="baz" type="java.lang.String"/>
- </provides>
- <properties propagation="true">
- <property name="foo" field="m_foo"/>
- <property name="bar" field="m_bar"/>
- </properties>
- </component>
-
- <!-- type & instance used to check instance lifecycle against factory validation & invalidation -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.SimpleType" architecture="true">
- <controller field="m_controller"/>
- </component>
- <instance component="org.apache.felix.ipojo.test.scenarios.component.SimpleType" name="SimpleInstance"/>
-
- <!-- check that instance state is recomputed after reconfiguration -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType" architecture="true">
- <properties>
- <property name="prop" field="prop"/>
- <property name="x" method="setX" value="x"/>
- </properties>
- <callback transition="validate" method="start"/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType"
- name="org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType2"
- architecture="true" immediate="true">
- <properties>
- <property name="prop" method="setProp"/>
- <property name="x" method="setX" value="x"/>
- </properties>
- <controller field="controller"/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType"
- name="org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType3"
- architecture="true" immediate="true">
- <properties>
- <property name="controller" method="setController" field="controller"/>
- <property name="x" method="setX" value="x"/>
- </properties>
- <controller field="controller"/>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/factory-version/cons.xml b/ipojo/tests/core/factory-version/cons.xml
deleted file mode 100644
index 69f729a..0000000
--- a/ipojo/tests/core/factory-version/cons.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component name="cons" classname="org.apache.felix.ipojo.tests.core.component.MyCons">
- <requires field="services"/>
- </component>
- <instance component="cons" name="mycons"/>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/factory-version/instances.xml b/ipojo/tests/core/factory-version/instances.xml
deleted file mode 100644
index 500d161..0000000
--- a/ipojo/tests/core/factory-version/instances.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
-
- <instance component="org.apache.felix.ipojo.tests.core.component.MyComponent"
- version="1.0"
- name="instance-v1"
- />
-
- <instance component="org.apache.felix.ipojo.tests.core.component.MyComponent"
- version="1.1"
- name="instance-v1.1"
- />
-
- <instance component="org.apache.felix.ipojo.tests.core.component.MyComponent"
- name="instance-any"
- />
-
- <instance component="MyComponent"
- name="MyComponentInstance"
- />
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/factory-version/pom.xml b/ipojo/tests/core/factory-version/pom.xml
deleted file mode 100644
index d15c426..0000000
--- a/ipojo/tests/core/factory-version/pom.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.factory-version</artifactId>
- <name>iPOJO Factory Version Test Suite</name>
- <version>${ipojo.core.snapshot}</version>
- <description>Test the factory version attribute</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!--
- <plugin> <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>maven-paxexam-plugin</artifactId> <executions>
- <execution> <id>generate-paxexam-config</id> <goals>
- <goal>generate-paxexam-config</goal> </goals> </execution>
- </executions> <configuration> <settings> <platform>felix</platform>
- </settings> </configuration> </plugin>
- -->
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
-
- <!--
- Pax Exam API:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- <!-- Tinybundles -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base-io</artifactId>
- <version>1.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base-lang</artifactId>
- <version>1.2.1</version>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-</project>
diff --git a/ipojo/tests/core/factory-version/provider-v1.1.xml b/ipojo/tests/core/factory-version/provider-v1.1.xml
deleted file mode 100644
index 6d387b6..0000000
--- a/ipojo/tests/core/factory-version/provider-v1.1.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component classname="org.apache.felix.ipojo.tests.core.component.MyComponent" version="BuNdlE">
- <provides/>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/factory-version/provider-v1.xml b/ipojo/tests/core/factory-version/provider-v1.xml
deleted file mode 100644
index a89195d..0000000
--- a/ipojo/tests/core/factory-version/provider-v1.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component classname="org.apache.felix.ipojo.tests.core.component.MyComponent" version="1.0">
- <provides/>
- </component>
-
-
- <component classname="org.apache.felix.ipojo.tests.core.component.MyComponent" name="MyComponent">
- <provides/>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/FactoryVersionTest.java b/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/FactoryVersionTest.java
deleted file mode 100644
index 9db5b2e..0000000
--- a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/FactoryVersionTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class FactoryVersionTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- equinox(),
- knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- // mavenBundle().groupId( "org.ops4j.pax.swissbox" ).artifactId( "pax-swissbox-tinybundles" ).version(asInProject())
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withBnd() )
- ),
- provision(
- // Component V1
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"ProviderV1")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withiPOJO(new File(tmp, "provider-v1.jar"), new File("provider-v1.xml"))),
- // Component V1.1 (Bundle Version)
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"ProviderV1.1")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .set(Constants.BUNDLE_VERSION, "1.1")
- .build( withiPOJO(new File(tmp, "provider-v1.1.jar"), new File("provider-v1.1.xml"))),
- // Instance declaration
- newBundle()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Instances")
- .build( withiPOJO(new File(tmp, "instances.jar"), new File("instances.xml")))
- )
- );
- return opt;
- }
-
- @Test
- public void testDeploy() {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
- }
- }
-
- @Test
- public void testInstanceArchitecture() {
- // Version 1.0
- ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1");
- Assert.assertNotNull(refv1);
- Architecture archv1 = (Architecture) osgi.getServiceObject(refv1);
-
- String version = archv1.getInstanceDescription().getComponentDescription().getVersion();
- Assert.assertEquals("1.0", version);
-
- // Version 1.1
- ServiceReference refv11 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1.1");
- Assert.assertNotNull(refv11);
- Architecture archv11 = (Architecture) osgi.getServiceObject(refv11);
-
- String version11 = archv11.getInstanceDescription().getComponentDescription().getVersion();
- Assert.assertEquals("1.1", version11);
-
- // No Version
- ServiceReference refany = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-any");
- Assert.assertNotNull(refany);
- Architecture archany = (Architecture) osgi.getServiceObject(refany);
-
- String any = archany.getInstanceDescription().getComponentDescription().getVersion();
- Assert.assertNotNull(any);
-
- // No version set in the factory, so no version.
- ServiceReference refmci = ipojo.getServiceReferenceByName(Architecture.class.getName(), "MyComponentInstance");
- Assert.assertNotNull(refmci);
- Architecture archmcy = (Architecture) osgi.getServiceObject(refmci);
-
- String mci = archmcy.getInstanceDescription().getComponentDescription().getVersion();
- Assert.assertNull(mci);
-
- }
-
- @Test
- public void testServiceProperty() throws InvalidSyntaxException {
-
- // Version 1.0
- //ServiceReference refv1 = ipojo.getServiceReferenceByName(MyService.class.getName(), "instance-v1");
- ServiceReference[] refv1 = context.getAllServiceReferences(MyService.class.getName(), "(instance.name=instance-v1)");
- Assert.assertNotNull(refv1);
- String version = (String) refv1[0].getProperty("factory.version");
- Assert.assertEquals("1.0", version);
-
- // Version 1.1
- ServiceReference[] refv11 = context.getAllServiceReferences(MyService.class.getName(), "(instance.name=instance-v1.1)");
- //ServiceReference refv11 = ipojo.getServiceReferenceByName(MyService.class.getName(), "instance-v1.1");
- Assert.assertNotNull(refv11);
- String version11 = (String) refv11[0].getProperty("factory.version");
-
- Assert.assertEquals("1.1", version11);
-
- // No Version
- ServiceReference[] refany = context.getAllServiceReferences(MyService.class.getName(), "(instance.name=instance-any)");
-
- // ServiceReference refany = ipojo.getServiceReferenceByName(MyService.class.getName(), "instance-any");
- Assert.assertNotNull(refany);
- String any = (String) refany[0].getProperty("factory.version");
- Assert.assertNotNull(any);
-
- // No version set in the factory, so no version.
- ServiceReference[] refmci = context.getAllServiceReferences(MyService.class.getName(), "(instance.name=MyComponentInstance)");
- //ServiceReference refmci = ipojo.getServiceReferenceByName(MyService.class.getName(), "MyComponentInstance");
- Assert.assertNotNull(refmci);
- String mci = (String) refmci[0].getProperty("factory.version");
- Assert.assertNull(mci);
- }
-
-
-}
diff --git a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java b/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
deleted file mode 100644
index 1d8de78..0000000
--- a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/VersionConflictTest.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.handlers.dependency.Dependency;
-import org.apache.felix.ipojo.handlers.dependency.DependencyDescription;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription;
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.component.MyCons;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.io.StreamUtils;
-import org.ops4j.lang.NullArgumentException;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class VersionConflictTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
-
- @Configuration
- public static Option[] configure() throws NullArgumentException, FileNotFoundException, IOException {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- File f1 = new File(tmp, "service-interface-v1.jar");
- StreamUtils.copyStream(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterfaceV1")
- .set(Constants.BUNDLE_VERSION, "1.0.0")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"1.0.0\"")
- .build( withBnd()),
- new FileOutputStream(f1),
- true);
-
- File f2 = new File(tmp, "service-interface-v2.jar");
- StreamUtils.copyStream(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterfaceV2")
- .set(Constants.BUNDLE_VERSION, "2.0.0")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"2.0.0\"")
- .build( withBnd()),
- new FileOutputStream(f2),
- true);
-
- File c1 = new File(tmp, "component-v1.jar");
- StreamUtils.copyStream(
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"ProviderV1")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"[1.0.0, 1.0.0]\"")
- .build( withiPOJO(new File("vprovider-v1.xml"))),
- new FileOutputStream(c1),
- true);
-
- File c2 = new File(tmp, "component-v2.jar");
- StreamUtils.copyStream(
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"ProviderV2")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"[2.0.0, 2.0.0]\"")
- .build( withiPOJO(new File("vprovider-v2.xml"))),
- new FileOutputStream(c2),
- true);
-
- File cons = new File(tmp, "cons.jar");
- StreamUtils.copyStream(
- newBundle()
- .add(MyCons.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyCons")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"[2.0.0, 2.0.0]\"")
- .set(Constants.BUNDLE_VERSION, "2.0")
- .build(withiPOJO(new File("cons.xml"))),
- new FileOutputStream(cons),
- true);
-
- File consV1 = new File(tmp, "cons-v1.jar");
- StreamUtils.copyStream(
- newBundle()
- .add(MyCons.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyCons")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service; version=\"[1.0.0, 1.0.0]\"")
- .set(Constants.BUNDLE_VERSION, "1.0")
- .build(withiPOJO(new File("cons.xml"))),
- new FileOutputStream(consV1),
- true);
-
- Option[] opt = options(
- felix(),
- equinox(),
- knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject(), mavenBundle().groupId("org.ops4j.base").artifactId("ops4j-base-lang").versionAsInProject()
-// mavenBundle().groupId( "org.ops4j.pax.swissbox" ).artifactId( "pax-swissbox-tinybundles" ).version(asInProject())
- ),
- systemProperty( "url1" ).value( f1.toURI().toURL().toExternalForm() ),
- systemProperty( "url2" ).value( f2.toURI().toURL().toExternalForm() ),
-
- systemProperty( "c1" ).value( c1.toURI().toURL().toExternalForm() ),
- systemProperty( "c2" ).value( c2.toURI().toURL().toExternalForm() ),
- systemProperty( "cons" ).value( cons.toURI().toURL().toExternalForm() ),
- systemProperty( "consV1" ).value( consV1.toURI().toURL().toExternalForm() )
- );
- return opt;
- }
-
- @Test
- public void deployBundlesAtRuntime() throws MalformedURLException, BundleException, InvalidSyntaxException {
-
- Bundle b1 = context.installBundle(context.getProperty("url1"));
- b1.start();
-
-
- Bundle b3 = context.installBundle(context.getProperty("c1"));
- b3.start();
-
- Bundle b2 = context.installBundle(context.getProperty("url2"));
- b2.start();
-
- Bundle b4 = context.installBundle(context.getProperty("c2"));
- b4.start();
-
- Bundle b5 = context.installBundle(context.getProperty("cons"));
- b5.start();
-
-
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- System.out.println("bundle " + bundles[i].getSymbolicName() + " : " + (bundles[i].getState() == Bundle.ACTIVE));
- //Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
- }
-
-
- PackageAdmin pa = osgi.getPackageAdmin();
- Bundle b = pa.getBundles("ServiceInterfaceV1", null)[0];
- ExportedPackage[] packages = pa.getExportedPackages(b);
- if (packages == null) {
- System.out.println("Packages ServiceInterfaceV1 : " + 0);
- } else {
- System.out.println("Packages ServiceInterfaceV1 : " + packages.length);
- for (ExportedPackage p : packages) {
- System.out.println("Package : " + p.getName() + " - " + p.getVersion().toString());
- }
- }
- b = pa.getBundles("ServiceInterfaceV2", null)[0];
- packages = pa.getExportedPackages(b);
- System.out.println("Packages ServiceInterfaceV2 : " + packages.length);
- for (ExportedPackage p : packages) {
- System.out.println("Package : " + p.getName() + " - " + p.getVersion().toString());
- }
-
- osgi.waitForService(Architecture.class.getName(), "(architecture.instance=mycons)", 2000);
-
- // Check that the two services are provided.
- ServiceReference[] refs = context.getAllServiceReferences(MyService.class.getName(), null);
- Assert.assertNotNull(refs);
- Assert.assertEquals(2, refs.length);
-
- ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "mycons");
- Assert.assertNotNull(refv1);
- Architecture arch = (Architecture) osgi.getServiceObject(refv1);
-
- HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
- Assert.assertNotNull(desc);
-
- DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
- Assert.assertNotNull(d.getDependencies());
- Assert.assertEquals(1, d.getDependencies().length);
-
- DependencyDescription dep = d.getDependencies()[0];
- Assert.assertEquals(Dependency.RESOLVED, dep.getState());
-
- Assert.assertEquals(1, dep.getServiceReferences().size());
- ServiceReference r = (ServiceReference) dep.getServiceReferences().get(0);
- Assert.assertEquals("provider", r.getProperty("factory.name"));
- Assert.assertEquals("2.0", r.getProperty("factory.version"));
- }
-
- @Test
- public void deployBundlesAtRuntimeV1() throws MalformedURLException, BundleException, InvalidSyntaxException {
-
- Bundle b1 = context.installBundle(context.getProperty("url1"));
- b1.start();
-
-
- Bundle b3 = context.installBundle(context.getProperty("c1"));
- b3.start();
-
- Bundle b2 = context.installBundle(context.getProperty("url2"));
- b2.start();
-
- Bundle b4 = context.installBundle(context.getProperty("c2"));
- b4.start();
-
- Bundle b5 = context.installBundle(context.getProperty("consV1"));
- b5.start();
-
-
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- System.out.println("bundle " + bundles[i].getSymbolicName() + " : " + (bundles[i].getState() == Bundle.ACTIVE));
- //Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
- }
-
-
- PackageAdmin pa = osgi.getPackageAdmin();
- Bundle b = pa.getBundles("ServiceInterfaceV1", null)[0];
- ExportedPackage[] packages = pa.getExportedPackages(b);
- if (packages == null) {
- System.out.println("Packages ServiceInterfaceV1 : " + 0);
- } else {
- System.out.println("Packages ServiceInterfaceV1 : " + packages.length);
- for (ExportedPackage p : packages) {
- System.out.println("Package : " + p.getName() + " - " + p.getVersion().toString());
- }
- }
- b = pa.getBundles("ServiceInterfaceV2", null)[0];
- packages = pa.getExportedPackages(b);
- System.out.println("Packages ServiceInterfaceV2 : " + packages.length);
- for (ExportedPackage p : packages) {
- System.out.println("Package : " + p.getName() + " - " + p.getVersion().toString());
- }
-
- osgi.waitForService(Architecture.class.getName(), "(architecture.instance=mycons)", 2000);
-
- // Check that the two services are provided.
- ServiceReference[] refs = context.getAllServiceReferences(MyService.class.getName(), null);
- Assert.assertNotNull(refs);
- Assert.assertEquals(2, refs.length);
-
- ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "mycons");
- Assert.assertNotNull(refv1);
- Architecture arch = (Architecture) osgi.getServiceObject(refv1);
-
- HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
- Assert.assertNotNull(desc);
-
- DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
- Assert.assertNotNull(d.getDependencies());
- Assert.assertEquals(1, d.getDependencies().length);
-
- DependencyDescription dep = d.getDependencies()[0];
- Assert.assertEquals(Dependency.RESOLVED, dep.getState());
-
- Assert.assertEquals(1, dep.getServiceReferences().size());
- ServiceReference r = (ServiceReference) dep.getServiceReferences().get(0);
-
- Assert.assertEquals("provider", r.getProperty("factory.name"));
- Assert.assertEquals("1.0", r.getProperty("factory.version"));
- }
-
-
-
-
-
-
-}
diff --git a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java b/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
deleted file mode 100644
index 71fcc94..0000000
--- a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.MyService;
-
-public class MyComponent implements MyService {
-
- public void foo() {
- // Nothing to do.
- }
-
-}
diff --git a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyCons.java b/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyCons.java
deleted file mode 100644
index e15d422..0000000
--- a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/component/MyCons.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.MyService;
-
-public class MyCons {
-
- private MyService[] services;
-
- public MyCons() {
- System.out.println("Bound to " + services.length);
- }
-
-}
diff --git a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java b/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
deleted file mode 100644
index 9ffaa52..0000000
--- a/ipojo/tests/core/factory-version/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.tests.core.service;
-
-public interface MyService {
-
- public void foo();
-
-}
diff --git a/ipojo/tests/core/factory-version/vprovider-v1.xml b/ipojo/tests/core/factory-version/vprovider-v1.xml
deleted file mode 100644
index 9aee6b7..0000000
--- a/ipojo/tests/core/factory-version/vprovider-v1.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component name="provider" classname="org.apache.felix.ipojo.tests.core.component.MyComponent" version="1.0">
- <provides/>
- </component>
- <instance component="provider" version="1.0"/>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/factory-version/vprovider-v2.xml b/ipojo/tests/core/factory-version/vprovider-v2.xml
deleted file mode 100644
index 676764d..0000000
--- a/ipojo/tests/core/factory-version/vprovider-v2.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component name="provider" classname="org.apache.felix.ipojo.tests.core.component.MyComponent" version="2.0">
- <provides/>
- </component>
- <instance component="provider" version="2.0"/>
-
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/core/handler/pom.xml b/ipojo/tests/core/handler/pom.xml
deleted file mode 100644
index d81c04d..0000000
--- a/ipojo/tests/core/handler/pom.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.handler</artifactId>
- <name>iPOJO Handler Mechanism Test Suite</name>
- <version>${ipojo.core.snapshot}</version>
- <description>Test the handler mechanism</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
-
- <!-- Pax Exam API: -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
-
- <!-- TinyBundle -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-bnd</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
-
- <!-- mockito -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-</project>
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/DummyHandlerTest.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/DummyHandlerTest.java
deleted file mode 100644
index 63d0c8d..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/DummyHandlerTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.tests.core.component.DummyImpl;
-import org.apache.felix.ipojo.tests.core.handler.DummyHandler;
-import org.apache.felix.ipojo.tests.core.service.Dummy;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.OptionUtils;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.exam.junit.JUnitOptions;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.useradmin.User;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-import aQute.lib.osgi.Constants;
-
-@RunWith(JUnit4TestRunner.class)
-public class DummyHandlerTest {
-
- private static final String DUMMY_TEST_FACTORY = "dummy.test";
-
- /*
- * Number of mock object by test.
- */
- private static final int NB_MOCK = 10;
-
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- @Before
- public void setUp() {
- osgi = new OSGiHelper(context);
- }
-
- @After
- public void tearDown() {
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- Option[] platform = options(CoreOptions.felix());
-
- Option[] bundles =
- options(
- provision(
- newBundle()
- .add(DummyHandler.class)
- .build(withiPOJO(new File("src/test/resources/dummy-handler.xml")))
- ),
- provision(
- newBundle()
- .add(Dummy.class)
- .add(DummyImpl.class)
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.handler.dummy.test")
- .build(withiPOJO(new File("src/test/resources/dummy-component.xml")))
- ),
- provision(
- mavenBundle().groupId("org.apache.felix").artifactId("org.osgi.compendium").version("1.4.0")
- ));
- Option[] r = OptionUtils.combine(platform, bundles);
-
- return r;
- }
-
- /**
- * iPOJO Bunles
- * @return
- */
- @Configuration
- public static Option[] configAdminBundle() {
- return options(
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").versionAsInProject(),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject());
- }
-
- /**
- * Mockito bundle
- * @return
- */
- @Configuration
- public static Option[] mockitoBundle() {
- return options(JUnitOptions.mockitoBundles());
- }
-
- /**
- * Basic Test, in order to know if the instance is correctly create.
- */
- @Test
- public void testDummyTestInstance() {
- ComponentInstance instance = null;
-
- // Get the factory
- Factory factory = Tools.getValidFactory(osgi, DUMMY_TEST_FACTORY);
- Assert.assertNotNull(factory);
-
- // Create an instance
- try {
- instance = factory.createComponentInstance(null);
- } catch (UnacceptableConfiguration e) {
- new AssertionError(e);
- } catch (MissingHandlerException e) {
- new AssertionError(e);
- e.printStackTrace();
- } catch (ConfigurationException e) {
- new AssertionError(e);
- }
-
- // Must be valid now
- Assert.assertEquals(instance.getState(), ComponentInstance.VALID);
-
- // Stop the instance
- instance.stop();
- Assert.assertEquals(instance.getState(), ComponentInstance.STOPPED);
-
- // Start the instance
- instance.start();
- Assert.assertEquals(instance.getState(), ComponentInstance.VALID);
- }
-
- /**
- * Test if the bind and unbind methods are called when the bind service are registered after the instance creation
- */
- @Test
- public void testDummyTestBindAfterStart() {
- ComponentInstance instance = null;
-
- // Get the factory
- Factory factory = Tools.getValidFactory(osgi, DUMMY_TEST_FACTORY);
-
- // Create an instance
- try {
- instance = factory.createComponentInstance(null);
- } catch (UnacceptableConfiguration e) {
- } catch (MissingHandlerException e) {
- } catch (ConfigurationException e) {
- }
-
- Map<User, ServiceRegistration> registrations = new HashMap<User, ServiceRegistration>();
-
- for (int i = 0; i < NB_MOCK; i++) {
- User service = mock(User.class);
- ServiceRegistration sr = context.registerService(User.class.getName(), service, null);
- registrations.put(service, sr);
- }
-
- //verify that the bind method of the handler has been called
- for (User user : registrations.keySet()) {
- verify(user).getName();
- }
-
- //verify that the unbind has been called
- for (User user : registrations.keySet()) {
- registrations.get(user).unregister();
- verify(user).getType();
- }
-
- //verify no more interaction
- for (User user : registrations.keySet()) {
- Mockito.verifyNoMoreInteractions(user);
- }
- }
-
-
- /**
- * Test if the bind and unbind methods when the bind services are registered before the instance creation
- */
- @Test
- public void testDummyTestBindBeforeStart() {
- ComponentInstance instance = null;
-
- Map<User, ServiceRegistration> registrations = new HashMap<User, ServiceRegistration>();
-
- for (int i = 0; i < NB_MOCK; i++) {
- User service = mock(User.class);
- ServiceRegistration sr = context.registerService(User.class.getName(), service, null);
- registrations.put(service, sr);
- }
-
- // Get the factory
- Factory factory = Tools.getValidFactory(osgi, DUMMY_TEST_FACTORY);
-
- // Create an instance
- try {
- instance = factory.createComponentInstance(null);
- } catch (UnacceptableConfiguration e) {
- } catch (MissingHandlerException e) {
- } catch (ConfigurationException e) {
- }
-
- //verify that the bind method of the handler has been called
- for (User user : registrations.keySet()) {
- verify(user).getName();
- }
-
- //verify that the unbind has been called
- for (User user : registrations.keySet()) {
- registrations.get(user).unregister();
- verify(user).getType();
- }
-
- //verify no more interaction
- for (User user : registrations.keySet()) {
- Mockito.verifyNoMoreInteractions(user);
- }
- }
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/IgnoreCaseHandlerSelectionTest.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/IgnoreCaseHandlerSelectionTest.java
deleted file mode 100644
index d090cc7..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/IgnoreCaseHandlerSelectionTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-
-import java.io.File;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.handler.EmptyHandler;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-/**
- * Check that the handler selection ignore case.
- * An empty handler declared with
- * name="EmPtY" and namespace="orG.apAche.feliX.iPOJO.tests.CORE.hAnDlEr"
- * is declared, and two instances using this handler are created. The test is
- * successful is the two instances are created correctly.
- * Test about Felix-1318 : Case mismatch problem of iPOJO custom handler name
- */
-@RunWith( JUnit4TestRunner.class )
-public class IgnoreCaseHandlerSelectionTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
-
- Option[] opt = options(
- felix(),
- equinox(),
- knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set( Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface" )
- .set( Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service" )
- .build( TinyBundles.withBnd() )
- ),
- provision(
- // Components and the handler
- newBundle()
- .add(MyComponent.class) // Component Implementation
- .add(EmptyHandler.class) // Handler.
- .set(Constants.BUNDLE_SYMBOLICNAME,"IgnoreCase")
- .set(Constants.IMPORT_PACKAGE,
- "org.apache.felix.ipojo.tests.core.service, " +
- "org.apache.felix.ipojo, " +
- "org.apache.felix.ipojo.metadata")
- .build(withiPOJO(new File(tmp, "ignorecase.jar"), new File("src/test/resources/ignorecase.xml")))));
- return opt;
- }
-
- @Test
- public void testDeploy() {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
- }
- }
-
- /**
- * Checks that the handler is declared and accessible.
- */
- @Test
- public void testHandlerAvailability() {
- ServiceReference[] refs = osgi.getServiceReferences(HandlerFactory.class.getName(), null);
- for (ServiceReference ref : refs) {
- String name = (String) ref.getProperty("handler.name");
- String ns = (String) ref.getProperty("handler.namespace");
- if (name != null
- && name.equalsIgnoreCase("EmPtY") // Check with ignore case.
- && ns != null
- && ns.equalsIgnoreCase("orG.apAche.feliX.iPOJO.tests.CORE.hAnDlEr")) { // Check with ignore case.
- Integer state = (Integer) ref.getProperty("factory.state");
- if (state != null) {
- Assert.assertEquals(Factory.VALID, state.intValue());
- return; // Handler found and valid.
- } else {
- Assert.fail("Handler found but no state exposed");
- }
- }
- }
- Assert.fail("Handler not found");
- }
-
- /**
- * Check that the instance is correctly created with "empty".
- */
- @Test
- public void testCreationOfIgnoreCase1() {
- ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "IgnoreCase-1");
- Assert.assertNotNull(refv1);
- Architecture arch = (Architecture) osgi.getServiceObject(refv1);
- Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());
-
- HandlerDescription desc = arch.getInstanceDescription()
- .getHandlerDescription("orG.apAche.feliX.iPOJO.tests.CORE.hAnDlEr:EmPtY"); // Check with the declared name.
-
- Assert.assertNotNull(desc);
- Assert.assertTrue(desc.isValid());
- }
-
- /**
- * Check that the instance is correctly created with "eMptY".
- */
- @Test
- public void testCreationOfIgnoreCase2() {
- ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "IgnoreCase-2");
- Assert.assertNotNull(refv1);
- Architecture arch = (Architecture) osgi.getServiceObject(refv1);
- Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());
-
- HandlerDescription desc = arch.getInstanceDescription()
- .getHandlerDescription("org.apache.felix.ipojo.tests.core.handler:empty"); // Check with different case.
- Assert.assertNotNull(desc);
- Assert.assertTrue(desc.isValid());
- }
-
-
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/Tools.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/Tools.java
deleted file mode 100644
index cdaa5bd..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/Tools.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import org.apache.felix.ipojo.Factory;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-public class Tools {
-
-
- /**
- * Get the Factory linked to the given pid
- * @param osgi
- * @param name
- * @return The factory
- */
- public static Factory getValidFactory(final OSGiHelper osgi, final String name) {
- // Get The Factory ServiceReference
- ServiceReference facref = osgi.getServiceReference(Factory.class.getName(), "(&(factory.state=1)(factory.name=" + name + "))");
- // Get the factory
- Factory factory = (Factory) osgi.getServiceObject(facref);
-
- return factory;
- }
-
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/DummyImpl.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/DummyImpl.java
deleted file mode 100644
index afcaff5..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/DummyImpl.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.Dummy;
-
-
-/**
- * Just a Dummy test
- */
-public class DummyImpl implements Dummy{
-
- private void start() {
- }
-
- private void stop() {
- }
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
deleted file mode 100644
index 71fcc94..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.MyService;
-
-public class MyComponent implements MyService {
-
- public void foo() {
- // Nothing to do.
- }
-
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/DummyHandler.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/DummyHandler.java
deleted file mode 100644
index fbb886c..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/DummyHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2009 OW2 Chameleon Licensed under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
- * or agreed to in writing, software distributed under the License is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-
-package org.apache.felix.ipojo.tests.core.handler;
-
-import java.util.Dictionary;
-
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.metadata.Element;
-import org.osgi.service.useradmin.User;
-
-
-public class DummyHandler extends PrimitiveHandler {
-
- public DummyHandler() {
- }
-
- /*------------------------------------------------------------*
- * Handler Specific Methods *
- *------------------------------------------------------------*/
-
- @Override
- public void initializeComponentFactory(ComponentTypeDescription typeDesc, Element metadata) throws ConfigurationException {
- // Initialize
- super.initializeComponentFactory(typeDesc, metadata);
- }
-
- @Override
- public void configure(Element metadata, Dictionary configuration) throws ConfigurationException {
- }
-
-
- private void bindUser(User user) {
- // in order to test
- user.getName();
- }
-
- private void unBindUser(User user) {
- // in order to test
- user.getType();
- }
-
- @Override
- public void start() {
- }
-
- @Override
- public void stop() {
- }
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/EmptyHandler.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/EmptyHandler.java
deleted file mode 100644
index 2a1db72..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/handler/EmptyHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.felix.ipojo.tests.core.handler;
-
-import java.util.Dictionary;
-
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.metadata.Element;
-
-public class EmptyHandler extends PrimitiveHandler {
-
- @Override
- public void configure(Element arg0, Dictionary arg1)
- throws ConfigurationException {
- info("Configured");
- }
-
- @Override
- public void start() {
- info("Started");
- }
-
- @Override
- public void stop() {
- info("Stopped");
- }
-
-}
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/Dummy.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/Dummy.java
deleted file mode 100644
index 7c317d7..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/Dummy.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.felix.ipojo.tests.core.service;
-
-public interface Dummy {
-}
-
diff --git a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java b/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
deleted file mode 100644
index 9ffaa52..0000000
--- a/ipojo/tests/core/handler/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.tests.core.service;
-
-public interface MyService {
-
- public void foo();
-
-}
diff --git a/ipojo/tests/core/handler/src/test/resources/dummy-component.xml b/ipojo/tests/core/handler/src/test/resources/dummy-component.xml
deleted file mode 100644
index b926293..0000000
--- a/ipojo/tests/core/handler/src/test/resources/dummy-component.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<iPOJO xmlns:dummy="org.apache.felix.ipojo.test.dummy.handler.dummyhandler">
- <component className="org.apache.felix.ipojo.tests.core.component.DummyImpl" name="dummy.test">
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
-
- <dummy:dummy/>
- </component>
-</iPOJO>
diff --git a/ipojo/tests/core/handler/src/test/resources/dummy-handler.xml b/ipojo/tests/core/handler/src/test/resources/dummy-handler.xml
deleted file mode 100644
index 19cc660..0000000
--- a/ipojo/tests/core/handler/src/test/resources/dummy-handler.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
- <!--
- <iPOJO xmlns:wbp="org.apache.felix.ipojo.whiteboard"
- xmlns:jmx="org.apache.felix.ipojo.handlers.jmx">
- -->
-<iPOJO>
- <!-- Declare the handler -->
- <handler classname="org.apache.felix.ipojo.tests.core.handler.DummyHandler" name="dummy"
- namespace="org.apache.felix.ipojo.test.dummy.handler.dummyhandler">
-
-
- <requires optional="true" aggregate="true">
- <callback type="bind" method="bindUser" />
- <callback type="unbind" method="unBindUser" />
- </requires>
- </handler>
-</iPOJO>
diff --git a/ipojo/tests/core/handler/src/test/resources/ignorecase.xml b/ipojo/tests/core/handler/src/test/resources/ignorecase.xml
deleted file mode 100644
index 1173031..0000000
--- a/ipojo/tests/core/handler/src/test/resources/ignorecase.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<ipojo xmlns:ex="org.apache.felix.ipojo.tests.core.handler">
-
-<!-- Empty handler, name and namespace written strangely -->
-<handler
- name="EmPtY"
- namespace="orG.apAche.feliX.iPOJO.tests.CORE.hAnDlEr"
- classname="org.apache.felix.ipojo.tests.core.handler.EmptyHandler">
-</handler>
-
-<component classname="org.apache.felix.ipojo.tests.core.component.MyComponent" name="IgnoreCase-1">
- <ex:empty/>
-</component>
-<instance component="IgnoreCase-1" name="IgnoreCase-1"/>
-
-<component classname="org.apache.felix.ipojo.tests.core.component.MyComponent" name="IgnoreCase-2">
- <ex:eMptY/>
-</component>
-<instance component="IgnoreCase-2" name="IgnoreCase-2"/>
-
-</ipojo>
diff --git a/ipojo/tests/core/lifecycle-callback/pom.xml b/ipojo/tests/core/lifecycle-callback/pom.xml
deleted file mode 100644
index d51650f..0000000
--- a/ipojo/tests/core/lifecycle-callback/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Lifecycle callback Test Suite</name>
- <artifactId>tests.core.lifecycle.callback</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.lifecycle.callback.LifeCycleCallbackTest
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java
deleted file mode 100644
index edffc63..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackCheckService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.FooService;
-
-public class CallbackCheckService extends ParentClass implements CheckService {
-
- int i = 0;
-
- FooService fs;
-
- public static CallbackCheckService singleton;
-
- public static int count = 0;
-
- private static CallbackCheckService singleton() {
- if (singleton == null) {
- count++;
- singleton = new CallbackCheckService();
- }
- return singleton;
- }
-
- public static CallbackCheckService several() {
- count++;
- return new CallbackCheckService();
- }
-
- private void start() {
- i++;
- }
-
- protected void stop() {
- i++;
- }
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties p = new Properties();
- p.put("int", new Integer(i));
- p.put("count", new Integer(count));
- return p;
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackWithErrorCheckService.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackWithErrorCheckService.java
deleted file mode 100644
index a33af51..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallbackWithErrorCheckService.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-
-public class CallbackWithErrorCheckService extends ParentClass implements CheckService {
-
-
- public void start() {
- throw new NullPointerException();
- }
-
- public void stop() {
- }
-
- public boolean check() {
- return true;
- }
-
- public Properties getProps() {
- Properties p = new Properties();
- return p;
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 35377c3..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
deleted file mode 100644
index f7fb580..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass {
-
- public void parentStart() {
-
- }
-
- public void parentStop() {
-
- }
-
- protected String[] strings;
-
- protected String string;
-
- protected int upStrings;
-
- protected int upString;
-
- public void updateStrings(String[] bb) {
- strings = bb;
- upStrings++;
- }
-
- public void updateString(String bb) {
- string = bb;
- upString++;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java
deleted file mode 100644
index 0d54e5e..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class CallbackTestCase extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
- ComponentInstance fooProvider;
-
- public void setUp() {
- Properties p2 = new Properties();
- p2.put("instance.name","fooProvider");
- fooProvider = Utils.getComponentInstance(getContext(), "LFCB-FooProviderType-1", p2);
- fooProvider.stop();
-
- Properties p1 = new Properties();
- p1.put("instance.name","callback");
- instance = Utils.getComponentInstance(getContext(), "LFCB-CallbackCheckService", p1);
-
- }
-
- public void tearDown() {
- instance.dispose();
- fooProvider.dispose();
- instance= null;
- fooProvider = null;
- }
-
- public void testCallback() {
- // Check instance is invalid
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
- assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
-
- // Start fooprovider
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check int property
- Integer index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 1", index.intValue(), 1);
-
- assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
-
- assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check int property
- index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
-
- assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
-
- // Clean up
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- cs = null;
- id_dep = null;
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ErrorCallbackTestCase.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ErrorCallbackTestCase.java
deleted file mode 100644
index 8625527..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ErrorCallbackTestCase.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Test the fix for FELIX-1965.
- * When a validate callback throws an exception, the service is still provided.
- */
-public class ErrorCallbackTestCase extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
-
- public void tearDown() {
- if (instance != null) {
- instance.dispose();
- instance= null;
- }
- }
-
- public void testErrorInValidateCallback() {
- Properties p2 = new Properties();
- p2.put("instance.name","error");
- instance = Utils.getComponentInstance(getContext(), "LFCB-CallbackWithError", p2);
-
- // The service should not be provided as the start method has thrown an exception
- ServiceReference ref = getServiceReference(CheckService.class.getName(), "(instance.name=" + instance.getInstanceName() +")");
- assertNull(ref);
-
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java
deleted file mode 100644
index c39f7ed..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ImmediateCallbackSeveralFactoryTest extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
- ComponentInstance fooProvider;
-
- public void setUp() {
- Properties p2 = new Properties();
- p2.put("instance.name","fooProvider");
- fooProvider = Utils.getComponentInstance(getContext(), "LFCB-FooProviderType-1", p2);
- fooProvider.stop();
-
- Properties p1 = new Properties();
- p1.put("instance.name","callback");
- instance = Utils.getComponentInstance(getContext(), "LFCB-ImmediateCallbackCheckServiceSeveral", p1);
-
- }
-
- public void tearDown() {
- instance.dispose();
- fooProvider.dispose();
- instance= null;
- fooProvider = null;
- CallbackCheckService.count = 0;
- }
-
- public void testCallback() {
- // Check instance is invalid
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
- assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
-
- // Start fooprovider
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
- // Check int property
- Integer index = (Integer) (cs.getProps().get("int"));
- Integer count = (Integer) (cs.getProps().get("count"));
- assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
- assertEquals("Check count property - 1 (" + count.intValue() +")", count.intValue(), 1);
-
- fooProvider.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
-
- assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check int property
- index = (Integer) (cs.getProps().get("int"));
- count = (Integer) (cs.getProps().get("count"));
- assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
- assertEquals("Check count property - 2 ("+count.intValue()+")", count.intValue(), 1);
-
- assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
-
- // Clean up
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- cs = null;
- id_dep = null;
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java
deleted file mode 100644
index 07eb5a3..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ImmediateCallbackSingletonFactoryTest extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
- ComponentInstance fooProvider;
-
- public void setUp() {
- Properties p2 = new Properties();
- p2.put("instance.name","fooProvider");
- fooProvider = Utils.getComponentInstance(getContext(), "LFCB-FooProviderType-1", p2);
- fooProvider.stop();
-
- Properties p1 = new Properties();
- p1.put("instance.name","callback");
- instance = Utils.getComponentInstance(getContext(), "LFCB-ImmediateCallbackCheckServiceSingleton", p1);
-
- }
-
- public void tearDown() {
- instance.dispose();
- fooProvider.dispose();
- instance= null;
- fooProvider = null;
- CallbackCheckService.count = 0;
- CallbackCheckService.singleton = null;
- }
-
- public void testCallback() {
- // Check instance is invalid
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
- assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
-
- // Start fooprovider
- fooProvider.start();
-
- // Check instance validity
- // id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
- // Check int property
- Integer index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
-
- fooProvider.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
-
- assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.start();
-
- // Check instance validity
- // id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check int property
- index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
-
- assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
-
- // Clean up
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- cs = null;
- id_dep = null;
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java
deleted file mode 100644
index dae2876..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ImmediateCallbackTest extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
- ComponentInstance fooProvider;
-
- public void setUp() {
- Properties p2 = new Properties();
- p2.put("instance.name","fooProvider");
- fooProvider = Utils.getComponentInstance(getContext(), "LFCB-FooProviderType-1", p2);
- fooProvider.stop();
-
- Properties p1 = new Properties();
- p1.put("instance.name","callback");
- instance = Utils.getComponentInstance(getContext(), "LFCB-ImmediateCallbackCheckService", p1);
-
- }
-
- public void tearDown() {
- instance.dispose();
- fooProvider.dispose();
- instance= null;
- fooProvider = null;
- }
-
- public void testCallback() {
- // Check instance is invalid
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription)((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
- assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
-
- // Start fooprovider
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
- // Check int property
- Integer index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
-
- fooProvider.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
-
- assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check int property
- index = (Integer) (cs.getProps().get("int"));
- assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
-
- assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
-
- // Clean up
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- cs = null;
- id_dep = null;
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java
deleted file mode 100644
index 4b41f25..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ImmediateLifeCycleControllerTest extends OSGiTestCase {
-
- private ComponentInstance under;
- private Factory factory;
-
- public void setUp() {
- factory = Utils.getFactoryByName(getContext(), "LFC-Test-Immediate");
- }
-
- public void testOne() {
- Properties props = new Properties();
- props.put("conf", "foo");
- props.put("instance.name","under");
- under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
-
- // The conf is correct, the PS must be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
- assertNotNull("Check service availability -1", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 1", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- // Reconfigure the instance with a bad configuration
- props.put("conf", "bar"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- // The instance should now be invalid
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a valid configuration
- props.put("conf", "foo"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 2", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
- public void testTwo() {
- Properties props = new Properties();
- props.put("conf", "bar");
- props.put("instance.name","under");
- under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
-
- assertEquals("check under state", under.getState(), ComponentInstance.INVALID);
-
- // The conf is incorrect, the PS must not be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
- assertNull("Check service availability -1", ref);
-
- // Reconfigure the instance with a correct configuration
- props.put("conf", "foo");
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under");
- assertNotNull("Check service availability -2", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state ", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java
deleted file mode 100644
index feccc8a..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class LifeCycleCallbackTest extends TestSuite {
-
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Lifecycle callbacks Test Suite", bc);
- ots.addTestSuite(CallbackTestCase.class);
- ots.addTestSuite(ParentCallbackTestCase.class);
- ots.addTestSuite(ImmediateCallbackTest.class);
- ots.addTestSuite(ImmediateCallbackSingletonFactoryTest.class);
- ots.addTestSuite(ImmediateCallbackSeveralFactoryTest.class);
- ots.addTestSuite(ErrorCallbackTestCase.class);
- return ots;
- }
-
-}
-
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java
deleted file mode 100644
index 94145c9..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ParentCallbackTestCase extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
- ComponentInstance fooProvider;
-
- public void setUp() {
- Properties p2 = new Properties();
- p2.put("instance.name","fooProvider");
- fooProvider = Utils.getComponentInstance(getContext(), "LFCB-FooProviderType-1", p2);
- fooProvider.stop();
-
- Properties p1 = new Properties();
- p1.put("instance.name","callback");
- instance = Utils.getComponentInstance(getContext(), "LFCB-ParentCallbackCheckService", p1);
-
- }
-
- public void tearDown() {
- instance.dispose();
- fooProvider.dispose();
- instance= null;
- fooProvider = null;
- }
-
- public void testCallback() {
- // Check instance is invalid
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Start fooprovider
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- // Check int property
- assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
-
- fooProvider.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- // Check instance validity
- //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
-
- // Check service providing
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Clean up
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- cs = null;
- id_dep = null;
- }
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java
deleted file mode 100644
index 45684ab..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java
deleted file mode 100644
index b1fdd34..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 1196bc2..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-callback/src/main/resources/metadata.xml b/ipojo/tests/core/lifecycle-callback/src/main/resources/metadata.xml
deleted file mode 100644
index 7dd3607..0000000
--- a/ipojo/tests/core/lifecycle-callback/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="LFCB-FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Lifecycle Callback -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- name="LFCB-CallbackCheckService" architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- name="LFCB-ParentCallbackCheckService" architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="parentStart" />
- <callback transition="invalidate" method="parentStop" />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- immediate="true" name="LFCB-ImmediateCallbackCheckService"
- architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- immediate="true" name="LFCB-ImmediateCallbackCheckServiceSingleton"
- factory-method="singleton" architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
- immediate="true" name="LFCB-ImmediateCallbackCheckServiceSeveral"
- factory-method="several" architecture="true">
- <requires field="fs" />
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
-
- <!-- Test initialization error -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CallbackWithErrorCheckService"
- name="LFCB-CallbackWithError">
- <provides />
- <callback transition="validate" method="start" />
- <callback transition="invalidate" method="stop" />
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/lifecycle-controller/pom.xml b/ipojo/tests/core/lifecycle-controller/pom.xml
deleted file mode 100644
index 734d0b6..0000000
--- a/ipojo/tests/core/lifecycle-controller/pom.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Lifecycle controller Test Suite</name>
- <artifactId>tests.core.lifecycle.controller</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.lfc.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.lfc.LifeCycleControllerTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- <metadata>
- <![CDATA[
- <ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
- name="LFC-Test">
- <provides />
- <controller field="m_state" />
- <properties>
- <property name="conf" field="m_conf" method="setConf" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
- name="LFC-Test-Immediate" immediate="true" architecture="true">
- <provides />
- <controller field="m_state" />
- <properties>
- <property name="conf" field="m_conf" method="setConf" />
- </properties>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ConfigurableLifecycleControllerTest"
- name="LFC-Test-Configurable" architecture="true">
- <provides />
- <!-- The property and the controller share the same field -->
- <controller field="m_state" />
- <properties>
- <property name="state" field="m_state" />
- </properties>
- </component>
- </ipojo>
- ]]>
- </metadata>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <logService>false</logService>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableLifecycleControllerTest.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableLifecycleControllerTest.java
deleted file mode 100644
index 05d2cdf..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableLifecycleControllerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
-
-public class ConfigurableLifecycleControllerTest implements CheckService {
-
- // This is both a property and the controller.
- private boolean m_state;
-
- public boolean check() {
- return m_state;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("state", new Boolean(m_state));
- return props;
- }
-
-}
-
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
deleted file mode 100644
index 9027ed1..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
-
-public class LifecycleControllerTest implements CheckService {
-
- private boolean m_state = true;
- private String m_conf;
-
- public void setConf(String newConf) {
- if (newConf.equals("foo")) {
- m_state = true;
- } else {
- m_state = false;
- }
- }
-
- public boolean check() {
- return m_state;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("conf", m_conf);
- props.put("state", new Boolean(m_state));
- return props;
- }
-}
-
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ConfigurableLifeCycleControllerTest.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ConfigurableLifeCycleControllerTest.java
deleted file mode 100644
index d70dbae..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ConfigurableLifeCycleControllerTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lfc;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class ConfigurableLifeCycleControllerTest extends OSGiTestCase {
-
- private ComponentInstance under;
-
- private Factory factory;
-
- public void setUp() {
- factory = Utils.getFactoryByName(getContext(), "LFC-Test-Configurable");
- }
-
- public void testValidThenInvalid() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties props = new Properties();
- props.put("instance.name","under1");
- props.put("state", "true");
- under = factory.createComponentInstance(props);
-
- // The conf is correct, the PS must be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -1", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 1", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- // Reconfigure the instance
- props.put("state", "false"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- // The instance should now be invalid
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a valid configuration
- props.put("state", "true");
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 2", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
- public void testInValidThenValid() throws Exception {
- Properties props = new Properties();
- props.put("instance.name","under1");
- props.put("state", "false");
- under = factory.createComponentInstance(props);
-
- // The instance should now be invalid
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance
- props.put("state", "true"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
-// Object[] objects = Utils.getServiceObjects(context, Architecture.class.getName(), null);
-// for (int i = 0; i < objects.length; i++) {
-// Architecture a = (Architecture) objects[i];
-// System.out.println(a.getInstanceDescription().getDescription());
-// }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -1", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 1", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- // Reconfigure the instance
- props.put("state", "false"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- // The instance should now be invalid
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a valid configuration
- props.put("state", "true");
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 2", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
-// /**
-// * This test must be removed as it is not compliant with OSGi. It unregisters a service during the creation of the
-// * service instance, so the returned object is null.
-// */
-// public void notestTwo() {
-// Properties props = new Properties();
-// props.put("conf", "bar");
-// props.put("instance.name","under2");
-// under = Utils.getComponentInstance(getContext(), "LFC-Test", props);
-//
-// // The conf is incorrect, but the test can appears only when the object is created : the PS must be provided
-// ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
-// assertNotNull("Check service availability -1", ref);
-//
-// System.out.println("CS received : " + getContext().getService(ref));
-// CheckService cs = (CheckService) getContext().getService(ref);
-// assertNotNull("Assert CS not null", cs);
-// try {
-// assertFalse("Check state (false)", cs.check());
-// } catch (Throwable e) {
-// e.printStackTrace();
-// fail(e.getMessage());
-// }
-//
-// // As soon as the instance is created, the service has to disappear :
-// ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
-// assertNull("Check service availability -2", ref);
-//
-// // Reconfigure the instance with a correct configuration
-// props.put("conf", "foo");
-// try {
-// factory.reconfigure(props);
-// } catch (Exception e) {
-// fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
-// }
-//
-// ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
-// assertNotNull("Check service availability -3", ref);
-// cs = (CheckService) getContext().getService(ref);
-// assertTrue("Check state ", cs.check());
-// getContext().ungetService(ref);
-// cs = null;
-//
-// under.dispose();
-// }
-
-}
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java
deleted file mode 100644
index 4b86fb0..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lfc;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ImmediateLifeCycleControllerTest extends OSGiTestCase {
-
- private ComponentInstance under;
- private Factory factory;
-
- public void setUp() {
- factory = Utils.getFactoryByName(getContext(), "LFC-Test-Immediate");
- }
-
- public void testOne() {
- Properties props = new Properties();
- props.put("conf", "foo");
- props.put("instance.name","under1");
- under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
-
- // The conf is correct, the PS must be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -1", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 1", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- // Reconfigure the instance with a bad configuration
- props.put("conf", "bar"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- // The instance should now be invalid
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a valid configuration
- props.put("conf", "foo"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 2", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
- public void testTwo() {
- Properties props = new Properties();
- props.put("conf", "bar");
- props.put("instance.name","under2");
- under = Utils.getComponentInstance(getContext(), "LFC-Test-Immediate", props);
-
- assertEquals("check under state", under.getState(), ComponentInstance.INVALID);
-
- // The conf is incorrect, the PS must not be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
- assertNull("Check service availability -1", ref);
-
- // Reconfigure the instance with a correct configuration
- props.put("conf", "foo");
- try {
- factory.reconfigure(props);
- } catch(Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
- assertNotNull("Check service availability -2", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state ", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
-
-
-}
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java
deleted file mode 100644
index 597b21a..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lfc;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class LifeCycleControllerTest extends OSGiTestCase {
-
- private ComponentInstance under;
-
- private Factory factory;
-
- public void setUp() {
- factory = Utils.getFactoryByName(getContext(), "LFC-Test");
- }
-
- public void testOne() {
- Properties props = new Properties();
- props.put("conf", "foo");
- props.put("instance.name","under1");
- under = Utils.getComponentInstance(getContext(), "LFC-Test", props);
-
- // The conf is correct, the PS must be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -1", ref);
- CheckService cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 1", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- // Reconfigure the instance with a bad configuration
- props.put("conf", "bar"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- // The instance should now be invalid
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a valid configuration
- props.put("conf", "foo"); // Bar is a bad conf
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under1");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state 2", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
- /**
- * This test must be removed as it is not compliant with OSGi. It unregisters a service during the creation of the
- * service instance, so the returned object is null.
- */
- public void notestTwo() {
- Properties props = new Properties();
- props.put("conf", "bar");
- props.put("instance.name","under2");
- under = Utils.getComponentInstance(getContext(), "LFC-Test", props);
-
- // The conf is incorrect, but the test can appears only when the object is created : the PS must be provided
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
- assertNotNull("Check service availability -1", ref);
-
- System.out.println("CS received : " + getContext().getService(ref));
- CheckService cs = (CheckService) getContext().getService(ref);
- assertNotNull("Assert CS not null", cs);
- try {
- assertFalse("Check state (false)", cs.check());
- } catch (Throwable e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- // As soon as the instance is created, the service has to disappear :
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
- assertNull("Check service availability -2", ref);
-
- // Reconfigure the instance with a correct configuration
- props.put("conf", "foo");
- try {
- factory.reconfigure(props);
- } catch (Exception e) {
- fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
- }
-
- ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), "under2");
- assertNotNull("Check service availability -3", ref);
- cs = (CheckService) getContext().getService(ref);
- assertTrue("Check state ", cs.check());
- getContext().ungetService(ref);
- cs = null;
-
- under.dispose();
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java
deleted file mode 100644
index 80ce329..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lfc;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class LifeCycleControllerTestSuite {
-
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Lifecycle Controller Test Suite", bc);
- ots.addTestSuite( LifeCycleControllerTest.class);
- ots.addTestSuite( ImmediateLifeCycleControllerTest.class);
- ots.addTestSuite(ConfigurableLifeCycleControllerTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java
deleted file mode 100644
index 3741060..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.lfc.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 055b9bd..0000000
--- a/ipojo/tests/core/lifecycle-controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-//import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/logger/component.xml b/ipojo/tests/core/logger/component.xml
deleted file mode 100644
index b30dab9..0000000
--- a/ipojo/tests/core/logger/component.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<ipojo>
-<component classname="org.apache.felix.ipojo.tests.core.component.MyComponent">
- <provides/>
-</component>
-<instance component="org.apache.felix.ipojo.tests.core.component.MyComponent"/>
-</ipojo>
diff --git a/ipojo/tests/core/logger/erroneous-component.xml b/ipojo/tests/core/logger/erroneous-component.xml
deleted file mode 100644
index 9ac7735..0000000
--- a/ipojo/tests/core/logger/erroneous-component.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<ipojo>
-<component immediate="true" classname="org.apache.felix.ipojo.tests.core.component.MyErroneousComponent">
- <provides/>
-</component>
-</ipojo>
diff --git a/ipojo/tests/core/logger/pom.xml b/ipojo/tests/core/logger/pom.xml
deleted file mode 100644
index 9b5925d..0000000
--- a/ipojo/tests/core/logger/pom.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.logger</artifactId>
- <name>iPOJO Logger Test Suite</name>
- <version>${ipojo.core.snapshot}</version>
- <description>Test the logger configuration</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.log</artifactId>
- <version>1.0.0</version>
- </dependency>
-
- <!--
- Pax Exam API:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- <!-- Tinybundles -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
-</dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-</project>
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/BNDManifestLoggerInfoTest.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/BNDManifestLoggerInfoTest.java
deleted file mode 100644
index 2b706cd..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/BNDManifestLoggerInfoTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.service.log.LogService;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class BNDManifestLoggerInfoTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- private LogReaderService log;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
-
- log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
- if (log == null) {
- throw new RuntimeException("No Log Service !");
- }
-
- LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
- logs.log(LogService.LOG_WARNING, "Ready");
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- equinox(),
- // knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId( "org.apache.felix" ).artifactId( "org.apache.felix.log" ).version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withBnd() )
- ),
- provision(
- // Component
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyComponent")
- .set(Constants.IMPORT_PACKAGE, "*")
- .set("IPOJO-log-level", "info")
- .build( withiPOJO(new File(tmp, "provider-with-level-in-manifest.jar"), new File("component.xml")))
- )
- );
- return opt;
- }
-
- @Test
- public void testMessages() throws InterruptedException {
- List<String> messages = getMessages(log.getLog());
- Assert.assertTrue(messages.contains("Ready"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : Instance org.apache.felix.ipojo.tests.core.component.MyComponent-0 from factory org.apache.felix.ipojo.tests.core.component.MyComponent created"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : New factory created : org.apache.felix.ipojo.tests.core.component.MyComponent"));
- }
-
- private List<String> getMessages(Enumeration<LogEntry> log2) {
- List<String> list = new ArrayList<String>();
- while (log2.hasMoreElements()) {
- LogEntry entry = (LogEntry) log2.nextElement();
- list.add(entry.getMessage());
- }
- return list;
- }
-
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ErrorHandlerTest.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ErrorHandlerTest.java
deleted file mode 100644
index 1e0f7d6..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ErrorHandlerTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ErrorHandler;
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.component.MyErroneousComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class ErrorHandlerTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
-// equinox(),
- provision(
- // Runtime.
- mavenBundle().groupId( "org.apache.felix" ).artifactId( "org.apache.felix.log" ).version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build()
- ),
- provision(
- // Component
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyComponent")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .set("Ipojo-log-level", "info")
- .build( withiPOJO(new File(tmp, "provider-with-level-in-manifest.jar"), new File("component.xml")))
- ),
- provision(
- // Component
- newBundle()
- .add(MyErroneousComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyErroneousComponent")
- .set("Ipojo-log-level", "debug")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withiPOJO(new File(tmp, "erroneous-provider-with-level-in-manifest.jar"), new File("erroneous-component.xml")))
- )
- );
- return opt;
- }
-
- @Test
- public void testErrorHandlerEmpty() throws InterruptedException, InvalidSyntaxException {
- MyErrorHandler handler = new MyErrorHandler();
- context.registerService(ErrorHandler.class.getName(), handler, null);
-
- System.out.println(handler.m_errors);
-
- Assert.assertTrue(handler.m_errors.isEmpty());
- }
-
- @Test
- public void testErrorHandler() throws InterruptedException, InvalidSyntaxException {
- MyErrorHandler handler = new MyErrorHandler();
- context.registerService(ErrorHandler.class.getName(), handler, null);
-
- try {
- ipojo.createComponentInstance("org.apache.felix.ipojo.tests.core.component.MyErroneousComponent");
- } catch (Exception e ) {
- System.out.println(e);
- }
-
-
- System.out.println(handler.m_errors);
-
- Assert.assertFalse(handler.m_errors.isEmpty());
- Assert.assertTrue(handler.m_errors.contains("org.apache.felix.ipojo.tests.core.component.MyErroneousComponent-0:[org.apache.felix.ipojo.tests.core.component.MyErroneousComponent-0] createInstance -> Cannot invoke the constructor method - the constructor throws an exception : bad:bad"));
- }
-
-
- private class MyErrorHandler implements ErrorHandler {
-
- private List<String> m_errors = new ArrayList<String>();
-
- public void onError(ComponentInstance instance, String message,
- Throwable error) {
- System.out.println("on Error ! " + instance + " - " + message);
- if (instance == null) {
- if (error == null) {
- m_errors.add("no-instance:" + message);
- } else {
- m_errors.add("no-instance:" + message + ":" + error.getMessage());
- }
- } else {
- if (error == null) {
- m_errors.add(instance.getInstanceName() + ":" + message);
- } else {
- m_errors.add(instance.getInstanceName() + ":" + message + ":" + error.getMessage());
- }
- }
- }
-
- public void onWarning(ComponentInstance instance, String message,
- Throwable error) {
- System.out.println("on warning ! " + instance + " - " + message);
- }
-
- }
-
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ManifestLoggerInfoTest.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ManifestLoggerInfoTest.java
deleted file mode 100644
index 5ca7c9d..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/ManifestLoggerInfoTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.service.log.LogService;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class ManifestLoggerInfoTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- private LogReaderService log;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
-
- log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
- if (log == null) {
- throw new RuntimeException("No Log Service !");
- }
-
- LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
- logs.log(LogService.LOG_WARNING, "Ready");
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- // Runtime.
- mavenBundle().groupId( "org.apache.felix" ).artifactId( "org.apache.felix.log" ).version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build()
- ),
- provision(
- // Component
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyComponent")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .set("Ipojo-log-level", "info")
- .build( withiPOJO(new File(tmp, "provider-with-level-in-manifest.jar"), new File("component.xml")))
- ),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build();
- }
- });
- return opt;
- }
-
- @Test
- public void testMessages() throws InterruptedException, InvalidSyntaxException {
- Bundle bundle = osgi.getBundle("MyComponent");
- Assert.assertNotNull(bundle);
- Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
-
- ServiceReference r = ipojo.getServiceReferenceByName(Architecture.class.getName(), "org.apache.felix.ipojo.tests.core.component.MyComponent-0");
- Assert.assertNotNull(r);
- System.out.println(((Architecture) osgi.getServiceObject(r)).getInstanceDescription().getDescription());
-
- ServiceReference[] refs = context.getAllServiceReferences(null, null);
- for (ServiceReference ref : refs) {
- System.out.println(ref.getBundle().getBundleId() + " -> " + Arrays.asList((String[]) ref.getProperty(Constants.OBJECTCLASS)));
- }
-
-
-
- Assert.assertNotNull(osgi.getServiceObject(MyService.class.getName(), null));
-
- osgi.waitForService("org.apache.felix.ipojo.tests.core.service.MyService", null, 5000);
- List<String> messages = getMessages(log.getLog());
- System.out.println(messages);
- Assert.assertTrue(messages.contains("Ready"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : Instance org.apache.felix.ipojo.tests.core.component.MyComponent-0 from factory org.apache.felix.ipojo.tests.core.component.MyComponent created"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : New factory created : org.apache.felix.ipojo.tests.core.component.MyComponent"));
- }
-
- private List<String> getMessages(Enumeration<LogEntry> log2) {
- List<String> list = new ArrayList<String>();
- while (log2.hasMoreElements()) {
- LogEntry entry = (LogEntry) log2.nextElement();
- list.add(entry.getMessage());
- }
- return list;
- }
-
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerInfoTest.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerInfoTest.java
deleted file mode 100644
index 63f2f40..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerInfoTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.service.log.LogService;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class SystemLoggerInfoTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- private LogReaderService log;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
-
- log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
- if (log == null) {
- throw new RuntimeException("No Log Service !");
- }
-
- LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
- logs.log(LogService.LOG_WARNING, "Ready");
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject(),
- mavenBundle().groupId( "org.apache.felix" ).artifactId( "org.apache.felix.log" ).version(asInProject())
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withBnd() )
- ),
- provision(
- // Component
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyComponent")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withiPOJO(new File(tmp, "provider.jar"), new File("component.xml")))
- ),
- systemProperty( "ipojo.log.level" ).value( "info" )
- );
- return opt;
- }
-
- @Test
- public void testMessages() throws InterruptedException {
- List<String> messages = getMessages(log.getLog());
- Assert.assertTrue(messages.contains("Ready"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : Instance org.apache.felix.ipojo.tests.core.component.MyComponent-0 from factory org.apache.felix.ipojo.tests.core.component.MyComponent created"));
- Assert.assertTrue(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : New factory created : org.apache.felix.ipojo.tests.core.component.MyComponent"));
- }
-
- private List<String> getMessages(Enumeration<LogEntry> log2) {
- List<String> list = new ArrayList<String>();
- while (log2.hasMoreElements()) {
- LogEntry entry = (LogEntry) log2.nextElement();
- list.add(entry.getMessage());
- }
- return list;
- }
-
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerWarningTest.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerWarningTest.java
deleted file mode 100644
index cc4fee6..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/SystemLoggerWarningTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.felix.ipojo.tests.core;
-
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.felix.ipojo.tests.core.component.MyComponent;
-import org.apache.felix.ipojo.tests.core.service.MyService;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.service.log.LogService;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class SystemLoggerWarningTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- private LogReaderService log;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
-
- log = (LogReaderService) osgi.getServiceObject(LogReaderService.class.getName(), null);
- if (log == null) {
- throw new RuntimeException("No Log Service !");
- }
-
- LogService logs = (LogService) osgi.getServiceObject(LogService.class.getName(), null);
- logs.log(LogService.LOG_WARNING, "Ready");
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- // equinox(),
- // knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId( "org.apache.felix" ).artifactId( "org.apache.felix.log" ).version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- newBundle()
- .add( MyService.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withBnd() )
- ),
- provision(
- // Component
- newBundle()
- .add(MyComponent.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MyComponent")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.core.service")
- .build( withiPOJO(new File(tmp, "provider.jar"), new File("component.xml")))
- ),
- systemProperty( "ipojo.log.level" ).value( "warning" )
- );
- return opt;
- }
-
- @Test
- public void testMessages() throws InterruptedException {
- List<String> messages = getMessages(log.getLog());
- Assert.assertTrue(messages.contains("Ready"));
- // Not logged.
- Assert.assertFalse(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : Instance org.apache.felix.ipojo.tests.core.component.MyComponent-0 from factory org.apache.felix.ipojo.tests.core.component.MyComponent created"));
- Assert.assertFalse(messages.contains("[INFO] org.apache.felix.ipojo.tests.core.component.MyComponent : New factory created : org.apache.felix.ipojo.tests.core.component.MyComponent"));
- }
-
- private List<String> getMessages(Enumeration<LogEntry> log2) {
- List<String> list = new ArrayList<String>();
- while (log2.hasMoreElements()) {
- LogEntry entry = (LogEntry) log2.nextElement();
- list.add(entry.getMessage());
- }
- return list;
- }
-
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
deleted file mode 100644
index 71fcc94..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyComponent.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.MyService;
-
-public class MyComponent implements MyService {
-
- public void foo() {
- // Nothing to do.
- }
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyErroneousComponent.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyErroneousComponent.java
deleted file mode 100644
index feca648..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/component/MyErroneousComponent.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.tests.core.component;
-
-import org.apache.felix.ipojo.tests.core.service.MyService;
-
-public class MyErroneousComponent implements MyService {
-
- public MyErroneousComponent() {
- throw new NullPointerException("bad");
- }
-
- public void foo() {
- // Nothing to do.
- }
-
-}
diff --git a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java b/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
deleted file mode 100644
index 9ffaa52..0000000
--- a/ipojo/tests/core/logger/src/test/java/org/apache/felix/ipojo/tests/core/service/MyService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.tests.core.service;
-
-public interface MyService {
-
- public void foo();
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml b/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml
deleted file mode 100644
index eff213c..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Dependency (Binding Policy) Test Suite</name>
- <artifactId>tests.core.service.dependency.bindingpolicy</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority, org.apache.felix.ipojo.test.scenarios.service.dependency.policies, org.apache.felix.ipojo.test.scenarios.service.dependency.statics, org.apache.felix.ipojo.test.scenarios.util
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.service.dependency.policies.DependencyTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <!--<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <hideOutputs>false</hideOutputs>
- </configuration>
- </execution>
- </executions>
- </plugin>-->
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java
deleted file mode 100644
index 4fb517e..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class DynamicPriorityDependencyTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Dynamic-Priority Dependency Test Suite", bc);
- ots.addTestSuite( SimpleDPDependencies.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java
deleted file mode 100644
index 2ea33d0..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class RankedFooProviderType1 implements FooService {
- private int m_grade;
-
-
- public boolean foo() {
- m_grade = m_grade + 2;
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("grade", new Integer(m_grade));
-
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() {
- return m_grade; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java
deleted file mode 100644
index 97b73df..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class SimpleDPDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance3;
- ComponentInstance fooProvider;
- ComponentInstance fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider-1");
- prov.put("service.ranking", "1");
- fooProvider = Utils.getFactoryByName(getContext(), "RankedFooProviderType").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider-2");
- prov2.put("service.ranking", "0");
- fooProvider2 = Utils.getFactoryByName(getContext(), "RankedFooProviderType").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "DPSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "DPObjectCheckServiceProvider").createComponentInstance(i3);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance3.dispose();
- fooProvider.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance3 = null;
- fooProvider = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- Integer grade = (Integer) cs.getProps().get("int");
- assertEquals("Check first grade", 1, grade.intValue());
-
- fooProvider.stop(); // Turn off the best provider.
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check second grade", 0, grade.intValue());
-
- fooProvider.start(); // Turn on the best provider.
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check third grade", 1, grade.intValue());
-
-
- // Increase the second provider grade.
- ServiceReference fs_ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check foo service (2) reference", fs_ref);
- FooService fs = (FooService) getContext().getService(fs_ref);
-
- fs.foo(); // Increase the grade (now = 2)
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check fourth grade", 2, grade.intValue());
-
- // Increase the other provider grade.
- fs_ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- assertNotNull("Check foo service (1) reference", fs_ref);
- fs = (FooService) getContext().getService(fs_ref);
- fs.foo(); //(grade = 3)
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check fifth grade", 3, grade.intValue());
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(fs_ref);
- fooProvider.stop();
- fooProvider2.stop();
- }
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckProviderParentClass.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckProviderParentClass.java
deleted file mode 100644
index 94e2ef7..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckServiceProvider.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckServiceProvider.java
deleted file mode 100644
index 0e125d3..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java
deleted file mode 100644
index 89c7c08..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority.DynamicPriorityDependencyTestSuite;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.StaticDependencyTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class DependencyTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Service Dependencies (Binding Policy) Test Suite", bc);
- ots.addTest(StaticDependencyTestSuite.suite(bc));
- ots.addTest(DynamicPriorityDependencyTestSuite.suite(bc));
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java
deleted file mode 100644
index a8b6310..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class DynCheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("int", new Integer(fs.getInt()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java
deleted file mode 100644
index a09290a..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MethodCheckServiceProvider implements CheckService {
-
- FooService fs;
-
- BundleContext context;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public MethodCheckServiceProvider(BundleContext bc) {
- context = bc;
- }
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- if(fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- } else {
- props.put("result", new Boolean(false));
- }
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
-
- if(fs != null) {
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
-
- return props;
- }
-
- protected void objectBind(FooService o) {
- if(o != null && o instanceof FooService) { objectB++; }
- fs = o;
- }
- protected void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- fs = null;
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- fs = (FooService) context.getService(sr);
- }
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- context.ungetService(sr);
- fs = null;
- }
-
- protected void bothBind(FooService o, ServiceReference ref) {
- if(ref != null && o != null && o instanceof FooService) { bothB++; }
- fs = o;
- }
- protected void bothUnbind(FooService o, ServiceReference ref) {
- if(ref != null && o != null && o instanceof FooService) { bothU++; }
- fs = null;
- }
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java
deleted file mode 100644
index db0ae19..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MethodMultipleCheckService implements CheckService {
-
- List fs = new ArrayList();
- BundleContext context;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- public MethodMultipleCheckService(BundleContext bc) {
- context = bc;
- }
-
- public boolean check() {
- boolean r = fs.size() != 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r & ((FooService) fs.get(i)).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) { return null; }
-
-// private Object getObject() {
-// boolean r = true;
-// for(int i = 0; i < fs.length; i++) {
-// r = r && ((Boolean) fs[i].getObject()).booleanValue();
-// }
-// return new Boolean(r);
-// }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void objectBind(FooService o) {
- if(o != null && o instanceof FooService) { objectB++; }
- fs.add(o);
- }
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- fs.remove(o);
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- fs.add(context.getService(sr));
- }
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- fs.remove(context.getService(sr));
- context.ungetService(sr);
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- fs.add(o);
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- fs.remove(o);
- bothU++;
- }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java
deleted file mode 100644
index 37cb9b1..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
-
-import java.util.Properties;
-
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MultipleCheckService implements CheckService {
-
- FooService fs[];
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- public boolean check() {
- boolean r = fs.length != 0;
- for (int i = 0; i < fs.length; i++) {
- r = r & fs[i].foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java
deleted file mode 100644
index 8443197..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MethodOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "StaticMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "StaticMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "StaticMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testObject() {
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
deleted file mode 100644
index 6630313..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MethodSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "StaticMObjectCheckServiceProvider").createComponentInstance(i3);
- assertNotNull("check instance 3", instance3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "StaticMRefCheckServiceProvider").createComponentInstance(i4);
- assertNotNull("check instance 4", instance4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "StaticMBothCheckServiceProvider").createComponentInstance(i5);
- assertNotNull("check instance 5", instance5);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
deleted file mode 100644
index 6f64a65..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MultipleDependencies.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "StaticSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "StaticVoidMultipleCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "StaticObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "StaticRefMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- instance1.stop();
- fooProvider1.start();
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // instance is stopped and then restarted, so bound to fooprovider 2.
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- instance2.stop();
- fooProvider1.start();
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- instance3.stop();
- fooProvider1.start();
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // Instance stopped and then restarted, bound to foo provider 2.
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- instance4.stop();
- fooProvider1.start();
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // Stop and then restarted, bound to foo provider 2.
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
deleted file mode 100644
index 842e3d4..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/OptionalDependencies.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "StaticSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "StaticVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "StaticObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "StaticRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "StaticBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // False, the provider was not bound
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDelayedSimple() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance1.stop();
- fooProvider.start();
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, the provider was bound
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken,re started with no service.
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDelayedVoid() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance2.stop();
- fooProvider.start();
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, the provider was bound
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
- // The instance is restarted.
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID); // Dependency broken and then (no service injected) restarted
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDelayedObject() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance3.stop();
- fooProvider.start();
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, the provider was bound
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken and restarted with no service
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void atestRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void atestBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java
deleted file mode 100644
index b3948ba..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/SimpleDependencies.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "StaticSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "StaticVoidCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "StaticObjectCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "StaticRefCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "StaticBothCheckServiceProvider").createComponentInstance(i5);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
- // instance1 has to be stopped and restarted.
-
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was invalidated and revalidated.
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = getContext().getService(cs_ref);
- CheckService cs = (CheckService) o;
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was revalidated.
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/StaticDependencyTestSuite.java b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/StaticDependencyTestSuite.java
deleted file mode 100644
index 33d6487..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/StaticDependencyTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.statics;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.MethodOptionalDependencies;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.MethodSimpleDependencies;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.MultipleDependencies;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.OptionalDependencies;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.SimpleDependencies;
-import org.osgi.framework.BundleContext;
-
-public class StaticDependencyTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Static Dependency Test Suite", bc);
- ots.addTestSuite( SimpleDependencies.class);
- ots.addTestSuite( OptionalDependencies.class);
- ots.addTestSuite( MultipleDependencies.class);
- ots.addTestSuite( MethodSimpleDependencies.class);
- ots.addTestSuite( MethodOptionalDependencies.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-bindingpolicy/src/main/resources/metadata.xml
deleted file mode 100644
index 36f49c3..0000000
--- a/ipojo/tests/core/service-dependency-bindingpolicy/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,264 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
-
- <!-- Static Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticSimpleCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticVoidCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticObjectCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticRefCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticBothCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMObjectCheckServiceProvider" architecture="true">
- <requires policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMRefCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMBothCheckServiceProvider" architecture="true">
- <requires policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Static Simple & Optional Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticSimpleOptionalCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" policy="static" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticVoidOptionalCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" policy="static">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticObjectOptionalCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticRefOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.CheckServiceProvider"
- name="StaticBothOptionalCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMObjectOptionalCheckServiceProvider"
- architecture="true">
- <requires optional="true" policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMRefOptionalCheckServiceProvider"
- architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true" policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodCheckServiceProvider"
- name="StaticMBothOptionalCheckServiceProvider"
- architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true" policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <!-- Static Multiple Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MultipleCheckService"
- name="StaticSimpleMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" policy="static" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MultipleCheckService"
- name="StaticVoidMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MultipleCheckService"
- name="StaticObjectMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MultipleCheckService"
- name="StaticRefMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MultipleCheckService"
- name="StaticBothMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodMultipleCheckService"
- name="StaticMObjectMultipleCheckServiceProvider"
- architecture="true">
- <requires aggregate="true" policy="static">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodMultipleCheckService"
- name="StaticMRefMultipleCheckServiceProvider"
- architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- aggregate="true" policy="static">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.MethodMultipleCheckService"
- name="StaticMBothMultipleCheckServiceProvider"
- architecture="true">
- <requires aggregate="true" policy="static">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Dynamic-Priority -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority.RankedFooProviderType1"
- name="RankedFooProviderType" architecture="true">
- <provides>
- <property field="m_grade" name="service.ranking"/>
- </provides>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.DynCheckServiceProvider"
- name="DPSimpleCheckServiceProvider" architecture="true">
- <requires field="fs" policy="dynamic-priority" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.policies.DynCheckServiceProvider"
- name="DPObjectCheckServiceProvider" architecture="true">
- <requires field="fs" policy="dynamic-priority">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/service-dependency-comparator/pom.xml b/ipojo/tests/core/service-dependency-comparator/pom.xml
deleted file mode 100644
index 583844e..0000000
--- a/ipojo/tests/core/service-dependency-comparator/pom.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Dependency Comparator Test Suite</name>
- <artifactId>tests.core.service.dependency.comparator</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.scenarios.service.dependency.comparator,
- org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.ComparatorTestCase
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java b/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java
deleted file mode 100644
index f5ca73a..0000000
--- a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.comparator;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.osgi.framework.ServiceReference;
-
-public class ComparatorTestCase extends OSGiTestCase {
-
- String gradeFactory="COMPARATOR-gradedFooProvider";
- String dynamic = "COMPARATOR-DynamicCheckService";
- String dynamicpriority = "COMPARATOR-DynamicPriorityCheckService";
-
-
- IPOJOHelper helper;
- ComponentInstance dynInstance;
- ComponentInstance dpInstance;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- dynInstance = helper.createComponentInstance(dynamic, (Properties) null);
- dpInstance = helper.createComponentInstance(dynamicpriority, (Properties) null);
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testDynamic() {
- createGrade(1);
- ComponentInstance grade2 = createGrade(2);
-
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), dynInstance.getInstanceName());
- assertNotNull("CS availability", ref);
-
- CheckService cs = (CheckService) getServiceObject(ref);
- Properties result = cs.getProps();
- int fsGrade = ((Integer) result.get("fs")).intValue();
- int fs2Grade = ((Integer) result.get("fs2")).intValue();
- int[] fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -1", 2, fsGrade);
- assertEquals("fs2 grade -1", 2, fs2Grade);
- assertEquals("fss grade size -1", 2, fssGrades.length);
-
-
- assertEquals("fss grade[0] -1", 2, fssGrades[0]);
- assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
- createGrade(3);
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -2", 2, fsGrade);
- assertEquals("fs2 grade -2", 2, fs2Grade);
- assertEquals("fss grade size -2", 3, fssGrades.length);
- assertEquals("fss grade[0] -2", 2, fssGrades[0]);
- assertEquals("fss grade[1] -2", 1, fssGrades[1]);
- assertEquals("fss grade[2] -2", 3, fssGrades[2]);
-
- grade2.stop();
-
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -3", 3, fsGrade);
- assertEquals("fs2 grade -3", 3, fs2Grade);
- assertEquals("fss grade size -3", 2, fssGrades.length);
- assertEquals("fss grade[0] -3", 1, fssGrades[0]);
- assertEquals("fss grade[1] -3", 3, fssGrades[1]);
- }
-
- public void testDynamicPriority() {
- createGrade(1);
- ComponentInstance grade2 = createGrade(2);
-
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), dpInstance.getInstanceName());
- assertNotNull("CS availability", ref);
-
- CheckService cs = (CheckService) getServiceObject(ref);
- Properties result = cs.getProps();
- int fsGrade = ((Integer) result.get("fs")).intValue();
- int fs2Grade = ((Integer) result.get("fs2")).intValue();
- int[] fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -1", 2, fsGrade);
- assertEquals("fs2 grade -1", 2, fs2Grade);
- assertEquals("fss grade size -1", 2, fssGrades.length);
- assertEquals("fss grade[0] -1", 2, fssGrades[0]);
- assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
- createGrade(3);
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -2", 3, fsGrade);
- assertEquals("fs2 grade -2", 3, fs2Grade);
- assertEquals("fss grade size -2", 3, fssGrades.length);
- assertEquals("fss grade[0] -2", 3, fssGrades[0]);
- assertEquals("fss grade[1] -2", 2, fssGrades[1]);
- assertEquals("fss grade[2] -2", 1, fssGrades[2]);
-
- grade2.stop();
-
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -3", 3, fsGrade);
- assertEquals("fs2 grade -3", 3, fs2Grade);
- assertEquals("fss grade size -3", 2, fssGrades.length);
- assertEquals("fss grade[0] -3", 3, fssGrades[0]);
- assertEquals("fss grade[1] -3", 1, fssGrades[1]);
- }
-
- private ComponentInstance createGrade(int grade) {
- Properties props = new Properties();
- props.put("grade", new Integer(grade));
- return helper.createComponentInstance(gradeFactory, props);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/CheckServiceProvider.java b/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/CheckServiceProvider.java
deleted file mode 100644
index 9881e1f..0000000
--- a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class CheckServiceProvider implements CheckService {
-
- FooService fs;
-
- FooService fs2;
-
- FooService[] fss;
-
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("fs", new Integer(fs.getInt()));
- props.put("fs2", new Integer(fs2.getInt()));
-
- int[] grades = new int[fss.length];
-
- for (int i = 0; i < grades.length; i++) {
- grades[i] = fss[i].getInt();
- }
-
- props.put("fss", grades);
-
- return props;
- }
-
- void bind(FooService svc) {
- fs2 = svc;
- }
-
- void unbind(FooService svc) {
- fs2 = null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradeComparator.java b/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradeComparator.java
deleted file mode 100644
index c3be86b..0000000
--- a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradeComparator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component;
-
-import java.util.Comparator;
-
-import org.osgi.framework.ServiceReference;
-
-public class GradeComparator implements Comparator {
-
- public int compare(Object arg0, Object arg1) {
- ServiceReference ref0 = null;
- ServiceReference ref1 = null;
- Integer grade0 = null;
- Integer grade1 = null;
- if (arg0 instanceof ServiceReference) {
- ref0 = (ServiceReference) arg0;
- grade0 = (Integer) ref0.getProperty("grade");
- }
- if (arg1 instanceof ServiceReference) {
- ref1 = (ServiceReference) arg1;
- grade1 = (Integer) ref1.getProperty("grade");
- }
-
- if (ref0 != null && ref1 != null
- && grade0 != null && grade1 != null) {
- return grade1.compareTo(grade0); // Best grade first.
- } else {
- return 0; // Equals
- }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradedFooServiceProvider.java b/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradedFooServiceProvider.java
deleted file mode 100644
index baca0ea..0000000
--- a/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/component/GradedFooServiceProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class GradedFooServiceProvider implements FooService {
-
-
- private int grade;
-
- public boolean foo() {
- return grade > 0;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return grade;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-comparator/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-comparator/src/main/resources/metadata.xml
deleted file mode 100644
index d278fe5..0000000
--- a/ipojo/tests/core/service-dependency-comparator/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradedFooServiceProvider"
- name="COMPARATOR-gradedFooProvider">
- <provides>
- <property field="grade"/>
- </provides>
- </component>
-
-
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.CheckServiceProvider"
- name="COMPARATOR-DynamicCheckService">
- <provides/>
- <requires field="fs" comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator"/>
- <requires field="fss" comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator"/>
- <requires comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator">
- <callback type="bind" method="bind"/>
- <callback type="unbind" method="unbind"/>
- </requires>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.CheckServiceProvider"
- name="COMPARATOR-DynamicPriorityCheckService">
- <provides/>
- <requires policy="dynamic-priority" field="fs" comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator"/>
- <requires policy="dynamic-priority" field="fss" comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator"/>
- <requires policy="dynamic-priority" comparator="org.apache.felix.ipojo.test.scenarios.service.dependency.comparator.component.GradeComparator">
- <callback type="bind" method="bind"/>
- <callback type="unbind" method="unbind"/>
- </requires>
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/service-dependency-filter/pom.xml b/ipojo/tests/core/service-dependency-filter/pom.xml
deleted file mode 100644
index 58fc221..0000000
--- a/ipojo/tests/core/service-dependency-filter/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Dependency (Filter) Test Suite</name>
- <artifactId>tests.core.service.dependency.filter</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.scenarios.service.dependency.filter, org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component, org.apache.felix.ipojo.test.scenarios.util
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.service.dependency.filter.FilteredDependencyTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java
deleted file mode 100644
index a231caa..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class FilteredDependencyTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("iPOJO Filtered Service Dependency Test Suite", bc);
- ots.addTestSuite(SimpleFilterDependencies.class);
- ots.addTestSuite(OptionalSimpleFilterDependencies.class);
- ots.addTestSuite(MultipleFilterDependencies.class);
- ots.addTestSuite(OptionalMultipleFilterDependencies.class);
- ots.addTestSuite(FromDependencies.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FromDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FromDependencies.java
deleted file mode 100644
index 9ddcb09..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FromDependencies.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class FromDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance providerA, providerB, providerC, providerD;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","A");
- providerA = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- providerA.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","B");
- providerB = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov2);
- providerB.stop();
-
- Properties prov3 = new Properties();
- prov3.put("service.pid", "A");
- providerC = Utils.getFactoryByName(getContext(), "SimplePIDCheckServiceProvider").createComponentInstance(prov3);
- providerC.stop();
-
- Properties prov4 = new Properties();
- prov4.put("service.pid", "D");
- prov4.put("instance.name","D");
- providerD = Utils.getFactoryByName(getContext(), "SimplePIDCheckServiceProvider").createComponentInstance(prov4);
- providerD.stop();
-
- // Uses the component type from value
- Properties i1 = new Properties();
- i1.put("instance.name","Subscriber1");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleFromCheckServiceSubscriber").createComponentInstance(i1);
-
- // Uses the instance configuration from value
- Properties i2 = new Properties();
- i2.put("instance.name","Subscriber2");
- Properties ii2 = new Properties();
- ii2.put("id1", "B");
- i2.put("requires.from", ii2);
- instance2 = Utils.getFactoryByName(getContext(), "SimpleFromCheckServiceSubscriber").createComponentInstance(i2);
-
- // Uses the instance configuration from value (*)
- Properties i3 = new Properties();
- i3.put("instance.name","Subscriber3");
- Properties ii3 = new Properties();
- ii3.put("id1", "*");
- i3.put("requires.from", ii3);
- instance3 = Utils.getFactoryByName(getContext(), "SimpleFromCheckServiceSubscriber").createComponentInstance(i3);
-
- // Uses the instance configuration from value, merge filter and from
- Properties i4 = new Properties();
- i4.put("instance.name","Subscriber4");
- Properties ii4 = new Properties();
- ii4.put("id1", "D");
- i4.put("requires.from", ii4);
- Properties iii4 = new Properties();
- iii4.put("id1", "(service.pid=D)");
- i4.put("requires.filters", iii4);
- instance4 = Utils.getFactoryByName(getContext(), "SimpleFromCheckServiceSubscriber").createComponentInstance(i4);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- providerA.dispose();
- providerB.dispose();
- providerC.dispose();
- providerD.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- providerA = null;
- providerB = null;
- providerC = null;
- providerD = null;
- }
-
- public void testFromInstanceName() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- providerA.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- providerA.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- providerA.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-
- providerA.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- providerB.stop();
- getContext().ungetService(arch_ref);
- }
-
- public void testFromPID() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- providerC.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- providerC.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- providerC.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- providerC.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- providerB.stop();
- getContext().ungetService(arch_ref);
- }
-
- public void testFromInstanceNameInstanceConfiguration() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- providerA.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- providerB.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- providerB.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- providerA.stop();
- getContext().ungetService(arch_ref);
- }
-
- public void testFromInstanceNameStar() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- providerA.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 0", id.getState() == ComponentInstance.VALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- providerB.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.VALID);
-
- providerA.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- providerB.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- providerB.stop();
- getContext().ungetService(arch_ref);
- }
-
- public void testFromAndFilter() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- providerA.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- providerD.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- providerD.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- providerD.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- providerD.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- providerA.stop();
- getContext().ungetService(arch_ref);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
deleted file mode 100644
index 71349d1..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MultipleFilterDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider1.stop();
-
- prov = new Properties();
- prov.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Subscriber1");
- instance1 = Utils.getFactoryByName(getContext(), "MultipleFilterCheckServiceSubscriber").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Subscriber2");
- Properties ii2 = new Properties();
- ii2.put("id2", "(toto=A)");
- i2.put("requires.filters", ii2);
- instance2 = Utils.getFactoryByName(getContext(), "MultipleFilterCheckServiceSubscriber2").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Subscriber3");
- Properties ii3 = new Properties();
- ii3.put("id1", "(toto=A)");
- i3.put("requires.filters", ii3);
- instance3 = Utils.getFactoryByName(getContext(), "MultipleFilterCheckServiceSubscriber").createComponentInstance(i3);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testMultipleNotMatch() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider2.start();
- cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatch() {
-
- fooProvider1.start();
- fooProvider2.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- fooProvider2.start();
- cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleNotMatchInstance() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.start();
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatchInstance() {
-
- fooProvider1.start();
- fooProvider2.start();
- instance3.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleNotMatchInstanceWithoutFilter() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.start();
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatchInstanceWithoutFilter() {
- fooProvider1.start();
- fooProvider2.start();
- instance2.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
deleted file mode 100644
index 3427003..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalMultipleFilterDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider1.stop();
-
- prov = new Properties();
- prov.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Subscriber1");
- instance1 = Utils.getFactoryByName(getContext(), "OptionalMultipleFilterCheckServiceSubscriber").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Subscriber2");
- Properties ii2 = new Properties();
- ii2.put("id2", "(toto=A)");
- i2.put("requires.filters", ii2);
- instance2 = Utils.getFactoryByName(getContext(), "OptionalMultipleFilterCheckServiceSubscriber2").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Subscriber3");
- Properties ii3 = new Properties();
- ii3.put("id1", "(toto=A)");
- i3.put("requires.filters", ii3);
- instance3 = Utils.getFactoryByName(getContext(), "OptionalMultipleFilterCheckServiceSubscriber").createComponentInstance(i3);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testMultipleNotMatch() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatch() {
-
- fooProvider1.start();
- fooProvider2.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleNotMatchInstance() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- fooProvider2.start();
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatchInstance() {
-
- fooProvider1.start();
- fooProvider2.start();
- instance3.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleNotMatchInstanceWithoutFilter() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- fooProvider2.start();
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
- CheckService cs2 = (CheckService) getContext().getService(cs_ref2);
- // change the value of the property toto
- cs2.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
-
- // change the value of the property toto
- cs2.check();
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- id = null;
- cs = null;
- cs2 = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
- public void testMultipleMatchInstanceWithoutFilter() {
-
-
- fooProvider1.start();
- fooProvider2.start();
- instance2.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- ServiceReference cs_ref2 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref2);
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));
-
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));
- assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(cs_ref2);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
deleted file mode 100644
index fb13882..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalSimpleFilterDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider1.stop();
-
- prov = new Properties();
- prov.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Subscriber1");
- instance1 = Utils.getFactoryByName(getContext(), "OptionalSimpleFilterCheckServiceSubscriber").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Subscriber2");
- Properties ii2 = new Properties();
- ii2.put("id2", "(toto=A)");
- i2.put("requires.filters", ii2);
- instance2 = Utils.getFactoryByName(getContext(), "OptionalSimpleFilterCheckServiceSubscriber2").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Subscriber3");
- Properties ii3 = new Properties();
- ii3.put("id1", "(toto=A)");
- i3.put("requires.filters", ii3);
- instance3 = Utils.getFactoryByName(getContext(), "OptionalSimpleFilterCheckServiceSubscriber").createComponentInstance(i3);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimpleNotMatch() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start(); // Registered with toto = A
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Optional
- assertTrue("Check service Binding - 7.0 (" + (Integer)cs_instance.getProps().get("Bind") +")", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
-
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check(); // Update toto to B
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3.1", id.getState() == ComponentInstance.VALID);
-
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
- assertTrue("Check service Binding - 7.1 (" + (Integer)cs_instance.getProps().get("Bind") +")", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatch() {
-
- fooProvider1.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check(); // Update toto to B
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5.1", id.getState() == ComponentInstance.VALID);
-
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleNotMatchInstance() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatchInstance() {
-
- fooProvider1.start();
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleNotMatchInstanceWithoutFilter() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatchInstanceWithoutFilter() {
-
- fooProvider1.start();
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));
- assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);
- assertTrue("Check service invocation", cs_instance.check());
- assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));
- assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
deleted file mode 100644
index ebc147b..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class SimpleFilterDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider1.stop();
-
- prov = new Properties();
- prov.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Subscriber1");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceSubscriber").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Subscriber2");
- Properties ii2 = new Properties();
- ii2.put("id2", "(toto=A)");
- i2.put("requires.filters", ii2);
- instance2 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceSubscriber2").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Subscriber3");
- Properties ii3 = new Properties();
- ii3.put("id1", "(toto=A)");
- i3.put("requires.filters", ii3);
- instance3 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceSubscriber").createComponentInstance(i3);
-
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimpleNotMatch() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- assertTrue("Check instance invalidity - 4.1", id.getState() == ComponentInstance.INVALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- cs.check();
-
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatch() {
-
- fooProvider1.start();
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4.1", id.getState() == ComponentInstance.INVALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- cs.check();
-
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleNotMatchInstance() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatchInstance() {
-
- fooProvider1.start();
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleNotMatchInstanceWithoutFilter() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testSimpleMatchInstanceWithoutFilter() {
-
- fooProvider1.start();
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("Check service invocation", cs_instance.check());
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- // change the value of the property toto
- cs.check();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_instance_ref);
- cs_instance = (CheckService) getContext().getService(cs_instance_ref);
- assertTrue("check CheckService invocation", cs_instance.check());
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- cs_instance = null;
- getContext().ungetService(cs_instance_ref);
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
deleted file mode 100644
index af7cc7a..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class FilterCheckProvider implements CheckService, FooService {
-
- private String m_toto;
-
- private int bind;
-
- private int unbind;
-
- public FilterCheckProvider() {
- m_toto = "A";
- }
-
- public boolean check() {
- if (m_toto.equals("A")){
- m_toto="B";
- return true;
- } else {
- m_toto="A";
- return false;
- }
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("Bind", new Integer(bind-unbind));
- return null;
- }
-
- private void Bind() {
- bind++;
- }
- private void Unbind() {
- unbind++;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean getBoolean() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public double getDouble() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getInt() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public long getLong() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Boolean getObject() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
deleted file mode 100644
index 5d1bc0d..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.Nullable;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class FilterCheckSubscriber implements CheckService {
-
- private FooService m_foo;
-
- private int bound;
-
- public FilterCheckSubscriber(){
- }
-
- public boolean check() {
- m_foo.foo();
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("Bind", new Integer(bound));
- props.put("Nullable", new Boolean(m_foo instanceof Nullable));
- return props;
- }
-
- private void Bind() {
- bound++;
- }
- private void Unbind() {
- bound--;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java
deleted file mode 100644
index ca4b3ff..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MultipleFilterCheckSubscriber implements CheckService {
-
- private FooService[] m_foo;
-
- private int binded;
-
- public MultipleFilterCheckSubscriber(){
- }
-
- public boolean check() {
- for (int i = 0; i < m_foo.length; i++) {
- m_foo[i].foo();
- }
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("Bind", new Integer(binded));
- props.put("Size", new Integer(m_foo.length));
- return props;
- }
-
- private void Bind() {
- binded++;
- }
- private void Unbind() {
- binded--;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
deleted file mode 100644
index 5cdf205..0000000
--- a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
-
- <!-- Simple Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
- name="SimpleFilterCheckServiceProvider" architecture="true">
- <provides>
- <property field="m_toto" name="toto" value="A" />
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFilterCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFromCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" from="A" id="id1" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
- name="SimplePIDCheckServiceProvider" architecture="true">
- <provides>
- <property type="String" name="service.pid" />
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFilterCheckServiceSubscriber2" architecture="true">
- <requires field="m_foo" id="id2" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Optional Simple Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="OptionalSimpleFilterCheckServiceSubscriber"
- architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1"
- optional="true" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="OptionalSimpleFilterCheckServiceSubscriber2"
- architecture="true">
- <requires field="m_foo" id="id2" optional="true" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Aggregate filter Dependencies-->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="MultipleFilterCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="MultipleFilterCheckServiceSubscriber2" architecture="true">
- <requires field="m_foo" id="id2" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Optional Aggregate Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="OptionalMultipleFilterCheckServiceSubscriber"
- architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false"
- optional="true">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="OptionalMultipleFilterCheckServiceSubscriber2"
- architecture="true">
- <requires field="m_foo" id="id2" optional="true" proxy="false">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/service-dependency-optional/pom.xml b/ipojo/tests/core/service-dependency-optional/pom.xml
deleted file mode 100644
index 06b0536..0000000
--- a/ipojo/tests/core/service-dependency-optional/pom.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.dependency.optional</artifactId>
- <name>iPOJO Optional Dependency Test Suite</name>
- <version>${ipojo.core.snapshot}</version>
- <description>Test the optional dependencies</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <!--
- Pax Exam API:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- <!-- Tinybundles -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-</project>
diff --git a/ipojo/tests/core/service-dependency-optional/src/main/java/org/apache/felix/ipojo/optional/MyComponent.java b/ipojo/tests/core/service-dependency-optional/src/main/java/org/apache/felix/ipojo/optional/MyComponent.java
deleted file mode 100644
index b7a13ef..0000000
--- a/ipojo/tests/core/service-dependency-optional/src/main/java/org/apache/felix/ipojo/optional/MyComponent.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.felix.ipojo.optional;
-
-import org.apache.felix.ipojo.Nullable;
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.osgi.service.log.LogService;
-
-
-@Component(immediate=true, name="optional-log-cons")
-public class MyComponent {
-
- @Requires(optional=true, proxy=false)
- private LogService log;
-
-
- public MyComponent() {
- System.out.println("Created ! : " + (log instanceof Nullable) + " - " + log);
- log.log(LogService.LOG_INFO, "Created !");
-
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency-optional/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-optional/src/main/resources/metadata.xml
deleted file mode 100644
index c8a1900..0000000
--- a/ipojo/tests/core/service-dependency-optional/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<ipojo>
-</ipojo>
diff --git a/ipojo/tests/core/service-dependency-optional/src/test/java/org/apache/felix/ipojo/test/optional/NullableTransitiveClassloadingTest.java b/ipojo/tests/core/service-dependency-optional/src/test/java/org/apache/felix/ipojo/test/optional/NullableTransitiveClassloadingTest.java
deleted file mode 100644
index 8704a3f..0000000
--- a/ipojo/tests/core/service-dependency-optional/src/test/java/org/apache/felix/ipojo/test/optional/NullableTransitiveClassloadingTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.apache.felix.ipojo.test.optional;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.optional.MyComponent;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-import aQute.lib.osgi.Constants;
-
-
-/**
- * Reproduces FELIX-2093
- * iPOJO doesn't always use the correct class loader to load nullable object.
- */
-@RunWith( JUnit4TestRunner.class )
-public class NullableTransitiveClassloadingTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
-
- Option[] opt = options(
- felix(),
- equinox(),
- knopflerfish(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- TinyBundles.newBundle()
- .add(MyComponent.class)
- .set(Constants.IMPORT_PACKAGE, "*")
- .build(withiPOJO(new File("src/main/resources/metadata.xml"))
- )
-
- ));
-
- return opt;
- }
-
- @Test
- public void testCreation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Factory factory = ipojo.getFactory("optional-log-cons");
- ComponentInstance ci = factory.createComponentInstance(null);
-
- ci.dispose();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/pom.xml b/ipojo/tests/core/service-dependency/pom.xml
deleted file mode 100644
index 6634d8b..0000000
--- a/ipojo/tests/core/service-dependency/pom.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Dependency Test Suite</name>
- <artifactId>tests.core.service.dependency</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.service.dependency.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.service.dependency.DependencyTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
deleted file mode 100644
index c1328e6..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Map;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
- int mapU = 0;
- int dictU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if (props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- }
-
- public void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- }
-
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index c660cb6..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
- int mapB = 0;
- int dictB = 0;
-
- int modified = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("mapB", new Integer(mapB));
- props.put("dictB", new Integer(dictB));
- props.put("mapU", new Integer(mapU));
- props.put("dictU", new Integer(dictU));
- if (fs != null) {
- // If nullable = false and proxy, a runtime exception may be launched here
- // catch the exception and add this to props.
- try {
- props.put("exception", Boolean.FALSE); // Set exception to false for checking.
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- } catch (RuntimeException e) {
- props.put("exception", Boolean.TRUE);
- }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
-
-
- // Add modified
- props.put("modified", new Integer(modified));
-
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- public void voidModify() {
- modified ++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- protected void objectModify(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! [" + modified + "]");
- return;
- }
- if(o != null && o instanceof FooService) { modified++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void refModify(ServiceReference sr) {
- if(sr != null) { modified++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
- public void bothModify(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { modified++; }
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- fs = o;
- }
-
- protected void propertiesDictionaryModify(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { modified++; }
- fs = o;
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- fs = o;
- }
-
- protected void propertiesMapModify(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { modified++; }
- fs = o;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java
deleted file mode 100644
index ac465d1..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CollectionCheckService implements CheckService {
-
- Collection fs;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- int mapB, mapU, dictB, dictU;
-
- public boolean check() {
- boolean r = fs.size() != 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r & ((FooService) it.next()).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getLong();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("mapB", new Integer(mapB));
- props.put("mapU", new Integer(mapU));
- props.put("dictB", new Integer(dictB));
- props.put("dictU", new Integer(dictU));
-
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- }
- protected void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- }
- protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java
deleted file mode 100644
index d4d5b1d..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class DynCheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
- int mapB, mapU, dictB, dictU;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("mapB", new Integer(mapB));
- props.put("mapU", new Integer(mapU));
- props.put("dictB", new Integer(dictB));
- props.put("dictU", new Integer(dictU));
-
- if (fs != null) {
- props.put("int", new Integer(fs.getInt()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- }
-
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 8dbe98e..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java
deleted file mode 100644
index d57a532..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType2.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType2 implements FooService {
-
- private int m_bar; // Service property.
- private String m_foo;
-
- private BundleContext m_context;
-
- private static int count = 0;
-
-
- public boolean foo() {
- // Update
- if (m_foo.equals("foo")) {
- m_foo = "bar";
- } else {
- m_foo = "foo";
- }
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java
deleted file mode 100644
index 6231d15..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class FooServiceDefaultImpl implements FooService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 5;
- }
-
- public int getInt() {
- return 5;
- }
-
- public long getLong() {
- return 5;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
deleted file mode 100644
index 52bccb7..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class ListCheckService implements CheckService {
-
- List fs;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- int mapB, mapU, dictB, dictU;
-
-
- public boolean check() {
- boolean r = fs.size() != 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r & ((FooService) fs.get(i)).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getDouble();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
-
- props.put("mapB", new Integer(mapB));
- props.put("mapU", new Integer(mapU));
- props.put("dictB", new Integer(dictB));
- props.put("dictU", new Integer(dictU));
-
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- }
- protected void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- }
- protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java
deleted file mode 100644
index d9c04a0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class MethodCheckServiceProvider implements CheckService {
-
- FooService fs;
-
- BundleContext context;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
- int mapB = 0;
- int dictB = 0;
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
- int mapU = 0;
- int dictU = 0;
-
-
- public MethodCheckServiceProvider(BundleContext bc) {
- context = bc;
- }
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- if(fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- } else {
- props.put("result", new Boolean(false));
- }
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("mapB", new Integer(mapB));
- props.put("dictB", new Integer(dictB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("mapU", new Integer(mapU));
- props.put("dictU", new Integer(dictU));
-
- if(fs != null) {
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
-
- return props;
- }
-
- protected void objectBind(FooService o) {
- if(o != null && o instanceof FooService) { objectB++; }
- fs = o;
- }
- protected void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- fs = null;
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- fs = (FooService) context.getService(sr);
- }
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- context.ungetService(sr);
- fs = null;
- }
-
- protected void bothBind(FooService o, ServiceReference ref) {
- if(ref != null && o != null && o instanceof FooService) { bothB++; }
- fs = o;
- }
- protected void bothUnbind(FooService o, ServiceReference ref) {
- if(ref != null && o != null && o instanceof FooService) { bothU++; }
- fs = null;
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- fs = o;
- }
- protected void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- fs = null;
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- fs = o;
- }
- protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- fs = null;
- }
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java
deleted file mode 100644
index 74115c0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MethodMultipleCheckService implements CheckService {
-
- List fs = new ArrayList();
- BundleContext context;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- int mapB = 0;
- int mapU = 0;
- int dictB = 0, dictU=0;
-
- public MethodMultipleCheckService(BundleContext bc) {
- context = bc;
- }
-
- public boolean check() {
- boolean r = fs.size() != 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r & ((FooService) fs.get(i)).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for(int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) { return null; }
-
-// private Object getObject() {
-// boolean r = true;
-// for(int i = 0; i < fs.length; i++) {
-// r = r && ((Boolean) fs[i].getObject()).booleanValue();
-// }
-// return new Boolean(r);
-// }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("mapU", new Integer(mapU));
- props.put("mapB", new Integer(mapB));
- props.put("dictU", new Integer(dictU));
- props.put("dictB", new Integer(dictB));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void objectBind(FooService o) {
- if(o != null && o instanceof FooService) { objectB++; }
- fs.add(o);
- }
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- fs.remove(o);
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- fs.add(context.getService(sr));
- }
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- fs.remove(context.getService(sr));
- context.ungetService(sr);
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- fs.add(o);
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- fs.remove(o);
- bothU++;
- }
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- fs.add(o);
- }
- protected void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- fs.remove(o);
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- fs.add(o);
- }
- protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- fs.remove(o);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
deleted file mode 100644
index 7c64936..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Properties;
-
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MultipleCheckService implements CheckService {
-
- FooService fs[];
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- int mapB, mapU, dictB, dictU;
-
-
- public boolean check() {
- boolean r = fs.length != 0;
- for (int i = 0; i < fs.length; i++) {
- r = r & fs[i].foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- props.put("mapB", new Integer(mapB));
- props.put("mapU", new Integer(mapU));
- props.put("dictB", new Integer(dictB));
- props.put("dictU", new Integer(dictU));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
- protected void propertiesMapBind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
- }
- protected void propertiesMapUnbind(FooService o, Map props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
- }
-
- protected void propertiesDictionaryBind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
- }
- protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
- if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleFilterCheckSubscriber.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleFilterCheckSubscriber.java
deleted file mode 100644
index 15f7dbe..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleFilterCheckSubscriber.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class MultipleFilterCheckSubscriber implements CheckService {
-
- private FooService[] m_foo;
-
- private int binded;
-
- public MultipleFilterCheckSubscriber(){
- }
-
- public boolean check() {
- for (int i = 0; i < m_foo.length; i++) {
- m_foo[i].foo();
- }
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("Bind", new Integer(binded));
- props.put("Size", new Integer(m_foo.length));
- return props;
- }
-
- private void Bind() {
- binded++;
- }
- private void Unbind() {
- binded--;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
deleted file mode 100644
index f7fb580..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass {
-
- public void parentStart() {
-
- }
-
- public void parentStop() {
-
- }
-
- protected String[] strings;
-
- protected String string;
-
- protected int upStrings;
-
- protected int upString;
-
- public void updateStrings(String[] bb) {
- strings = bb;
- upStrings++;
- }
-
- public void updateString(String bb) {
- string = bb;
- upString++;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedFooProviderType1.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedFooProviderType1.java
deleted file mode 100644
index 6b25a0c..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/RankedFooProviderType1.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class RankedFooProviderType1 implements FooService {
- private int m_grade;
-
-
- public boolean foo() {
- m_grade = m_grade + 2;
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("grade", new Integer(m_grade));
-
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() {
- return m_grade; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SetCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SetCheckService.java
deleted file mode 100644
index 8fbbc11..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SetCheckService.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class SetCheckService implements CheckService {
-
- Set fs;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- public boolean check() {
- boolean r = fs.size() != 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r & ((FooService) it.next()).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- Iterator it = fs.iterator();
- while(it.hasNext()) {
- r = r + ((FooService) it.next()).getLong();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java
deleted file mode 100644
index 6c7011f..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-import java.util.Vector;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class VectorCheckService implements CheckService {
-
- Vector fs;
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- public boolean check() {
- boolean r = fs.size() != 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r & ((FooService) fs.get(i)).foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for (int i = 0; i < fs.size(); i++) {
- r = r + ((FooService) fs.get(i)).getDouble();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- // simpleB++;
- }
-
- public void voidUnbind() {
- // simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- // objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- // objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C1.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C1.java
deleted file mode 100644
index a1e6f57..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C1.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.inner;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.Call;
-
-public class C1 implements Call {
-
- public String callMe() {
- return "called";
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C2.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C2.java
deleted file mode 100644
index b0e23ab..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C2.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.inner;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.Call;
-
-public class C2 {
-
- private Call c1;
-
- public String authenticate() {
- return c1.callMe();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C3.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C3.java
deleted file mode 100644
index c9bd632..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/C3.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.inner;
-
-public class C3 {
-
- private C2 c2;
-
- public MyFilter getFilter() {
- return new MyFilter() {
- public String authenticate() {
- System.out.println("My Filter ...");
- String r = c2.authenticate();
- System.out.println(" ... " + r);
- return r;
- }
- };
-
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/MyFilter.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/MyFilter.java
deleted file mode 100644
index 2b5adc2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inner/MyFilter.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.inner;
-
-public interface MyFilter {
-
- public String authenticate();
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/CollectionMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/CollectionMultipleDependencies.java
deleted file mode 100644
index 3027fa0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/CollectionMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class CollectionMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleCollectionCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "OptionalCollectionCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java
deleted file mode 100644
index 4df02b9..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class DelayedMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothMultipleCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MapMultipleCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "DictMultipleCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance4.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance5.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance6.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance7.stop();
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java
deleted file mode 100644
index 8a0ff11..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-
-public class DelayedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "DictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 518a9d8..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayedOptionalMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java
deleted file mode 100644
index 4adf04b..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-public class DelayedSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MapCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "DictCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- fooProvider.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
deleted file mode 100644
index 4130ea0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.handlers.dependency.Dependency;
-import org.apache.felix.ipojo.handlers.dependency.DependencyDescription;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DependencyArchitectureTest extends OSGiTestCase {
-
- ComponentInstance fooProvider1, fooProvider2;
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i5 = new Properties();
- i5.put("instance.name","ProxiedSimple");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i5);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Multiple");
- instance3 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","OptionalMultiple");
- instance4 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- private DependencyHandlerDescription getDependencyDesc(InstanceDescription id) {
- DependencyHandlerDescription handler = (DependencyHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:requires");
- if (handler == null) {
- fail("Dependency Handler not found");
- return null;
- } else {
- return handler;
- }
- }
-
- private DependencyDescription getDependencyDescBySpecification(
- PrimitiveInstanceDescription id, String spec) {
- return id.getDependency(spec);
- }
-
- private ProvidedServiceHandlerDescription getPSDesc(InstanceDescription id) {
- ProvidedServiceHandlerDescription handler = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
- if (handler == null) {
- fail("Provided Service Handler not found");
- return null;
- } else {
- return handler;
- }
- }
-
- public void testSimpleDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
- assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
- assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());
-
- fooProvider1.start();
-
- ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider1.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testProxiedSimpleDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
- assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
- assertTrue("Check dependency proxy", dhd.getDependencies()[0].isProxy());
-
- fooProvider1.start();
-
- ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider1.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptionalDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");
- assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider1.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testMultipleDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- DependencyDescription dd = getDependencyDescBySpecification(id_dep, FooService.class.getName());
- assertFalse("Check dependency handler invalidity", dhd.isValid());
- assertTrue("Check dependency invalidity", dd.getState() == Dependency.UNRESOLVED);
-
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- assertEquals("Check dependency interface", dd.getSpecification(), FooService.class.getName());
- assertTrue("Check dependency cardinality", dd.isMultiple());
- assertFalse("Check dependency optionality", dd.isOptional());
- assertNull("Check dependency ref -1", dd.getServiceReferences());
- assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());
-
- fooProvider1.start();
-
- ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 1 (" + dhd.getDependencies()[0].getUsedServices().size() + ")", dhd.getDependencies()[0].getUsedServices().size(), 0);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 2", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- // Start a second foo service provider
- fooProvider2.start();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- assertNotNull("Check architecture 2 availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
- assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
- assertEquals("Check used ref - 2 ", dhd.getDependencies()[0].getUsedServices().size(), 1); // provider 2 not already used
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
- ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 3.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
- assertTrue("Check service reference - 3.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 3 ("+dhd.getDependencies()[0].getUsedServices().size()+")", dhd.getDependencies()[0].getUsedServices().size(), 2);
-
- fooProvider2.stop();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 4 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 5 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider2.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
-
- assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- psh = getPSDesc(id_ps2);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 6 ", dhd.getDependencies()[0].getUsedServices().size(), 0);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps2);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 7 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- fooProvider2.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testMultipleOptionalDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- // Start a second foo service provider
- fooProvider2.start();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- assertNotNull("Check architecture 2 availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
- assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
- ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 2.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
- assertTrue("Check service reference - 2.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
-
- fooProvider2.stop();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 3", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider2.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps2);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps2);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider2.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
deleted file mode 100644
index 51045e2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.di.DefaultImplementationTestSuite;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.inner.InnerProxyMixTest;
-import org.osgi.framework.BundleContext;
-
-public class DependencyTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Service Dependencies Test Suite", bc);
- ots.addTestSuite(SimpleDependencies.class);
- ots.addTestSuite(ProxiedSimpleDependencies.class);
- ots.addTestSuite(OptionalDependencies.class);
- ots.addTestSuite(ProxiedOptionalDependencies.class);
- ots.addTestSuite(OptionalNoNullableDependencies.class);
- ots.addTestSuite(MultipleDependencies.class);
- ots.addTestSuite(OptionalMultipleDependencies.class);
- ots.addTestSuite(DelayedSimpleDependencies.class);
- ots.addTestSuite(ProxiedDelayedSimpleDependencies.class);
- ots.addTestSuite(DelayedOptionalDependencies.class);
- ots.addTestSuite(ProxiedDelayedOptionalDependencies.class);
- ots.addTestSuite(DelayedMultipleDependencies.class);
- ots.addTestSuite(ProxiedDelayedMultipleDependencies.class);
- ots.addTestSuite(DelayedOptionalMultipleDependencies.class);
- ots.addTestSuite(ProxiedDelayedOptionalMultipleDependencies.class);
- ots.addTestSuite(MethodSimpleDependencies.class);
- ots.addTestSuite(MethodOptionalDependencies.class);
- ots.addTestSuite(MethodMultipleDependencies.class);
- ots.addTestSuite(MethodOptionalMultipleDependencies.class);
- ots.addTestSuite(MethodDelayedSimpleDependencies.class);
- ots.addTestSuite(MethodDelayedOptionalDependencies.class);
- ots.addTestSuite(MethodDelayedMultipleDependencies.class);
- ots.addTestSuite(MethodDelayedOptionalMultipleDependencies.class);
- ots.addTest(DefaultImplementationTestSuite.suite(bc));
- ots.addTestSuite(DependencyArchitectureTest.class);
- ots.addTestSuite(ListMultipleDependencies.class);
- ots.addTestSuite(ProxiedListMultipleDependencies.class);
- ots.addTestSuite(VectorMultipleDependencies.class);
- ots.addTestSuite(SetMultipleDependencies.class);
- ots.addTestSuite(ProxiedSetMultipleDependencies.class);
- ots.addTestSuite(CollectionMultipleDependencies.class);
- ots.addTestSuite(ProxiedCollectionMultipleDependencies.class);
- ots.addTestSuite(ModifyDependencies.class);
- ots.addTestSuite(ProxyTest.class);
- ots.addTestSuite(NonProxiedNotInterfaceDependencies.class);
- ots.addTestSuite(InnerProxyMixTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java
deleted file mode 100644
index 5c0afee..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ListMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleListCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "OptionalListCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java
deleted file mode 100644
index f454970..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodDelayedMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothMultipleCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapMultipleCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "MDictMultipleCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testObject() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance4.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance5.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance6.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance7.stop();
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java
deleted file mode 100644
index e897558..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodDelayedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "MDictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7= null;
- fooProvider = null;
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 96e5f37..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodDelayedOptionalMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
-
- public void setUp() {
- try {
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java
deleted file mode 100644
index b0e6f68..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodDelayedSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "MDictCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
-}
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java
deleted file mode 100644
index b2aa4e5..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefMultipleCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothMultipleCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapMultipleCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "MDictMultipleCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java
deleted file mode 100644
index 8118bf5..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "MDictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testObject() {
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java
deleted file mode 100644
index a1312f2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodOptionalMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java
deleted file mode 100644
index 238a63d..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MethodSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "MObjectCheckServiceProvider").createComponentInstance(i3);
- assertNotNull("check instance 3", instance3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "MRefCheckServiceProvider").createComponentInstance(i4);
- assertNotNull("check instance 4", instance4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "MBothCheckServiceProvider").createComponentInstance(i5);
- assertNotNull("check instance 5", instance5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MMapCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "MDictCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ModifyDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ModifyDependencies.java
deleted file mode 100644
index c99951f..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ModifyDependencies.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-
-public class ModifyDependencies extends OSGiTestCase {
-
- ComponentInstance instance2, instance3, instance4, instance5, instance7, instance8;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-Updatable").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidModifyCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectModifyCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefModifyCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothModifyCheckServiceProvider").createComponentInstance(i5);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Map");
- instance7 = Utils.getFactoryByName(getContext(), "MapModifyCheckServiceProvider").createComponentInstance(i7);
-
- Properties i8 = new Properties();
- i8.put("instance.name","Dictionary");
- instance8 = Utils.getFactoryByName(getContext(), "DictModifyCheckServiceProvider").createComponentInstance(i8);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance7.dispose();
- instance8.dispose();
- fooProvider.dispose();
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance7 = null;
- instance8 = null;
- fooProvider = null;
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = getContext().getService(cs_ref);
- CheckService cs = (CheckService) o;
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check modify -1", ((Integer)props.get("modified")).intValue(), 1); // Already called inside the method
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1.1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1.1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1.1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1.1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1.1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1.1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1.1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1.1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1.1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3); // 1 (first foo) + 1 (our foo) + 1 (check foo)
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
-
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check modify -1 (" + ((Integer)props.get("modified")).intValue() + ")", ((Integer)props.get("modified")).intValue(), 1);
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3);
-
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check modify -1 (" + ((Integer)props.get("modified")).intValue() + ")", ((Integer)props.get("modified")).intValue(), 1);
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check modify -1 (" + ((Integer)props.get("modified")).intValue() + ")", ((Integer)props.get("modified")).intValue(), 1);
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
- }
-
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("check modify -1 (" + ((Integer)props.get("modified")).intValue() + ")", ((Integer)props.get("modified")).intValue(), 1);
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance8.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance8.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("check modify -1 (" + ((Integer)props.get("modified")).intValue() + ")", ((Integer)props.get("modified")).intValue(), 1);
-
- ServiceReference ref = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), fooProvider.getInstanceName());
- FooService fs = (FooService) getContext().getService(ref);
-
- fs.foo(); // Update
-
- props = cs.getProps();
- //Check properties
- assertEquals("check modify -1.1", ((Integer)props.get("modified")).intValue(), 3);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- fs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MultipleDependencies.java
deleted file mode 100644
index 837afc0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MultipleDependencies.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class MultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidMultipleCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/NonProxiedNotInterfaceDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/NonProxiedNotInterfaceDependencies.java
deleted file mode 100644
index b15e578..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/NonProxiedNotInterfaceDependencies.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.AbstractMap;
-import java.util.HashMap;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.InstanceManager;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.osgi.framework.ServiceRegistration;
-
-public class NonProxiedNotInterfaceDependencies extends OSGiTestCase {
-
- InstanceManager instance1;
- ComponentInstance fooProvider;
-
- ServiceRegistration reg, reg2;
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- reg = context.registerService(String.class.getName(), "ahahah", null);
- reg2 = context.registerService(AbstractMap.class.getName(), new HashMap(), null);
-
- }
-
- public void tearDown() {
- if (reg != null) {
- reg.unregister();
- }
- if (reg2 != null) {
- reg2.unregister();
- }
- }
-
- public void testInstanceCreation() {
- instance1 = (InstanceManager) helper
- .createComponentInstance("org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceUsingStringService");
- Assert.assertTrue(instance1.getState() == ComponentInstance.VALID);
- Assert.assertTrue(((CheckService) instance1.getPojoObject()).check());
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java
deleted file mode 100644
index 61450be..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "DictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue()); // Nullable object.
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalMultipleDependencies.java
deleted file mode 100644
index 7c1f0da..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalMultipleDependencies.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java
deleted file mode 100644
index a2d47f1..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalNoNullableDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleOptionalNoNullableCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidOptionalNoNullableCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectOptionalNoNullableCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefOptionalNoNullableCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothOptionalNoNullableCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "MapOptionalNoNullableCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "DictOptionalNoNullableCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) {
- e.getMessage();
- fail(e.getMessage());
- }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- // no service, no nullable => runtime exception expected
- assertTrue("check excepted exception", ((Boolean) props.get("exception")).booleanValue());
- assertNull("check CheckService invocation - 1 (" + props.get("result") + ")", props.get("result")); // Null
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
- // No exception expected
- assertFalse("check unexcepted exception", ((Boolean) props.get("exception")).booleanValue());
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation - 1", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result"));
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // No provider.
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -1", props.get("result")); //Null, no provider
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java
deleted file mode 100644
index 79943853..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ProxiedCollectionMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCollectionCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalCollectionCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java
deleted file mode 100644
index 8f3e0d6..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class ProxiedDelayedMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothMultipleCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapMultipleCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictMultipleCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance4.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance5.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance6.stop();
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance7.stop();
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java
deleted file mode 100644
index 2fca044..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-
-public class ProxiedDelayedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 3609844..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ProxiedDelayedOptionalMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java
deleted file mode 100644
index 982dfe5..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-public class ProxiedDelayedSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dict");
- instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- fooProvider.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- public void testMap() {
- instance6.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
- public void testDict() {
- instance7.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java
deleted file mode 100644
index 9365c1c..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ProxiedListMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleListCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalListCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java
deleted file mode 100644
index eef46e2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class ProxiedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue()); // Nullable object.
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java
deleted file mode 100644
index 002d57f..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ProxiedSetMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleSetCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalSetCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java
deleted file mode 100644
index a87026f..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class ProxiedSimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Double");
- instance6 = Utils.getFactoryByName(getContext(), "ProxiedDoubleCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Map");
- instance7 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i7);
-
- Properties i8 = new Properties();
- i8.put("instance.name","Dictionary");
- instance8 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i8);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- instance8.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- instance8 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = getContext().getService(cs_ref);
- CheckService cs = (CheckService) o;
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDouble() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertNotNull("Check cs", cs);
- cs.check();
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance8.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance8.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
deleted file mode 100644
index b68624b..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class ProxyTest extends OSGiTestCase {
-
-
- public void testDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1-Proxy");
- ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- public void testDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name","DelegatorNullable");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertFalse(cs.check()); // Nullable.
-
- instance1.dispose();
- }
-
-
- public void testGetAndDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1-Proxy");
- ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- public void testGetAndDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name","DelegatorNullable");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertFalse(cs.check()); // Nullable.
-
-
- instance1.dispose();
- }
-
- public void testImmediate() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1-Proxy");
- ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
- ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- public void testImmediateNoService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator-with-no-service");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
- ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- try {
- cs.getProps();
- fail("Exception expected");
- } catch(RuntimeException e) {
- //OK
- }
-
- instance1.dispose();
- }
-
- public void testProxyDisabled() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Disable proxy
- System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_DISABLED);
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1-Proxy");
- ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertFalse(helper.toString().contains("$$Proxy")); // Not a proxy.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_ENABLED);
-
- }
-
- public void testDynamicProxy() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Dynamic proxy
- System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.DYNAMIC_PROXY);
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1-Proxy");
- ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name","Delegator");
- ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
- "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) context.getService(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertFalse(helper.toString().contains("$$Proxy")); // Dynamic proxy.
- assertTrue(helper.toString().contains("DynamicProxyFactory"));
- assertTrue(helper.hashCode() > 0);
-
- assertTrue(helper.equals(helper));
- assertFalse(helper.equals(i1)); // This is a quite stupid test...
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.SMART_PROXY);
-
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SetMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SetMultipleDependencies.java
deleted file mode 100644
index 9ec946d..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SetMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class SetMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleSetCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "OptionalSetCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java
deleted file mode 100644
index 8c03ab2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class SimpleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "VoidCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "ObjectCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "RefCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "BothCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Double");
- instance6 = Utils.getFactoryByName(getContext(), "DoubleCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Map");
- instance7 = Utils.getFactoryByName(getContext(), "MapCheckServiceProvider").createComponentInstance(i7);
-
- Properties i8 = new Properties();
- i8.put("instance.name","Dictionary");
- instance8 = Utils.getFactoryByName(getContext(), "DictCheckServiceProvider").createComponentInstance(i8);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- instance8.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- instance8 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = getContext().getService(cs_ref);
- CheckService cs = (CheckService) o;
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDouble() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertNotNull("Check cs", cs);
- cs.check();
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testMap() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testDict() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance8.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance8.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
- assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
- assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
- assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
- assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java
deleted file mode 100644
index 9397917..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class VectorMultipleDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleVectorCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "OptionalVectorCheckServiceProvider").createComponentInstance(i2);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptional() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);
-
- fooProvider1.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
-
- fooProvider1.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.
- assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider2.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DefaultImplementationTestSuite.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DefaultImplementationTestSuite.java
deleted file mode 100644
index f754ce6..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DefaultImplementationTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.di;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class DefaultImplementationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Default Implementation Test Suite", bc);
- ots.addTestSuite( OptionalDependencies.class);
- ots.addTestSuite( MethodOptionalDependencies.class);
- ots.addTestSuite( DelayedOptionalDependencies.class);
- ots.addTestSuite( MethodDelayedOptionalDependencies.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DelayedOptionalDependencies.java
deleted file mode 100644
index 3bcd003..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/DelayedOptionalDependencies.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.di;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class DelayedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodDelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodDelayedOptionalDependencies.java
deleted file mode 100644
index a2ba8d0..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.di;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MethodDelayedOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodOptionalDependencies.java
deleted file mode 100644
index cbfab94..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/MethodOptionalDependencies.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.di;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class MethodOptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testObject() {
-
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/OptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/OptionalDependencies.java
deleted file mode 100644
index d1ca439..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/di/OptionalDependencies.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.di;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class OptionalDependencies extends OSGiTestCase {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = Utils.getFactoryByName(getContext(), "DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = Utils.getFactoryByName(getContext(), "DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = Utils.getFactoryByName(getContext(), "DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(getContext(), "DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- public void testSimple() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 5.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
- assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testVoid() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 5.0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 5.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testObject() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testRef() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void testBoth() {
- ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/inner/InnerProxyMixTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/inner/InnerProxyMixTest.java
deleted file mode 100644
index 1a59c0a..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/inner/InnerProxyMixTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.inner;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.inner.C1;
-import org.apache.felix.ipojo.test.scenarios.component.inner.C2;
-import org.apache.felix.ipojo.test.scenarios.component.inner.C3;
-
-public class InnerProxyMixTest extends OSGiTestCase {
-
- public static String C1 = C1.class.getName();
- public static String C2 = C2.class.getName();
- public static String C3 = C3.class.getName();
-
- IPOJOHelper ipojo;
- private ComponentInstance instancec1;
- private ComponentInstance instancec2;
- private ComponentInstance instancec3;
-
- public void setUp() {
- ipojo = new IPOJOHelper(this);
- // Create the instances
- instancec1 = ipojo.createComponentInstance(C1);
- instancec2 = ipojo.createComponentInstance(C2);
- instancec3 = ipojo.createComponentInstance(C3);
- }
-
- public void tearDown() {
- ipojo.dispose();
- }
-
- public void testMix() {
- // Check that everything is OK
- assertEquals(ComponentInstance.VALID, instancec1.getState());
- assertEquals(ComponentInstance.VALID, instancec2.getState());
- assertEquals(ComponentInstance.VALID, instancec3.getState());
-
- // Call C3
- C3 svc = (C3) getServiceObject(C3, null);
- assertNotNull(svc);
- assertEquals("called", svc.getFilter().authenticate());
-
- // So far, all right
-
- //We stop c1 and c2.
- instancec1.stop();
- instancec2.stop();
-
- assertEquals(ComponentInstance.INVALID, instancec3.getState()); // C2 dependency invalid
-
- instancec1.start();
- instancec2.start();
-
- // Check that everything is OK
- assertEquals(ComponentInstance.VALID, instancec1.getState());
- assertEquals(ComponentInstance.VALID, instancec2.getState());
- assertEquals(ComponentInstance.VALID, instancec3.getState());
-
- // Call C3
- svc = (C3) getServiceObject(C3, null);
- assertNotNull(svc);
- assertEquals("called", svc.getFilter().authenticate());
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
deleted file mode 100644
index 9d2c736..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class CheckServiceDelegator implements CheckService {
-
- private FooService fs;
-
- private Helper helper;
-
- public CheckServiceDelegator(BundleContext bc) {
- helper = new Helper(bc, fs);
- }
-
- public boolean check() {
- // Don't access the service
- // Just delegate
- return helper.check();
- }
-
- public Properties getProps() {
- // Don't access the service
- // Just delegate
- return helper.getProps();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
deleted file mode 100644
index 7f8be1e..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class CheckServiceGetAndDelegate implements CheckService {
-
- private FooService fs;
-
- private Helper helper;
-
- public CheckServiceGetAndDelegate(BundleContext bc) {
- helper = new Helper(bc, fs);
- }
-
- public boolean check() {
- fs.foo();
- return helper.check();
- }
-
- public Properties getProps() {
- fs.getBoolean();
- return helper.getProps();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
deleted file mode 100644
index a72e313..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class CheckServiceNoDelegate implements CheckService {
-
- private FooService fs;
-
- private Helper helper;
-
- private BundleContext context;
-
- public CheckServiceNoDelegate(BundleContext bc) {
- context = bc;
- helper = new Helper(context, fs);
- }
-
- public void start() {
- helper.publish();
- }
-
- public void stop() {
- helper.unpublish();
- }
-
- public boolean check() {
- // Don't access the service
- // Just delegate
- return helper.check();
- }
-
- public Properties getProps() {
- // Don't access the service
- // Just delegate
- return helper.getProps();
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceUsingStringService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceUsingStringService.java
deleted file mode 100644
index f822b95..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceUsingStringService.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
-
-import java.util.AbstractMap;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-
-public class CheckServiceUsingStringService implements CheckService {
-
- private String string;
- private AbstractMap map;
-
-
- public CheckServiceUsingStringService() {
- System.out.println("Service : " + string);
- System.out.println("Map : " + map);
- }
-
- public boolean check() {
- return string != null
- && map != null;
- }
-
- public Properties getProps() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
deleted file mode 100644
index c2f0f29..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
-
-public class Helper implements CheckService {
-
-
- private FooService fs;
- private BundleContext context;
- private ServiceRegistration reg;
-
- public Helper(BundleContext bc, FooService svc) {
- fs = svc;
- context = bc;
- }
-
- public void publish() {
- Properties props = new Properties();
- props.put(Constants.SERVICE_PID, "Helper");
- reg = context.registerService(CheckService.class.getName(), this, props);
- }
-
- public void unpublish() {
- if (reg != null) {
- reg.unregister();
- }
- reg = null;
- }
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- fs.getBoolean();
- props.put("helper.fs", fs);
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/Call.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/Call.java
deleted file mode 100644
index 34513fb..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/Call.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.service.dependency.service;
-
-public interface Call {
-
-
- public String callMe();
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/CheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/CheckService.java
deleted file mode 100644
index 2fed64e..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/FooService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/FooService.java
deleted file mode 100644
index c5932c3..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.service.dependency.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 1196bc2..0000000
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
deleted file mode 100644
index e4e3a7f..0000000
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,1064 +0,0 @@
-<ipojo>
-<!--
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
- -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Simple Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="SimpleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="VoidCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ObjectCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="RefCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="BothCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="MapCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DictCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedSimpleCheckServiceProvider" architecture="true">
- <requires field="fs" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedVoidCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedObjectCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedRefCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedBothCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedMapCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedDictCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DoubleCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <requires field="fs" proxy="true"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedDoubleCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <requires field="fs" />
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MObjectCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MRefCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MBothCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MMapCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MDictCheckServiceProvider" architecture="true">
- <requires>
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Simple & Optional Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="SimpleOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" id="FooService" proxy="false"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="SimpleOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="VoidOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="VoidOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ObjectOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ObjectOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="RefOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="RefOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="BothOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="MapOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DictOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedSimpleOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" id="FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedVoidOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedObjectOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedRefOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedBothOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedMapOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ProxiedDictOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="BothOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="MapOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DictOptionalNoNullableCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" nullable="false">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MObjectOptionalCheckServiceProvider" architecture="true">
- <requires optional="true">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MRefOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MBothOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MMapOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="MDictOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
-
- <!-- Simple & Optional Dependencies with default-implementation -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DISimpleOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIVoidOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIObjectOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIRefOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIBothOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIMapOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DIDictOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="DIMObjectOptionalCheckServiceProvider" architecture="true">
- <requires optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="DIMRefOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="DIMBothOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="DIMMapOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
- name="DIMDictOptionalCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- optional="true"
- default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Multiple Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="SimpleMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedSimpleMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" />
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="VoidMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedVoidMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ObjectMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedObjectMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="RefMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedRefMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="BothMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedBothMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="MapMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" proxy="false">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedMapMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="DictMultipleCheckServiceProvider" architecture="true" >
- <requires field="fs" proxy="false">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedDictMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MObjectMultipleCheckServiceProvider" architecture="true">
- <requires aggregate="true">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MRefMultipleCheckServiceProvider" architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- aggregate="true">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MBothMultipleCheckServiceProvider" architecture="true">
- <requires aggregate="true">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MMapMultipleCheckServiceProvider" architecture="true">
- <requires aggregate="true">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MDictMultipleCheckServiceProvider" architecture="true">
- <requires aggregate="true">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Multiple & Optional Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="SimpleOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" proxy="false"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="VoidOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ObjectOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="RefOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" proxy="false">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedSimpleOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedVoidOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedObjectOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ProxiedRefOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires field="fs" optional="true">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MObjectOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires aggregate="true" optional="true">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
- name="MRefOptionalMultipleCheckServiceProvider"
- architecture="true">
- <requires
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
- aggregate="true" optional="true">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- </requires>
- <provides />
- </component>
-
- <!-- Aggregate dependency as List -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
- name="SimpleListCheckServiceProvider" architecture="true">
- <requires proxy="false"
- field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
- name="OptionalListCheckServiceProvider"
- architecture="true">
- <requires proxy="false"
- specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
- name="ProxiedSimpleListCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
- name="ProxiedOptionalListCheckServiceProvider"
- architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
- <provides />
- </component>
-
- <!-- Aggregate dependency as Vector -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"
- name="SimpleVectorCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="objectBind"/>
- <callback type="unbind" method="objectUnbind"/>
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"
- name="OptionalVectorCheckServiceProvider"
- architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
- <provides />
- </component>
-
- <!-- Aggregate dependency as Set -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
- name="SimpleSetCheckServiceProvider" architecture="true">
- <requires proxy="false" field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
- name="OptionalSetCheckServiceProvider"
- architecture="true">
- <requires proxy="false" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
- name="ProxiedSimpleSetCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
- name="ProxiedOptionalSetCheckServiceProvider"
- architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
- <provides />
- </component>
-
- <!-- Aggregate dependency as Collection -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
- name="SimpleCollectionCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" proxy="false"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
- name="ProxiedSimpleCollectionCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
- name="OptionalCollectionCheckServiceProvider"
- architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true"
- proxy="false"
- />
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
- name="ProxiedOptionalCollectionCheckServiceProvider"
- architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true"
- proxy="false"
- />
- <provides />
- </component>
-
-
- <!-- Modify method test -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"
- name="FooProviderType-Updatable" architecture="true">
- <provides>
- <property name="foo" field="m_foo" value="foo"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="VoidModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="voidBind" />
- <callback type="unbind" method="voidUnbind" />
- <callback type="modified" method="voidModify"/>
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="ObjectModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="objectBind" />
- <callback type="unbind" method="objectUnbind" />
- <callback type="modified" method="objectModify" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="RefModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="refBind" />
- <callback type="unbind" method="refUnbind" />
- <callback type="modified" method="refModify" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="BothModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="bothBind" />
- <callback type="unbind" method="bothUnbind" />
- <callback type="modified" method="bothModify" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="MapModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesMapBind" />
- <callback type="unbind" method="propertiesMapUnbind" />
- <callback type="modified" method="propertiesMapModify" />
- </requires>
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
- name="DictModifyCheckServiceProvider" architecture="true">
- <requires field="fs">
- <callback type="bind" method="propertiesDictionaryBind" />
- <callback type="unbind" method="propertiesDictionaryUnbind" />
- <callback type="modified" method="propertiesDictionaryModify" />
- </requires>
- <provides />
- </component>
-
- <!-- Proxy Tests -->
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator">
- <provides/>
- <requires field="fs" optional="true"/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate">
- <provides/>
- <requires field="fs" optional="true"/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate">
- <provides/>
- <requires field="fs" optional="true"/>
- <callback transition="validate" method="start"/>
- <callback transition="invalidate" method="stop"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceUsingStringService"
- immediate="true">
- <provides/>
- <requires field="string"/>
- <requires field="map"/>
- </component>
-
- <!-- Inner + Proxy mix -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inner.C1">
- <provides/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inner.C2">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inner.C2"/>
- <requires field="c1"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inner.C3">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inner.C3"/>
- <requires field="c2"/>
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/service-providing-inheritance/pom.xml b/ipojo/tests/core/service-providing-inheritance/pom.xml
deleted file mode 100644
index 585cf54..0000000
--- a/ipojo/tests/core/service-providing-inheritance/pom.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.inheritance</artifactId>
- <name>iPOJO Service Providing with inheritance Test Suite</name>
- <version>${ipojo.core.snapshot}</version>
- <description>The the service providing with inheritance</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <!-- Pax Exam API: -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
-
- <!-- TinyBundle -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.base</groupId>
- <artifactId>ops4j-base</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-bnd</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
-
- <!-- mockito -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-</project>
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/InheritanceTest.java b/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/InheritanceTest.java
deleted file mode 100644
index f6a2bd3..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/InheritanceTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package org.apache.felix.ipojo.tests.inheritance;
-
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.handlers.dependency.DependencyDescription;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription;
-import org.apache.felix.ipojo.tests.inheritance.a.IA;
-import org.apache.felix.ipojo.tests.inheritance.b.IB;
-import org.apache.felix.ipojo.tests.inheritance.c.C;
-import org.apache.felix.ipojo.tests.inheritance.d.D;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class InheritanceTest {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
-
- File tmp = new File("target/tmp");
- tmp.mkdirs();
-
- Option[] opt = options(
- felix(),
- equinox(),
- provision(
- // Runtime.
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- // Bundle A
- provision(
- newBundle()
- .add( IA.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"A")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.inheritance.a")
- .build( withBnd() )
- ),
- // Bundle B
- provision(
- newBundle()
- .add( IB.class )
- .set(Constants.BUNDLE_SYMBOLICNAME,"B")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.inheritance.a")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.tests.inheritance.b")
- .build( withBnd() )
- ),
- // Bundle C and D : iPOJO Bundles
- provision(
- // Component C
- newBundle()
- .add(C.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"C")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.inheritance.b," +
- "org.apache.felix.ipojo.tests.inheritance.a")
- .build( withiPOJO(new File(tmp, "provider.jar"), new File("src/test/resources/provider.xml"))),
- // Component D
- newBundle()
- .add(D.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"D")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.tests.inheritance.b," +
- "org.apache.felix.ipojo.tests.inheritance.a")
- .build( withiPOJO(new File(tmp, "cons.jar"), new File("src/test/resources/cons.xml"))))
- );
- return opt;
- }
-
- @Test
- public void testDeploy() {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- Assert.assertEquals(bundles[i].getSymbolicName() + " is not active", Bundle.ACTIVE, bundles[i].getState());
- }
-
- osgi.waitForService(Architecture.class.getName(), "(architecture.instance=c)", 2000);
- osgi.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 2000);
-
- Object[] arch = osgi.getServiceObjects(Architecture.class.getName(), null);
- for (Object o : arch) {
- Architecture a = (Architecture) o;
- if ( a.getInstanceDescription().getState() != ComponentInstance.VALID) {
- Assert.fail("Instance " + a.getInstanceDescription().getName() + " not valid : " + a.getInstanceDescription().getDescription());
- }
- }
- }
-
- @Test
- public void testArchitecture() {
- osgi.waitForService(Architecture.class.getName(), "(architecture.instance=d)", 2000);
- ServiceReference ref = ipojo.getServiceReferenceByName(Architecture.class.getName(), "d");
- Assert.assertNotNull(ref);
-
- Architecture arch = (Architecture) osgi.getServiceObject(ref);
-
- System.out.println(arch.getInstanceDescription().getDescription());
-
- Assert.assertEquals(ComponentInstance.VALID, arch.getInstanceDescription().getState());
- DependencyDescription dd = getDependency(arch, "org.apache.felix.ipojo.tests.inheritance.b.IB");
-
- Assert.assertTrue(! dd.getServiceReferences().isEmpty());
-
- ServiceReference dref = (ServiceReference) dd.getServiceReferences().get(0);
- Assert.assertEquals(dref.getBundle().getSymbolicName(), "C");
-
- }
-
- private DependencyDescription getDependency(Architecture arch, String id) {
- DependencyHandlerDescription hd = (DependencyHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
- Assert.assertNotNull(hd);
- for(DependencyDescription dd : hd.getDependencies()) {
- if (dd.getId().equals(id)) { return dd; }
- }
- Assert.fail("Dependency " + id + " not found");
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/a/IA.java b/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/a/IA.java
deleted file mode 100644
index a224fd6..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/a/IA.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.tests.inheritance.a;
-
-public interface IA {
-
- public String methOne();
-
-}
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/b/IB.java b/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/b/IB.java
deleted file mode 100644
index 91185e2..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/b/IB.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.felix.ipojo.tests.inheritance.b;
-
-import org.apache.felix.ipojo.tests.inheritance.a.IA;
-
-public interface IB extends IA {
-
- public String methTwo();
-}
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/c/C.java b/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/c/C.java
deleted file mode 100644
index e1243d5..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/c/C.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.felix.ipojo.tests.inheritance.c;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Provides;
-import org.apache.felix.ipojo.tests.inheritance.b.IB;
-
-@Component
-@Provides
-public class C implements IB {
-
- public String methOne() { return "one";}
- public String methTwo() { return "two";}
-
-}
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/d/D.java b/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/d/D.java
deleted file mode 100644
index b440cad..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/java/org/apache/felix/ipojo/tests/inheritance/d/D.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.felix.ipojo.tests.inheritance.d;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.annotations.Validate;
-import org.apache.felix.ipojo.tests.inheritance.a.IA;
-import org.apache.felix.ipojo.tests.inheritance.b.IB;
-
-@Component
-public class D {
- @Requires
- private IB[] cImpls;
- private IB cImplDesired;
-
- // works if I use following instead and cast to C type below
- // in for loop
- // but this creates dependency on bundle C instead of just
- // the interface bundles A & B
- // @Requires(default-implementation=C)
- // private iB[] cImpls;
- // private C cImplDesired;
-
- @Validate
- public void start() {
- for( IB iimpl : cImpls) {
-
- // works just fine
- System.out.println(iimpl.methTwo());
-
- // following produces
- // invalid D instance with NoMethodFoundError
- // unless I cast to C instead of iA
- if( ((IA) iimpl).methOne().equals( "one")) {
- cImplDesired = iimpl;
- System.out.println(iimpl.methOne());
- }
- }
- }
-}
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/resources/cons.xml b/ipojo/tests/core/service-providing-inheritance/src/test/resources/cons.xml
deleted file mode 100644
index 70a34c4..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/resources/cons.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<ipojo>
-<instance component="org.apache.felix.ipojo.tests.inheritance.d.D" name="d"/>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing-inheritance/src/test/resources/provider.xml b/ipojo/tests/core/service-providing-inheritance/src/test/resources/provider.xml
deleted file mode 100644
index bdc91ab..0000000
--- a/ipojo/tests/core/service-providing-inheritance/src/test/resources/provider.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<ipojo>
-<instance component="org.apache.felix.ipojo.tests.inheritance.c.C" name="c"/>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing-strategies/pom.xml b/ipojo/tests/core/service-providing-strategies/pom.xml
deleted file mode 100755
index 541a64f..0000000
--- a/ipojo/tests/core/service-providing-strategies/pom.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Providing Strategy Test Suite</name>
- <artifactId>tests.core.ps.strategy</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <artifactId>tests.core.ps</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test.scenarios.component.strategies, org.apache.felix.ipojo.test.scenarios.ps.strategies
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.ps.strategies.ProvidedServiceStrategyTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/BarConsumer.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/BarConsumer.java
deleted file mode 100644
index c7cf2d2..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/BarConsumer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-
-public class BarConsumer implements CheckService {
-
- private BarService bs;
-
-
- public boolean check() {
- return bs.bar();
- }
-
- public Properties getProps() {
- Properties props = bs.getProps();
- props.put("object", bs);
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/Consumer.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/Consumer.java
deleted file mode 100644
index 1479eb1..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/Consumer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class Consumer implements CheckService {
-
- private FooService fs;
-
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = fs.fooProps();
- props.put("object", fs);
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy.java
deleted file mode 100644
index 5bc3838..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.IPOJOServiceFactory;
-import org.apache.felix.ipojo.InstanceManager;
-import org.apache.felix.ipojo.handlers.providedservice.CreationStrategy;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class DummyCreationStrategy extends CreationStrategy implements InvocationHandler {
-
- /**
- * Map [ComponentInstance->ServiceObject] storing created service objects.
- */
- private Map/*<ComponentInstance, ServiceObject>*/ m_instances = new HashMap();
-
- private InstanceManager m_manager;
-
- private String[] m_specs;
-
- /**
- * A method is invoked on the proxy object.
- * If the method is the {@link IPOJOServiceFactory#getService(ComponentInstance)}
- * method, this method creates a service object if no already created for the asking
- * component instance.
- * If the method is {@link IPOJOServiceFactory#ungetService(ComponentInstance, Object)}
- * the service object is unget (i.e. removed from the map and deleted).
- * In all other cases, a {@link UnsupportedOperationException} is thrown as this policy
- * requires to use the {@link IPOJOServiceFactory} interaction pattern.
- * @param arg0 the proxy object
- * @param arg1 the called method
- * @param arg2 the arguments
- * @return the service object attached to the asking instance for 'get',
- * <code>null</code> for 'unget',
- * a {@link UnsupportedOperationException} for all other methods.
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
- */
- public Object invoke(Object arg0, Method arg1, Object[] arg2) {
- if (isGetServiceMethod(arg1)) {
- return getService((ComponentInstance) arg2[0]);
- }
-
- if (isUngetServiceMethod(arg1)) {
- ungetService((ComponentInstance) arg2[0], arg2[1]);
- return null;
- }
-
- throw new UnsupportedOperationException("This service requires an advanced creation policy. "
- + "Before calling the service, call the getService(ComponentInstance) method to get "
- + "the service object. " + arg1.getName());
- }
-
- /**
- * A service object is required.
- * This policy returns a service object per asking instance.
- * @param instance the instance requiring the service object
- * @return the service object for this instance
- * @see org.apache.felix.ipojo.IPOJOServiceFactory#getService(org.apache.felix.ipojo.ComponentInstance)
- */
- public Object getService(ComponentInstance instance) {
- Object obj = m_instances.get(instance);
- if (obj == null) {
- obj = m_manager.createPojoObject();
- m_instances.put(instance, obj);
- }
- return obj;
- }
-
- /**
- * A service object is unget.
- * The service object is removed from the map and deleted.
- * @param instance the instance releasing the service
- * @param svcObject the service object
- * @see org.apache.felix.ipojo.IPOJOServiceFactory#ungetService(org.apache.felix.ipojo.ComponentInstance, java.lang.Object)
- */
- public void ungetService(ComponentInstance instance, Object svcObject) {
- Object pojo = m_instances.remove(instance);
- m_manager.deletePojoObject(pojo);
- }
-
- /**
- * The service is going to be registered.
- * @param im the instance manager
- * @param interfaces the published interfaces
- * @param props the properties
- * @see org.apache.felix.ipojo.handlers.providedservice.CreationStrategy#onPublication(org.osgi.framework.BundleContext, java.lang.String[], java.util.Properties)
- */
- public void onPublication(InstanceManager im, String[] interfaces,
- Properties props) {
-
- m_manager = im;
- m_specs = interfaces;
-
- }
-
- /**
- * The service is going to be unregistered.
- * The instance map is cleared. Created object are disposed.
- * @see org.apache.felix.ipojo.handlers.providedservice.CreationStrategy#onUnpublication()
- */
- public void onUnpublication() {
- Collection col = m_instances.values();
- Iterator it = col.iterator();
- while (it.hasNext()) {
- m_manager.deletePojoObject(it.next());
- }
- m_instances.clear();
- }
-
- /**
- * OSGi Service Factory getService method.
- * @param arg0 the asking bundle
- * @param arg1 the service registration
- * @return a proxy implementing the {@link IPOJOServiceFactory}
- * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
- */
- public Object getService(Bundle arg0, ServiceRegistration arg1) {
- Object proxy = Proxy.newProxyInstance(m_manager.getClazz().getClassLoader(),
- getSpecificationsWithIPOJOServiceFactory(m_specs, m_manager.getContext()), this);
- return proxy;
- }
-
- /**
- * OSGi Service factory unget method.
- * Does nothing.
- * @param arg0 the asking bundle
- * @param arg1 the service registration
- * @param arg2 the service object created for this bundle.
- * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
- */
- public void ungetService(Bundle arg0, ServiceRegistration arg1,
- Object arg2) { }
-
- /**
- * Utility method returning the class array of provided service
- * specification and the {@link IPOJOServiceFactory} interface.
- * @param specs the published service interface
- * @param bc the bundle context, used to load classes
- * @return the class array containing provided service specification and
- * the {@link IPOJOServiceFactory} class.
- */
- private Class[] getSpecificationsWithIPOJOServiceFactory(String[] specs, BundleContext bc) {
- Class[] classes = new Class[specs.length + 1];
- int i = 0;
- for (i = 0; i < specs.length; i++) {
- try {
- classes[i] = bc.getBundle().loadClass(specs[i]);
- } catch (ClassNotFoundException e) {
- // Should not happen.
- }
- }
- classes[i] = IPOJOServiceFactory.class;
- return classes;
- }
-
-
-}
-
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy2.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy2.java
deleted file mode 100644
index 8b2374f..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyCreationStrategy2.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import org.apache.felix.ipojo.IPOJOServiceFactory;
-import org.apache.felix.ipojo.InstanceManager;
-import org.apache.felix.ipojo.handlers.providedservice.strategy.ConfigurableCreationStrategy;
-
-public class DummyCreationStrategy2 extends ConfigurableCreationStrategy {
-
- protected IPOJOServiceFactory getServiceFactory(InstanceManager manager) {
- return new DummyServiceFactory(manager);
- }
-
-
-}
-
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyServiceFactory.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyServiceFactory.java
deleted file mode 100644
index 3c9c24d..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/DummyServiceFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.InstanceManager;
-import org.apache.felix.ipojo.handlers.providedservice.strategy.ServiceObjectFactory;
-
-public class DummyServiceFactory implements ServiceObjectFactory {
-
- /**
- * Map [ComponentInstance->ServiceObject] storing created service objects.
- */
- private Map/*<ComponentInstance, ServiceObject>*/ m_instances = new HashMap();
-
- private InstanceManager m_manager;
-
- public DummyServiceFactory(InstanceManager manager) {
- m_manager = manager;
- }
-
- /**
- * A service object is required.
- * This policy returns a service object per asking instance.
- * @param instance the instance requiring the service object
- * @return the service object for this instance
- * @see org.apache.felix.ipojo.IPOJOServiceFactory#getService(org.apache.felix.ipojo.ComponentInstance)
- */
- public Object getService(ComponentInstance instance) {
- Object obj = m_instances.get(instance);
- if (obj == null) {
- obj = m_manager.createPojoObject();
- m_instances.put(instance, obj);
- }
- return obj;
- }
-
- /**
- * A service object is unget.
- * The service object is removed from the map and deleted.
- * @param instance the instance releasing the service
- * @param svcObject the service object
- * @see org.apache.felix.ipojo.IPOJOServiceFactory#ungetService(org.apache.felix.ipojo.ComponentInstance, java.lang.Object)
- */
- public void ungetService(ComponentInstance instance, Object svcObject) {
- Object pojo = m_instances.remove(instance);
- m_manager.deletePojoObject(pojo);
- }
-
- public void close() {
- Collection col = m_instances.values();
- Iterator it = col.iterator();
- while (it.hasNext()) {
- m_manager.deletePojoObject(it.next());
- }
- m_instances.clear();
- }
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooBarProviderType1.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooBarProviderType1.java
deleted file mode 100644
index be254c5..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooBarProviderType1.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class FooBarProviderType1 implements FooService, BarService {
-
- public static long id = 0;
-
- public static long getNewId() {
- id++;
- return id;
- }
-
- public static long getReturnedIds() {
- return id;
- }
-
- public static void resetIds() {
- id = 0;
- }
-
- private int m_bar;
- private String m_foo;
-
- private long myid = getNewId();
-
-
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- System.out.println(this + " - id : " + myid); //TODO DEBUG
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
-
- p.put("id", new Long(myid));
- return p;
- }
-
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- public boolean bar() {
- return foo();
- }
-
- public Properties getProps() {
- return fooProps();
- }
-
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooProviderType1.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooProviderType1.java
deleted file mode 100755
index 967a8de..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/component/strategies/FooProviderType1.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class FooProviderType1 implements FooService {
-
- public static long id = 0;
-
- public static long getNewId() {
- id++;
- return id;
- }
-
- public static long getReturnedIds() {
- return id;
- }
-
- public static void resetIds() {
- id = 0;
- }
-
- private int m_bar;
- private String m_foo;
-
- private long myid = getNewId();
-
-
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- System.out.println(this + " - id : " + myid); //TODO DEBUG
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
-
- p.put("id", new Long(myid));
- return p;
- }
-
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategy2Test.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategy2Test.java
deleted file mode 100644
index db6bf46..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategy2Test.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.ps.strategies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1;
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-public class CustomStrategy2Test extends OSGiTestCase {
-
-
- private IPOJOHelper helper;
- private ComponentInstance cons1, cons2, prov;
- private ComponentInstance cons3, prov2;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- cons1 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons1 invalid", ComponentInstance.INVALID, cons1.getState());
- cons2 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons2 invalid", ComponentInstance.INVALID, cons2.getState());
- prov = helper.createComponentInstance("PSS-FooProviderType-Custom2");
- prov2 = helper.createComponentInstance("PSS-FooBarProviderType-Custom2");
- cons3 = helper.createComponentInstance("PSS-ConsBar");
- prov2.stop();
- prov.stop();
- }
-
- public void tearDown() {
- reset();
- }
-
-
- private void reset() {
- FooProviderType1.resetIds();
- FooBarProviderType1.resetIds();
- }
-
- private void checkCreatedObjects(ComponentInstance ci, int expected) {
- assertEquals("Number of created objects", expected, ((PrimitiveInstanceDescription) ci.getInstanceDescription()).getCreatedObjects().length);
- }
-
- public void testOneService() {
- prov.start();
- cons2.stop();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov.getInstanceName());
- assertNotNull("Service available", ref);
- checkCreatedObjects(prov, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov, 1);
-
-
- // Step 2 : create a second consumer
- cons2.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- System.out.println("cons2 stopping");
- cons2.stop();
- System.out.println("cons2 stopped");
- checkCreatedObjects(prov, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
- public void testObjectCreation() {
- prov.start();
-
- // The two consumers are started and use their own objects.
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- FooService fscons1 = (FooService) props.get("object");
-
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- FooService fscons2 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Stop the provider
- prov.stop();
- // Cons1 and 2 are invalid.
- assertEquals("Cons1 invalidity", ComponentInstance.INVALID, cons1.getState());
- assertEquals("Cons2 invalidity", ComponentInstance.INVALID, cons2.getState());
-
- // No object created in prov
- checkCreatedObjects(prov, 0);
-
- // Restart the provider
- prov.start();
-
- // Consumers are valid.
- assertEquals("Cons1 validity", ComponentInstance.VALID, cons1.getState());
- assertEquals("Cons2 validity", ComponentInstance.VALID, cons2.getState());
-
- // Check objects
- refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- cs_cons1 = (CheckService) getServiceObject(refcons1);
- props = cs_cons1.getProps();
- Object fscons3 = (FooService) props.get("object");
-
- refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- cs_cons2 = (CheckService) getServiceObject(refcons2);
- props2 = cs_cons2.getProps();
- Object fscons4 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons3, fscons4);
- assertNotSame("Two new objects - 1", fscons3, fscons1);
- assertNotSame("Two new objects - 2", fscons4, fscons2);
-
- }
-
- public void testTwoServices() {
- cons3.stop();
- prov2.start();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov2.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", ref);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", refBar);
- checkCreatedObjects(prov2, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov2, 1);
-
-
- // Step 2 : create a second consumer
- cons3.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons3.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov2, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- cons3.stop();
- checkCreatedObjects(prov2, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
-}
\ No newline at end of file
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategyTest.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategyTest.java
deleted file mode 100644
index ec1a58c..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/CustomStrategyTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.ps.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1;
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CustomStrategyTest extends OSGiTestCase {
-
-
- private IPOJOHelper helper;
- private ComponentInstance cons1, cons2, prov;
- private ComponentInstance cons3, prov2;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- cons1 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons1 invalid", ComponentInstance.INVALID, cons1.getState());
- cons2 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons2 invalid", ComponentInstance.INVALID, cons2.getState());
- prov = helper.createComponentInstance("PSS-FooProviderType-Custom");
- prov2 = helper.createComponentInstance("PSS-FooBarProviderType-Custom");
- cons3 = helper.createComponentInstance("PSS-ConsBar");
- prov2.stop();
- prov.stop();
- }
-
- public void tearDown() {
- reset();
- }
-
-
- private void reset() {
- FooProviderType1.resetIds();
- FooBarProviderType1.resetIds();
- }
-
- private void checkCreatedObjects(ComponentInstance ci, int expected) {
- assertEquals("Number of created objects", expected, ((PrimitiveInstanceDescription) ci.getInstanceDescription()).getCreatedObjects().length);
- }
-
- public void testOneService() {
- prov.start();
- cons2.stop();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov.getInstanceName());
- assertNotNull("Service available", ref);
- checkCreatedObjects(prov, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov, 1);
-
-
- // Step 2 : create a second consumer
- cons2.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- System.out.println("cons2 stopping");
- cons2.stop();
- System.out.println("cons2 stopped");
- checkCreatedObjects(prov, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
- public void testObjectCreation() {
- prov.start();
-
- // The two consumers are started and use their own objects.
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- FooService fscons1 = (FooService) props.get("object");
-
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- FooService fscons2 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Stop the provider
- prov.stop();
- // Cons1 and 2 are invalid.
- assertEquals("Cons1 invalidity", ComponentInstance.INVALID, cons1.getState());
- assertEquals("Cons2 invalidity", ComponentInstance.INVALID, cons2.getState());
-
- // No object created in prov
- checkCreatedObjects(prov, 0);
-
- // Restart the provider
- prov.start();
-
- // Consumers are valid.
- assertEquals("Cons1 validity", ComponentInstance.VALID, cons1.getState());
- assertEquals("Cons2 validity", ComponentInstance.VALID, cons2.getState());
-
- // Check objects
- refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- cs_cons1 = (CheckService) getServiceObject(refcons1);
- props = cs_cons1.getProps();
- Object fscons3 = (FooService) props.get("object");
-
- refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- cs_cons2 = (CheckService) getServiceObject(refcons2);
- props2 = cs_cons2.getProps();
- Object fscons4 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons3, fscons4);
- assertNotSame("Two new objects - 1", fscons3, fscons1);
- assertNotSame("Two new objects - 2", fscons4, fscons2);
-
- }
-
- public void testTwoServices() {
- cons3.stop();
- prov2.start();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov2.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", ref);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", refBar);
- checkCreatedObjects(prov2, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov2, 1);
-
-
- // Step 2 : create a second consumer
- cons3.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons3.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov2, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- cons3.stop();
- checkCreatedObjects(prov2, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/PerInstanceStrategyTest.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/PerInstanceStrategyTest.java
deleted file mode 100644
index 5343ca9..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/PerInstanceStrategyTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.ps.strategies;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1;
-import org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1;
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class PerInstanceStrategyTest extends OSGiTestCase {
-
-
- private IPOJOHelper helper;
- private ComponentInstance cons1, cons2, prov;
- private ComponentInstance cons3, prov2;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- cons1 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons1 invalid", ComponentInstance.INVALID, cons1.getState());
- cons2 = helper.createComponentInstance("PSS-Cons");
- assertEquals("cons2 invalid", ComponentInstance.INVALID, cons2.getState());
- prov = helper.createComponentInstance("PSS-FooProviderType-Instance");
- prov2 = helper.createComponentInstance("PSS-FooBarProviderType-Instance");
- cons3 = helper.createComponentInstance("PSS-ConsBar");
- prov2.stop();
- prov.stop();
- }
-
- public void tearDown() {
- reset();
- }
-
-
- private void reset() {
- FooProviderType1.resetIds();
- FooBarProviderType1.resetIds();
- }
-
- private void checkCreatedObjects(ComponentInstance ci, int expected) {
- assertEquals("Number of created objects", expected, ((PrimitiveInstanceDescription) ci.getInstanceDescription()).getCreatedObjects().length);
- }
-
- public void testOneService() {
- prov.start();
- cons2.stop();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov.getInstanceName());
- assertNotNull("Service available", ref);
- checkCreatedObjects(prov, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov, 1);
-
-
- // Step 2 : create a second consumer
- cons2.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- System.out.println("cons2 stopping");
- cons2.stop();
- System.out.println("cons2 stopped");
- checkCreatedObjects(prov, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
- public void testObjectCreation() {
- prov.start();
-
- // The two consumers are started and use their own objects.
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- FooService fscons1 = (FooService) props.get("object");
-
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- FooService fscons2 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Stop the provider
- prov.stop();
- // Cons1 and 2 are invalid.
- assertEquals("Cons1 invalidity", ComponentInstance.INVALID, cons1.getState());
- assertEquals("Cons2 invalidity", ComponentInstance.INVALID, cons2.getState());
-
- // No object created in prov
- checkCreatedObjects(prov, 0);
-
- // Restart the provider
- prov.start();
-
- // Consumers are valid.
- assertEquals("Cons1 validity", ComponentInstance.VALID, cons1.getState());
- assertEquals("Cons2 validity", ComponentInstance.VALID, cons2.getState());
-
- // Check objects
- refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
- cs_cons1 = (CheckService) getServiceObject(refcons1);
- props = cs_cons1.getProps();
- Object fscons3 = (FooService) props.get("object");
-
- refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons2.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
- cs_cons2 = (CheckService) getServiceObject(refcons2);
- props2 = cs_cons2.getProps();
- Object fscons4 = (FooService) props2.get("object");
-
- checkCreatedObjects(prov, 2);
- assertNotSame("Two objects", fscons3, fscons4);
- assertNotSame("Two new objects - 1", fscons3, fscons1);
- assertNotSame("Two new objects - 2", fscons4, fscons2);
-
- }
-
- public void testTwoServices() {
- cons3.stop();
- prov2.start();
- cons1.stop();
- assertEquals("Prov valid", ComponentInstance.VALID, prov2.getState());
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", ref);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), prov2.getInstanceName());
- assertNotNull("Service available", refBar);
- checkCreatedObjects(prov2, 0);
-
- // Step 1 : create start one consumer
- cons1.start();
- ServiceReference refcons1 = helper.getServiceReferenceByName(CheckService.class.getName(), cons1.getInstanceName());
- assertNotNull("Cons1 Service available", refcons1);
-
- CheckService cs_cons1 = (CheckService) getServiceObject(refcons1);
- Properties props = cs_cons1.getProps();
- Long id = (Long) props.get("id");
- FooService fscons1 = (FooService) props.get("object");
- assertEquals("id 1", 1, id.intValue());
- checkCreatedObjects(prov2, 1);
-
-
- // Step 2 : create a second consumer
- cons3.start();
- ServiceReference refcons2 = helper.getServiceReferenceByName(CheckService.class.getName(), cons3.getInstanceName());
- assertNotNull("Cons2 Service available", refcons2);
-
- CheckService cs_cons2 = (CheckService) getServiceObject(refcons2);
- Properties props2 = cs_cons2.getProps();
- Long id2 = (Long) props2.get("id");
- FooService fscons2 = (FooService) props2.get("object");
- assertEquals("id 2", 2, id2.intValue());
- checkCreatedObjects(prov2, 2);
-
-
- assertNotSame("Two objects", fscons1, fscons2);
-
- // Step 3 : stop the second provider
- cons3.stop();
- checkCreatedObjects(prov2, 1);
-
- // Step 4 : stop the first consumer
- cons1.stop();
- checkCreatedObjects(prov, 0);
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/ProvidedServiceStrategyTestSuite.java b/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/ProvidedServiceStrategyTestSuite.java
deleted file mode 100755
index 9b1a99d..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/strategies/ProvidedServiceStrategyTestSuite.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.strategies;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ProvidedServiceStrategyTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Provided Service Strategy Test Suite", bc);
- ots.addTestSuite(PerInstanceStrategyTest.class);
- ots.addTestSuite(CustomStrategyTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
deleted file mode 100755
index bb892b3..0000000
--- a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Simple provider -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
- name="PSS-FooProviderType-Instance" architecture="true">
- <provides strategy="instance"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.Consumer"
- name="PSS-Cons" architecture="true">
- <requires field="fs" proxy="false"/>
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.BarConsumer"
- name="PSS-ConsBar" architecture="true">
- <requires field="bs" proxy="false"/>
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"
- name="PSS-FooBarProviderType-Instance" architecture="true">
- <provides strategy="instance"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
- name="PSS-FooProviderType-Custom" architecture="true">
- <provides strategy="org.apache.felix.ipojo.test.scenarios.component.strategies.DummyCreationStrategy"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"
- name="PSS-FooBarProviderType-Custom" architecture="true">
- <provides strategy="org.apache.felix.ipojo.test.scenarios.component.strategies.DummyCreationStrategy"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
- name="PSS-FooProviderType-Custom2" architecture="true">
- <provides strategy="org.apache.felix.ipojo.test.scenarios.component.strategies.DummyCreationStrategy2"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"
- name="PSS-FooBarProviderType-Custom2" architecture="true">
- <provides strategy="org.apache.felix.ipojo.test.scenarios.component.strategies.DummyCreationStrategy2"/>
- </component>
-
-
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/pom.xml b/ipojo/tests/core/service-providing/pom.xml
deleted file mode 100644
index 98e150c..0000000
--- a/ipojo/tests/core/service-providing/pom.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Providing Test Suite</name>
- <artifactId>tests.core.ps</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.ps.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.ps.ProvidedServiceTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/README b/ipojo/tests/core/service-providing/src/main/ipojo/README
deleted file mode 100644
index 657bcef..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/README
+++ /dev/null
@@ -1 +0,0 @@
-This folder contains the iPOJO metadata.
\ No newline at end of file
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml b/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml
deleted file mode 100644
index 5816366..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Simple provider -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="PS-FooProviderType-1" architecture="true">
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="PS-FooProviderType-itf" architecture="true">
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="PS-FooProviderType-3" architecture="true">
- <provides>
- <property name="foo" field="m_foo"/>
- <property name="bar" field="m_bar"/>
- <property name="baz" type="java.lang.String"/>
- </provides>
- <properties propagation="true">
- <property name="foo" field="m_foo"/>
- <property name="bar" field="m_bar"/>
- </properties>
- </component>
-
- <!-- Providers providing 2 services -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
- name="PS-FooBarProviderType-1" architecture="true">
- <provides/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
- name="PS-FooBarProviderType-2" architecture="true">
- <provides
- specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService, org.apache.felix.ipojo.test.scenarios.ps.service.BarService }"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
- name="PS-FooBarProviderType-3" architecture="true">
- <provides
- specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService}">
- <property name="baz" type="java.lang.String" value="foo"/>
- </provides>
- <provides
- specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.BarService}">
- <property name="baz" type="java.lang.String" value="bar"/>
- </provides>
- </component>
-
-
- <!-- Provider with dynamic property -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="PS-FooProviderType-Dyn" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2"/>
- <property name="boolean" field="boolProp" value="false"/>
- <property name="string" field="strProp" value="foo"/>
- <property name="strAProp" field="strAProp"
- value="{foo, bar}"/>
- <property name="intAProp" field="intAProp" value="{1,2,3}"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="PS-FooProviderType-2" architecture="true">
- <provides>
- <property name="int" type="int" value="2"/>
- <property name="long" type="long" value="40"/>
- <property name="string" type="java.lang.String" value="foo"/>
- <property name="strAProp" type="java.lang.String[]"
- value="{foo, bar}"/>
- <property name="intAProp" type="int[]" value="{1,2,3}"/>
- </provides>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn2"
- name="PS-FooProviderType-Dyn2" architecture="true">
- <provides>
- <property name="int" field="intProp" value="4"/>
- <property name="boolean" field="boolProp"/>
- <property name="string" field="strProp"/>
- <property name="strAProp" field="strAProp"/>
- <property name="intAProp" field="intAProp"
- value="{1, 2,3 }"/>
- </provides>
- </component>
-
- <!-- Null Check -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.NullCheckServiceProvider" immediate="true"
- name="PS-Null">
- <provides>
- <property field="prop1"/>
- <property field="prop2"/>
- </provides>
- </component>
-
- <!-- Anonymous classes -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderWithAnonymousClass"
- name="PS-FooProviderTypeAnonymous-Dyn" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2"/>
- <property name="boolean" field="boolProp" value="false"/>
- <property name="string" field="strProp" value="foo"/>
- <property name="strAProp" field="strAProp"
- value="{foo, bar}"/>
- <property name="intAProp" field="intAProp" value="{1,2,3}"/>
- </provides>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml b/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml
deleted file mode 100644
index 7963170..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Registration callbacks -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
- name="PS-Callbacks-reg-only">
- <provides post-registration="registered"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
- name="PS-Callbacks-both">
- <provides post-registration="registered" post-unregistration="unregistered"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
- name="PS-Callbacks-unreg-only">
- <provides post-unregistration="unregistered"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
- name="PS-Callbacks-both-2">
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"
- post-unregistration="unregistered" post-registration="registered"/>
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"
- post-unregistration="unregistered2" post-registration="registered2"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"
- name="PS-Callbacks-both-1">
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"
- post-unregistration="unregistered" post-registration="registered"/>
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"
- post-unregistration="unregistered" post-registration="registered"/>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml b/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
deleted file mode 100644
index 843e17a..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="org.apache.felix.ipojo"
->
-
- <!-- Concrete and abstract class -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"
- name="PS-PI4" architecture="true">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"
- name="PS-PI5" architecture="true">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation4"
- name="PS-PI6" architecture="true">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"
- name="PS-PI7" architecture="true">
- <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation, org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.SimpleClass">
- <provides/>
- </component>
-
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml b/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml
deleted file mode 100644
index bff80f4..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Service Controller -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
- name="PS-Controller-1-default">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
- <controller field="controller"/>
- </provides>
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
- </provides>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
- name="PS-Controller-1-false">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
- <property name="test2" type="string" value="test2"/>
- <controller field="controller" value="false"/>
- <property name="test" type="string" value="test"/>
- </provides>
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
- </provides>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-truetrue">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="true"/>
- <property name="test" type="string" value="test"/>
- </provides>
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
- <controller field="controllerCS" value="true"/>
- </provides>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-truefalse">
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="false"/>
- <property name="test" type="string" value="test"/>
- </provides>
- <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
- <controller field="controllerCS" value="true"/>
- </provides>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-spec1">
- <provides>
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>
- <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>
- <property name="test" type="string" value="test"/>
- </provides>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-spec2">
- <provides>
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>
- <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>
- <property name="test" type="string" value="test"/>
- </provides>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-spec3">
- <provides>
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>
- <controller field="controllerCS" value="true"/>
- <property name="test" type="string" value="test"/>
- </provides>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
- name="PS-Controller-2-spec4">
- <provides>
- <property name="test2" type="string" value="test2"/>
- <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>
- <controller field="controllerCS" value="true"/>
- <property name="test" type="string" value="test"/>
- </provides>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml b/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml
deleted file mode 100644
index dd103ac..0000000
--- a/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="org.apache.felix.ipojo"
->
-
- <!-- Inherited Provides -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"
- name="PS-PI1" architecture="true">
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"
- name="PS-PI1-1" architecture="true">
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"
- name="PS-PI1-2" architecture="true">
- <provides
- specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface, org.apache.felix.ipojo.test.scenarios.ps.service.ParentInterface2}"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"
- name="PS-PI2" architecture="true">
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"
- name="PS-PI2-1" architecture="true">
- <provides
- specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"
- name="PS-PI3" architecture="true">
- <provides/>
- </component>
-</ipojo>
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
deleted file mode 100644
index cef0891..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public abstract class CheckProviderParentClass {
-
- int simpleU = 0;
- int objectU = 0;
- int refU = 0;
- int bothU = 0;
-
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothU++; }
- }
-
- public void refUnbind(ServiceReference sr) {
- if(sr != null) { refU++; }
- }
-
- public void objectUnbind(FooService o) {
- if(o != null && o instanceof FooService) { objectU++; }
- else {
- System.err.println("Unbind null : " + o);
- }
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index a41f977..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
-
- FooService fs;
-
- int simpleB = 0;
- int objectB = 0;
- int refB = 0;
- int bothB = 0;
-
- public boolean check() {
- return fs.foo();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- if (fs != null) {
- props.put("result", new Boolean(fs.foo()));
- props.put("boolean", new Boolean(fs.getBoolean()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
- }
- props.put("static", CheckService.foo);
- props.put("class", CheckService.class.getName());
- return props;
- }
-
- private void voidBind() {
- simpleB++;
- }
-
- protected void objectBind(FooService o) {
- if (o == null) {
- System.err.println("Bind receive null !!! ");
- return;
- }
- if(o != null && o instanceof FooService) { objectB++; }
- }
-
- public void refBind(ServiceReference sr) {
- if(sr != null) { refB++; }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if(sr != null && o != null && o instanceof FooService) { bothB++; }
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
deleted file mode 100644
index 5fbac9f..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class FooBarProviderType1 implements FooService, BarService {
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- return new Properties();
- }
-
- public boolean bar() {
- return true;
- }
-
- public Properties getProps() {
- return new Properties();
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index cac57b2..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
deleted file mode 100644
index a83cd7a..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-
-public class FooProviderTypeDyn implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
-
- public boolean foo() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java
deleted file mode 100644
index 40f6698..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn2.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class FooProviderTypeDyn2 implements FooService {
-
- private int intProp = 2;
- private boolean boolProp = true;
- private String strProp = "foo";
- private String[] strAProp = new String[] {"foo", "bar"};
- private int[] intAProp = new int[] {1, 2, 3};
-
- public boolean foo() {
- intAProp = null;
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
deleted file mode 100644
index 351871c..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import javax.swing.SwingUtilities;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class FooProviderWithAnonymousClass implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
-
- public boolean foo() {
- Runnable runnable = new Runnable() {
- public void run() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- }
- };
- new Thread(runnable).start();
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- }
- });
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- return true;
- }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullCheckServiceProvider.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullCheckServiceProvider.java
deleted file mode 100644
index ee775b3..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullCheckServiceProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class NullCheckServiceProvider implements FooService {
-
- private String prop1;
- private String prop2;
-
- public NullCheckServiceProvider() {
- if (prop1 == null) {
- prop2= "0";
- }
- }
-
-
- public boolean foo() {
- if (prop1 == null && prop2 != null) {
- prop1 = "0";
- prop2 = null;
- return true;
- }
- if (prop2 == null && prop1 != null) {
- prop1 = null;
- prop2 = "0";
- return true;
- }
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
deleted file mode 100644
index 5761947..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SimpleClass.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class SimpleClass {
-
- // This class do not implement any interface, it will be exposed as SimpleClass
-
- public String hello() {
- return "Hello";
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/callbacks/CallbacksCheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/callbacks/CallbacksCheckService.java
deleted file mode 100644
index 56b6b6e..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/callbacks/CallbacksCheckService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.callbacks;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class CallbacksCheckService implements FooService, CheckService {
-
- // 4 Counters
- int registered = 0;
- int unregistered = 0;
- int registered2 = 0;
- int unregistered2 = 0;
-
- // 4 Methods
- public void registered(ServiceReference ref) {
- if (ref == null) {
- throw new IllegalArgumentException("ref null");
- }
- registered++;
- }
-
- public void unregistered(ServiceReference ref) {
- if (ref == null) {
- throw new IllegalArgumentException("ref null");
- }
- unregistered++;
- }
-
- public void registered2(ServiceReference ref) {
- if (ref == null) {
- throw new IllegalArgumentException("ref null");
- }
- registered2++;
- }
-
- public void unregistered2(ServiceReference ref) {
- if (ref == null) {
- throw new IllegalArgumentException("ref null");
- }
- unregistered2++;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties props = new Properties();
- props.put("registered", new Integer(registered));
- props.put("registered2", new Integer(registered2));
- props.put("unregistered", new Integer(unregistered));
- props.put("unregistered2", new Integer(unregistered2));
- return props;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean check() {
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("registered", new Integer(registered));
- props.put("registered2", new Integer(registered2));
- props.put("unregistered", new Integer(unregistered));
- props.put("unregistered2", new Integer(unregistered2));
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java
deleted file mode 100644
index 988294f..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.controller;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class ControllerCheckService implements FooService, CheckService {
-
-
- private boolean controller;
-
- public boolean foo() {
- return controller;
- }
-
- public Properties fooProps() {
- Properties props = new Properties();
- props.put("controller", new Boolean(controller));
- return props;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean check() {
- System.out.println("Before : " + controller);
- controller = ! controller; // Change
- System.out.println("After : " + controller);
- return controller;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("controller", new Boolean(controller));
- return props;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java
deleted file mode 100644
index bdfa92c..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component.controller;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class DoubleControllerCheckService implements FooService, CheckService {
-
-
- private boolean controllerFoo;
- private boolean controllerCS;
-
- public boolean foo() {
- controllerFoo = ! controllerFoo;
- return controllerFoo;
- }
-
- public Properties fooProps() {
- Properties props = new Properties();
- props.put("controller", new Boolean(controllerFoo));
-
- controllerCS = true;
- controllerFoo = true;
-
- return props;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
- public boolean check() {
- controllerCS = ! controllerCS;
- return controllerCS;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("controller", new Boolean(controllerCS));
-
- // Invert both
- controllerCS = ! controllerCS;
- controllerFoo = ! controllerFoo;
-
- return props;
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation1.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation1.java
deleted file mode 100644
index 46488a8..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation1.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.inherited;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.ChildInterface;
-
-public class ProcessImplementation1 implements ChildInterface {
-
- public void processChild() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent1() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParentParent() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent2() {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation2.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation2.java
deleted file mode 100644
index 49e9267..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation2.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.inherited;
-
-
-public class ProcessImplementation2 extends ProcessParentImplementation {
-
- public void processChild() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent1() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParentParent() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent2() {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation3.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation3.java
deleted file mode 100644
index d59adbd..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation3.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.inherited;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class ProcessImplementation3 extends ProcessParentImplementation implements FooService {
-
- public void processChild() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent1() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParentParent() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent2() {
- // TODO Auto-generated method stub
-
- }
-
- public boolean foo() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Properties fooProps() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean getBoolean() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public double getDouble() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getInt() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public long getLong() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Boolean getObject() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
deleted file mode 100644
index d6066de..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessImplementation4.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.inherited;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class ProcessImplementation4 extends ProcessImplementation2 implements FooService {
-
- public void processChild() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent1() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParentParent() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent2() {
- // TODO Auto-generated method stub
-
- }
-
- public boolean foo() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Properties fooProps() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean getBoolean() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public double getDouble() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getInt() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public long getLong() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Boolean getObject() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessParentImplementation.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessParentImplementation.java
deleted file mode 100644
index 4872be4..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/inherited/ProcessParentImplementation.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.inherited;
-
-import org.apache.felix.ipojo.test.scenarios.ps.service.ChildInterface;
-
-public class ProcessParentImplementation implements ChildInterface {
-
- public void processChild() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent1() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParentParent() {
- // TODO Auto-generated method stub
-
- }
-
- public void processParent2() {
- // TODO Auto-generated method stub
-
- }
-
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/CallbacksTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/CallbacksTest.java
deleted file mode 100644
index d5ef6b9..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/CallbacksTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class CallbacksTest extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testWithPostRegistrationOnly() {
- ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-reg-only");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- Integer reg = (Integer) check.getProps().get("registered");
- Integer unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(0), unreg);
-
- ci.stop();
-
- reg = (Integer) check.getProps().get("registered");
- unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(0), unreg);
- }
-
- public void testWithBoth() {
- ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- Integer reg = (Integer) check.getProps().get("registered");
- Integer unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(0), unreg);
-
- ci.stop();
-
- reg = (Integer) check.getProps().get("registered");
- unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(1), unreg);
- }
-
- public void testWithPostUnregistrationOnly() {
- ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-unreg-only");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- Integer reg = (Integer) check.getProps().get("registered");
- Integer unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(0), reg);
- assertEquals(new Integer(0), unreg);
-
- ci.stop();
-
- reg = (Integer) check.getProps().get("registered");
- unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(0), reg);
- assertEquals(new Integer(1), unreg);
- }
-
- public void testWithTwoPairsOfCallbacks() {
- ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both-2");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- Integer reg = (Integer) check.getProps().get("registered");
- Integer unreg = (Integer) check.getProps().get("unregistered");
- Integer reg2 = (Integer) check.getProps().get("registered2");
- Integer unreg2 = (Integer) check.getProps().get("unregistered2");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertNotNull(reg2);
- assertNotNull(unreg2);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(0), unreg);
- assertEquals(new Integer(1), reg2);
- assertEquals(new Integer(0), unreg2);
-
- ci.stop();
-
- reg = (Integer) check.getProps().get("registered");
- unreg = (Integer) check.getProps().get("unregistered");
- reg2 = (Integer) check.getProps().get("registered2");
- unreg2 = (Integer) check.getProps().get("unregistered2");
- assertNotNull(reg2);
- assertNotNull(unreg2);
- assertEquals(new Integer(1), reg);
- assertEquals(new Integer(1), unreg);
- assertEquals(new Integer(1), reg2);
- assertEquals(new Integer(1), unreg2);
- }
-
- public void testWithOnePairForTwoService() {
- ComponentInstance ci = helper.createComponentInstance("PS-Callbacks-both-1");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- Integer reg = (Integer) check.getProps().get("registered");
- Integer unreg = (Integer) check.getProps().get("unregistered");
- assertNotNull(reg);
- assertNotNull(unreg);
- assertEquals(new Integer(2), reg);
- assertEquals(new Integer(0), unreg);
-
- ci.stop();
-
- reg = (Integer) check.getProps().get("registered");
- unreg = (Integer) check.getProps().get("unregistered");
- assertEquals(new Integer(2), reg);
- assertEquals(new Integer(2), unreg);
- }
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
deleted file mode 100644
index de241b9..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ClassTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class ClassTest extends OSGiTestCase {
-
- private Factory pi4, pi5, pi6, pi7;
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- pi4 = helper.getFactory("PS-PI4");
- pi5 = helper.getFactory("PS-PI5");
- pi6 = helper.getFactory("PS-PI6");
- pi7 = helper.getFactory("PS-PI7");
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
-
- public void testIP4() {
- helper.createComponentInstance( pi4.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation", "ci");
- assertNotNull("Check itself", ref1);
-
- ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
-
- itself.processChild();
- }
-
- public void testIP5() {
- helper.createComponentInstance( pi5.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation", "ci");
- assertNotNull("Check parent", ref1);
-
- ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
-
- itself.processChild();
-
- }
-
- public void testIP6() {
- helper.createComponentInstance( pi6.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation", "ci");
- assertNotNull("Check parent-parent", ref1);
-
- ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
-
- itself.processChild();
- }
-
- public void testIP7() {
- helper.createComponentInstance( pi7.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName("org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation", "ci");
- assertNotNull("Check parent-parent", ref1);
-
- ProcessParentImplementation itself = (ProcessParentImplementation) getServiceObject(ref1);
-
- itself.processChild();
-
- ServiceReference ref5 = helper.getServiceReferenceByName( FooService.class.getName(), "ci");
- assertNotNull("Check FS", ref5);
- }
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java
deleted file mode 100644
index fd351b9..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class DynamicProps extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- String type = "PS-FooProviderType-Dyn";
- helper.createComponentInstance(type, "FooProvider-1");
-
- Properties p2 = new Properties();
- p2.put("instance.name","FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("boolean", new Boolean(false));
- p2.put("string", new String("bar"));
- p2.put("strAProp", new String[] {"bar", "foo"});
- p2.put("intAProp", new int[] {1, 2, 3});
- helper.createComponentInstance(type, p2);
-
- String type2 = "PS-FooProviderType-Dyn2";
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", new Integer(0));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String(""));
- p3.put("strAProp", new String[0]);
- p3.put("intAProp", new int[0]);
- helper.createComponentInstance(type2, p3);
-
- Properties p4 = new Properties();
- p4.put("instance.name","FooProvider-4");
- helper.createComponentInstance(type2, p4);
-
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testProperties1() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity (1)", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1)"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1)"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (2)", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity (2)", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
- }
- assertNotNull("Check intAProp not nullity (2)", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2)"); }
- }
-
- fs = null;
- }
-
- public void testProperties2() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-2");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", boolProp, new Boolean(false));
- assertEquals("Check strProp equality", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"bar", "foo"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(3));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fs = null;
- }
-
- public void testProperties3() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String(""));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[0];
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[0];
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- fs = null;
- }
-
- public void testProperties4() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Object boolProp = sr.getProperty("boolean");
- Object strProp = sr.getProperty("string");
- Object strAProp = sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4)); // Set by the component type.
- assertEquals("Check boolProp equality", boolProp, null);
- assertEquals("Check strProp equality", strProp, null);
- assertNull("Check strAProp nullity", strAProp);
- assertNotNull("Check intAProp not nullity", intAProp); // Set by the component type.
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < ((String[]) strAProp).length; i++) {
- if(! ((String[]) strAProp)[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- fs = null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java
deleted file mode 100644
index 680d4d2..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class DynamicPropsReconfiguration extends OSGiTestCase {
- ComponentInstance fooProvider3, fooProvider4;
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- String type2 = "PS-FooProviderType-Dyn2";
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", new Integer(0));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String(""));
- p3.put("strAProp", new String[0]);
- p3.put("intAProp", new int[0]);
- fooProvider3 = helper.createComponentInstance(type2, p3);
-
- fooProvider4 = helper.createComponentInstance(type2, "FooProvider-4");
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testFactoryReconf() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String(""));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[0];
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[0];
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- Factory fact = (Factory) getServiceObject(fact_ref);
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- // Reconfiguration
- fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- fact = (Factory) getServiceObject(fact_ref);
- p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- fs = null;
- }
-
- public void testFactoryReconfString() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String(""));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[0];
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[0];
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- Factory fact = (Factory) getServiceObject(fact_ref);
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", "1");
- p3.put("boolean", "true");
- p3.put("string", "foo");
- p3.put("strAProp", "{foo, bar, baz}");
- p3.put("intAProp", "{1, 2, 3}");
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- // Reconfiguration
- fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- fact = (Factory) getServiceObject(fact_ref);
- p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", "1");
- p3.put("boolean", "true");
- p3.put("string", "foo");
- p3.put("strAProp", "{foo, bar, baz}");
- p3.put("intAProp", "{ 1, 2, 3}");
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- fs = null;
- }
-
- public void testMSFReconf() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String(""));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[0];
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[0];
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
- ManagedServiceFactory fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- Properties p3 = new Properties();
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.updated("FooProvider-3", p3);
- } catch (ConfigurationException e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- // Reconfiguration
- fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
- fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- p3 = new Properties();
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.updated("FooProvider-3", p3);
- } catch (ConfigurationException e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- fs = null;
- }
-
- public void testMSFReconfString() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String(""));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[0];
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[0];
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
- ManagedServiceFactory fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- Properties p3 = new Properties();
- p3.put("int", "1");
- p3.put("boolean", "true");
- p3.put("string", "foo");
- p3.put("strAProp", "{foo, bar, baz}");
- p3.put("intAProp", "{ 1, 2, 3}");
- try {
- fact.updated("FooProvider-3", p3);
- } catch (ConfigurationException e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- // Reconfiguration
- fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
- fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- p3 = new Properties();
- p3.put("int", "1");
- p3.put("boolean", "true");
- p3.put("string", "foo");
- p3.put("strAProp", "{foo, bar, baz}");
- p3.put("intAProp", "{ 1, 2, 3}");
- try {
- fact.updated("FooProvider-3", p3);
- } catch (ConfigurationException e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- fs = null;
- }
-
- public void testFactoryReconfNoValue() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Object boolProp = sr.getProperty("boolean");
- Object strProp = sr.getProperty("string");
- Object strAProp = sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", boolProp, null);
- assertEquals("Check strProp equality", strProp, null);
- assertNull("Check strAProp nullity", strAProp);
-
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- Factory fact = (Factory) getServiceObject(fact_ref);
- Properties p3 = new Properties();
- p3.put("instance.name","FooProvider-4");
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < ((String[]) strAProp).length; i++) {
- if(! ((String[])strAProp)[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar"};
- for (int i = 0; i < ((String[]) strAProp).length; i++) {
- if(!((String[]) strAProp)[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNull("Check intAProp hidding (no value)", intAProp);
-
- // Reconfiguration
- fact_ref = helper.getServiceReferenceByName(Factory.class.getName() , "PS-FooProviderType-Dyn2");
- fact = (Factory) getServiceObject(fact_ref);
- p3 = new Properties();
- p3.put("instance.name","FooProvider-3");
- p3.put("int", new Integer(1));
- p3.put("boolean", new Boolean(true));
- p3.put("string", new String("foo"));
- p3.put("strAProp", new String[] {"foo", "bar", "baz"});
- p3.put("intAProp", new int[] { 1, 2, 3});
- try {
- fact.reconfigure(p3);
- } catch(Exception e) {
- fail("Unable to reconfigure the instance with : " + p3);
- }
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(1));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < ((String[])strAProp).length; i++) {
- if(!((String[]) strAProp)[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] { 1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- fs = null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java
deleted file mode 100644
index d888e61..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class Exposition extends OSGiTestCase {
-
- private ComponentInstance fooProviderSimple;
- private ComponentInstance fooProviderItf;
- private ComponentInstance fooBarProvider;
- private ComponentInstance fooBarProvider2;
- private ComponentInstance fooBarProvider3;
-
- private IPOJOHelper helper;
-
- public void setUp(){
- helper = new IPOJOHelper(this);
- fooProviderSimple = helper.createComponentInstance("PS-FooProviderType-1", "fooProviderSimple");
-
- fooProviderItf = helper.createComponentInstance("PS-FooProviderType-itf", "fooProviderItf");
-
- fooBarProvider = helper.createComponentInstance("PS-FooBarProviderType-1", "fooProviderItfs");
-
- fooBarProvider2 = helper.createComponentInstance("PS-FooBarProviderType-2", "fooProviderItfs2");
-
- fooBarProvider3 = helper.createComponentInstance("PS-FooBarProviderType-3", "fooProviderItfs3");
-
- assertNotNull("Check the instance creation of fooProviderSimple", fooProviderSimple);
- assertNotNull("Check the instance creation of fooProviderItf", fooProviderItf);
- assertNotNull("Check the instance creation of fooProviderItfs", fooBarProvider);
- assertNotNull("Check the instance creation of fooProviderItfs2", fooBarProvider2);
- assertNotNull("Check the instance creation of fooProviderItfs3", fooBarProvider3);
-
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testSimpleExposition() {
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderSimple.getInstanceName());
- assertNotNull("Check the availability of the FS from "+fooProviderSimple.getInstanceName(), ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check fs invocation", fs.foo());
- fs = null;
- fooProviderSimple.stop();
- ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderSimple.getInstanceName());
- assertNull("Check the absence of the FS from "+fooProviderSimple.getInstanceName(), ref);
-
- }
-
- public void testItfExposition() {
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderItf.getInstanceName());
- assertNotNull("Check the availability of the FS from "+fooProviderItf.getInstanceName(), ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check fs invocation", fs.foo());
- fs = null;
- fooProviderItf.stop();
-
- ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderItf.getInstanceName());
- assertNull("Check the absence of the FS from "+fooProviderItf.getInstanceName(), ref);
- }
-
- public void testItfsExposition() {
- ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider.getInstanceName());
- assertNotNull("Check the availability of the FS from "+fooBarProvider.getInstanceName(), refFoo);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider.getInstanceName());
- assertNotNull("Check the availability of the BS from "+fooBarProvider.getInstanceName(), refBar);
-
- assertSame("Check service reference equality", refFoo, refBar);
-
- FooService fs = (FooService) getServiceObject(refFoo);
- assertTrue("Check fs invocation", fs.foo());
- fs = null;
-
- BarService bs = (BarService) getServiceObject(refBar);
- assertTrue("Check bs invocation", bs.bar());
- bs = null;
-
- fooBarProvider.stop();
-
- refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider.getInstanceName());
- refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider.getInstanceName());
- assertNull("Check the absence of the FS from "+fooBarProvider.getInstanceName(), refFoo);
- assertNull("Check the absence of the BS from "+fooBarProvider.getInstanceName(), refBar);
- }
-
- public void testItfsExposition2() {
- ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider2.getInstanceName());
- assertNotNull("Check the availability of the FS from "+fooBarProvider2.getInstanceName(), refFoo);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider2.getInstanceName());
- assertNotNull("Check the availability of the BS from "+fooBarProvider2.getInstanceName(), refBar);
-
- assertSame("Check service reference equality", refFoo, refBar);
-
- FooService fs = (FooService) getServiceObject(refFoo);
- assertTrue("Check fs invocation", fs.foo());
- fs = null;
-
- BarService bs = (BarService) getServiceObject(refBar);
- assertTrue("Check bs invocation", bs.bar());
- bs = null;
-
- fooBarProvider2.stop();
-
- refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider2.getInstanceName());
- refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider2.getInstanceName());
- assertNull("Check the absence of the FS from "+fooBarProvider.getInstanceName(), refFoo);
- assertNull("Check the absence of the BS from "+fooBarProvider.getInstanceName(), refBar);
- }
-
- public void testItfsExposition3() {
- ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider3.getInstanceName());
- assertNotNull("Check the availability of the FS from "+fooBarProvider3.getInstanceName(), refFoo);
- ServiceReference refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider3.getInstanceName());
- assertNotNull("Check the availability of the BS from "+fooBarProvider3.getInstanceName(), refBar);
-
- assertNotSame("Check service reference inequality", refFoo, refBar);
-
- FooService fs = (FooService) getServiceObject(refFoo);
- assertTrue("Check fs invocation", fs.foo());
- fs = null;
-
- BarService bs = (BarService) getServiceObject(refBar);
- assertTrue("Check bs invocation", bs.bar());
- bs = null;
-
- // Check properties
- String baz1 = (String) refFoo.getProperty("baz");
- String baz2 = (String) refBar.getProperty("baz");
-
- assertEquals("Check Baz Property 1", baz1, "foo");
- assertEquals("Check Baz Property 2", baz2, "bar");
-
- fooBarProvider3.stop();
-
- refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider3.getInstanceName());
- refBar = helper.getServiceReferenceByName(BarService.class.getName(), fooBarProvider3.getInstanceName());
- assertNull("Check the absence of the FS from "+fooBarProvider.getInstanceName(), refFoo);
- assertNull("Check the absence of the BS from "+fooBarProvider.getInstanceName(), refBar);
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java
deleted file mode 100644
index 41777ea..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.ChildInterface;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.ParentInterface1;
-import org.apache.felix.ipojo.test.scenarios.ps.service.ParentInterface2;
-import org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface;
-import org.osgi.framework.ServiceReference;
-
-public class InheritedTest extends OSGiTestCase {
-
- private Factory pi1, pi11, pi12, pi2, pi21, pi3;
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- pi1 = helper.getFactory("PS-PI1");
- pi11 = helper.getFactory("PS-PI1-1");
- pi12 = helper.getFactory("PS-PI1-2");
-
- pi2 = helper.getFactory("PS-PI2");
- pi21 = helper.getFactory("PS-PI2-1");
-
- pi3 = helper.getFactory("PS-PI3");
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- private boolean contains(String[] arr, String txt) {
- for (int i = 0; i < arr.length; i++) {
- if (arr[i].equals(txt)) {
- return true;
- }
- }
- return false;
- }
-
- public void testPI1Factory() {
- String[] specs = pi1.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count", specs.length, 4);
- assertTrue("Check Child", contains(specs, ChildInterface.class.getName()));
- assertTrue("Check Parent1", contains(specs, ParentInterface1.class.getName()));
- assertTrue("Check Parent2", contains(specs, ParentInterface2.class.getName()));
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- }
-
- public void testPI11Factory() {
- String[] specs = pi11.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count", specs.length, 1);
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- }
-
- public void testPI12Factory() {
- String[] specs = pi12.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count", specs.length, 2);
- assertTrue("Check Parent2", contains(specs, ParentInterface2.class.getName()));
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- }
-
- public void testPI2Factory() {
- String[] specs = pi2.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count ("+specs.length+")", specs.length, 4);
- assertTrue("Check Child", contains(specs, ChildInterface.class.getName()));
- assertTrue("Check Parent1", contains(specs, ParentInterface1.class.getName()));
- assertTrue("Check Parent2", contains(specs, ParentInterface2.class.getName()));
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- }
-
- public void testPI21Factory() {
- String[] specs = pi21.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count", specs.length, 1);
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- }
-
- public void testPI3Factory() {
- String[] specs = pi3.getComponentDescription().getprovidedServiceSpecification();
- assertEquals("Check provides count", specs.length, 5);
- assertTrue("Check Child", contains(specs, ChildInterface.class.getName()));
- assertTrue("Check Parent1", contains(specs, ParentInterface1.class.getName()));
- assertTrue("Check Parent2", contains(specs, ParentInterface2.class.getName()));
- assertTrue("Check ParentParent", contains(specs, ParentParentInterface.class.getName()));
- assertTrue("Check FS", contains(specs, FooService.class.getName()));
- }
-
- public void testIP1() {
- ComponentInstance ci = helper.createComponentInstance( pi1.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
- assertNotNull("Check Child", ref1);
-
- ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
- assertNotNull("Check Parent1", ref2);
-
- ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
- assertNotNull("Check Parent2", ref3);
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ci.dispose();
- }
-
- public void testIP11() {
- ComponentInstance ci = helper.createComponentInstance( pi11.getName(), "ci");
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ci.dispose();
- }
-
- public void testIP12() {
- ComponentInstance ci = helper.createComponentInstance( pi12.getName(), "ci");
-
- ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
- assertNotNull("Check Parent2", ref3);
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ci.dispose();
- }
-
- public void testIP2() {
- ComponentInstance ci = helper.createComponentInstance( pi2.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
- assertNotNull("Check Child", ref1);
-
- ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
- assertNotNull("Check Parent1", ref2);
-
- ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
- assertNotNull("Check Parent2", ref3);
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ci.dispose();
- }
-
- public void testIP21() {
- ComponentInstance ci = helper.createComponentInstance( pi21.getName(), "ci");
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ci.dispose();
- }
-
- public void testIP3() {
- ComponentInstance ci = helper.createComponentInstance( pi3.getName(), "ci");
-
- ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
- assertNotNull("Check Child", ref1);
-
- ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
- assertNotNull("Check Parent1", ref2);
-
- ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
- assertNotNull("Check Parent2", ref3);
-
- ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
- assertNotNull("Check PP", ref4);
-
- ServiceReference ref5 = helper.getServiceReferenceByName( FooService.class.getName(), "ci");
- assertNotNull("Check FS", ref5);
-
- ci.dispose();
- }
-
-
-
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/NullCheck.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/NullCheck.java
deleted file mode 100644
index 9466f33..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/NullCheck.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class NullCheck extends OSGiTestCase {
-
- public void testNull() {
- IPOJOHelper helper = new IPOJOHelper(this);
-
- String factName = "PS-Null";
- String compName = "NullCheck";
- ServiceReference ref = null;
-
- // Check that no Foo Service are available
- ref = getServiceReference(FooService.class.getName());
- assertNull("FS already available", ref);
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory(factName);
- assertNotNull("Cannot find the factory FooProvider-1", fact);
-
- // Don't give any configuration so, properties are null.
- helper.createComponentInstance(factName, compName);
-
- // Get a FooService provider
- ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
-
- assertNotNull("FS not available", ref);
-
- // Check service properties
- assertNull(ref.getProperty("prop1"));
- assertNotNull(ref.getProperty("prop2"));
-
- // Test foo invocation
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("FooService invocation failed", fs.foo());
-
- ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
- // Check service properties
- assertNotNull(ref.getProperty("prop1"));
- assertNull(ref.getProperty("prop2"));
-
-
- helper.dispose();
-
-
- // Check that there is no more FooService
- ref = getServiceReference(FooService.class.getName(), null);
-
-
- assertNull("FS available, but component instance stopped", ref);
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/OSGiPropertiesTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/OSGiPropertiesTest.java
deleted file mode 100644
index 4ddbac9..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/OSGiPropertiesTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-public class OSGiPropertiesTest extends OSGiTestCase {
-
- public void testOSGiProperties() {
- IPOJOHelper helper = new IPOJOHelper(this);
-
- String factName = "PS-FooProviderType-1";
- String compName = "FooProvider-1";
- ServiceReference ref = null;
-
- // Check that no Foo Service are available
- ref = getServiceReference(FooService.class.getName());
-
- assertNull("FS already available", ref);
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory(factName);
- assertNotNull("Cannot find the factory FooProvider-1", fact);
-
- Dictionary conf = new Properties();
- conf.put(Constants.SERVICE_DESCRIPTION, "description");
- conf.put(Constants.SERVICE_RANKING, "10");
- conf.put(Constants.SERVICE_VENDOR, "ASF");
- conf.put(Constants.SERVICE_PID, "my.pid");
-
- helper.createComponentInstance(factName, compName, conf);
-
- // Get a FooService provider
- ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
-
- assertNotNull("FS not available", ref);
-
- // Check properties
- assertEquals("description", ref.getProperty(Constants.SERVICE_DESCRIPTION));
- assertEquals(new Integer(10), ref.getProperty(Constants.SERVICE_RANKING));
- assertEquals("ASF", ref.getProperty(Constants.SERVICE_VENDOR));
- assertEquals("my.pid", ref.getProperty(Constants.SERVICE_PID));
-
-
- // Test foo invocation
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("FooService invocation failed", fs.foo());
-
- helper.dispose();
-
-
- // Check that there is no more FooService
- ref = getServiceReference(FooService.class.getName(), null);
-
-
- assertNull("FS available, but component instance stopped", ref);
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java
deleted file mode 100644
index d40599e..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class PropertiesInAnonymousClassTest extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- String type = "PS-FooProviderTypeAnonymous-Dyn";
- helper.createComponentInstance(type, "FooProviderAno-1");
-
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testRunnable() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity (1)", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1)"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1)"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.foo());
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (2)", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity (2)", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
- }
- assertNotNull("Check intAProp not nullity (2)", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2)"); }
- }
-
- fs = null;
- }
-
- public void testSwingWorker() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Boolean boolProp = (Boolean) sr.getProperty("boolean");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity (1)", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1)"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1)"); }
- }
-
- // Invoke
- FooService fs = (FooService) getServiceObject(sr);
- assertTrue("invoke fs", fs.getBoolean());
-
- sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
- // Re-check the property (change)
- intProp = (Integer) sr.getProperty("int");
- boolProp = (Boolean) sr.getProperty("boolean");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality (2)", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
- assertNotNull("Check strAProp not nullity (2)", strAProp);
- v = new String[] {"foo", "bar", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
- }
- assertNotNull("Check intAProp not nullity (2)", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2)"); }
- }
-
- fs = null;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java
deleted file mode 100644
index 6476b1f..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class ProvidedServiceArchitectureTest extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testExposition() {
- String factName = "PS-FooProviderType-1";
- String compName = "FooProvider-1";
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory( factName);
- assertNotNull("Cannot find the factory FooProvider-1", fact);
-
- helper.createComponentInstance(factName, compName);
-
- ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
- assertNotNull("Architecture not available", arch_ref);
-
- Architecture arch = (Architecture) getServiceObject(arch_ref);
- InstanceDescription id = arch.getInstanceDescription();
-
- assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
- assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- HandlerDescription[] handlers = id.getHandlers();
- assertEquals("Number of handlers", handlers.length, 2);
-
- //Look for the ProvidedService Handler
- ProvidedServiceHandlerDescription pshd = null;
- pshd = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
-
-// for(int i = 0; i < handlers.length; i++) {
-// if(handlers[i].getHandlerName().equals("org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler")) {
-// pshd = (ProvidedServiceHandlerDescription) handlers[i];
-// }
-// }
-//
- assertNotNull("Check ProvidedServiceHandlerDescription", pshd);
- ProvidedServiceDescription[] ps = pshd.getProvidedServices();
-
- assertEquals("Check ProvidedService number", ps.length, 1);
- assertEquals("Check Provided Service Specs - 1", ps[0].getServiceSpecifications().length, 1);
- assertEquals("Check Provided Service Specs - 2", ps[0].getServiceSpecifications()[0], FooService.class.getName());
- assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
- Properties prop = ps[0].getProperties();
- assertNotNull("Check Props", prop);
- assertEquals("Check service properties number", prop.size(), 2);
- assertEquals("Check instance.name property", prop.getProperty("instance.name"), compName);
- assertEquals("Check factory.name property", prop.getProperty("factory.name"), factName);
- }
-
- public void testProps() {
- String factName = "PS-FooProviderType-3";
- String compName = "FooProvider";
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory( factName);
- assertNotNull("Cannot find the factory FooProvider", fact);
-
- Properties props = new Properties();
- props.put("instance.name",compName);
- props.put("foo", "foo");
- props.put("bar", "2");
- props.put("baz", "baz");
- helper.createComponentInstance(factName, props);
-
- ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
- assertNotNull("Architecture not available", arch_ref);
-
- Architecture arch = (Architecture) getServiceObject(arch_ref);
- InstanceDescription id = arch.getInstanceDescription();
-
- assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
- assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- HandlerDescription[] handlers = id.getHandlers();
- assertEquals("Number of handlers", handlers.length, 3);
-
- //Look for the ProvidedService Handler
- ProvidedServiceHandlerDescription pshd = null;
- pshd = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
-
-
- assertNotNull("Check ProvidedServiceHandlerDescription", pshd);
- ProvidedServiceDescription[] ps = pshd.getProvidedServices();
-
- assertEquals("Check ProvidedService number", ps.length, 1);
- assertEquals("Check Provided Service Specs - 1", ps[0].getServiceSpecifications().length, 1);
- assertEquals("Check Provided Service Specs - 2", ps[0].getServiceSpecifications()[0], FooService.class.getName());
- assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
-
- Properties prop = ps[0].getProperties();
- assertNotNull("Check Props", prop);
- assertEquals("Check service properties number (#" + prop + "?=5)" , prop.size(), 5);
- assertEquals("Check instance.name property", prop.getProperty("instance.name"), compName);
- assertEquals("Check factory.name property", prop.getProperty("factory.name"), factName);
- assertEquals("Check foo property", prop.get("foo"), "foo");
- assertEquals("Check bar property", prop.get("bar"), new Integer(2));
- assertEquals("Check baz property", prop.get("baz"), "baz");
-
- }
-
- public void testDoubleProviding() {
- String factName = "PS-FooBarProviderType-1";
- String compName = "FooProvider";
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory( factName);
- assertNotNull("Cannot find the factory FooProvider", fact);
-
- helper.createComponentInstance(factName, compName);
-
- ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
- assertNotNull("Architecture not available", arch_ref);
-
- Architecture arch = (Architecture) getServiceObject(arch_ref);
- InstanceDescription id = arch.getInstanceDescription();
-
- assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
- assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1");
-
- HandlerDescription[] handlers = id.getHandlers();
- assertEquals("Number of handlers", handlers.length, 2);
-
- //Look for the ProvidedService Handler
- ProvidedServiceHandlerDescription pshd = null;
- pshd = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
-
-// for(int i = 0; i < handlers.length; i++) {
-// if(handlers[i].getHandlerName().equals("org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler")) {
-// pshd = (ProvidedServiceHandlerDescription) handlers[i];
-// }
-// }
-
- assertNotNull("Check ProvidedServiceHandlerDescription", pshd);
- ProvidedServiceDescription[] ps = pshd.getProvidedServices();
-
- assertEquals("Check ProvidedService number", ps.length, 1);
- assertEquals("Check Provided Service Specs - 1", ps[0].getServiceSpecifications().length, 2);
- assertContains("Check provided service specs - 2", ps[0].getServiceSpecifications(), FooService.class.getName());;
- assertContains("Check provided service specs - 2", ps[0].getServiceSpecifications(), BarService.class.getName());
- assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
-
- }
-
- public void testPropsNoValue() {
- String factName = "PS-FooProviderType-3";
- String compName = "FooProvider";
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory( factName);
- assertNotNull("Cannot find the factory FooProvider", fact);
-
- helper.createComponentInstance(factName, compName);
-
- ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
- assertNotNull("Architecture not available", arch_ref);
-
- Architecture arch = (Architecture) getServiceObject(arch_ref);
- InstanceDescription id = arch.getInstanceDescription();
-
- assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
- assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.test.scenarios.component.FooProviderType1");
-
- HandlerDescription[] handlers = id.getHandlers();
- assertEquals("Number of handlers", handlers.length, 3);
-
- //Look for the ProvidedService Handler
- ProvidedServiceHandlerDescription pshd = null;
- pshd = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
-
-// for(int i = 0; i < handlers.length; i++) {
-// if(handlers[i].getHandlerName().equals("org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler")) {
-// pshd = (ProvidedServiceHandlerDescription) handlers[i];
-// }
-// }
-
- assertNotNull("Check ProvidedServiceHandlerDescription", pshd);
- ProvidedServiceDescription[] ps = pshd.getProvidedServices();
-
- assertEquals("Check ProvidedService number", ps.length, 1);
- assertEquals("Check Provided Service Specs - 1", ps[0].getServiceSpecifications().length, 1);
- assertEquals("Check Provided Service Specs - 2", ps[0].getServiceSpecifications()[0], FooService.class.getName());
- assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
-
- Properties prop = ps[0].getProperties();
- assertNotNull("Check Props", prop);
- assertEquals("Check service properties number (#" + prop + "?=5)" , prop.size(), 2);
- assertEquals("Check instance.name property", prop.getProperty("instance.name"), compName);
- assertEquals("Check factory.name property", prop.getProperty("factory.name"), factName);
-
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
deleted file mode 100644
index 5ba666d..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ProvidedServiceTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Provided Service Test Suite", bc);
- ots.addTestSuite(Exposition.class);
- ots.addTestSuite(SimplePS.class);
- ots.addTestSuite(StaticProps.class);
- ots.addTestSuite(DynamicProps.class);
- ots.addTestSuite(StaticPropsReconfiguration.class);
- ots.addTestSuite(DynamicPropsReconfiguration.class);
- ots.addTestSuite(InheritedTest.class);
- ots.addTestSuite(ProvidedServiceArchitectureTest.class);
- ots.addTestSuite(ClassTest.class);
- ots.addTestSuite(OSGiPropertiesTest.class);
- ots.addTestSuite(NullCheck.class);
- ots.addTestSuite(ServiceControllerTest.class);
- ots.addTestSuite(PropertiesInAnonymousClassTest.class);
- ots.addTestSuite(CallbacksTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java
deleted file mode 100644
index 4261d3e..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-
-public class ServiceControllerTest extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
-
- public void tearDown() {
- helper.dispose();
- }
-
-
- public void testComponentWithAController() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-default");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- assertFalse(check.check());
-
- // FooService should not be there anymore
- assertNull(getServiceReference(FooService.class.getName()));
-
- assertTrue(check.check());
-
- assertNotNull(getServiceReference(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithAControllerSetToFalse() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-false");
- // Controller set to false.
- waitForService(CheckService.class.getName(), null, 5000);
- assertNull(getServiceReference(FooService.class.getName()));
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- assertTrue(check.check());
- assertNotNull(getServiceReference(FooService.class.getName()));
-
- assertFalse(check.check());
- // FooService should not be there anymore
- assertNull(getServiceReference(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersSetToTrue() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-truetrue");
-
- waitForService(CheckService.class.getName(), null, 5000);
- waitForService(FooService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.check();
-
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNotNull(getServiceReference(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.foo();
-
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNull(getServiceReference(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersSetToTrueAndFalse() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-truefalse");
-
- waitForService(CheckService.class.getName(), null, 5000);
-
- assertFalse(isServiceAvailable(FooService.class.getName()));
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.getProps();
-
- assertFalse(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.fooProps();
-
- assertTrue(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersUsingBothSpecificationsTrueFalse() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-spec1");
-
- waitForService(CheckService.class.getName(), null, 5000);
-
- assertFalse(isServiceAvailable(FooService.class.getName()));
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.getProps();
-
- assertFalse(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.fooProps();
-
- assertTrue(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersUsingBothSpecificationsTrueTrue() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-spec2");
-
- waitForService(CheckService.class.getName(), null, 5000);
- waitForService(FooService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.check();
- // CheckService not available
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNotNull(getServiceReference(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.foo();
-
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNull(getServiceReference(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersUsingSpecificationAndAllTrueTrue() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-spec3");
-
- waitForService(CheckService.class.getName(), null, 5000);
- waitForService(FooService.class.getName(), null, 5000);
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.check();
- // CheckService not available
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNotNull(getServiceReference(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.foo();
-
- assertNull(getServiceReference(CheckService.class.getName()));
- assertNull(getServiceReference(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testComponentWithTwoControllersUsingSpecificationAndAllTrueFalse() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-spec4");
-
- waitForService(CheckService.class.getName(), null, 5000);
-
- assertFalse(isServiceAvailable(FooService.class.getName()));
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- check.getProps();
-
- assertFalse(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
- fs.fooProps();
-
- assertTrue(isServiceAvailable(CheckService.class.getName()));
- assertTrue(isServiceAvailable(FooService.class.getName()));
-
- ci.dispose();
- }
-
- public void testArchitecture() {
- ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-default");
- // Controller set to true.
- waitForService(FooService.class.getName(), null, 5000);
- waitForService(CheckService.class.getName(), null, 5000);
-
- ProvidedServiceHandlerDescription pshd = null;
- pshd = (ProvidedServiceHandlerDescription) ci.getInstanceDescription()
- .getHandlerDescription("org.apache.felix.ipojo:provides");
-
- ProvidedServiceDescription ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
- assertEquals("true", ps.getController());
-
- CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
- assertNotNull(check);
-
- assertFalse(check.check());
-
- ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
- assertEquals("false", ps.getController());
-
- assertTrue(check.check());
-
- ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
- assertEquals("true", ps.getController());
-
- }
-
- private ProvidedServiceDescription getPS(String itf, ProvidedServiceDescription[] svc) {
- for (int i = 0; i < svc.length; i++) {
- if (svc[i].getServiceSpecifications()[0].equals(itf)) {
- return svc[i];
- }
- }
-
- fail("Service : " + itf + " not found");
- return null;
- }
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
deleted file mode 100644
index 044fc38..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.SimpleClass;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class SimplePS extends OSGiTestCase {
-
- public void testPS() {
- IPOJOHelper helper = new IPOJOHelper(this);
-
- String factName = "PS-FooProviderType-1";
- String compName = "FooProvider-1";
- ServiceReference ref = null;
-
- // Check that no Foo Service are available
- ref = getServiceReference(FooService.class.getName());
-
- assertNull("FS already available", ref);
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory(factName);
- assertNotNull("Cannot find the factory FooProvider-1", fact);
-
- helper.createComponentInstance(factName, compName);
-
- // Get a FooService provider
- ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
-
- assertNotNull("FS not available", ref);
-
- // Test foo invocation
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("FooService invocation failed", fs.foo());
-
- helper.dispose();
-
-
- // Check that there is no more FooService
- ref = getServiceReference(FooService.class.getName(), null);
-
-
- assertNull("FS available, but component instance stopped", ref);
-
- }
-
- public void testWhenNoInterface() {
- IPOJOHelper helper = new IPOJOHelper(this);
- String factoryName = "org.apache.felix.ipojo.test.scenarios.component.SimpleClass";
- ComponentInstance ci = helper.createComponentInstance(factoryName);
- waitForService(SimpleClass.class.getName(), null, 5000);
- SimpleClass simple = (SimpleClass) getServiceObject(SimpleClass.class.getName(), null);
- assertEquals("Hello", simple.hello());
- ci.dispose();
- }
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticProps.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticProps.java
deleted file mode 100644
index f40bbe6..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticProps.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class StaticProps extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- String type = "PS-FooProviderType-2";
-
- helper.createComponentInstance(type, "FooProvider-1");
-
- Properties p2 = new Properties();
- p2.put("instance.name","FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("long", new Long(42));
- p2.put("string", new String("bar"));
- p2.put("strAProp", new String[] {"bar", "foo"});
- p2.put("intAProp", new int[] {1, 2, 3});
- helper.createComponentInstance(type, p2);
-
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testProperties1() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", longProp, new Long(40));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- }
-
- public void testProperties2() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-2");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", longProp, new Long(42));
- assertEquals("Check strProp equality", strProp, new String("bar"));
-
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"bar", "foo"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
- }
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticPropsReconfiguration.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticPropsReconfiguration.java
deleted file mode 100644
index 8d944d4..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticPropsReconfiguration.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class StaticPropsReconfiguration extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
-
- String type = "PS-FooProviderType-2";
- helper.createComponentInstance(type, "FooProvider-1");
-
- Properties p2 = new Properties();
- p2.put("instance.name","FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("long", new Long(42));
- p2.put("string", new String("bar"));
- p2.put("strAProp", new String[] {"bar", "foo"});
- p2.put("intAProp", new int[] {1, 2, 3});
- helper.createComponentInstance(type, p2);
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testReconfFactory1() {
- ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", longProp, new Long(40));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName(Factory.class.getName(), "PS-FooProviderType-2");
- Dictionary reconf = new Properties();
- reconf.put("instance.name","FooProvider-1");
- reconf.put("int", new Integer(5));
- reconf.put("long", new Long(43));
- reconf.put("string", new String("toto"));
- reconf.put("strAProp", new String[] {"foo", "baz"});
- reconf.put("intAProp", new int[] {3, 2, 1});
- Factory fact = (Factory) getServiceObject(fact_ref);
- try {
- fact.reconfigure(reconf);
- } catch(Exception e) {
- fail("Configuration non acceptable : " + reconf);
- }
-
- sr = helper.getServiceReferenceByName( FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties after the reconfiguration
- intProp = (Integer) sr.getProperty("int");
- longProp = (Long) sr.getProperty("long");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));
- assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));
- assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));
- assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);
- v = new String[] {"foo", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
-
- }
-
- public void testReconfFactory2() {
- ServiceReference sr = helper.getServiceReferenceByName( FooService.class.getName(), "FooProvider-2");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", longProp, new Long(42));
- assertEquals("Check strProp equality", strProp, new String("bar"));
-
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"bar", "foo"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName( Factory.class.getName(), "PS-FooProviderType-2");
- Dictionary reconf = new Properties();
- reconf.put("instance.name","FooProvider-2");
- reconf.put("int", new Integer(5));
- reconf.put("long", new Long(43));
- reconf.put("string", new String("toto"));
- reconf.put("strAProp", new String[] {"foo", "baz"});
- reconf.put("intAProp", new int[] {3, 2, 1});
- Factory fact = (Factory) getServiceObject(fact_ref);
- try {
- fact.reconfigure(reconf);
- } catch(Exception e) {
- fail("Configuration non acceptable : " + reconf);
- }
-
- // Check service properties after the reconfiguration
- intProp = (Integer) sr.getProperty("int");
- longProp = (Long) sr.getProperty("long");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));
- assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));
- assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));
- assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);
- v = new String[] {"foo", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
- fact = null;
- }
-
- public void testMSFFactory1() {
- ServiceReference sr = helper.getServiceReferenceByName( FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(2));
- assertEquals("Check longProp equality", longProp, new Long(40));
- assertEquals("Check strProp equality", strProp, new String("foo"));
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"foo", "bar"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName( ManagedServiceFactory.class.getName(), "PS-FooProviderType-2");
- Dictionary reconf = new Properties();
- reconf.put("int", new Integer(5));
- reconf.put("long", new Long(43));
- reconf.put("string", new String("toto"));
- reconf.put("strAProp", new String[] {"foo", "baz"});
- reconf.put("intAProp", new int[] {3, 2, 1});
- ManagedServiceFactory fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- try {
- fact.updated("FooProvider-1", reconf);
- } catch (ConfigurationException e) {
- fail("Configuration non acceptable : " + reconf);
- }
-
- sr = helper.getServiceReferenceByName( FooService.class.getName(), "FooProvider-1");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties after the reconfiguration
- intProp = (Integer) sr.getProperty("int");
- longProp = (Long) sr.getProperty("long");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));
- assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));
- assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));
- assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);
- v = new String[] {"foo", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
-
- }
-
- public void testReconfMSF2() {
- ServiceReference sr = helper.getServiceReferenceByName( FooService.class.getName(), "FooProvider-2");
- assertNotNull("Check the availability of the FS service", sr);
-
- // Check service properties
- Integer intProp = (Integer) sr.getProperty("int");
- Long longProp = (Long) sr.getProperty("long");
- String strProp = (String) sr.getProperty("string");
- String[] strAProp = (String[]) sr.getProperty("strAProp");
- int[] intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality", intProp, new Integer(4));
- assertEquals("Check longProp equality", longProp, new Long(42));
- assertEquals("Check strProp equality", strProp, new String("bar"));
-
- assertNotNull("Check strAProp not nullity", strAProp);
- String[] v = new String[] {"bar", "foo"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- int[] v2 = new int[] {1, 2, 3};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- // Reconfiguration
- ServiceReference fact_ref = helper.getServiceReferenceByName( ManagedServiceFactory.class.getName(), "PS-FooProviderType-2");
- Dictionary reconf = new Properties();
- reconf.put("int", new Integer(5));
- reconf.put("long", new Long(43));
- reconf.put("string", new String("toto"));
- reconf.put("strAProp", new String[] {"foo", "baz"});
- reconf.put("intAProp", new int[] {3, 2, 1});
- ManagedServiceFactory fact = (ManagedServiceFactory) getServiceObject(fact_ref);
- try {
- fact.updated("FooProvider-2", reconf);
- } catch (ConfigurationException e) {
- fail("Configuration non acceptable : " + reconf);
- }
-
- // Check service properties after the reconfiguration
- intProp = (Integer) sr.getProperty("int");
- longProp = (Long) sr.getProperty("long");
- strProp = (String) sr.getProperty("string");
- strAProp = (String[]) sr.getProperty("strAProp");
- intAProp = (int[]) sr.getProperty("intAProp");
-
- assertEquals("Check intProp equality after reconfiguration", intProp, new Integer(5));
- assertEquals("Check longProp equality after reconfiguration", longProp, new Long(43));
- assertEquals("Check strProp equality after reconfiguration", strProp, new String("toto"));
- assertNotNull("Check strAProp not nullity after reconfiguration", strAProp);
- v = new String[] {"foo", "baz"};
- for (int i = 0; i < strAProp.length; i++) {
- if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
- }
- assertNotNull("Check intAProp not nullity", intAProp);
- v2 = new int[] {3, 2, 1};
- for (int i = 0; i < intAProp.length; i++) {
- if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
- }
-
- fact = null;
- }
-
-
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/BarService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/BarService.java
deleted file mode 100644
index 7ccee67..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/CheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/CheckService.java
deleted file mode 100644
index f500f79..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ChildInterface.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ChildInterface.java
deleted file mode 100644
index b3d8974..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ChildInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-public interface ChildInterface extends ParentInterface1, ParentInterface2 {
-
- public void processChild();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/FooService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/FooService.java
deleted file mode 100644
index 7bf3e25..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface1.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface1.java
deleted file mode 100644
index f032f3e..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-public interface ParentInterface1 extends ParentParentInterface {
-
- public void processParent1();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface2.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface2.java
deleted file mode 100644
index 8369a14..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentInterface2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-public interface ParentInterface2 {
-
- public void processParent2();
-
-}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentParentInterface.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentParentInterface.java
deleted file mode 100644
index d9fa406..0000000
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/service/ParentParentInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.ps.service;
-
-public interface ParentParentInterface {
-
- public void processParentParent();
-
-}
diff --git a/ipojo/tests/handler/eventadmin/pom.xml b/ipojo/tests/handler/eventadmin/pom.xml
deleted file mode 100644
index 908f17d..0000000
--- a/ipojo/tests/handler/eventadmin/pom.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.eah.snapshot}</version>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Event Admin Handler Test Suite</name>
- <artifactId>tests.eventadmin.handler</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>
- <version>${ipojo.eah.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.eventadmin</artifactId>
- <version>1.2.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Private-Package>org.apache.felix.ipojo.test.*
- </Private-Package>
- <Import-Package>org.apache.felix.ipojo.handlers.event, *</Import-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.EahTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
-
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/BadTests.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/BadTests.java
deleted file mode 100644
index bdab8ab..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/BadTests.java
+++ /dev/null
@@ -1,964 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.felix.ipojo.ComponentFactory;
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.apache.felix.ipojo.test.donut.Donut;
-import org.apache.felix.ipojo.test.donut.DonutConsumer;
-import org.apache.felix.ipojo.test.donut.DonutProvider;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.apache.felix.ipojo.test.util.IPojoTestUtils;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Test the good behaviour of the EventAdminHandler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class BadTests extends OSGiTestCase {
-
- /**
- * The utility class instance.
- */
- public EahTestUtils m_utils;
-
- /**
- * The namespace of the Event admin handler.
- */
- private static final String NAMESPACE = "org.apache.felix.ipojo.handlers.event";
-
- /**
- * The available components.
- */
- private Element[] m_components;
-
- /**
- * The description of a component that uses an event publisher.
- */
- private Element m_provider;
-
- /**
- * The event publisher description.
- */
- private Element m_publisher;
-
- /**
- * The name attribute of the event publisher.
- */
- private Attribute m_publisherName;
-
- /**
- * The field attribute of the event publisher.
- */
- private Attribute m_publisherField;
-
- /**
- * The topics attribute of the event publisher.
- */
- private Attribute m_publisherTopics;
-
- /**
- * The data-key attribute of the event publisher.
- */
- private Attribute m_publisherDataKey;
-
- /**
- * The synchronous attribute of the event publisher.
- */
- private Attribute m_publisherSynchronous;
-
- /**
- * The description of a component that uses an event subscriber.
- */
- private Element m_consumer;
-
- /**
- * The event subscriber description.
- */
- private Element m_subscriber;
-
- /**
- * The name attribute of the event subscriber.
- */
- private Attribute m_subscriberName;
-
- /**
- * The callback attribute of the event subscriber.
- */
- private Attribute m_subscriberCallback;
-
- /**
- * The topics attribute of the event subscriber.
- */
- private Attribute m_subscriberTopics;
-
- /**
- * The data-key attribute of the event subscriber.
- */
- private Attribute m_subscriberDataKey;
-
- /**
- * The data-type attribute of the event subscriber.
- */
- private Attribute m_subscriberDataType;
-
- private Element getManipulationForComponent(String compName) {
- for (int i = 0; i < m_components.length; i++) {
- if (m_components[i].containsAttribute("name")
- && m_components[i].getAttribute("name").equals(compName)) {
- return m_components[i].getElements("manipulation")[0];
- }
- }
- return null;
- }
-
- /**
- * Initialization before test cases.
- *
- * Create all the instances
- *
- */
- public void setUp() {
- m_utils = new EahTestUtils(getContext());
- /**
- * Get the list of available components.
- */
- try {
- String header = (String) getContext().getBundle().getHeaders().get(
- "iPOJO-Components");
- m_components = ManifestMetadataParser.parseHeaderMetadata(header)
- .getElements("component");
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- /**
- * Initialize the standard publishing component (based on the
- * asynchronous donut provider).
- */
- m_provider = new Element("component", "");
- m_provider.addAttribute(new Attribute("className",
- "org.apache.felix.ipojo.test.donut.DonutProviderImpl"));
- m_provider.addAttribute(new Attribute("name",
- "standard donut provider for bad tests"));
-
- // The provided service of the publisher
- Element providesDonutProvider = new Element("provides", "");
- providesDonutProvider.addAttribute(new Attribute("interface",
- "org.apache.felix.ipojo.test.donut.DonutProvider"));
- Element providesDonutProviderProperty = new Element("property", "");
- providesDonutProviderProperty
- .addAttribute(new Attribute("name", "name"));
- providesDonutProviderProperty.addAttribute(new Attribute("field",
- "m_name"));
- providesDonutProviderProperty.addAttribute(new Attribute("value",
- "Unknown donut vendor"));
- providesDonutProvider.addElement(providesDonutProviderProperty);
- m_provider.addElement(providesDonutProvider);
-
- // The event publisher, corresponding to the following description :
- // <ev:publisher name="donut-publisher" field="m_publisher"
- // topics="food/donuts" data-key="food" synchronous="false"/>
- m_publisher = new Element("publisher", NAMESPACE);
- m_publisherName = new Attribute("name", "donut-publisher");
- m_publisherField = new Attribute("field", "m_publisher");
- m_publisherTopics = new Attribute("topics", "food/donuts");
- m_publisherDataKey = new Attribute("data-key", "food");
- m_publisherSynchronous = new Attribute("synchronous", "false");
- m_publisher.addAttribute(m_publisherName);
- m_publisher.addAttribute(m_publisherField);
- m_publisher.addAttribute(m_publisherTopics);
- m_publisher.addAttribute(m_publisherDataKey);
- m_publisher.addAttribute(m_publisherSynchronous);
- m_provider.addElement(m_publisher);
-
- m_provider.addElement(getManipulationForComponent("donut-provider"));
-
- /**
- * Initialize the standard subscribing component (based on the donut
- * consumer).
- */
- m_consumer = new Element("component", "");
- m_consumer.addAttribute(new Attribute("className",
- "org.apache.felix.ipojo.test.donut.DonutConsumerImpl"));
- m_consumer.addAttribute(new Attribute("name",
- "standard donut consumer for bad tests"));
-
- // The provided service of the publisher
- Element providesDonutConsumer = new Element("provides", "");
- providesDonutConsumer.addAttribute(new Attribute("interface",
- "org.apache.felix.ipojo.test.donut.DonutConsumer"));
- Element providesDonutConsumerNameProperty = new Element("property", "");
- providesDonutConsumerNameProperty.addAttribute(new Attribute("name",
- "name"));
- providesDonutConsumerNameProperty.addAttribute(new Attribute("field",
- "m_name"));
- providesDonutConsumerNameProperty.addAttribute(new Attribute("value",
- "Unknown donut consumer"));
- providesDonutConsumer.addElement(providesDonutConsumerNameProperty);
- Element providesDonutConsumerSlowProperty = new Element("property", "");
- providesDonutConsumerSlowProperty.addAttribute(new Attribute("name",
- "slow"));
- providesDonutConsumerSlowProperty.addAttribute(new Attribute("field",
- "m_isSlow"));
- providesDonutConsumerSlowProperty.addAttribute(new Attribute("value",
- "false"));
- providesDonutConsumer.addElement(providesDonutConsumerSlowProperty);
- m_consumer.addElement(providesDonutConsumer);
-
- // The event publisher, corresponding to the following description :
- // <ev:subscriber name="donut-subscriber" callback="receiveDonut"
- // topics="food/donuts" data-key="food"
- // data-type="org.apache.felix.ipojo.test.donut.Donut"/>
- m_subscriber = new Element("subscriber", NAMESPACE);
- m_subscriberName = new Attribute("name", "donut-subscriber");
- m_subscriberCallback = new Attribute("callback", "receiveDonut");
- m_subscriberTopics = new Attribute("topics", "food/donuts");
- m_subscriberDataKey = new Attribute("data-key", "food");
- m_subscriberDataType = new Attribute("data-type",
- "org.apache.felix.ipojo.test.donut.Donut");
- m_subscriber.addAttribute(m_subscriberName);
- m_subscriber.addAttribute(m_subscriberCallback);
- m_subscriber.addAttribute(m_subscriberTopics);
- m_subscriber.addAttribute(m_subscriberDataKey);
- m_subscriber.addAttribute(m_subscriberDataType);
- m_consumer.addElement(m_subscriber);
-
- m_consumer.addElement(getManipulationForComponent("donut-consumer"));
- }
-
- /**
- * Test the base configuration is correct to be sure the bad tests will fail
- * because of they are really bad, and not because of an other application
- * error.
- *
- * This test simply create a provider and a consumer instance, send one
- * event and check it is received.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testGoodConfig()
- throws ConfigurationException, UnacceptableConfiguration,
- MissingHandlerException {
- /**
- * Create the provider and the consumer instances.
- */
- Dictionary properties = new Hashtable();
-
- // Provider
- ComponentFactory providerFactory = new ComponentFactory(getContext(),
- m_provider);
- providerFactory.start();
- properties.put("instance.name","Emperor of donuts");
- ComponentInstance providerInstance = providerFactory
- .createComponentInstance(properties);
- ServiceReference providerService = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutProvider.class
- .getName(), providerInstance.getInstanceName());
- DonutProvider provider = (DonutProvider) getContext()
- .getService(providerService);
-
- // The consumer
- properties = new Hashtable();
- ComponentFactory consumerFactory = new ComponentFactory(getContext(),
- m_consumer);
- consumerFactory.start();
- properties.put("instance.name","Homer Simpson");
- properties.put("slow", "false");
- ComponentInstance consumerInstance = consumerFactory
- .createComponentInstance(properties);
- ServiceReference consumerService = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), consumerInstance.getInstanceName());
- DonutConsumer consumer = (DonutConsumer) getContext()
- .getService(consumerService);
-
- /**
- * Test the normal behaviour of the instances.
- */
- consumer.clearDonuts();
- Donut sentDonut = provider.sellDonut();
- Donut receivedDonut = consumer.waitForDonut();
- assertEquals("The received donut must be the same as the sent one.",
- sentDonut, receivedDonut);
-
- /**
- * Destroy component's instances.
- */
- getContext().ungetService(providerService);
- providerInstance.dispose();
- getContext().ungetService(consumerService);
- consumerInstance.dispose();
- providerFactory.stop();
- consumerFactory.stop();
- }
-
- /**
- * Try to create a publisher with no name.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithoutName()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher
- m_publisher.removeAttribute(m_publisherName);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when no name is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.addAttribute(m_publisherName);
- }
- }
-
- /**
- * Try to create a publisher with no field.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithoutField()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher
- m_publisher.removeAttribute(m_publisherField);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when no field is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.addAttribute(m_publisherField);
- }
- }
-
- /**
- * Try to create a publisher with an unexisting field.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithUnexistingField()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher and replace with an
- // unexisting field name
- m_publisher.removeAttribute(m_publisherField);
- Attribute unexistingField = new Attribute("field", "m_unexistingField");
- m_publisher.addAttribute(unexistingField);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when an unexisting field is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.removeAttribute(unexistingField);
- m_publisher.addAttribute(m_publisherField);
- }
- }
-
- /**
- * Try to create a publisher with a bad typed field.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithBadTypedField()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher and replace with an
- // bad typed field name
- m_publisher.removeAttribute(m_publisherField);
- Attribute badTypedField = new Attribute("field", "m_name");
- m_publisher.addAttribute(badTypedField);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when an bad typed field is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.removeAttribute(badTypedField);
- m_publisher.addAttribute(m_publisherField);
- }
- }
-
- /**
- * Try to create a publisher instance without topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithoutTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the publisher
- m_publisher.removeAttribute(m_publisherTopics);
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- fact.start();
-
- // Try to create an instance without specified topics
- Dictionary conf = new Hashtable();
- conf.put("instance.name","provider without topics");
-
- ComponentInstance instance;
- try {
- instance = fact.createComponentInstance(conf);
- // Should not be executed
- instance.dispose();
- fail("The factory must not create instance without specified topics.");
- } catch (ConfigurationException e) {
- // OK
- } finally {
- fact.stop();
- // Restore the original state of the publisher
- m_publisher.addAttribute(m_publisherTopics);
- }
- }
-
- /**
- * Try to create a publisher with malformed topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithMalformedTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the publisher and replace with a
- // malformed one
- m_publisher.removeAttribute(m_publisherTopics);
- Attribute malformedTopics = new Attribute("topics",
- "| |\\| \\/ /-\\ |_ | |)");
- m_publisher.addAttribute(malformedTopics);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when invalid topics are specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.removeAttribute(malformedTopics);
- m_publisher.addAttribute(m_publisherTopics);
- }
- }
-
- /**
- * Try to create a publisher with a pattern topic (ending with '*') instead of a fixed topic.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithPatternTopic()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the publisher and replace with a
- // malformed one
- m_publisher.removeAttribute(m_publisherTopics);
- Attribute malformedTopics = new Attribute("topics",
- "a/pattern/topic/*");
- m_publisher.addAttribute(malformedTopics);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when invalid topics are specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_publisher.removeAttribute(malformedTopics);
- m_publisher.addAttribute(m_publisherTopics);
- }
- }
-
- /**
- * Try to create a publisher with malformed instance topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testPublisherWithMalformedInstanceTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the publisher and replace with a
- // malformed one
- m_publisher.removeAttribute(m_publisherTopics);
- ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
- fact.start();
-
- // Try to create an instance with malformed specified topics
- Dictionary conf = new Hashtable();
- conf.put("instance.name","provider with malformed topics");
- Dictionary topics = new Hashtable();
- topics.put("donut-publisher", "| |\\| \\/ /-\\ |_ | |)");
- conf.put("event.topics", topics);
-
- ComponentInstance instance;
- try {
- instance = fact.createComponentInstance(conf);
- // Should not be executed
- instance.dispose();
- fail("The factory must not create instance with invalid specified topics.");
- } catch (ConfigurationException e) {
- // OK
- } finally {
- fact.stop();
- // Restore the original state of the publisher
- m_publisher.addAttribute(m_publisherTopics);
- }
- }
-
- /**
- * Try to create a subscriber with no name.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithoutName()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher
- m_subscriber.removeAttribute(m_subscriberName);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when no name is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_subscriber.addAttribute(m_subscriberName);
- }
- }
-
- /**
- * Try to create a subscriber with no callback.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithoutCallback()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the name attribute of the publisher
- m_subscriber.removeAttribute(m_subscriberCallback);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when no callback is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the publisher
- m_subscriber.addAttribute(m_subscriberCallback);
- }
- }
-
- /**
- * Try to create a subscriber instance without topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithoutTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the subscriber
- m_subscriber.removeAttribute(m_subscriberTopics);
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- fact.start();
-
- // Try to create an instance without specified topics
- Dictionary conf = new Hashtable();
- conf.put("instance.name","consumer without topics");
- conf.put("slow", "false");
-
- ComponentInstance instance;
- try {
- instance = fact.createComponentInstance(conf);
- // Should not be executed
- instance.dispose();
- fail("The factory must not create instance without specified topics.");
- } catch (ConfigurationException e) {
- // OK
- } finally {
- fact.stop();
- // Restore the original state of the subscriber
- m_subscriber.addAttribute(m_subscriberTopics);
- }
- }
-
- /**
- * Try to create a subscriber with malformed topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithMalformedTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the subscriber and replace with a
- // malformed one
- m_subscriber.removeAttribute(m_subscriberTopics);
- Attribute malformedTopics = new Attribute("topics",
- "| |\\| \\/ /-\\ |_ | |)");
- m_subscriber.addAttribute(malformedTopics);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when invalid topics are specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the subscriber
- m_subscriber.removeAttribute(malformedTopics);
- m_subscriber.addAttribute(m_subscriberTopics);
- }
- }
-
- /**
- * Try to create a subscriber with malformed instance topics.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithMalformedInstanceTopics()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the topics attribute of the subscriber and replace with a
- // malformed one
- m_subscriber.removeAttribute(m_subscriberTopics);
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- fact.start();
-
- // Try to create an instance with malformed specified topics
- Dictionary conf = new Hashtable();
- conf.put("instance.name","consumer with malformed topics");
- Dictionary topics = new Hashtable();
- topics.put("donut-subscriber", "| |\\| \\/ /-\\ |_ | |)");
- conf.put("event.topics", topics);
-
- ComponentInstance instance;
- try {
- instance = fact.createComponentInstance(conf);
- // Should not be executed
- instance.dispose();
- fail("The factory must not create instance with invalid specified topics.");
- } catch (ConfigurationException e) {
- // OK
- } finally {
- fact.stop();
- // Restore the original state of the subscriber
- m_subscriber.addAttribute(m_subscriberTopics);
- }
- }
-
- /**
- * Try to create a subscriber with unknown data type.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithUnknownDataType()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the data-type attribute of the subscriber and replace with a
- // malformed one
- m_subscriber.removeAttribute(m_subscriberDataType);
- Attribute unknownType = new Attribute("data-type", "org.unknown.Clazz");
- m_subscriber.addAttribute(unknownType);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when unknown data type is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the subscriber
- m_subscriber.removeAttribute(unknownType);
- m_subscriber.addAttribute(m_subscriberDataType);
- }
- }
-
- /**
- * Try to create a subscriber with a data type that does not match with the
- * callback parameter type.
- *
- * @throws ConfigurationException
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws UnacceptableConfiguration
- * something bad happened
- */
- public void testSubscriberWithUnappropriatedDataType()
- throws ConfigurationException, MissingHandlerException,
- UnacceptableConfiguration {
-
- // Remove the data-type attribute of the subscriber and replace with a
- // malformed one
- m_subscriber.removeAttribute(m_subscriberDataType);
- Attribute unknownType = new Attribute("data-type", "java.lang.String");
- m_subscriber.addAttribute(unknownType);
-
- // Create and try to start the factory
- ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
- try {
- fact.start();
- // Should not be executed
- fact.stop();
- fail("The factory must not start when unappropriated data type is specified.");
- } catch (IllegalStateException e) {
- // OK
- } finally {
- // Restore the original state of the subscriber
- m_subscriber.removeAttribute(unknownType);
- m_subscriber.addAttribute(m_subscriberDataType);
- }
- }
-
- /**
- * Finalization after test cases.
- *
- * Release all services references and destroy instances.
- */
- public void tearDown() {
-
- }
-
- // DEBUG
- public void dumpElement(String message, Element root) {
- System.err.println(message + "\n" + dumpElement(0, root));
- }
-
- // DEBUG
- private String dumpElement(int level, Element element) {
- StringBuilder sb = new StringBuilder();
- // Enter tag
- for (int i = 0; i < level; i++) {
- sb.append(" ");
- }
- sb.append('<');
- sb.append(element.getName());
- Attribute[] attributes = element.getAttributes();
- for (int i = 0; i < attributes.length; i++) {
- Attribute attribute = attributes[i];
- sb.append(' ');
- sb.append(attribute.getName());
- sb.append('=');
- sb.append(attribute.getValue());
- }
- sb.append(">\n");
- // Children
- Element[] elements = element.getElements();
- for (int i = 0; i < elements.length; i++) {
- sb.append(dumpElement(level + 1, elements[i]));
- }
- // Exit tag
- for (int i = 0; i < level; i++) {
- sb.append(" ");
- }
- sb.append("</" + element.getName() + ">\n");
- return sb.toString();
- }
-
- /**
- * Creates a subscriber listening on a pattern topic (ending with '*').
- * @throws ConfigurationException something bad happened.
- * @throws MissingHandlerException something bad happened.
- * @throws UnacceptableConfiguration something bad happened.
- */
- public void testSubscriberWithPatternTopic() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Dictionary properties = new Hashtable();
- Dictionary topics = new Hashtable();
-
- // Create the donut consumer instance, listening on a pattern topic
- properties.put("instance.name","subscriber with pattern topic");
- topics.put("donut-subscriber", "a/pattern/topic/*rf");
- properties.put("event.topics", topics);
- ComponentInstance instance = null;
- try {
- instance = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
-
- // Should not been executed
- instance.dispose();
- fail("An invalid topic scope was accepted)");
-
- } catch (ConfigurationException e) {
- // Nothing to do
- }
-
- properties = new Hashtable();
- topics = new Hashtable();
-
- // Create the donut consumer instance, listening on a pattern topic
- properties.put("instance.name","subscriber with pattern topic");
- topics.put("donut-subscriber", "a/pattern/*topic/rf");
- properties.put("event.topics", topics);
-
- try {
- instance = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
- instance.dispose();
- fail("An invalid topic scope was accepted (2)");
- } catch (ConfigurationException e) {
- // Nothing to do
- }
- }
-
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java
deleted file mode 100644
index 7eddfca..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/EahTestSuite.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-/**
- * Event Admin Handler test suite.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class EahTestSuite {
-
- /**
- * Generate the Event Admin Handler test suite.
- *
- * @param bc
- * the OSGi bundle context
- * @return the Event Admin Handler test suite.
- */
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Event Admin Handler test suite",
- bc);
- ots.addTestSuite(BadTests.class);
- ots.addTestSuite(GoodTests.class);
- ots.addTestSuite(GoodTestsWithNewAttributes.class);
- ots.addTestSuite(PublishesTests.class);
- return ots;
- }
-
-}
\ No newline at end of file
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTests.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTests.java
deleted file mode 100644
index ff949ac..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTests.java
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.donut.Donut;
-import org.apache.felix.ipojo.test.donut.DonutConsumer;
-import org.apache.felix.ipojo.test.donut.DonutProvider;
-import org.apache.felix.ipojo.test.donut.EventTracker;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.apache.felix.ipojo.test.util.IPojoTestUtils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-
-/**
- * Test the good behaviour of the EventAdminHandler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class GoodTests extends OSGiTestCase {
-
- /**
- * The number of providers to test.
- */
- private static final int NUMBER_OF_PROVIDERS = 6;
-
- /**
- * The number of providers using the event admin handler to test.
- */
- private static final int NUMBER_OF_EAH_PROVIDERS = 4;
-
- /**
- * The number of consumers to test.
- */
- private static final int NUMBER_OF_CONSUMERS = 6;
-
- /**
- * The number of synchronous providers to test.
- */
- private static final int NUMBER_OF_SYNCHRONOUS_PROVIDERS = 3;
-
- /**
- * The number of slow consumers to test.
- */
- private static final int NUMBER_OF_QUICK_CONSUMERS = 3;
-
- /**
- * The list of topics to test.
- */
- private static final String[] TOPICS_LIST = { "foo", "bar", "nut",
- "foo,bar", "bar,nut", "foo,nut", "foo,bar,nut" };
-
- /**
- * The utility class instance.
- */
- public EahTestUtils m_utils;
-
- /**
- * The providers' instances.
- */
- private ComponentInstance[] m_providersInstances;
-
- /**
- * The providers' service references.
- */
- private ServiceReference[] m_providersServices;
-
- /**
- * The providers' services.
- */
- private DonutProvider[] m_providers;
-
- /**
- * The synchronous providers' services.
- */
- private DonutProvider[] m_synchronousProviders;
-
- /**
- * The instances of providers that uses the event admin handler.
- */
- private ComponentInstance[] m_eahProvidersInstances;
-
- /**
- * The services of the providers that uses the event admin handler.
- */
- private DonutProvider[] m_eahProviders;
-
- /**
- * The synchronous donut event provider service.
- */
- private DonutProvider m_synchronousDonutEventProvider;
-
- /**
- * The consumers' instances.
- */
- private ComponentInstance[] m_consumersInstances;
-
- /**
- * The consumers' service references.
- */
- private ServiceReference[] m_consumersServices;
-
- /**
- * The consumers' services.
- */
- private DonutConsumer[] m_consumers;
-
- /**
- * The slow consumers' services.
- */
- private DonutConsumer[] m_quickConsumers;
-
- /**
- * The event tracker' instances.
- */
- private ComponentInstance m_eventTrackerInstance;
-
- /**
- * The event tracker' service references.
- */
- private ServiceReference m_eventTrackerService;
-
- /**
- * The event tracker service.
- */
- private EventTracker m_eventTracker;
-
- /**
- * The filtered consumers' instances.
- */
- private ComponentInstance[] m_filteredConsumersInstances;
-
- /**
- * The filtered consumers' service references.
- */
- private ServiceReference[] m_filteredConsumersServices;
-
- /**
- * The filtered consumers' services.
- */
- private DonutConsumer[] m_filteredConsumers;
-
- /**
- * The providers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsProvidersInstances;
-
- /**
- * The providers' service references with specified topics.
- */
- private ServiceReference[] m_topicsProvidersServices;
-
- /**
- * The providers' service with specified topics.
- */
- private DonutProvider[] m_topicsProviders;
-
- /**
- * The provider that send donuts on the "foo" topic.
- */
- private DonutProvider m_fooProvider;
-
- /**
- * The provider that send donuts on the "bar" topic.
- */
- private DonutProvider m_barProvider;
-
- /**
- * The provider that send donuts on the "nut" topic.
- */
- private DonutProvider m_nutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar" topics.
- */
- private DonutProvider m_fooBarProvider;
-
- /**
- * The provider that send donuts on the "bar,nut" topics.
- */
- private DonutProvider m_barNutProvider;
-
- /**
- * The provider that send donuts on the "foo,nut" topics.
- */
- private DonutProvider m_fooNutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar,nut" topics.
- */
- private DonutProvider m_fooBarNutProvider;
-
- /**
- * The consumers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsConsumersInstances;
-
- /**
- * The consumers' service references with specified topics.
- */
- private ServiceReference[] m_topicsConsumersServices;
-
- /**
- * The consumers' service references with specified topics.
- */
- private DonutConsumer[] m_topicsConsumers;
-
- /**
- * The consumer that receive donuts on the "foo" topic.
- */
- private DonutConsumer m_fooConsumer;
-
- /**
- * The consumer that receive donuts on the "bar" topic.
- */
- private DonutConsumer m_barConsumer;
-
- /**
- * The consumer that receive donuts on the "nut" topic.
- */
- private DonutConsumer m_nutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar" topics.
- */
- private DonutConsumer m_fooBarConsumer;
-
- /**
- * The consumer that receive donuts on the "bar,nut" topics.
- */
- private DonutConsumer m_barNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,nut" topics.
- */
- private DonutConsumer m_fooNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar,nut" topics.
- */
- private DonutConsumer m_fooBarNutConsumer;
-
- /**
- * Initialization before test cases.
- *
- * Create all the instances
- *
- * @throws UnacceptableConfiguration
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws ConfigurationException
- * something bad happened
- *
- */
- public void setUp()
- throws UnacceptableConfiguration, MissingHandlerException,
- ConfigurationException {
-
- m_utils = new EahTestUtils(getContext());
- Dictionary properties = new Hashtable();
-
- // All the providers
- m_providersInstances = new ComponentInstance[NUMBER_OF_PROVIDERS];
- m_providersServices = new ServiceReference[NUMBER_OF_PROVIDERS];
- m_providers = new DonutProvider[NUMBER_OF_PROVIDERS];
- m_synchronousProviders = new DonutProvider[NUMBER_OF_SYNCHRONOUS_PROVIDERS];
- m_eahProviders = new DonutProvider[NUMBER_OF_EAH_PROVIDERS];
- m_eahProvidersInstances = new ComponentInstance[NUMBER_OF_EAH_PROVIDERS];
- m_topicsProvidersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsProvidersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsProviders = new DonutProvider[TOPICS_LIST.length];
-
- // Create the (asynchronous) donut provider
- properties.put("instance.name","asynchronous donut provider");
- m_providersInstances[0] = m_utils.getDonutProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut provider");
- m_providersInstances[1] = m_utils.getSynchronousDonutProviderFactory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) donut event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous donut event provider");
- m_providersInstances[2] = m_utils.getDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut event provider");
- m_providersInstances[3] = m_utils
- .getSynchronousDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous event provider");
- m_providersInstances[4] = m_utils.getEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous event provider");
- m_providersInstances[5] = m_utils.getSynchronousEventProviderFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- m_providersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutProvider.class.getName(),
- m_providersInstances[i].getInstanceName());
- m_providers[i] = (DonutProvider) getContext()
- .getService(m_providersServices[i]);
- }
- m_synchronousProviders[0] = m_providers[1];
- m_synchronousProviders[1] = m_providers[3];
- m_synchronousProviders[2] = m_providers[5];
- m_eahProviders[0] = m_providers[0];
- m_eahProviders[1] = m_providers[1];
- m_eahProviders[2] = m_providers[2];
- m_eahProviders[3] = m_providers[3];
- m_eahProvidersInstances[0] = m_providersInstances[0];
- m_eahProvidersInstances[1] = m_providersInstances[1];
- m_eahProvidersInstances[2] = m_providersInstances[2];
- m_eahProvidersInstances[3] = m_providersInstances[3];
- m_synchronousDonutEventProvider = m_providers[3];
-
- // All the consumers
- m_consumersInstances = new ComponentInstance[NUMBER_OF_CONSUMERS];
- m_consumersServices = new ServiceReference[NUMBER_OF_CONSUMERS];
- m_consumers = new DonutConsumer[NUMBER_OF_CONSUMERS];
- m_quickConsumers = new DonutConsumer[NUMBER_OF_QUICK_CONSUMERS];
- m_filteredConsumersInstances = new ComponentInstance[Donut.FLAVOURS.length];
- m_filteredConsumersServices = new ServiceReference[Donut.FLAVOURS.length];
- m_filteredConsumers = new DonutConsumer[Donut.FLAVOURS.length];
- m_topicsConsumersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsConsumersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsConsumers = new DonutConsumer[TOPICS_LIST.length];
-
- // Create the (quick) donut consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut consumer");
- m_consumersInstances[0] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the (quick) donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut event consumer");
- m_consumersInstances[1] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the (quick) event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick event consumer");
- m_consumersInstances[2] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow donut consumer
- properties = new Hashtable();
- properties.put("slow", Boolean.TRUE);
- properties.put("instance.name","slow donut consumer");
- m_consumersInstances[3] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow donut event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[4] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[5] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutConsumer.class.getName(),
- m_consumersInstances[i].getInstanceName());
- m_consumers[i] = (DonutConsumer) getContext()
- .getService(m_consumersServices[i]);
- }
- m_quickConsumers[0] = m_consumers[0];
- m_quickConsumers[1] = m_consumers[1];
- m_quickConsumers[2] = m_consumers[2];
-
- // Create the event tracker
- properties = new Hashtable();
- properties.put("instance.name","event tracker");
- m_eventTrackerInstance = m_utils.getEventTrackerFactory()
- .createComponentInstance(properties);
- m_eventTrackerService = IPojoTestUtils.getServiceReferenceByName(
- getContext(), EventTracker.class.getName(), m_eventTrackerInstance
- .getInstanceName());
- m_eventTracker = (EventTracker) getContext()
- .getService(m_eventTrackerService);
-
- // Create the filtered consumer
- Dictionary filter = new Hashtable();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- String flavour = Donut.FLAVOURS[i];
- properties = new Hashtable();
- filter.put("donut-event-subscriber", "(flavour=" + flavour + ")");
- properties.put("instance.name",flavour + " donut consumer");
- properties.put("event.filter", filter);
- m_filteredConsumersInstances[i] = m_utils
- .getDonutEventConsumerFactory().createComponentInstance(
- properties);
- m_filteredConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_filteredConsumersInstances[i]
- .getInstanceName());
- m_filteredConsumers[i] = (DonutConsumer) getContext()
- .getService(m_filteredConsumersServices[i]);
- }
-
- // Create the providers and consumers selling and receiving donuts on
- // specific topics
- Dictionary topics = new Hashtable();
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- String topicsString = TOPICS_LIST[i];
- properties = new Hashtable();
- // Create provider
- topics.put("donut-publisher", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut provider");
- m_topicsProvidersInstances[i] = m_utils
- .getSynchronousDonutProviderFactory()
- .createComponentInstance(properties);
- m_topicsProvidersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutProvider.class
- .getName(), m_topicsProvidersInstances[i]
- .getInstanceName());
- m_topicsProviders[i] = (DonutProvider) getContext()
- .getService(m_topicsProvidersServices[i]);
-
- // Create consumer
- properties = new Hashtable();
- topics.put("donut-subscriber", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut consumer");
-
- m_topicsConsumersInstances[i] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
- m_topicsConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_topicsConsumersInstances[i]
- .getInstanceName());
- m_topicsConsumers[i] = (DonutConsumer) getContext()
- .getService(m_topicsConsumersServices[i]);
- topics.remove("donut-subscriber");
- }
-
- m_fooProvider = m_topicsProviders[0];
- m_barProvider = m_topicsProviders[1];
- m_nutProvider = m_topicsProviders[2];
- m_fooBarProvider = m_topicsProviders[3];
- m_barNutProvider = m_topicsProviders[4];
- m_fooNutProvider = m_topicsProviders[5];
- m_fooBarNutProvider = m_topicsProviders[6];
- m_fooConsumer = m_topicsConsumers[0];
- m_barConsumer = m_topicsConsumers[1];
- m_nutConsumer = m_topicsConsumers[2];
- m_fooBarConsumer = m_topicsConsumers[3];
- m_barNutConsumer = m_topicsConsumers[4];
- m_fooNutConsumer = m_topicsConsumers[5];
- m_fooBarNutConsumer = m_topicsConsumers[6];
-
- }
-
- /**
- * Creates a subscriber listening on a pattern topic (ending with '*').
- * @throws ConfigurationException something bad happened.
- * @throws MissingHandlerException something bad happened.
- * @throws UnacceptableConfiguration something bad happened.
- */
- public void testSubscriberWithPatternTopic() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Dictionary properties = new Hashtable();
- Dictionary topics = new Hashtable();
-
- // Create the donut consumer instance, listening on a pattern topic
- properties.put("instance.name","subscriber with pattern topic");
- topics.put("donut-subscriber", "a/pattern/topic/*");
- properties.put("event.topics", topics);
-
- ComponentInstance instance = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
- instance.dispose();
- }
-
- /**
- * Test the event handler reliability by sending events with all kinds of
- * publisher and check they are received by all kinds of subscriber.
- */
- public void testReliability() {
-
- // Flush donut list for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumers[i].clearDonuts();
- }
-
- // Send a lot of donut with each provider
- List sentDonuts = new ArrayList(NUMBER_OF_PROVIDERS
- * EahTestUtils.NUMBER_OF_TESTS);
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- sentDonuts.add(m_providers[i].sellDonut());
- }
- }
-
- // Wait a respectable amount of time
- EahTestUtils.sleep(EahTestUtils.BLACK_LIST_TIME
- + EahTestUtils.A_LONG_TIME);
-
- // Collect all received donuts for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- List receivedDonuts = Arrays.asList(m_consumers[i].getAllDonuts());
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts.",
- sentDonuts.size(), receivedDonuts.size());
- assertTrue("The receiver must have eaten all sent donuts.",
- receivedDonuts.containsAll(sentDonuts));
- }
- }
-
- /**
- * Test the synchronism of event sending for the component.
- *
- * This test consists to send synchronously a big amount of donuts and to
- * check immediately if it has been received (by all quick consumers).
- */
- public void testSynchronism() {
-
- // Flush donut list for quick consumers
- for (int i = 0; i < NUMBER_OF_QUICK_CONSUMERS; i++) {
- m_quickConsumers[i].clearDonuts();
- }
-
- // Send a lot of donuts and check they are immediately received.
- Donut sentDonut;
- Donut receivedDonut;
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- for (int j = 0; j < NUMBER_OF_SYNCHRONOUS_PROVIDERS; j++) {
- sentDonut = m_synchronousProviders[j].sellDonut();
- for (int k = 0; k < NUMBER_OF_QUICK_CONSUMERS; k++) {
- receivedDonut = m_quickConsumers[k].getDonut();
- assertEquals(
- "The donut must have been received immediately and be the be the same as the sent one.",
- sentDonut, receivedDonut);
- }
- }
- }
- }
-
- /**
- * Test that the received events contains the instance name of the sender.
- */
- public void testInstanceName() {
-
- // Flush event list of the event tracker
- m_eventTracker.clearEvents();
-
- // Send donuts and check the sender instance name
- Event receivedEvent;
- for (int i = 0; i < NUMBER_OF_EAH_PROVIDERS; i++) {
- m_eahProviders[i].sellDonut();
- receivedEvent = m_eventTracker.waitForEvent();
- assertEquals(
- "The instance name property of the received message must be the same as the sender instance name.",
- m_eahProvidersInstances[i].getInstanceName(), receivedEvent
- .getProperty("publisher.instance.name"));
- }
- }
-
- /**
- * Test the event filtering.
- *
- * This test send donuts with different flavours. Each filtered consumer
- * must receive only a certain kind of donut. Of course, all donuts must
- * have been received too.
- */
- public void testFilters() {
-
- // The sent donuts, sorted by flavour
- List[] sentDonuts = new List[Donut.FLAVOURS.length];
-
- // Flush donut list for each filtered consumer
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- m_filteredConsumers[i].clearDonuts();
- sentDonuts[i] = new ArrayList(EahTestUtils.NUMBER_OF_TESTS
- / Donut.FLAVOURS.length);
- }
-
- // Send donuts
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- Donut donut = m_synchronousDonutEventProvider.sellDonut();
- sentDonuts[EahTestUtils.flavourIndex(donut.getFlavour())]
- .add(donut);
- }
-
- // Check the received donuts
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- Donut[] receivedDonuts = m_filteredConsumers[i].getAllDonuts();
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts with the matching flavour.",
- sentDonuts[i].size(), receivedDonuts.length);
- assertTrue(
- "The receiver must have eaten all sent donuts matching the wanted flavour.",
- Arrays.asList(receivedDonuts).containsAll(sentDonuts[i]));
- }
-
- }
-
- /**
- * Test the event topic.
- *
- * This test send donuts on several topics. Each consumer (who listens to
- * one or several topics) must receive donuts sent on his specifics topics.
- */
- public void testTopics() {
-
- // The sent donuts, sorted by topic
- int foos = 0;
- int bars = 0;
- int nuts = 0;
-
- // Flush consumers
- m_fooConsumer.clearDonuts();
- m_barConsumer.clearDonuts();
- m_nutConsumer.clearDonuts();
- m_fooBarConsumer.clearDonuts();
- m_barNutConsumer.clearDonuts();
- m_fooNutConsumer.clearDonuts();
- m_fooBarNutConsumer.clearDonuts();
-
- // Send donuts
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- m_fooProvider.sellDonut();
- foos++;
-
- m_barProvider.sellDonut();
- bars++;
-
- m_nutProvider.sellDonut();
- nuts++;
-
- m_fooBarProvider.sellDonut();
- foos++;
- bars++;
-
- m_barNutProvider.sellDonut();
- bars++;
- nuts++;
-
- m_fooNutProvider.sellDonut();
- foos++;
- nuts++;
-
- m_fooBarNutProvider.sellDonut();
- foos++;
- bars++;
- nuts++;
- }
-
- // Check received donuts
- assertEquals("The number of received donuts must be correct.", foos,
- m_fooConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars,
- m_barConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", nuts,
- m_nutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars, m_fooBarConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars
- + nuts, m_barNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + nuts, m_fooNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars + nuts, m_fooBarNutConsumer.getAllDonuts().length);
-
- }
-
- /**
- * Finalization after test cases.
- *
- * Release all services references and destroy instances.
- */
- public void tearDown() {
- int index;
- for (index = 0; index < NUMBER_OF_PROVIDERS; index++) {
- getContext().ungetService(m_providersServices[index]);
- m_providersInstances[index].dispose();
- }
- for (index = 0; index < NUMBER_OF_CONSUMERS; index++) {
- getContext().ungetService(m_consumersServices[index]);
- m_consumersInstances[index].dispose();
- }
- getContext().ungetService(m_eventTrackerService);
- m_eventTrackerInstance.dispose();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- getContext().ungetService(m_filteredConsumersServices[i]);
- m_filteredConsumersInstances[i].dispose();
- }
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- getContext().ungetService(m_topicsProvidersServices[i]);
- m_topicsProvidersInstances[i].dispose();
- getContext().ungetService(m_topicsConsumersServices[i]);
- m_topicsConsumersInstances[i].dispose();
- }
-
- }
-
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTestsWithNewAttributes.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTestsWithNewAttributes.java
deleted file mode 100644
index 1cdea8d..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/GoodTestsWithNewAttributes.java
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.donut.Donut;
-import org.apache.felix.ipojo.test.donut.DonutConsumer;
-import org.apache.felix.ipojo.test.donut.DonutProvider;
-import org.apache.felix.ipojo.test.donut.EventTracker;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.apache.felix.ipojo.test.util.IPojoTestUtils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-
-/**
- * Test the good behaviour of the EventAdminHandler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class GoodTestsWithNewAttributes extends OSGiTestCase {
-
- /**
- * The number of providers to test.
- */
- private static final int NUMBER_OF_PROVIDERS = 6;
-
- /**
- * The number of providers using the event admin handler to test.
- */
- private static final int NUMBER_OF_EAH_PROVIDERS = 4;
-
- /**
- * The number of consumers to test.
- */
- private static final int NUMBER_OF_CONSUMERS = 6;
-
- /**
- * The number of synchronous providers to test.
- */
- private static final int NUMBER_OF_SYNCHRONOUS_PROVIDERS = 3;
-
- /**
- * The number of slow consumers to test.
- */
- private static final int NUMBER_OF_QUICK_CONSUMERS = 3;
-
- /**
- * The list of topics to test.
- */
- private static final String[] TOPICS_LIST = { "foo", "bar", "nut",
- "foo,bar", "bar,nut", "foo,nut", "foo,bar,nut" };
-
- /**
- * The utility class instance.
- */
- public EahTestUtils m_utils;
-
- /**
- * The providers' instances.
- */
- private ComponentInstance[] m_providersInstances;
-
- /**
- * The providers' service references.
- */
- private ServiceReference[] m_providersServices;
-
- /**
- * The providers' services.
- */
- private DonutProvider[] m_providers;
-
- /**
- * The synchronous providers' services.
- */
- private DonutProvider[] m_synchronousProviders;
-
- /**
- * The instances of providers that uses the event admin handler.
- */
- private ComponentInstance[] m_eahProvidersInstances;
-
- /**
- * The services of the providers that uses the event admin handler.
- */
- private DonutProvider[] m_eahProviders;
-
- /**
- * The synchronous donut event provider service.
- */
- private DonutProvider m_synchronousDonutEventProvider;
-
- /**
- * The consumers' instances.
- */
- private ComponentInstance[] m_consumersInstances;
-
- /**
- * The consumers' service references.
- */
- private ServiceReference[] m_consumersServices;
-
- /**
- * The consumers' services.
- */
- private DonutConsumer[] m_consumers;
-
- /**
- * The slow consumers' services.
- */
- private DonutConsumer[] m_quickConsumers;
-
- /**
- * The event tracker' instances.
- */
- private ComponentInstance m_eventTrackerInstance;
-
- /**
- * The event tracker' service references.
- */
- private ServiceReference m_eventTrackerService;
-
- /**
- * The event tracker service.
- */
- private EventTracker m_eventTracker;
-
- /**
- * The filtered consumers' instances.
- */
- private ComponentInstance[] m_filteredConsumersInstances;
-
- /**
- * The filtered consumers' service references.
- */
- private ServiceReference[] m_filteredConsumersServices;
-
- /**
- * The filtered consumers' services.
- */
- private DonutConsumer[] m_filteredConsumers;
-
- /**
- * The providers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsProvidersInstances;
-
- /**
- * The providers' service references with specified topics.
- */
- private ServiceReference[] m_topicsProvidersServices;
-
- /**
- * The providers' service with specified topics.
- */
- private DonutProvider[] m_topicsProviders;
-
- /**
- * The provider that send donuts on the "foo" topic.
- */
- private DonutProvider m_fooProvider;
-
- /**
- * The provider that send donuts on the "bar" topic.
- */
- private DonutProvider m_barProvider;
-
- /**
- * The provider that send donuts on the "nut" topic.
- */
- private DonutProvider m_nutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar" topics.
- */
- private DonutProvider m_fooBarProvider;
-
- /**
- * The provider that send donuts on the "bar,nut" topics.
- */
- private DonutProvider m_barNutProvider;
-
- /**
- * The provider that send donuts on the "foo,nut" topics.
- */
- private DonutProvider m_fooNutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar,nut" topics.
- */
- private DonutProvider m_fooBarNutProvider;
-
- /**
- * The consumers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsConsumersInstances;
-
- /**
- * The consumers' service references with specified topics.
- */
- private ServiceReference[] m_topicsConsumersServices;
-
- /**
- * The consumers' service references with specified topics.
- */
- private DonutConsumer[] m_topicsConsumers;
-
- /**
- * The consumer that receive donuts on the "foo" topic.
- */
- private DonutConsumer m_fooConsumer;
-
- /**
- * The consumer that receive donuts on the "bar" topic.
- */
- private DonutConsumer m_barConsumer;
-
- /**
- * The consumer that receive donuts on the "nut" topic.
- */
- private DonutConsumer m_nutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar" topics.
- */
- private DonutConsumer m_fooBarConsumer;
-
- /**
- * The consumer that receive donuts on the "bar,nut" topics.
- */
- private DonutConsumer m_barNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,nut" topics.
- */
- private DonutConsumer m_fooNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar,nut" topics.
- */
- private DonutConsumer m_fooBarNutConsumer;
-
- /**
- * Initialization before test cases.
- *
- * Create all the instances
- *
- * @throws UnacceptableConfiguration
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws ConfigurationException
- * something bad happened
- *
- */
- public void setUp()
- throws UnacceptableConfiguration, MissingHandlerException,
- ConfigurationException {
-
- m_utils = new EahTestUtils(getContext());
- Dictionary properties = new Hashtable();
-
- // All the providers
- m_providersInstances = new ComponentInstance[NUMBER_OF_PROVIDERS];
- m_providersServices = new ServiceReference[NUMBER_OF_PROVIDERS];
- m_providers = new DonutProvider[NUMBER_OF_PROVIDERS];
- m_synchronousProviders = new DonutProvider[NUMBER_OF_SYNCHRONOUS_PROVIDERS];
- m_eahProviders = new DonutProvider[NUMBER_OF_EAH_PROVIDERS];
- m_eahProvidersInstances = new ComponentInstance[NUMBER_OF_EAH_PROVIDERS];
- m_topicsProvidersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsProvidersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsProviders = new DonutProvider[TOPICS_LIST.length];
-
- // Create the (asynchronous) donut provider
- properties.put("instance.name","asynchronous donut provider");
- m_providersInstances[0] = m_utils.getDonutProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut provider");
- m_providersInstances[1] = m_utils.getSynchronousDonutProvider2Factory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) donut event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous donut event provider");
- m_providersInstances[2] = m_utils.getDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut event provider");
- m_providersInstances[3] = m_utils
- .getSynchronousDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous event provider");
- m_providersInstances[4] = m_utils.getEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous event provider");
- m_providersInstances[5] = m_utils.getSynchronousEventProviderFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- m_providersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutProvider.class.getName(),
- m_providersInstances[i].getInstanceName());
- m_providers[i] = (DonutProvider) getContext()
- .getService(m_providersServices[i]);
- }
- m_synchronousProviders[0] = m_providers[1];
- m_synchronousProviders[1] = m_providers[3];
- m_synchronousProviders[2] = m_providers[5];
- m_eahProviders[0] = m_providers[0];
- m_eahProviders[1] = m_providers[1];
- m_eahProviders[2] = m_providers[2];
- m_eahProviders[3] = m_providers[3];
- m_eahProvidersInstances[0] = m_providersInstances[0];
- m_eahProvidersInstances[1] = m_providersInstances[1];
- m_eahProvidersInstances[2] = m_providersInstances[2];
- m_eahProvidersInstances[3] = m_providersInstances[3];
- m_synchronousDonutEventProvider = m_providers[3];
-
- // All the consumers
- m_consumersInstances = new ComponentInstance[NUMBER_OF_CONSUMERS];
- m_consumersServices = new ServiceReference[NUMBER_OF_CONSUMERS];
- m_consumers = new DonutConsumer[NUMBER_OF_CONSUMERS];
- m_quickConsumers = new DonutConsumer[NUMBER_OF_QUICK_CONSUMERS];
- m_filteredConsumersInstances = new ComponentInstance[Donut.FLAVOURS.length];
- m_filteredConsumersServices = new ServiceReference[Donut.FLAVOURS.length];
- m_filteredConsumers = new DonutConsumer[Donut.FLAVOURS.length];
- m_topicsConsumersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsConsumersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsConsumers = new DonutConsumer[TOPICS_LIST.length];
-
- // Create the (quick) donut consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut consumer");
- m_consumersInstances[0] = m_utils.getDonutConsumer2Factory()
- .createComponentInstance(properties);
-
- // Create the (quick) donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut event consumer");
- m_consumersInstances[1] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the (quick) event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick event consumer");
- m_consumersInstances[2] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow donut consumer
- properties = new Hashtable();
- properties.put("slow", Boolean.TRUE);
- properties.put("instance.name","slow donut consumer");
- m_consumersInstances[3] = m_utils.getDonutConsumer2Factory()
- .createComponentInstance(properties);
-
- // Create the slow donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow donut event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[4] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[5] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutConsumer.class.getName(),
- m_consumersInstances[i].getInstanceName());
- m_consumers[i] = (DonutConsumer) getContext()
- .getService(m_consumersServices[i]);
- }
- m_quickConsumers[0] = m_consumers[0];
- m_quickConsumers[1] = m_consumers[1];
- m_quickConsumers[2] = m_consumers[2];
-
- // Create the event tracker
- properties = new Hashtable();
- properties.put("instance.name","event tracker");
- m_eventTrackerInstance = m_utils.getEventTrackerFactory()
- .createComponentInstance(properties);
- m_eventTrackerService = IPojoTestUtils.getServiceReferenceByName(
- getContext(), EventTracker.class.getName(), m_eventTrackerInstance
- .getInstanceName());
- m_eventTracker = (EventTracker) getContext()
- .getService(m_eventTrackerService);
-
- // Create the filtered consumer
- Dictionary filter = new Hashtable();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- String flavour = Donut.FLAVOURS[i];
- properties = new Hashtable();
- filter.put("donut-event-subscriber", "(flavour=" + flavour + ")");
- properties.put("instance.name",flavour + " donut consumer");
- properties.put("event.filter", filter);
- m_filteredConsumersInstances[i] = m_utils
- .getDonutEventConsumerFactory().createComponentInstance(
- properties);
- m_filteredConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_filteredConsumersInstances[i]
- .getInstanceName());
- m_filteredConsumers[i] = (DonutConsumer) getContext()
- .getService(m_filteredConsumersServices[i]);
- }
-
- // Create the providers and consumers selling and receiving donuts on
- // specific topics
- Dictionary topics = new Hashtable();
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- String topicsString = TOPICS_LIST[i];
- properties = new Hashtable();
- // Create provider
- topics.put("donut-publisher", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut provider");
- m_topicsProvidersInstances[i] = m_utils
- .getSynchronousDonutProviderFactory()
- .createComponentInstance(properties);
- m_topicsProvidersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutProvider.class
- .getName(), m_topicsProvidersInstances[i]
- .getInstanceName());
- m_topicsProviders[i] = (DonutProvider) getContext()
- .getService(m_topicsProvidersServices[i]);
-
- // Create consumer
- properties = new Hashtable();
- topics.put("donut-subscriber", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut consumer");
-
- m_topicsConsumersInstances[i] = m_utils.getDonutConsumer2Factory()
- .createComponentInstance(properties);
- m_topicsConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_topicsConsumersInstances[i]
- .getInstanceName());
- m_topicsConsumers[i] = (DonutConsumer) getContext()
- .getService(m_topicsConsumersServices[i]);
- topics.remove("donut-subscriber");
- }
-
- m_fooProvider = m_topicsProviders[0];
- m_barProvider = m_topicsProviders[1];
- m_nutProvider = m_topicsProviders[2];
- m_fooBarProvider = m_topicsProviders[3];
- m_barNutProvider = m_topicsProviders[4];
- m_fooNutProvider = m_topicsProviders[5];
- m_fooBarNutProvider = m_topicsProviders[6];
- m_fooConsumer = m_topicsConsumers[0];
- m_barConsumer = m_topicsConsumers[1];
- m_nutConsumer = m_topicsConsumers[2];
- m_fooBarConsumer = m_topicsConsumers[3];
- m_barNutConsumer = m_topicsConsumers[4];
- m_fooNutConsumer = m_topicsConsumers[5];
- m_fooBarNutConsumer = m_topicsConsumers[6];
-
- }
-
- /**
- * Creates a subscriber listening on a pattern topic (ending with '*').
- * @throws ConfigurationException something bad happened.
- * @throws MissingHandlerException something bad happened.
- * @throws UnacceptableConfiguration something bad happened.
- */
- public void testSubscriberWithPatternTopic() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Dictionary properties = new Hashtable();
- Dictionary topics = new Hashtable();
-
- // Create the donut consumer instance, listening on a pattern topic
- properties.put("instance.name","subscriber with pattern topic");
- topics.put("donut-subscriber", "a/pattern/topic/*");
- properties.put("event.topics", topics);
-
- ComponentInstance instance = m_utils.getDonutConsumer2Factory()
- .createComponentInstance(properties);
- instance.dispose();
- }
-
- /**
- * Test the event handler reliability by sending events with all kinds of
- * publisher and check they are received by all kinds of subscriber.
- */
- public void testReliability() {
-
- // Flush donut list for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumers[i].clearDonuts();
- }
-
- // Send a lot of donut with each provider
- List sentDonuts = new ArrayList(NUMBER_OF_PROVIDERS
- * EahTestUtils.NUMBER_OF_TESTS);
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- sentDonuts.add(m_providers[i].sellDonut());
- }
- }
-
- // Wait a respectable amount of time
- EahTestUtils.sleep(EahTestUtils.BLACK_LIST_TIME
- + EahTestUtils.A_LONG_TIME);
-
- // Collect all received donuts for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- List receivedDonuts = Arrays.asList(m_consumers[i].getAllDonuts());
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts.",
- sentDonuts.size(), receivedDonuts.size());
- assertTrue("The receiver must have eaten all sent donuts.",
- receivedDonuts.containsAll(sentDonuts));
- }
- }
-
- /**
- * Test the synchronism of event sending for the component.
- *
- * This test consists to send synchronously a big amount of donuts and to
- * check immediately if it has been received (by all quick consumers).
- */
- public void testSynchronism() {
-
- // Flush donut list for quick consumers
- for (int i = 0; i < NUMBER_OF_QUICK_CONSUMERS; i++) {
- m_quickConsumers[i].clearDonuts();
- }
-
- // Send a lot of donuts and check they are immediately received.
- Donut sentDonut;
- Donut receivedDonut;
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- for (int j = 0; j < NUMBER_OF_SYNCHRONOUS_PROVIDERS; j++) {
- sentDonut = m_synchronousProviders[j].sellDonut();
- for (int k = 0; k < NUMBER_OF_QUICK_CONSUMERS; k++) {
- receivedDonut = m_quickConsumers[k].getDonut();
- assertEquals(
- "The donut must have been received immediately and be the be the same as the sent one.",
- sentDonut, receivedDonut);
- }
- }
- }
- }
-
- /**
- * Test that the received events contains the instance name of the sender.
- */
- public void testInstanceName() {
-
- // Flush event list of the event tracker
- m_eventTracker.clearEvents();
-
- // Send donuts and check the sender instance name
- Event receivedEvent;
- for (int i = 0; i < NUMBER_OF_EAH_PROVIDERS; i++) {
- m_eahProviders[i].sellDonut();
- receivedEvent = m_eventTracker.waitForEvent();
- assertEquals(
- "The instance name property of the received message must be the same as the sender instance name.",
- m_eahProvidersInstances[i].getInstanceName(), receivedEvent
- .getProperty("publisher.instance.name"));
- }
- }
-
- /**
- * Test the event filtering.
- *
- * This test send donuts with different flavours. Each filtered consumer
- * must receive only a certain kind of donut. Of course, all donuts must
- * have been received too.
- */
- public void testFilters() {
-
- // The sent donuts, sorted by flavour
- List[] sentDonuts = new List[Donut.FLAVOURS.length];
-
- // Flush donut list for each filtered consumer
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- m_filteredConsumers[i].clearDonuts();
- sentDonuts[i] = new ArrayList(EahTestUtils.NUMBER_OF_TESTS
- / Donut.FLAVOURS.length);
- }
-
- // Send donuts
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- Donut donut = m_synchronousDonutEventProvider.sellDonut();
- sentDonuts[EahTestUtils.flavourIndex(donut.getFlavour())]
- .add(donut);
- }
-
- // Check the received donuts
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- Donut[] receivedDonuts = m_filteredConsumers[i].getAllDonuts();
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts with the matching flavour.",
- sentDonuts[i].size(), receivedDonuts.length);
- assertTrue(
- "The receiver must have eaten all sent donuts matching the wanted flavour.",
- Arrays.asList(receivedDonuts).containsAll(sentDonuts[i]));
- }
-
- }
-
- /**
- * Test the event topic.
- *
- * This test send donuts on several topics. Each consumer (who listens to
- * one or several topics) must receive donuts sent on his specifics topics.
- */
- public void testTopics() {
-
- // The sent donuts, sorted by topic
- int foos = 0;
- int bars = 0;
- int nuts = 0;
-
- // Flush consumers
- m_fooConsumer.clearDonuts();
- m_barConsumer.clearDonuts();
- m_nutConsumer.clearDonuts();
- m_fooBarConsumer.clearDonuts();
- m_barNutConsumer.clearDonuts();
- m_fooNutConsumer.clearDonuts();
- m_fooBarNutConsumer.clearDonuts();
-
- // Send donuts
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- m_fooProvider.sellDonut();
- foos++;
-
- m_barProvider.sellDonut();
- bars++;
-
- m_nutProvider.sellDonut();
- nuts++;
-
- m_fooBarProvider.sellDonut();
- foos++;
- bars++;
-
- m_barNutProvider.sellDonut();
- bars++;
- nuts++;
-
- m_fooNutProvider.sellDonut();
- foos++;
- nuts++;
-
- m_fooBarNutProvider.sellDonut();
- foos++;
- bars++;
- nuts++;
- }
-
- // Check received donuts
- assertEquals("The number of received donuts must be correct.", foos,
- m_fooConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars,
- m_barConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", nuts,
- m_nutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars, m_fooBarConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars
- + nuts, m_barNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + nuts, m_fooNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars + nuts, m_fooBarNutConsumer.getAllDonuts().length);
-
- }
-
- /**
- * Finalization after test cases.
- *
- * Release all services references and destroy instances.
- */
- public void tearDown() {
- int index;
- for (index = 0; index < NUMBER_OF_PROVIDERS; index++) {
- getContext().ungetService(m_providersServices[index]);
- m_providersInstances[index].dispose();
- }
- for (index = 0; index < NUMBER_OF_CONSUMERS; index++) {
- getContext().ungetService(m_consumersServices[index]);
- m_consumersInstances[index].dispose();
- }
- getContext().ungetService(m_eventTrackerService);
- m_eventTrackerInstance.dispose();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- getContext().ungetService(m_filteredConsumersServices[i]);
- m_filteredConsumersInstances[i].dispose();
- }
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- getContext().ungetService(m_topicsProvidersServices[i]);
- m_topicsProvidersInstances[i].dispose();
- getContext().ungetService(m_topicsConsumersServices[i]);
- m_topicsConsumersInstances[i].dispose();
- }
-
- }
-
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java
deleted file mode 100644
index 0e3f6e9..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/PublishesTests.java
+++ /dev/null
@@ -1,766 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.donut.Donut;
-import org.apache.felix.ipojo.test.donut.DonutConsumer;
-import org.apache.felix.ipojo.test.donut.DonutProvider;
-import org.apache.felix.ipojo.test.donut.EventTracker;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.apache.felix.ipojo.test.util.IPojoTestUtils;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.event.Event;
-
-/**
- * Test the good behaviour of the EventAdminHandler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class PublishesTests extends OSGiTestCase {
-
- /**
- * The number of providers to test.
- */
- private static final int NUMBER_OF_PROVIDERS = 6;
-
- /**
- * The number of providers using the event admin handler to test.
- */
- private static final int NUMBER_OF_EAH_PROVIDERS = 4;
-
- /**
- * The number of consumers to test.
- */
- private static final int NUMBER_OF_CONSUMERS = 6;
-
- /**
- * The number of synchronous providers to test.
- */
- private static final int NUMBER_OF_SYNCHRONOUS_PROVIDERS = 3;
-
- /**
- * The number of slow consumers to test.
- */
- private static final int NUMBER_OF_QUICK_CONSUMERS = 3;
-
- /**
- * The list of topics to test.
- */
- private static final String[] TOPICS_LIST = { "foo", "bar", "nut",
- "foo,bar", "bar,nut", "foo,nut", "foo,bar,nut" };
-
- /**
- * The utility class instance.
- */
- public EahTestUtils m_utils;
-
- /**
- * The providers' instances.
- */
- private ComponentInstance[] m_providersInstances;
-
- /**
- * The providers' service references.
- */
- private ServiceReference[] m_providersServices;
-
- /**
- * The providers' services.
- */
- private DonutProvider[] m_providers;
-
- /**
- * The synchronous providers' services.
- */
- private DonutProvider[] m_synchronousProviders;
-
- /**
- * The instances of providers that uses the event admin handler.
- */
- private ComponentInstance[] m_eahProvidersInstances;
-
- /**
- * The services of the providers that uses the event admin handler.
- */
- private DonutProvider[] m_eahProviders;
-
- /**
- * The synchronous donut event provider service.
- */
- private DonutProvider m_synchronousDonutEventProvider;
-
- /**
- * The consumers' instances.
- */
- private ComponentInstance[] m_consumersInstances;
-
- /**
- * The consumers' service references.
- */
- private ServiceReference[] m_consumersServices;
-
- /**
- * The consumers' services.
- */
- private DonutConsumer[] m_consumers;
-
- /**
- * The slow consumers' services.
- */
- private DonutConsumer[] m_quickConsumers;
-
- /**
- * The event tracker' instances.
- */
- private ComponentInstance m_eventTrackerInstance;
-
- /**
- * The event tracker' service references.
- */
- private ServiceReference m_eventTrackerService;
-
- /**
- * The event tracker service.
- */
- private EventTracker m_eventTracker;
-
- /**
- * The filtered consumers' instances.
- */
- private ComponentInstance[] m_filteredConsumersInstances;
-
- /**
- * The filtered consumers' service references.
- */
- private ServiceReference[] m_filteredConsumersServices;
-
- /**
- * The filtered consumers' services.
- */
- private DonutConsumer[] m_filteredConsumers;
-
- /**
- * The providers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsProvidersInstances;
-
- /**
- * The providers' service references with specified topics.
- */
- private ServiceReference[] m_topicsProvidersServices;
-
- /**
- * The providers' service with specified topics.
- */
- private DonutProvider[] m_topicsProviders;
-
- /**
- * The provider that send donuts on the "foo" topic.
- */
- private DonutProvider m_fooProvider;
-
- /**
- * The provider that send donuts on the "bar" topic.
- */
- private DonutProvider m_barProvider;
-
- /**
- * The provider that send donuts on the "nut" topic.
- */
- private DonutProvider m_nutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar" topics.
- */
- private DonutProvider m_fooBarProvider;
-
- /**
- * The provider that send donuts on the "bar,nut" topics.
- */
- private DonutProvider m_barNutProvider;
-
- /**
- * The provider that send donuts on the "foo,nut" topics.
- */
- private DonutProvider m_fooNutProvider;
-
- /**
- * The provider that send donuts on the "foo,bar,nut" topics.
- */
- private DonutProvider m_fooBarNutProvider;
-
- /**
- * The consumers' instances with specified topics.
- */
- private ComponentInstance[] m_topicsConsumersInstances;
-
- /**
- * The consumers' service references with specified topics.
- */
- private ServiceReference[] m_topicsConsumersServices;
-
- /**
- * The consumers' service references with specified topics.
- */
- private DonutConsumer[] m_topicsConsumers;
-
- /**
- * The consumer that receive donuts on the "foo" topic.
- */
- private DonutConsumer m_fooConsumer;
-
- /**
- * The consumer that receive donuts on the "bar" topic.
- */
- private DonutConsumer m_barConsumer;
-
- /**
- * The consumer that receive donuts on the "nut" topic.
- */
- private DonutConsumer m_nutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar" topics.
- */
- private DonutConsumer m_fooBarConsumer;
-
- /**
- * The consumer that receive donuts on the "bar,nut" topics.
- */
- private DonutConsumer m_barNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,nut" topics.
- */
- private DonutConsumer m_fooNutConsumer;
-
- /**
- * The consumer that receive donuts on the "foo,bar,nut" topics.
- */
- private DonutConsumer m_fooBarNutConsumer;
-
- /**
- * Initialization before test cases.
- *
- * Create all the instances
- *
- * @throws UnacceptableConfiguration
- * something bad happened
- * @throws MissingHandlerException
- * something bad happened
- * @throws ConfigurationException
- * something bad happened
- *
- */
- public void setUp()
- throws UnacceptableConfiguration, MissingHandlerException,
- ConfigurationException {
-
- m_utils = new EahTestUtils(getContext());
- Dictionary properties = new Hashtable();
-
- // All the providers
- m_providersInstances = new ComponentInstance[NUMBER_OF_PROVIDERS];
- m_providersServices = new ServiceReference[NUMBER_OF_PROVIDERS];
- m_providers = new DonutProvider[NUMBER_OF_PROVIDERS];
- m_synchronousProviders = new DonutProvider[NUMBER_OF_SYNCHRONOUS_PROVIDERS];
- m_eahProviders = new DonutProvider[NUMBER_OF_EAH_PROVIDERS];
- m_eahProvidersInstances = new ComponentInstance[NUMBER_OF_EAH_PROVIDERS];
- m_topicsProvidersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsProvidersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsProviders = new DonutProvider[TOPICS_LIST.length];
-
- // Create the (asynchronous) donut provider
- properties.put("instance.name","asynchronous donut provider");
- m_providersInstances[0] = m_utils.getDonutProviderUsingPublishesFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut provider");
- m_providersInstances[1] = m_utils.getSynchronousDonutProviderFactory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) donut event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous donut event provider");
- m_providersInstances[2] = m_utils.getDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous donut event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous donut event provider");
- m_providersInstances[3] = m_utils
- .getSynchronousDonutEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the (asynchronous) event provider
- properties = new Hashtable();
- properties.put("instance.name","asynchronous event provider");
- m_providersInstances[4] = m_utils.getEventProviderFactory()
- .createComponentInstance(properties);
-
- // Create the synchronous event provider
- properties = new Hashtable();
- properties.put("instance.name","synchronous event provider");
- m_providersInstances[5] = m_utils.getSynchronousEventProviderFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- m_providersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutProvider.class.getName(),
- m_providersInstances[i].getInstanceName());
- m_providers[i] = (DonutProvider) getContext()
- .getService(m_providersServices[i]);
- }
- m_synchronousProviders[0] = m_providers[1];
- m_synchronousProviders[1] = m_providers[3];
- m_synchronousProviders[2] = m_providers[5];
- m_eahProviders[0] = m_providers[0];
- m_eahProviders[1] = m_providers[1];
- m_eahProviders[2] = m_providers[2];
- m_eahProviders[3] = m_providers[3];
- m_eahProvidersInstances[0] = m_providersInstances[0];
- m_eahProvidersInstances[1] = m_providersInstances[1];
- m_eahProvidersInstances[2] = m_providersInstances[2];
- m_eahProvidersInstances[3] = m_providersInstances[3];
- m_synchronousDonutEventProvider = m_providers[3];
-
- // All the consumers
- m_consumersInstances = new ComponentInstance[NUMBER_OF_CONSUMERS];
- m_consumersServices = new ServiceReference[NUMBER_OF_CONSUMERS];
- m_consumers = new DonutConsumer[NUMBER_OF_CONSUMERS];
- m_quickConsumers = new DonutConsumer[NUMBER_OF_QUICK_CONSUMERS];
- m_filteredConsumersInstances = new ComponentInstance[Donut.FLAVOURS.length];
- m_filteredConsumersServices = new ServiceReference[Donut.FLAVOURS.length];
- m_filteredConsumers = new DonutConsumer[Donut.FLAVOURS.length];
- m_topicsConsumersInstances = new ComponentInstance[TOPICS_LIST.length];
- m_topicsConsumersServices = new ServiceReference[TOPICS_LIST.length];
- m_topicsConsumers = new DonutConsumer[TOPICS_LIST.length];
-
- // Create the (quick) donut consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut consumer");
- m_consumersInstances[0] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the (quick) donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick donut event consumer");
- m_consumersInstances[1] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the (quick) event consumer
- properties = new Hashtable();
- properties.put("instance.name","quick event consumer");
- m_consumersInstances[2] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow donut consumer
- properties = new Hashtable();
- properties.put("slow", Boolean.TRUE);
- properties.put("instance.name","slow donut consumer");
- m_consumersInstances[3] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow donut event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow donut event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[4] = m_utils.getDonutEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Create the slow event consumer
- properties = new Hashtable();
- properties.put("instance.name","slow event consumer");
- properties.put("slow", Boolean.TRUE);
- m_consumersInstances[5] = m_utils.getEventConsumerFactory()
- .createComponentInstance(properties);
-
- // Get all the services references
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumersServices[i] = IPojoTestUtils.getServiceReferenceByName(
- getContext(), DonutConsumer.class.getName(),
- m_consumersInstances[i].getInstanceName());
- m_consumers[i] = (DonutConsumer) getContext()
- .getService(m_consumersServices[i]);
- }
- m_quickConsumers[0] = m_consumers[0];
- m_quickConsumers[1] = m_consumers[1];
- m_quickConsumers[2] = m_consumers[2];
-
- // Create the event tracker
- properties = new Hashtable();
- properties.put("instance.name","event tracker");
- m_eventTrackerInstance = m_utils.getEventTrackerFactory()
- .createComponentInstance(properties);
- m_eventTrackerService = IPojoTestUtils.getServiceReferenceByName(
- getContext(), EventTracker.class.getName(), m_eventTrackerInstance
- .getInstanceName());
- m_eventTracker = (EventTracker) getContext()
- .getService(m_eventTrackerService);
-
- // Create the filtered consumer
- Dictionary filter = new Hashtable();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- String flavour = Donut.FLAVOURS[i];
- properties = new Hashtable();
- filter.put("donut-event-subscriber", "(flavour=" + flavour + ")");
- properties.put("instance.name",flavour + " donut consumer");
- properties.put("event.filter", filter);
- m_filteredConsumersInstances[i] = m_utils
- .getDonutEventConsumerFactory().createComponentInstance(
- properties);
- m_filteredConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_filteredConsumersInstances[i]
- .getInstanceName());
- m_filteredConsumers[i] = (DonutConsumer) getContext()
- .getService(m_filteredConsumersServices[i]);
- }
-
- // Create the providers and consumers selling and receiving donuts on
- // specific topics
- Dictionary topics = new Hashtable();
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- String topicsString = TOPICS_LIST[i];
- properties = new Hashtable();
- // Create provider
- topics.put("donut-publisher", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut provider");
- m_topicsProvidersInstances[i] = m_utils
- .getSynchronousDonutProviderFactory()
- .createComponentInstance(properties);
- m_topicsProvidersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutProvider.class
- .getName(), m_topicsProvidersInstances[i]
- .getInstanceName());
- m_topicsProviders[i] = (DonutProvider) getContext()
- .getService(m_topicsProvidersServices[i]);
-
- // Create consumer
- properties = new Hashtable();
- topics.put("donut-subscriber", topicsString);
- properties.put("event.topics", topics);
- properties.put("instance.name",topicsString + " donut consumer");
-
- m_topicsConsumersInstances[i] = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
- m_topicsConsumersServices[i] = IPojoTestUtils
- .getServiceReferenceByName(getContext(), DonutConsumer.class
- .getName(), m_topicsConsumersInstances[i]
- .getInstanceName());
- m_topicsConsumers[i] = (DonutConsumer) getContext()
- .getService(m_topicsConsumersServices[i]);
- topics.remove("donut-subscriber");
- }
-
- m_fooProvider = m_topicsProviders[0];
- m_barProvider = m_topicsProviders[1];
- m_nutProvider = m_topicsProviders[2];
- m_fooBarProvider = m_topicsProviders[3];
- m_barNutProvider = m_topicsProviders[4];
- m_fooNutProvider = m_topicsProviders[5];
- m_fooBarNutProvider = m_topicsProviders[6];
- m_fooConsumer = m_topicsConsumers[0];
- m_barConsumer = m_topicsConsumers[1];
- m_nutConsumer = m_topicsConsumers[2];
- m_fooBarConsumer = m_topicsConsumers[3];
- m_barNutConsumer = m_topicsConsumers[4];
- m_fooNutConsumer = m_topicsConsumers[5];
- m_fooBarNutConsumer = m_topicsConsumers[6];
-
- }
-
- /**
- * Creates a subscriber listening on a pattern topic (ending with '*').
- * @throws ConfigurationException something bad happened.
- * @throws MissingHandlerException something bad happened.
- * @throws UnacceptableConfiguration something bad happened.
- */
- public void testSubscriberWithPatternTopic() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Dictionary properties = new Hashtable();
- Dictionary topics = new Hashtable();
-
- // Create the donut consumer instance, listening on a pattern topic
- properties.put("instance.name","subscriber with pattern topic");
- topics.put("donut-subscriber", "a/pattern/topic/*");
- properties.put("event.topics", topics);
-
- ComponentInstance instance = m_utils.getDonutConsumerFactory()
- .createComponentInstance(properties);
- instance.dispose();
- }
-
- /**
- * Test the event handler reliability by sending events with all kinds of
- * publisher and check they are received by all kinds of subscriber.
- */
- public void testReliability() {
-
- // Flush donut list for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- m_consumers[i].clearDonuts();
- }
-
- // Send a lot of donut with each provider
- List sentDonuts = new ArrayList(NUMBER_OF_PROVIDERS
- * EahTestUtils.NUMBER_OF_TESTS);
- for (int i = 0; i < NUMBER_OF_PROVIDERS; i++) {
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- sentDonuts.add(m_providers[i].sellDonut());
- }
- }
-
- // Wait a respectable amount of time
- EahTestUtils.sleep(EahTestUtils.BLACK_LIST_TIME
- + EahTestUtils.A_LONG_TIME);
-
- // Collect all received donuts for each consumer
- for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) {
- List receivedDonuts = Arrays.asList(m_consumers[i].getAllDonuts());
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts.",
- sentDonuts.size(), receivedDonuts.size());
- assertTrue("The receiver must have eaten all sent donuts.",
- receivedDonuts.containsAll(sentDonuts));
- }
- }
-
- /**
- * Test the synchronism of event sending for the component.
- *
- * This test consists to send synchronously a big amount of donuts and to
- * check immediately if it has been received (by all quick consumers).
- */
- public void testSynchronism() {
-
- // Flush donut list for quick consumers
- for (int i = 0; i < NUMBER_OF_QUICK_CONSUMERS; i++) {
- m_quickConsumers[i].clearDonuts();
- }
-
- // Send a lot of donuts and check they are immediately received.
- Donut sentDonut;
- Donut receivedDonut;
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- for (int j = 0; j < NUMBER_OF_SYNCHRONOUS_PROVIDERS; j++) {
- sentDonut = m_synchronousProviders[j].sellDonut();
- for (int k = 0; k < NUMBER_OF_QUICK_CONSUMERS; k++) {
- receivedDonut = m_quickConsumers[k].getDonut();
- assertEquals(
- "The donut must have been received immediately and be the be the same as the sent one.",
- sentDonut, receivedDonut);
- }
- }
- }
- }
-
- /**
- * Test that the received events contains the instance name of the sender.
- */
- public void testInstanceName() {
-
- // Flush event list of the event tracker
- m_eventTracker.clearEvents();
-
- // Check that the publishes handler is here
- HandlerFactory[] handlers = IPojoTestUtils.getHandlerFactories(context);
- for (int i = 0; i < handlers.length; i++) {
- String name = handlers[i].getHandlerName();
- if ("composite".equals(handlers[i].getType())) {
- name = name + " [composite]";
- }
- if (handlers[i].getMissingHandlers().size() == 0) {
- System.out.println("Handler " + name + " (VALID)");
- } else {
- System.out.println("Handler " + name + " (INVALID : " + handlers[i].getMissingHandlers() + ")");
- }
- }
-
- Factory factory = IPojoTestUtils.getFactoryByName(context, "donut-provider-publishes");
- assertNotNull(factory);
- System.out.println(factory.getDescription());
-
- // Send donuts and check the sender instance name
- Event receivedEvent;
- for (int i = 0; i < NUMBER_OF_EAH_PROVIDERS; i++) {
- m_eahProviders[i].sellDonut();
- receivedEvent = m_eventTracker.waitForEvent();
- assertEquals(
- "The instance name property of the received message must be the same as the sender instance name.",
- m_eahProvidersInstances[i].getInstanceName(), receivedEvent
- .getProperty("publisher.instance.name"));
- }
- }
-
- /**
- * Test the event filtering.
- *
- * This test send donuts with different flavours. Each filtered consumer
- * must receive only a certain kind of donut. Of course, all donuts must
- * have been received too.
- */
- public void testFilters() {
-
- // The sent donuts, sorted by flavour
- List[] sentDonuts = new List[Donut.FLAVOURS.length];
-
- // Flush donut list for each filtered consumer
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- m_filteredConsumers[i].clearDonuts();
- sentDonuts[i] = new ArrayList(EahTestUtils.NUMBER_OF_TESTS
- / Donut.FLAVOURS.length);
- }
-
- // Send donuts
- for (int j = 0; j < EahTestUtils.NUMBER_OF_TESTS; j++) {
- Donut donut = m_synchronousDonutEventProvider.sellDonut();
- sentDonuts[EahTestUtils.flavourIndex(donut.getFlavour())]
- .add(donut);
- }
-
- // Check the received donuts
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- Donut[] receivedDonuts = m_filteredConsumers[i].getAllDonuts();
- assertEquals(
- "The number of received donuts must be the same as the number of sent donuts with the matching flavour.",
- sentDonuts[i].size(), receivedDonuts.length);
- assertTrue(
- "The receiver must have eaten all sent donuts matching the wanted flavour.",
- Arrays.asList(receivedDonuts).containsAll(sentDonuts[i]));
- }
-
- }
-
- /**
- * Test the event topic.
- *
- * This test send donuts on several topics. Each consumer (who listens to
- * one or several topics) must receive donuts sent on his specifics topics.
- */
- public void testTopics() {
-
- // The sent donuts, sorted by topic
- int foos = 0;
- int bars = 0;
- int nuts = 0;
-
- // Flush consumers
- m_fooConsumer.clearDonuts();
- m_barConsumer.clearDonuts();
- m_nutConsumer.clearDonuts();
- m_fooBarConsumer.clearDonuts();
- m_barNutConsumer.clearDonuts();
- m_fooNutConsumer.clearDonuts();
- m_fooBarNutConsumer.clearDonuts();
-
- // Send donuts
- for (int i = 0; i < EahTestUtils.NUMBER_OF_TESTS; i++) {
- m_fooProvider.sellDonut();
- foos++;
-
- m_barProvider.sellDonut();
- bars++;
-
- m_nutProvider.sellDonut();
- nuts++;
-
- m_fooBarProvider.sellDonut();
- foos++;
- bars++;
-
- m_barNutProvider.sellDonut();
- bars++;
- nuts++;
-
- m_fooNutProvider.sellDonut();
- foos++;
- nuts++;
-
- m_fooBarNutProvider.sellDonut();
- foos++;
- bars++;
- nuts++;
- }
-
- // Check received donuts
- assertEquals("The number of received donuts must be correct.", foos,
- m_fooConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars,
- m_barConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", nuts,
- m_nutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars, m_fooBarConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", bars
- + nuts, m_barNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + nuts, m_fooNutConsumer.getAllDonuts().length);
- assertEquals("The number of received donuts must be correct.", foos
- + bars + nuts, m_fooBarNutConsumer.getAllDonuts().length);
-
- }
-
- /**
- * Finalization after test cases.
- *
- * Release all services references and destroy instances.
- */
- public void tearDown() {
- int index;
- for (index = 0; index < NUMBER_OF_PROVIDERS; index++) {
- getContext().ungetService(m_providersServices[index]);
- m_providersInstances[index].dispose();
- }
- for (index = 0; index < NUMBER_OF_CONSUMERS; index++) {
- getContext().ungetService(m_consumersServices[index]);
- m_consumersInstances[index].dispose();
- }
- getContext().ungetService(m_eventTrackerService);
- m_eventTrackerInstance.dispose();
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- getContext().ungetService(m_filteredConsumersServices[i]);
- m_filteredConsumersInstances[i].dispose();
- }
- for (int i = 0; i < TOPICS_LIST.length; i++) {
- getContext().ungetService(m_topicsProvidersServices[i]);
- m_topicsProvidersInstances[i].dispose();
- getContext().ungetService(m_topicsConsumersServices[i]);
- m_topicsConsumersInstances[i].dispose();
- }
-
- }
-
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/AsyncEventProviderImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/AsyncEventProviderImpl.java
deleted file mode 100644
index 6b0da14..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/AsyncEventProviderImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Random;
-
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * Implementation of an event vendor that directly uses the Event Admin service
- * to post (asynchronously) raw events.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class AsyncEventProviderImpl implements DonutProvider {
-
- /**
- * The donut current serial number.
- */
- private long m_serial = 0L;
-
- /**
- * The name of the donut vendor.
- */
- private String m_name;
-
- /**
- * A random generator.
- */
- private Random m_random;
-
- /**
- * The Event Admin service reference.
- */
- private EventAdmin m_ea;
-
- /**
- * Construct a new donut provider. The initial serial number is randomly
- * generated.
- */
- public AsyncEventProviderImpl() {
- m_random = new Random(System.currentTimeMillis());
- }
-
- /**
- * Sell a donut with a random flavour.
- *
- * @return the sold donut
- */
- public Donut sellDonut() {
- Dictionary rawEvent = new Hashtable();
- Donut donut = new Donut(m_serial++, m_name, Donut.FLAVOURS[m_random
- .nextInt(Donut.FLAVOURS.length)]);
- rawEvent.put("food", donut);
- m_ea.postEvent(new Event("food/donuts", rawEvent));
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Selling donut " + donut);
- }
- return donut;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/Donut.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/Donut.java
deleted file mode 100644
index c7b4fc5..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/Donut.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-/**
- * Donut representation.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class Donut {
-
- /**
- * All possible donut flavours.
- */
- public static final String[] FLAVOURS = { "unflavoured", "icing sugar",
- "chocolate", "toffee", "strawberry", "apple" };
-
- /**
- * The vendor's unique donut identifier.
- */
- private final long m_id;
-
- /**
- * The name of this donut's vendor.
- */
- private final String m_vendorName;
-
- /**
- * The m_flavour of this donut.
- */
- private final String m_flavour;
-
- /**
- * Create a new donut.
- *
- * @param id
- * the vendor's unique donut identifier
- * @param vendorName
- * the name of this donut's vendor
- * @param flavour
- * the m_flavour of this donut
- */
- public Donut(long id, String vendorName, String flavour) {
- this.m_id = id;
- this.m_vendorName = vendorName;
- this.m_flavour = flavour;
- }
-
- /**
- * Get the vendor's unique identifier of this donut.
- *
- * @return the id
- */
- public long getId() {
- return m_id;
- }
-
- /**
- * Get the vendor name of this donut.
- *
- * @return the name
- */
- public String getVendorName() {
- return m_vendorName;
- }
-
- /**
- * Get the flavour of this donut.
- *
- * @return the flavour
- */
- public String getFlavour() {
- return m_flavour;
- }
-
- /**
- * Return the string representation of this donut.
- *
- * @return this donut as a String
- */
- public String toString() {
- return m_id + " " + m_flavour + " (" + m_vendorName + ")";
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumer.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumer.java
deleted file mode 100644
index 0e5c483..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import org.osgi.service.event.Event;
-
-/**
- * Specification of a donut consumer.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public interface DonutConsumer {
-
- /**
- * Donut receiver callback. This method is called when a donut is received
- * on the listened topic.
- *
- * @param donut
- * the received donut
- */
- void receiveDonut(Donut donut);
-
- /**
- * Event donut receiver callback. This method is called when an event is
- * received on the listened topic.
- *
- * @param event
- * the received event
- */
- void receiveEvent(Event event);
-
- /**
- * Clear the eaten donuts list. (Useful before tests)
- */
- void clearDonuts();
-
- /**
- * Get the first received donut and remove it from the eaten donut list.
- *
- * @return the first received donut or null if no donut is available
- */
- Donut getDonut();
-
- /**
- * Get the whole list of eaten donuts.
- *
- * @return the array containing all eaten donuts
- */
- Donut[] getAllDonuts();
-
- /**
- * Get the first donut if available or wait for an incoming donut. The
- * returned donut is removed from the eaten donut list.
- *
- * @return the first available donut.
- */
- Donut waitForDonut();
-
- /**
- * Return the size of the eaten donut list.
- *
- * @return the size of the eaten donut list
- */
- int getNumberOfDonuts();
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumerImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumerImpl.java
deleted file mode 100644
index 664290f..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutConsumerImpl.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.osgi.service.event.Event;
-
-/**
- * Implementation of a donut consumer.
- *
- * @see Homer Simpson
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class DonutConsumerImpl implements DonutConsumer {
-
- /**
- * The name of the donut consumer.
- */
- private String m_name;
-
- /**
- * The list of eaten donuts.
- */
- private List m_donuts = new ArrayList();
-
- /**
- * Is this consumer a slow eater ?
- */
- private boolean m_isSlow;
-
- /**
- * Process incoming donuts. This method is called by the receiveDonut
- * callback.
- *
- * @param donut
- * the received donut
- */
- private void doReceiveDonut(Donut donut) {
- synchronized (m_donuts) {
- m_donuts.add(donut);
- m_donuts.notify();
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Eating donut " + donut);
- }
- }
- }
-
- /**
- * Utility method that causes the current thread to sleep.
- *
- * @param millis
- * the number of milliseconds to wait
- */
- public static void sleep(long millis) {
- long past = System.currentTimeMillis();
- long future = past + millis;
- long now = past;
- while (now < future) {
- try {
- Thread.sleep(future - now);
- } catch (Exception e) {
- }
- now = System.currentTimeMillis();
- }
- }
-
- /**
- * Donut receiver callback. This method is called when a donut is received
- * on the listened topic.
- *
- * @param donut
- * the received donut
- */
- public void receiveDonut(Donut donut) {
- final Donut myDonut = donut;
- if (m_isSlow) {
- new Thread(new Runnable() {
- public void run() {
- sleep(EahTestUtils.BLACK_LIST_TIME);
- doReceiveDonut(myDonut);
- }
- }, m_name + " eating " + donut).start();
- } else {
- doReceiveDonut(donut);
- }
- }
-
- /**
- * Event donut receiver callback. This method is called when an event is
- * received on the listened topic.
- *
- * @param event
- * the received event
- */
- public void receiveEvent(Event event) {
- Object thing = event.getProperty("food");
- if (Donut.class.isInstance(thing)) {
- receiveDonut((Donut) thing);
- } else {
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] D'oh ! Received an uneatable thing : "
- + thing);
- throw new ClassCastException("I want DONUTS !");
- }
- }
- }
-
- /**
- * Clear the eaten donuts list. (Useful before tests)
- */
- public void clearDonuts() {
- synchronized (m_donuts) {
- m_donuts.clear();
- }
- }
-
- /**
- * Get the first received donut and remove it from the eaten donut list.
- *
- * @return the first received donut or null if no donut is available
- */
- public Donut getDonut() {
- Donut donut = null;
- synchronized (m_donuts) {
- if (!m_donuts.isEmpty()) {
- donut = (Donut) m_donuts.remove(0);
- }
- }
- return donut;
- }
-
- /**
- * Get the whole list of eaten donuts.
- *
- * @return the array containing all eaten donuts
- */
- public Donut[] getAllDonuts() {
- Donut[] donuts = new Donut[0];
- synchronized (m_donuts) {
- donuts = (Donut[]) m_donuts.toArray(donuts);
- m_donuts.clear();
- }
- return donuts;
- }
-
- /**
- * Get the first donut if available or wait for an incoming donut. The
- * returned donut is removed from the eaten donut list.
- *
- * @return the first available donut.
- */
- public Donut waitForDonut() {
- Donut donut = null;
- synchronized (m_donuts) {
- while (donut == null) {
- if (m_donuts.isEmpty()) {
- try {
- m_donuts.wait();
- } catch (InterruptedException e) {
- // Thanks Checkstyle to forbid empty catch statements
- // ;-(
- }
- } else {
- donut = (Donut) m_donuts.remove(0);
- }
- }
- }
- return donut;
- }
-
- /**
- * Return the size of the eaten donut list.
- *
- * @return the size of the eaten donut list
- */
- public int getNumberOfDonuts() {
- int length;
- synchronized (m_donuts) {
- length = m_donuts.size();
- }
- return length;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutEventProviderImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutEventProviderImpl.java
deleted file mode 100644
index 154eff4..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutEventProviderImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Random;
-
-import org.apache.felix.ipojo.handlers.event.publisher.Publisher;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-
-/**
- * Implementation of a donut vendor that send raw events instead of sending
- * Donut objects.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class DonutEventProviderImpl implements DonutProvider {
-
- /**
- * The donut current serial number.
- */
- private long m_serial = 0L;
-
- /**
- * The name of the donut vendor.
- */
- private String m_name;
-
- /**
- * A random generator.
- */
- private Random m_random;
-
- /**
- * The event publisher of the donut vendor.
- */
- private Publisher m_publisher;
-
- /**
- * Construct a new donut provider. The initial serial number is randomly
- * generated.
- */
- public DonutEventProviderImpl() {
- m_random = new Random(System.currentTimeMillis());
- }
-
- /**
- * Sell a donut with a random flavour.
- *
- * @return the sold donut
- */
- public Donut sellDonut() {
- Dictionary rawEvent = new Hashtable();
- String flavour = Donut.FLAVOURS[m_random.nextInt(Donut.FLAVOURS.length)];
- Donut donut = new Donut(m_serial++, m_name, flavour);
- rawEvent.put("food", donut);
- rawEvent.put("flavour", flavour);
- m_publisher.send(rawEvent);
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Selling event donut " + donut);
- }
- return donut;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProvider.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProvider.java
deleted file mode 100644
index 17a1b92..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-/**
- * Specification of a donut vendor.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public interface DonutProvider {
-
- /**
- * Sell a donut with a random flavour.
- *
- * @return the sold donut
- */
- Donut sellDonut();
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProviderImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProviderImpl.java
deleted file mode 100644
index 961eb1e..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/DonutProviderImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.Random;
-
-import org.apache.felix.ipojo.handlers.event.publisher.Publisher;
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-
-/**
- * The standard implementation of a donut vendor.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class DonutProviderImpl implements DonutProvider {
-
-
-
- /**
- * The donut current serial number.
- */
- private long m_serial = 0L;
-
- /**
- * The name of the donut vendor.
- */
- private String m_name;
-
- /**
- * A random generator.
- */
- private Random m_random;
-
- /**
- * The donut publisher of the vendor.
- */
- private Publisher m_publisher;
-
- /**
- * Construct a new donut provider. The initial serial number is randomly
- * generated.
- */
- public DonutProviderImpl() {
- m_random = new Random(System.currentTimeMillis());
- }
-
- /**
- * Sell a donut with a random flavour.
- *
- * @return the sold donut
- */
- public Donut sellDonut() {
- Donut donut = new Donut(m_serial++, m_name, Donut.FLAVOURS[m_random
- .nextInt(Donut.FLAVOURS.length)]);
- m_publisher.sendData(donut);
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Selling donut " + donut);
- }
- return donut;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventConsumerImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventConsumerImpl.java
deleted file mode 100644
index 78b6f9f..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventConsumerImpl.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
-
-/**
- * Implementation of a donut consumer.
- *
- * @see Homer Simpson
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class EventConsumerImpl implements DonutConsumer, EventHandler {
-
- /**
- * The name of the donut consumer.
- */
- private String m_name;
-
- /**
- * The list of eaten donuts.
- */
- private List m_donuts = new ArrayList();
-
- /**
- * Is this consumer a slow eater ?
- */
- private boolean m_isSlow;
-
- /**
- * Process incoming donuts. This method is called by the receiveDonut
- * callback.
- *
- * @param donut
- * the received donut
- */
- private void doReceiveDonut(Donut donut) {
- synchronized (m_donuts) {
- m_donuts.add(donut);
- m_donuts.notify();
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Eating donut " + donut);
- }
- }
- }
-
- /**
- * Utility method that causes the current thread to sleep.
- *
- * @param millis
- * the number of milliseconds to wait
- */
- public static void sleep(long millis) {
- long past = System.currentTimeMillis();
- long future = past + millis;
- long now = past;
- while (now < future) {
- try {
- Thread.sleep(future - now);
- } catch (Exception e) {
- }
- now = System.currentTimeMillis();
- }
- }
-
- /**
- * Donut receiver callback. This method is called when a donut is received
- * on the listened topic.
- *
- * @param donut
- * the received donut
- */
- public void receiveDonut(Donut donut) {
- final Donut myDonut = donut;
- if (m_isSlow) {
- new Thread(new Runnable() {
- public void run() {
- sleep(EahTestUtils.BLACK_LIST_TIME);
- doReceiveDonut(myDonut);
- }
- }, m_name + " eating " + donut).start();
- } else {
- doReceiveDonut(donut);
- }
- }
-
- /**
- * Event donut receiver callback. This method is called when an event is
- * received on the listened topic.
- *
- * @param event
- * the received event
- */
- public void receiveEvent(Event event) {
- Object thing = event.getProperty("food");
- if (Donut.class.isInstance(thing)) {
- receiveDonut((Donut) thing);
- } else {
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] D'oh ! Received an uneatable thing : "
- + thing);
- throw new ClassCastException("I want DONUTS !");
- }
- }
- }
-
- /**
- * Event receiver callback. This method is called by the event admin service
- * when a event is received.
- *
- * @param event
- * the received event
- */
- public void handleEvent(Event event) {
- receiveEvent(event);
- }
-
- /**
- * Clear the eaten donuts list. (Useful before tests)
- */
- public void clearDonuts() {
- synchronized (m_donuts) {
- m_donuts.clear();
- }
- }
-
- /**
- * Get the first received donut and remove it from the eaten donut list.
- *
- * @return the first received donut or null if no donut is available
- */
- public Donut getDonut() {
- Donut donut = null;
- synchronized (m_donuts) {
- if (!m_donuts.isEmpty()) {
- donut = (Donut) m_donuts.remove(0);
- }
- }
- return donut;
- }
-
- /**
- * Get the whole list of eaten donuts.
- *
- * @return the array containing all eaten donuts
- */
- public Donut[] getAllDonuts() {
- Donut[] donuts = new Donut[0];
- synchronized (m_donuts) {
- donuts = (Donut[]) m_donuts.toArray(donuts);
- m_donuts.clear();
- }
- return donuts;
- }
-
- /**
- * Get the first donut if available or wait for an incoming donut. The
- * returned donut is removed from the eaten donut list.
- *
- * @return the first available donut.
- */
- public Donut waitForDonut() {
- Donut donut = null;
- synchronized (m_donuts) {
- while (donut == null) {
- if (m_donuts.isEmpty()) {
- try {
- m_donuts.wait();
- } catch (InterruptedException e) {
- // Thanks Checkstyle to forbid empty catch statements
- // ;-(
- }
- } else {
- donut = (Donut) m_donuts.remove(0);
- }
- }
- }
- return donut;
- }
-
- /**
- * Return the size of the eaten donut list.
- *
- * @return the size of the eaten donut list
- */
- public int getNumberOfDonuts() {
- int length;
- synchronized (m_donuts) {
- length = m_donuts.size();
- }
- return length;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTracker.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTracker.java
deleted file mode 100644
index eaca6c5..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTracker.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import org.osgi.service.event.Event;
-
-/**
- * Specification of an event tracker.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public interface EventTracker {
-
- /**
- * Clear the received events list. (Useful before tests)
- */
- void clearEvents();
-
- /**
- * Get the first received event and remove it from the events list.
- *
- * @return the first received event or null if no event is available
- */
- Event getEvent();
-
- /**
- * Get the whole list of received events.
- *
- * @return the array containing all received events
- */
- Event[] getAllEvents();
-
- /**
- * Get the first event if available or wait for an incoming event. The
- * returned event is removed from the eaten event list.
- *
- * @return the first available event.
- */
- Event waitForEvent();
-
- /**
- * Return the size of the events list.
- *
- * @return the size of the events list
- */
- int getNumberOfEvents();
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTrackerImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTrackerImpl.java
deleted file mode 100644
index cb46662..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/EventTrackerImpl.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
-
-/**
- * Implementation of an event tracker.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class EventTrackerImpl implements EventTracker, EventHandler {
-
- /**
- * The name of the event tracker.
- */
- private String m_name;
-
- /**
- * The list of received events
- */
- private List m_events = new ArrayList();
-
- /**
- * Event receiver callback. This method is called by the event admin service
- * when a event is received.
- *
- * @param event
- * the received event
- */
- public void handleEvent(Event event) {
- synchronized (m_events) {
- m_events.add(event);
- m_events.notify();
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Event received : " + event);
- }
- }
- }
-
- /**
- * Clear the received events list. (Useful before tests)
- */
- public void clearEvents() {
- synchronized (m_events) {
- m_events.clear();
- }
- }
-
- /**
- * Get the first received event and remove it from the events list.
- *
- * @return the first received event or null if no event is available
- */
- public Event getEvent() {
- Event event = null;
- synchronized (m_events) {
- if (!m_events.isEmpty()) {
- event = (Event) m_events.remove(0);
- }
- }
- return event;
- }
-
- /**
- * Get the whole list of received events.
- *
- * @return the array containing all received events
- */
- public Event[] getAllEvents() {
- Event[] events = new Event[0];
- synchronized (m_events) {
- events = (Event[]) m_events.toArray(events);
- m_events.clear();
- }
- return events;
- }
-
- /**
- * Get the first event if available or wait for an incoming event. The
- * returned event is removed from the eaten event list.
- *
- * @return the first available event.
- */
- public Event waitForEvent() {
- Event event = null;
- synchronized (m_events) {
- while (event == null) {
- if (m_events.isEmpty()) {
- try {
- m_events.wait();
- } catch (InterruptedException e) {
- // Thanks Checkstyle to forbid empty catch statements
- // ;-(
- }
- } else {
- event = (Event) m_events.remove(0);
- }
- }
- }
- return event;
- }
-
- /**
- * Return the size of the events list.
- *
- * @return the size of the events list
- */
- public int getNumberOfEvents() {
- int length;
- synchronized (m_events) {
- length = m_events.size();
- }
- return length;
- }
-
- /**
- * Return the string representation of a given event.
- *
- * @return the string representation of a given event
- */
- public static String eventToString(Event e) {
- StringBuilder buf = new StringBuilder();
- buf.append("[" + e.getTopic() + "] {");
-
- String[] properties = e.getPropertyNames();
- int n = properties.length - 1;
- for (int i = 0; i <= n; i++) {
- String name = properties[i];
- buf.append(name + "=" + e.getProperty(name));
- if (i != n)
- buf.append(", ");
- }
- buf.append("}");
- return buf.toString();
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/SyncEventProviderImpl.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/SyncEventProviderImpl.java
deleted file mode 100644
index b8bfc8b..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/donut/SyncEventProviderImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.donut;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Random;
-
-import org.apache.felix.ipojo.test.util.EahTestUtils;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-
-/**
- * Implementation of an event vendor that directly uses the Event Admin service
- * to send (synchronously) raw events.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class SyncEventProviderImpl implements DonutProvider {
-
- /**
- * The donut current serial number.
- */
- private long m_serial = 0L;
-
- /**
- * The name of the donut vendor.
- */
- private String m_name;
-
- /**
- * A random generator.
- */
- private Random m_random;
-
- /**
- * The Event Admin service reference.
- */
- private EventAdmin m_ea;
-
- /**
- * Construct a new donut provider. The initial serial number is randomly
- * generated.
- */
- public SyncEventProviderImpl() {
- m_random = new Random(System.currentTimeMillis());
- }
-
- /**
- * Sell a donut with a random flavour.
- *
- * @return the sold donut
- */
- public Donut sellDonut() {
- Dictionary rawEvent = new Hashtable();
- Donut donut = new Donut(m_serial++, m_name, Donut.FLAVOURS[m_random
- .nextInt(Donut.FLAVOURS.length)]);
- rawEvent.put("food", donut);
- m_ea.sendEvent(new Event("food/donuts", rawEvent));
- if (EahTestUtils.TRACE) {
- System.err.println("[" + this.getClass().getSimpleName() + ":"
- + m_name + "] Selling donut " + donut);
- }
- return donut;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java
deleted file mode 100644
index 7119584..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/EahTestUtils.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.util;
-
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.test.donut.Donut;
-import org.osgi.framework.BundleContext;
-
-/**
- * Useful variables used for the tests of the Event Admin Handler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class EahTestUtils {
-
- /**
- * Enable debug messages ?
- */
- public static final boolean TRACE = false;
-
- /**
- * The number of tests to execute.
- */
- public static final int NUMBER_OF_TESTS = 50;
-
- /**
- * The time that is normally necessary to cause a blacklist from the event
- * admin service.
- */
- public static final long BLACK_LIST_TIME = 5000L;
-
- /**
- * The long amount of time.
- */
- public static final long A_LONG_TIME = 1000L;
-
- /**
- * The bundle context.
- */
- private BundleContext m_context;
-
- /**
- * Construct a new Event Admin Handler Tests utility instance.
- *
- * @param context
- * the bundle context
- */
- public EahTestUtils(BundleContext context) {
- m_context = context;
- }
-
- /**
- * Return the (asynchronous) donut provider factory.
- *
- * @return the (asynchronous) donut provider factory
- */
- public Factory getDonutProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "donut-provider");
- }
-
- /**
- * Return the (asynchronous) donut provider using publishes factory.
- *
- * @return the (asynchronous) donut provider using publishes factory
- */
- public Factory getDonutProviderUsingPublishesFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "donut-provider-publishes");
- }
-
- /**
- * Return the synchronous donut provider factory.
- *
- * @return the synchronous donut provider factory
- */
- public Factory getSynchronousDonutProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "synchronous-donut-provider");
- }
-
- /**
- * Return the synchronous donut provider factory using
- * dataKey
- *
- * @return the synchronous donut provider factory
- */
- public Factory getSynchronousDonutProvider2Factory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "synchronous-donut-provider-2");
- }
-
- /**
- * Return the (asynchronous) donut event provider factory.
- *
- * @return the (asynchronous) donut event provider factory
- */
- public Factory getDonutEventProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "donut-event-provider");
- }
-
- /**
- * Return the synchronous donut event provider factory.
- *
- * @return the synchronous donut event provider factory
- */
- public Factory getSynchronousDonutEventProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "synchronous-donut-event-provider");
- }
-
- /**
- * Return the event provider factory.
- *
- * @return the event provider factory
- */
- public Factory getEventProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "event-provider");
- }
-
- /**
- * Return the synchronous event provider factory.
- *
- * @return the synchronous event provider factory
- */
- public Factory getSynchronousEventProviderFactory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "synchronous-event-provider");
- }
-
- /**
- * Return the donut consumer factory.
- *
- * @return the donut consumer factory
- */
- public Factory getDonutConsumerFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "donut-consumer");
- }
-
- /**
- * Return the donut consumer factory using dataKey
- * and dataType.
- *
- * @return the donut consumer factory
- */
- public Factory getDonutConsumer2Factory() {
- return IPojoTestUtils.getFactoryByName(m_context, "donut-consumer-2");
- }
-
- /**
- * Return the donut event consumer factory.
- *
- * @return the donut event consumer factory
- */
- public Factory getDonutEventConsumerFactory() {
- return IPojoTestUtils.getFactoryByName(m_context,
- "donut-event-consumer");
- }
-
- /**
- * Return the event consumer factory.
- *
- * @return the event consumer factory
- */
- public Factory getEventConsumerFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "event-consumer");
- }
-
- /**
- * Return the event tracker.
- *
- * @return the event consumer factory
- */
- public Factory getEventTrackerFactory() {
- return IPojoTestUtils.getFactoryByName(m_context, "event-tracker");
- }
-
- /**
- * Utility method that causes the current thread to sleep.
- *
- * @param millis
- * the number of milliseconds to wait
- */
- public static void sleep(long millis) {
- long past = System.currentTimeMillis();
- long future = past + millis;
- long now = past;
- if (TRACE) {
- System.err.println("Sleeping for " + millis + "ms");
- }
- while (now < future) {
- try {
- Thread.sleep(future - now);
- } catch (Exception e) {
- }
- now = System.currentTimeMillis();
- }
- }
-
- /**
- * Return the index of the given donut flavour in the flavour array.
- *
- * @return the index of the given flavour or -1 if not found
- */
- public static int flavourIndex(String flavour) {
- for (int i = 0; i < Donut.FLAVOURS.length; i++) {
- if (Donut.FLAVOURS[i].equals(flavour))
- return i;
- }
- return -1;
- }
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java b/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java
deleted file mode 100644
index cd4fdbb..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/java/org/apache/felix/ipojo/test/util/IPojoTestUtils.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-/**
- * Useful iPOJO methods used for the tests of the Event Admin Handler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class IPojoTestUtils {
-
- public static ComponentInstance getComponentInstance(BundleContext bc,
- String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName
- + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc,
- String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- return null;
- }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err
- .println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstanceByName(
- BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName
- + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (Factory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : "
- + e.getMessage());
- return null;
- }
- }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs == null) {
- return null;
- }
- return (Factory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : "
- + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory getHandlerFactoryByName(BundleContext bc,
- String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "("
- + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : "
- + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory[] getHandlerFactories(BundleContext bc) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(HandlerFactory.class.getName(), null);
- if (refs == null) {
- System.err.println("Cannot get the handler factories");
- return null;
- }
- HandlerFactory[] factories = new HandlerFactory[refs.length];
- for (int i = 0; i < factories.length; i++) {
- factories[i] = (HandlerFactory) bc.getService(refs[i]);
- }
- return factories;
- } catch (InvalidSyntaxException e) {
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf,
- String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf,
- String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf,
- String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf,
- String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc,
- String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc,
- String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
-}
diff --git a/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml b/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml
deleted file mode 100644
index 7f443fd..0000000
--- a/ipojo/tests/handler/eventadmin/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,180 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:ev="org.apache.felix.ipojo.handlers.event">
-
- <!-- The (asynchronous) donut provider -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
- name="donut-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Donut publisher -->
- <ev:publisher name="donut-publisher" field="m_publisher"
- topics="food/donuts" data-key="food" synchronous="false"/>
- </component>
-
- <!-- The (asynchronous) donut provider using publishes -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
- name="donut-provider-publishes">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Donut publisher -->
- <ev:publishes name="donut-publisher" field="m_publisher"
- topics="food/donuts" dataKey="food" synchronous="false"/>
- </component>
-
- <!-- The synchronous donut provider -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
- name="synchronous-donut-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Donut publisher -->
- <ev:publisher name="donut-publisher" field="m_publisher"
- topics="food/donuts" data-key="food" synchronous="true"/>
- </component>
-
- <!-- The synchronous donut provider using dataKey -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutProviderImpl"
- name="synchronous-donut-provider-2">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Donut publisher -->
- <ev:publisher name="donut-publisher" field="m_publisher"
- topics="food/donuts" dataKey="food" synchronous="true"/>
- </component>
-
- <!-- The (asynchronous) donut event provider -->
- <component
- classname="org.apache.felix.ipojo.test.donut.DonutEventProviderImpl"
- name="donut-event-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Raw events publisher -->
- <ev:publisher name="event-publisher" field="m_publisher"
- topics="food/donuts" synchronous="false"/>
- </component>
-
- <!-- The synchronous donut event provider -->
- <component
- classname="org.apache.felix.ipojo.test.donut.DonutEventProviderImpl"
- name="synchronous-donut-event-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Raw events publisher -->
- <ev:publisher name="event-publisher" field="m_publisher"
- topics="food/donuts" synchronous="true"/>
- </component>
-
- <!-- The (asynchronous) event provider -->
- <component
- classname="org.apache.felix.ipojo.test.donut.AsyncEventProviderImpl"
- name="event-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Direcly interacts with the Event Admin service -->
- <requires field="m_ea"/>
- </component>
-
- <!-- The synchronous event provider -->
- <component
- classname="org.apache.felix.ipojo.test.donut.SyncEventProviderImpl"
- name="synchronous-event-provider">
- <!-- Expose the donut provider service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutProvider">
- <property name="name" field="m_name" value="Unknown donut vendor"/>
- </provides>
- <!-- Direcly interacts with the Event Admin service -->
- <requires field="m_ea"/>
- </component>
-
- <!-- The donut consumer -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutConsumerImpl"
- name="donut-consumer">
- <!-- Expose the donut consumer service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutConsumer">
- <property name="name" field="m_name" value="Unknown donut consumer"/>
- <property name="slow" field="m_isSlow" value="false"/>
- </provides>
- <!-- Donut events subscriber -->
- <ev:subscriber name="donut-subscriber" callback="receiveDonut"
- topics="food/donuts" data-key="food"
- data-type="org.apache.felix.ipojo.test.donut.Donut"/>
- </component>
-
- <!-- The donut consumer using dataKey and dataType -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutConsumerImpl"
- name="donut-consumer-2">
- <!-- Expose the donut consumer service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutConsumer">
- <property name="name" field="m_name" value="Unknown donut consumer"/>
- <property name="slow" field="m_isSlow" value="false"/>
- </provides>
- <!-- Donut events subscriber -->
- <ev:subscriber name="donut-subscriber" callback="receiveDonut"
- topics="food/donuts" dataKey="food"
- dataType="org.apache.felix.ipojo.test.donut.Donut"/>
- </component>
-
-
- <!-- The donut event consumer -->
- <component classname="org.apache.felix.ipojo.test.donut.DonutConsumerImpl"
- name="donut-event-consumer">
- <!-- Expose the donut consumer service -->
- <provides specifications="org.apache.felix.ipojo.test.donut.DonutConsumer">
- <property name="name" field="m_name" value="Unknown donut consumer"/>
- <property name="slow" field="m_isSlow" value="false"/>
- </provides>
- <!-- Raw events subscriber -->
- <ev:subscriber name="donut-event-subscriber" callback="receiveEvent"
- topics="food/donuts"/>
- </component>
-
- <!-- The event consumer -->
- <component classname="org.apache.felix.ipojo.test.donut.EventConsumerImpl"
- name="event-consumer">
- <!-- Expose the donut consumer service -->
- <provides
- specifications="{org.apache.felix.ipojo.test.donut.DonutConsumer,org.osgi.service.event.EventHandler}">
- <property name="name" field="m_name" value="Unknown event consumer"/>
- <property name="slow" field="m_isSlow" value="false"/>
- <property name="event.topics" type="String" value="food/donuts"/>
- </provides>
- </component>
-
- <!-- The event tracker -->
- <component classname="org.apache.felix.ipojo.test.donut.EventTrackerImpl"
- name="event-tracker">
- <!-- Expose the donut consumer service -->
- <provides
- specifications="{org.apache.felix.ipojo.test.donut.EventTracker,org.osgi.service.event.EventHandler}">
- <property name="name" field="m_name" value="Unknown event tracker"/>
- <property name="event.topics" type="String" value="food/donuts"/>
- </provides>
- </component>
-
-
- <!-- Example instances -->
- <instance component="donut-provider" name="zeifhgbzre">
- <property name="name" value="Zeifhgbzre donuts"/>
- </instance>
- <instance component="donut-consumer" name="zeifhgbzre simpson">
- <property name="name" value="Zeifhgbzre simpson"/>
- <property name="slow" value="false"/>
- </instance>
-
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/jmx/pom.xml b/ipojo/tests/handler/jmx/pom.xml
deleted file mode 100644
index 51d9697..0000000
--- a/ipojo/tests/handler/jmx/pom.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <groupId>ipojo.tests</groupId>
- <version>1.5.0-SNAPSHOT</version>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO JMX Handler Test Suite</name>
- <artifactId>tests.jmx.handler</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.jmx</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Private-Package>org.apache.felix.ipojo.test.*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.JmxTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>false</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <hideOutputs>false</hideOutputs>
- <logService>false</logService>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/JmxTestSuite.java b/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/JmxTestSuite.java
deleted file mode 100644
index 51ba0fb..0000000
--- a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/JmxTestSuite.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-/**
- * Event Admin Handler test suite.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class JmxTestSuite {
-
- /**
- * Generate the Event Admin Handler test suite.
- *
- * @param bc
- * the OSGi bundle context
- * @return the Event Admin Handler test suite.
- */
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("JMX Handler test suite",
- bc);
- ots.addTestSuite(MBeanTests.class);
- return ots;
- }
-
-}
\ No newline at end of file
diff --git a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/MBeanTests.java b/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/MBeanTests.java
deleted file mode 100644
index f1a91ee..0000000
--- a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/MBeanTests.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test;
-
-import java.lang.management.ManagementFactory;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-
-/**
- * Test the good behaviour of the EventAdminHandler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class MBeanTests extends OSGiTestCase {
-
- /**
- * Helper used to create test components.
- */
- private IPOJOHelper m_helper;
-
- /**
- * The MBean server used to access exposed MBeans.
- */
- private MBeanServer m_server;
-
- /**
- * Initialize test.
- */
- public void setUp() {
- m_helper = new IPOJOHelper(this);
- m_server = ManagementFactory.getPlatformMBeanServer();
- }
-
- /**
- * Clean test.
- */
- public void tearDown() {
- m_helper.dispose();
- }
-
- /**
- * Test the MBean exposed by the simple component, defined without
- * annotations and with the brand new JMX handler syntax.
- */
- public void testMBeanWithoutAnnotations() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ListenerNotFoundException, ReflectionException, MBeanException {
- // Create an instance of the component
- ComponentInstance componentInstance = m_helper
- .createComponentInstance("org.apache.felix.ipojo.test.component.SimpleManagedComponent");
- String instanceName = componentInstance.getInstanceName();
- ObjectName objectName = new ObjectName(
- "org.apache.felix.ipojo.test.component:type=org.apache.felix.ipojo.test.component.SimpleManagedComponent,instance="
- + instanceName);
- doTest(objectName);
- }
-
- /**
- * Test the MBean exposed by the simple component, defined without
- * annotations and with the deprecated JMX handler syntax.
- */
- public void testMBeanWithoutAnnotationsDeprecated() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ListenerNotFoundException, ReflectionException, MBeanException {
- // Create an instance of the component
- ComponentInstance componentInstance = m_helper
- .createComponentInstance("org.apache.felix.ipojo.test.component.SimpleManagedComponentDeprecated");
- String instanceName = componentInstance.getInstanceName();
- ObjectName objectName = new ObjectName(
- "org.apache.felix.ipojo.test.component:type=org.apache.felix.ipojo.test.component.SimpleManagedComponent,instance="
- + instanceName);
- doTest(objectName);
- }
-
-
- /**
- * Test the MBean exposed by the simple component, defined with
- * annotations.
- */
- public void testMBeanWithAnnotations() throws MalformedObjectNameException, IntrospectionException,
- InstanceNotFoundException, ListenerNotFoundException,
- ReflectionException, MBeanException {
- // Create an instance of the component
- ComponentInstance componentInstance = m_helper
- .createComponentInstance("org.apache.felix.ipojo.test.component.SimpleManagedComponentAnnotated");
- String instanceName = componentInstance.getInstanceName();
- ObjectName objectName = new ObjectName(
- "org.apache.felix.ipojo.test.component:type=org.apache.felix.ipojo.test.component.SimpleManagedComponentAnnotated,instance="
- + instanceName);
- doTest(objectName);
- }
-
- /**
- * Test the MBean exposed by the simple component, defined with
- * annotations.
- */
- public void testMBeanWithAnnotationsDeprecated() throws MalformedObjectNameException, IntrospectionException,
- InstanceNotFoundException, ListenerNotFoundException,
- ReflectionException, MBeanException {
- // Create an instance of the component
- ComponentInstance componentInstance = m_helper
- .createComponentInstance("org.apache.felix.ipojo.test.component.SimpleManagedComponentAnnotatedDeprecated");
- String instanceName = componentInstance.getInstanceName();
- ObjectName objectName = new ObjectName(
- "org.apache.felix.ipojo.test.component:type=org.apache.felix.ipojo.test.component.SimpleManagedComponentAnnotatedDeprecated,instance="
- + instanceName);
- doTest(objectName);
- }
-
- /**
- * Utility method used to test the MBean with the given objectName.
- * @param objectName the objectName of the MBean to test.
- */
- private void doTest(ObjectName objectName) throws IntrospectionException, InstanceNotFoundException, ReflectionException, MBeanException, ListenerNotFoundException {
-
- // Get the MBean from the platform MBean server
-
- MBeanInfo mBeanInfo = m_server.getMBeanInfo(objectName);
- ObjectInstance objectInstance = m_server.getObjectInstance(objectName);
- assertNotNull(mBeanInfo);
- assertNotNull(objectInstance);
- // Check that the property is exposed
- MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
- assertEquals(1, attributes.length);
- MBeanAttributeInfo attribute = attributes[0];
- assertEquals("integer", attribute.getName());
- assertEquals("int", attribute.getType());
- assertTrue(attribute.isReadable());
- assertFalse(attribute.isWritable());
- // Check that both methods are exposed
- MBeanOperationInfo[] operations = mBeanInfo.getOperations();
- assertEquals(2, operations.length);
- MBeanOperationInfo getOperation;
- MBeanOperationInfo setOperation;
- // Order is not important
- if (operations[0].getName().equals("getIntegerValue")) {
- getOperation = operations[0];
- setOperation = operations[1];
- } else {
- setOperation = operations[0];
- getOperation = operations[1];
- }
- // Check the 'get' operation
- assertEquals("getIntegerValue", getOperation.getName());
- assertEquals("Get the value of the integer",
- getOperation.getDescription());
- assertEquals("int", getOperation.getReturnType());
- MBeanParameterInfo[] getOperationParams = getOperation.getSignature();
- assertEquals(0, getOperationParams.length);
- // Check the 'set' operation
- assertEquals("setIntegerValue", setOperation.getName());
- assertEquals("Set the value of the integer",
- setOperation.getDescription());
- assertEquals("int", setOperation.getReturnType());
- MBeanParameterInfo[] setOperationParams = setOperation.getSignature();
- assertEquals(1, setOperationParams.length);
- assertEquals("int", setOperationParams[0].getType());
- // Call the methods and test the result, also test notifications
- CustomNotificationListener listener = new CustomNotificationListener();
- m_server.addNotificationListener(objectName, listener, null, null);
- int value1 = 123;
- int value2 = 456;
- m_server.invoke(objectName, "setIntegerValue", new Object[] { value1 },
- new String[] { "int" });
- m_server.invoke(objectName, "setIntegerValue", new Object[] { value2 },
- new String[] { "int" });
- int result = (Integer) m_server.invoke(objectName, "getIntegerValue",
- new Object[0], new String[0]);
- assertEquals(value2, result);
- m_server.removeNotificationListener(objectName, listener, null, null);
- //assertEquals(2, listener.getCount());
- }
-
- /**
- * Custom listener used to count MBean notifications.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
- private class CustomNotificationListener implements NotificationListener {
-
- /**
- * Counter for the notifications.
- */
- private int m_counter = 0;
-
- /**
- * Notified !
- * @param notification the notification
- * @param handback ignored
- */
- public void handleNotification(Notification notification,
- Object handback) {
- m_counter++;
- }
-
- /**
- * Return the notification count of this listener.
- * @return the notification count of this listener.
- */
- public int getCount() {
- return m_counter;
- }
- }
-
-}
diff --git a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponent.java b/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponent.java
deleted file mode 100644
index 2a22a9b..0000000
--- a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.component;
-
-import java.util.Random;
-
-/**
- * Simple component that holds an integer. It is exposed as a MBean.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class SimpleManagedComponent {
-
- /**
- * The integer.
- */
- private int m_integer /*= new Random().nextInt()*/;
-
- /**
- * Set the value of the integer.
- * @param newValue the new value
- * @return the old value of the integer.
- */
- @SuppressWarnings("unused")
- private synchronized int setIntegerValue(int newValue) {
- int oldValue = m_integer;
- m_integer = newValue;
- return oldValue;
- }
-
- /**
- * Get the value of the integer.
- * @return the currentvalue of the integer.
- */
- @SuppressWarnings("unused")
- private synchronized int getIntegerValue() {
- return m_integer;
- }
-
-}
diff --git a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotated.java b/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotated.java
deleted file mode 100644
index 398948e..0000000
--- a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotated.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.component;
-
-import java.util.Random;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.jmx.JMXBean;
-import org.apache.felix.ipojo.handlers.jmx.JMXMethod;
-import org.apache.felix.ipojo.handlers.jmx.JMXProperty;
-
-/**
- * Simple component that holds an integer. It is exposed as a MBean. This
- * version uses the brand new annotations of the JMX handler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-@Component(immediate = true)
-@JMXBean
-public class SimpleManagedComponentAnnotated {
-
- /**
- * The integer.
- */
- @JMXProperty(name = "integer", rights = "r", notification = true)
- private int m_integer = new Random().nextInt();;
-
- /**
- * Set the value of the integer.
- *
- * @param newValue
- * the new value
- * @return the old value of the integer.
- */
- @SuppressWarnings("unused")
- @JMXMethod(description = "Set the value of the integer")
- private synchronized int setIntegerValue(int newValue) {
- int oldValue = m_integer;
- m_integer = newValue;
- return oldValue;
- }
-
- /**
- * Get the value of the integer.
- *
- * @return the currentvalue of the integer.
- */
- @SuppressWarnings("unused")
- @JMXMethod(description = "Get the value of the integer")
- private synchronized int getIntegerValue() {
- return m_integer;
- }
-}
diff --git a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotatedDeprecated.java b/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotatedDeprecated.java
deleted file mode 100644
index 716514b..0000000
--- a/ipojo/tests/handler/jmx/src/main/java/org/apache/felix/ipojo/test/component/SimpleManagedComponentAnnotatedDeprecated.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.component;
-
-import java.util.Random;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.handlers.jmx.Config;
-import org.apache.felix.ipojo.handlers.jmx.Method;
-import org.apache.felix.ipojo.handlers.jmx.Property;
-
-
-/**
- * Simple component that holds an integer. It is exposed as a MBean. This
- * version uses the deprecated annotations of the JMX handler.
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-@Component(immediate = true)
-@Config
-public class SimpleManagedComponentAnnotatedDeprecated {
-
- /**
- * The integer.
- */
- @Property(name = "integer", rights = "r", notification = true)
- private int m_integer = new Random().nextInt();;
-
- /**
- * Set the value of the integer.
- *
- * @param newValue
- * the new value
- * @return the old value of the integer.
- */
- @SuppressWarnings("unused")
- @Method(description = "Set the value of the integer")
- private synchronized int setIntegerValue(int newValue) {
- int oldValue = m_integer;
- m_integer = newValue;
- return oldValue;
- }
-
- /**
- * Get the value of the integer.
- *
- * @return the currentvalue of the integer.
- */
- @SuppressWarnings("unused")
- @Method(description = "Get the value of the integer")
- private synchronized int getIntegerValue() {
- return m_integer;
- }
-}
diff --git a/ipojo/tests/handler/jmx/src/main/resources/metadata.xml b/ipojo/tests/handler/jmx/src/main/resources/metadata.xml
deleted file mode 100644
index cbc7b03..0000000
--- a/ipojo/tests/handler/jmx/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:jmx="org.apache.felix.ipojo.handlers.jmx">
-
- <!-- The simple managed component without annotations and with brand new JMX handler syntax -->
- <component classname="org.apache.felix.ipojo.test.component.SimpleManagedComponent" immediate="true">
- <!-- Expose field and methods with JMX handler -->
- <jmx:config>
- <jmx:jmxmethod name="getIntegerValue" description="Get the value of the integer"/>
- <jmx:jmxmethod name="setIntegerValue" description="Set the value of the integer"/>
- <jmx:jmxproperty name="integer" field="m_integer" rights="r" notification="true"/>
- </jmx:config>
- </component>
-
- <!-- The simple managed component without annotations and with brand new JMX handler syntax -->
- <component classname="org.apache.felix.ipojo.test.component.SimpleManagedComponent" immediate="true" name="org.apache.felix.ipojo.test.component.SimpleManagedComponentDeprecated">
- <!-- Expose field and methods with JMX handler -->
- <jmx:config>
- <jmx:method name="getIntegerValue" description="Get the value of the integer"/>
- <jmx:method name="setIntegerValue" description="Set the value of the integer"/>
- <jmx:property name="integer" field="m_integer" rights="r" notification="true"/>
- </jmx:config>
- </component>
-
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/temporal/pom.xml b/ipojo/tests/handler/temporal/pom.xml
deleted file mode 100644
index f2e7559..0000000
--- a/ipojo/tests/handler/temporal/pom.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Temporal Dependency Test Suite</name>
- <artifactId>tests.temporal</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.temporal.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.temporal</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.temporal.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.temporal.TemporalTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
deleted file mode 100644
index b654826..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class CheckServiceProvider implements CheckService {
-
- /**
- * Temporal dependency.
- */
- private FooService fs;
-
- public boolean check() {
- if (fs != null) {
- return fs.foo();
- }
- return false;
- }
-
- public Properties getProps() {
- if (fs != null) {
- return fs.fooProps();
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckServiceProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckServiceProvider.java
deleted file mode 100644
index 03c5776..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckServiceProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class CollectionCheckServiceProvider implements CheckService {
-
- /**
- * Temporal dependency.
- */
- private Collection fs;
-
- public boolean check() {
- boolean result = true;
- //Use a local variable to avoid to wait at each access.
- Collection col = fs;
- if (col != null) {
- Iterator it = col.iterator();
- while (it.hasNext()) {
- FooService svc = (FooService) it.next();
- result = result && svc.foo();
- }
- }
- return result;
- }
-
- public Properties getProps() {
- Iterator it = fs.iterator();
- if (it.hasNext()) {
- FooService svc = (FooService) it.next();
- return svc.fooProps();
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java
deleted file mode 100644
index 7bd5540..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class FooProvider implements FooService {
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return 0;
- }
-
- public int getInt() {
- return 0;
- }
-
- public long getLong() {
- return 0;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java
deleted file mode 100644
index fb96538..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class MultipleCheckServiceProvider implements CheckService {
-
- /**
- * Temporal dependency.
- */
- private FooService[] fs;
-
- public boolean check() {
- boolean result = true;
- //Use a local variable to avoid to wait at each access.
- FooService[] array = fs;
- for (int i = 0; array != null && i < array.length; i++) {
- result = result && array[i].foo();
- System.out.println("Result : " + result);
- }
- return result;
- }
-
- public Properties getProps() {
- return fs[0].fooProps();
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableFooProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableFooProvider.java
deleted file mode 100644
index 821c8c8..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NullableFooProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class NullableFooProvider implements FooService {
-
- public boolean foo() {
- return false;
- }
-
- public Properties fooProps() {
- return null;
- }
-
- public boolean getBoolean() {
- return false;
- }
-
- public double getDouble() {
- return -1;
- }
-
- public int getInt() {
- return -1;
- }
-
- public long getLong() {
- return -1;
- }
-
- public Boolean getObject() {
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CheckServiceProviderHelper.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CheckServiceProviderHelper.java
deleted file mode 100755
index 0f1e8d3..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CheckServiceProviderHelper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class CheckServiceProviderHelper implements CheckService {
-
- /**
- * injected dependency.
- */
- private FooService fs;
-
- public CheckServiceProviderHelper(FooService svc) {
- fs = svc;
- }
-
- public boolean check() {
- if (fs != null) { // Cannot be null
- try {
- return fs.foo();
- } catch (RuntimeException e) { // Now it's a runtime exception (FELIX-2472)
- // Can throw a RTE for null policy and for time out
- if (e.getMessage().equals("No service available")) {
- // Has detected a null policy.
- System.out.println(e.getMessage());
- return false;
- } else {
- // Timeout
- // Propagate the exception
- throw e;
- }
- }
- }
- return false;
- }
-
- public Properties getProps() {
- if (fs != null) {
- return fs.fooProps();
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CollectionCheckServiceProviderHelper.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CollectionCheckServiceProviderHelper.java
deleted file mode 100644
index 9344722..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/CollectionCheckServiceProviderHelper.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.proxy;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class CollectionCheckServiceProviderHelper implements CheckService {
-
- /**
- * Injected dependency.
- */
- private Collection fs;
-
- public CollectionCheckServiceProviderHelper(Collection col) {
- fs = col;
- }
-
- public boolean check() {
- boolean result = true;
- //Use a local variable to avoid to wait at each access.
- Collection col = fs;
- if (col != null) {
- Iterator it = col.iterator(); // Get the cached copy
- while (it != null && it.hasNext()) {
- FooService svc = (FooService) it.next();
- result = result && svc.foo();
- }
- }
- return result;
- }
-
- public Properties getProps() {
- Iterator it = fs.iterator();
- if (it.hasNext()) {
- FooService svc = (FooService) it.next();
- return svc.fooProps();
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCheckServiceProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCheckServiceProvider.java
deleted file mode 100755
index f4b4099..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCheckServiceProvider.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.proxy;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-
-public class HelpedCheckServiceProvider implements CheckService {
-
- /**
- * Temporal dependency.
- */
- private FooService fs;
-
- private CheckServiceProviderHelper helper = new CheckServiceProviderHelper(fs);
-
- public boolean check() {
- return helper.check();
- }
-
- public Properties getProps() {
- return helper.getProps();
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCollectionCheckServiceProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCollectionCheckServiceProvider.java
deleted file mode 100644
index f0c0e5d..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/component/proxy/HelpedCollectionCheckServiceProvider.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.proxy;
-
-import java.util.Collection;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-
-public class HelpedCollectionCheckServiceProvider implements CheckService {
-
- /**
- * Temporal dependency.
- */
- private Collection fs;
-
- private CollectionCheckServiceProviderHelper helper = new CollectionCheckServiceProviderHelper(fs);
-
- public boolean check() {
- return helper.check();
- }
-
- public Properties getProps() {
- return helper.getProps();
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DefaultImplementationTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DefaultImplementationTest.java
deleted file mode 100644
index bf3e7b0..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DefaultImplementationTest.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DefaultImplementationTest extends OSGiTestCase {
-
- public void testDefaultImplementation() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DICheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDefaultImplementationWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDefaultImplementationTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DICheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDefaultImplementationTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DICheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIProxiedCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDefaultImplementationMultipleTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDefaultImplementationCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDefaultImplementationProxiedCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-DIProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayOnMultipleDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained DI will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained DI will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnProxiedCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained DI will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java
deleted file mode 100644
index bbd6a5c..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class DelayTest extends OSGiTestCase {
-
- public void testDelay() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- assertNull("No FooService", Utils.getServiceReference(context, FooService.class.getName(), null));
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
-
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay (" + (end - begin) + ")", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
-
- public void testTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 4000);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 4000);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testDelayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testSetTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testSetTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
- public void testDelayOnMultipleDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-MultipleCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
-
- public void testDelayOnCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
-
- public void testDelayOnProxiedCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java
deleted file mode 100644
index a5c508e..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-
-public class DelayedProvider implements Runnable {
-
-
- public static final long DELAY = 1000;
- ComponentInstance instance;
- long delay = DELAY;
- Thread thread;
-
- public DelayedProvider(ComponentInstance ci) {
- instance =ci;
- }
-
- public DelayedProvider(ComponentInstance ci, long time) {
- instance =ci;
- delay = time;
- }
-
- public void start() {
- thread = new Thread(this);
- thread.start();
- }
-
- public void stop() {
- if (thread != null) {
- thread.interrupt();
- }
- }
-
- public void run() {
- System.out.println("Start sleeping for " + delay);
- long begin = System.currentTimeMillis();
- try {
- Thread.sleep(delay);
- long end = System.currentTimeMillis();
- if (end - begin < delay) {
- // Wait for the remaining time
- Thread.sleep(delay - (end - begin));
- }
- } catch (InterruptedException e) {
- System.out.println("Interrupted ...");
- return;
- }
- System.out.println("Wakeup");
- thread = null;
- instance.start();
- System.out.println(instance.getInstanceName() + " started");
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyTest.java
deleted file mode 100755
index 1ecf5bf..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class EmptyTest extends OSGiTestCase {
-
- public void testEmptyArrayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("An empty array was expected ...");
- }
- assertTrue("Check empty array", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testEmptyCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("An empty array was expected ...");
- }
- assertTrue("Check empty array", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testEmptyProxiedCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("An empty array was expected ...");
- }
- assertTrue("Check empty array", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayOnMultipleDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnProxiedCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyProxiedColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/FilterTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/FilterTest.java
deleted file mode 100644
index c8a0cd7..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/FilterTest.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-/**
- * Checks <tt>requires.filter</tt>, <tt>temporal.filter</tt>, <tt>temporal.from</tt> and
- * <tt>requires.from</tt> attributes.
- */
-public class FilterTest extends OSGiTestCase {
-
- /**
- * Checks <tt>temporal.filter</tt> with dependency id.
- * The filter is made to get only one provider.
- */
- public void testWithTemporalFilters() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-
- Dictionary configuration = new Hashtable();
- String un = "under-1";
- configuration.put("instance.name", un);
- Dictionary filter = new Hashtable();
- filter.put("foo", "(instance.name=provider2)");
- configuration.put("temporal.filters", filter);
- ComponentInstance under = Utils.getComponentInstance(context, "TEMPORAL-MultipleCheckServiceProvider", configuration);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- /**
- * Checks <tt>requires.filter</tt> with dependency id.
- * The filter is made to get only one provider.
- */
- public void testWithRequireFilters() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-
- Dictionary configuration = new Hashtable();
- String un = "under-1";
- configuration.put("instance.name", un);
- Dictionary filter = new Hashtable();
- filter.put("foo", "(instance.name=provider2)");
- configuration.put("requires.filters", filter);
- ComponentInstance under = Utils.getComponentInstance(context, "TEMPORAL-MultipleCheckServiceProvider", configuration);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- /**
- * Checks <tt>temporal.from</tt> with dependency id.
- * The filter is made to get only one specific provider.
- */
- public void testWithTemporalFrom() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-
- Dictionary configuration = new Hashtable();
- String un = "under-1";
- configuration.put("instance.name", un);
- Dictionary filter = new Hashtable();
- filter.put("foo", "provider2");
- configuration.put("temporal.from", filter);
- ComponentInstance under = Utils.getComponentInstance(context, "TEMPORAL-MultipleCheckServiceProvider", configuration);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- /**
- * Checks <tt>requires.from</tt> with dependency id.
- * The filter is made to get only one specific provider.
- */
- public void testWithRequiresFrom() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-
- Dictionary configuration = new Hashtable();
- String un = "under-1";
- configuration.put("instance.name", un);
- Dictionary filter = new Hashtable();
- filter.put("foo", "provider2");
- configuration.put("requires.from", filter);
- ComponentInstance under = Utils.getComponentInstance(context, "TEMPORAL-MultipleCheckServiceProvider", configuration);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider1.stop();
- provider2.stop();
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java
deleted file mode 100644
index 0e31841..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class NoDelayTest extends OSGiTestCase {
-
- public void testNoDelay() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
- assertNotNull("Check creation", under);
- assertNotNull("Check provider creation", prov);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNoDelayWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProvider", un);
- assertNotNull("Check creation", under);
- assertNotNull("Check provider creation", prov);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testMultipleNoDelay() {
- String prov1 = "provider-1";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov1);
- String un = "under-2";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-MultipleCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov1);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- provider1.stop();
- provider1.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testCollectionNoDelay() {
- String prov1 = "provider-1";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov1);
- String un = "under-2";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov1);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- provider1.stop();
- provider1.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testProxiedCollectionNoDelay() {
- String prov1 = "provider-1";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov1);
- String un = "under-2";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedColCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov1);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- provider1.stop();
- provider1.dispose();
- under.stop();
- under.dispose();
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java
deleted file mode 100644
index 81ad5b0..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class NullTest extends OSGiTestCase {
-
- public void testNull() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A null was expected ...");
- }
- assertFalse("Check null", res); // Return false when the foo service is null.
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A null was expected ...");
- }
- assertFalse("Check null", res); // Return false when the foo service is null.
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullProxiedCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullMultipleTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A null was expected ...");
- }
- assertTrue("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testNullCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A null was expected ...");
- }
- assertTrue("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testNullProxiedCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A null was expected ... : " + e.getMessage());
- e.printStackTrace();
- }
- assertTrue("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayOnMultipleDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnProxiedCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java
deleted file mode 100644
index b4a4c04..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class NullableTest extends OSGiTestCase {
-
- public void testNullable() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullableTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullableWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullableTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedCheckServiceProvider", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testNullableMultipleTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testNullableCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testNullableProxiedCollectionTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- boolean res = false;
- try {
- res = cs.check();
- } catch(RuntimeException e) {
- fail("A nullable was expected ...");
- }
- assertFalse("Check nullable", res);
-
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- public void testDelayOnMultipleDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayOnProxiedCollectionDependency() {
- String prov = "provider";
- ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String prov2 = "provider2";
- ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the providers.
- provider1.stop();
- provider2.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider1, 1500);
- DelayedProvider dp2 = new DelayedProvider(provider2, 100);
- dp.start();
- dp2.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
- System.out.println("delay = " + (end - begin));
- assertTrue("Assert min delay", (end - begin) >= 100);
- assertTrue("Assert max delay", (end - begin) <= 1000);
- dp.stop();
- dp2.stop();
-
- provider1.stop();
- provider2.stop();
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
-
- assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
-
- provider1.dispose();
- provider2.dispose();
- under.stop();
- under.dispose();
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTest.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTest.java
deleted file mode 100644
index b8d884d..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTest.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class TemporalTest extends OSGiTestCase {
-
- public void testDelay() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- assertNull("No FooService", Utils.getServiceReference(context, FooService.class.getName(), null));
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
-
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay (" + (end - begin) + ")", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
-
- public void testTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 4000);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 4000);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testDelayTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeoutUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testDelayTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- long begin = System.currentTimeMillis();
- DelayedProvider dp = new DelayedProvider(provider, 200);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 2", cs.check());
- long end = System.currentTimeMillis();
-
- assertTrue("Assert delay", (end - begin) >= 200);
-
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 3", ref_cs);
- cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation - 3", cs.check());
-
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- }
-
- public void testSetTimeout() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeoutUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-
-
- public void testSetTimeoutWithProxy() {
- String prov = "provider";
- ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
- String un = "under-1";
- ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal", un);
-
- ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
- assertNotNull("Check foo availability", ref_fs);
-
- ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability", ref_cs);
-
- CheckService cs = (CheckService) context.getService(ref_cs);
- assertTrue("Check invocation", cs.check());
-
- // Stop the provider.
- provider.stop();
- ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
- assertNotNull("Check cs availability - 2", ref_cs);
- DelayedProvider dp = new DelayedProvider(provider, 400);
- dp.start();
- cs = (CheckService) context.getService(ref_cs);
- try {
- cs.check();
- } catch(RuntimeException e) {
- // OK
- dp.stop();
- provider.stop();
- provider.dispose();
- under.stop();
- under.dispose();
- return;
- }
-
- fail("Timeout expected");
- }
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java
deleted file mode 100644
index ebc01b6..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class TemporalTestSuite extends TestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Temporal Dependency Test Suite", bc);
- ots.addTestSuite(NoDelayTest.class);
- ots.addTestSuite(DelayTest.class);
- ots.addTestSuite(NullableTest.class);
- ots.addTestSuite(DefaultImplementationTest.class);
- ots.addTestSuite(NullTest.class);
- ots.addTestSuite(EmptyTest.class);
- ots.addTestSuite(TemporalTest.class);
- ots.addTestSuite(FilterTest.class);
- return ots;
- }
-
-}
-
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java
deleted file mode 100644
index 9e058c9..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java
deleted file mode 100644
index f8ec6ca..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java
deleted file mode 100644
index 9aec761..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-public interface ChildInterface extends ParentInterface1, ParentInterface2 {
-
- public void processChild();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java
deleted file mode 100644
index 52537a1..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java
deleted file mode 100644
index 373ba7e..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-public interface ParentInterface1 extends ParentParentInterface {
-
- public void processParent1();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java
deleted file mode 100644
index 5ec4d0a..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-public interface ParentInterface2 {
-
- public void processParent2();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java
deleted file mode 100644
index c4bcf4d..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.temporal.service;
-
-public interface ParentParentInterface {
-
- public void processParentParent();
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index 0af896b..0000000
--- a/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Element getMetatadata(BundleContext bc, String component) {
- String elem = (String) bc.getBundle().getHeaders().get("iPOJO-Components");
- Assert.assertNotNull("iPOJO Components exists", elem);
- try {
- Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
- Element[] childs = element.getElements("component");
- for (int i = 0; i < childs.length; i++) {
- String name = childs[i].getAttribute("name");
- String clazz = childs[i].getAttribute("classname");
- if (name != null && name.equalsIgnoreCase(component)) {
- return childs[i];
- }
- if (clazz.equalsIgnoreCase(component)) {
- return childs[i];
- }
- }
- Assert.fail("Component " + component + " not found in " + bc.getBundle().getSymbolicName());
- } catch (ParseException e) {
- Assert.fail("Cannot parse the components from " + bc.getBundle().getSymbolicName() + ": " + e.getMessage());
- }
-
- return null;
-
- }
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/handler/temporal/src/main/resources/metadata.xml b/ipojo/tests/handler/temporal/src/main/resources/metadata.xml
deleted file mode 100644
index 42262d8..0000000
--- a/ipojo/tests/handler/temporal/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,246 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd
- org.apache.felix.ipojo.handler.temporal http://felix.apache.org/ipojo/schemas/SNAPSHOT/temporal.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:temp="org.apache.felix.ipojo.handler.temporal">
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProvider">
- <temp:requires field="fs"/>
- <provides/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderUsingTemporal">
- <temp:temporal field="fs"/>
- <provides/>
- </component>
-
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProvider">
- <temp:requires field="fs" proxy="true"/>
- <provides/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderUsingTemporal">
- <temp:temporal field="fs" proxy="true"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300"/>
- <provides/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderTimeoutUsingTemporal">
- <temp:temporal field="fs" timeout="300"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" timeout="300"/>
- <provides/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal">
- <temp:temporal field="fs" proxy="true" timeout="300"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-MultipleCheckServiceProvider">
- <temp:requires field="fs" id="foo"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-ColCheckServiceProvider">
- <temp:requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-ProxiedColCheckServiceProvider">
- <temp:requires field="fs" proxy="true" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.FooProvider" name="TEMPORAL-FooProvider">
- <provides/>
- </component>
-
- <!-- Dependencies using nullables -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-NullableMultipleCheckServiceProvider">
- <temp:requires field="fs" onTimeout="nullable"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-NullableColCheckServiceProvider">
- <temp:requires field="fs" onTimeout="nullable" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullableProxiedColCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="nullable" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-NullableCheckServiceProvider">
- <temp:requires field="fs" onTimeout="nullable"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullableProxiedCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="nullable"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-NullableCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="nullable"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullableProxiedCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" onTimeout="nullable" timeout="300"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-NullableMultipleCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="nullable"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-NullableColCheckServiceProviderTimeout">
- <temp:requires field="fs" onTimeout="nullable" timeout="300" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullableProxiedColCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" onTimeout="nullable" timeout="300" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <!-- Dependencies using default implementation -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-DIMultipleCheckServiceProvider">
- <temp:requires field="fs" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-DIColCheckServiceProvider">
- <temp:requires field="fs" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-DIProxiedColCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-DICheckServiceProvider">
- <temp:requires field="fs" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-DIProxiedCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-DICheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-DIProxiedCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" timeout="300" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-DIMultipleCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-DIColCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-DIProxiedColCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" timeout="300" onTimeout="org.apache.felix.ipojo.test.scenarios.component.NullableFooProvider" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <!-- Dependencies using null -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-NullMultipleCheckServiceProvider">
- <temp:requires field="fs" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-NullColCheckServiceProvider">
- <temp:requires field="fs" onTimeout="null" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullProxiedColCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="null" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-NullCheckServiceProvider">
- <temp:requires field="fs" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullProxiedCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-NullCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullProxiedCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" timeout="300" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-NullMultipleCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="null"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-NullColCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="null" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullProxiedColCheckServiceProviderTimeout">
- <temp:requires field="fs" proxy="true" timeout="300" onTimeout="null" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <!-- Dependencies using empty arrays -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-EmptyMultipleCheckServiceProvider">
- <temp:requires field="fs" onTimeout="empty-array"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-EmptyColCheckServiceProvider">
- <temp:requires field="fs" onTimeout="empty" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-EmptyProxiedColCheckServiceProvider">
- <temp:requires field="fs" proxy="true" onTimeout="empty" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-EmptyMultipleCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="empty-array"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckServiceProvider" name="TEMPORAL-EmptyColCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" onTimeout="empty" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.scenarios.component.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-EmptyProxiedColCheckServiceProviderTimeout">
- <temp:requires field="fs" timeout="300" proxy="true" onTimeout="empty" specification="org.apache.felix.ipojo.test.scenarios.temporal.service.FooService"/>
- <provides/>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/pom.xml b/ipojo/tests/handler/transaction/pom.xml
deleted file mode 100644
index 9c355ca..0000000
--- a/ipojo/tests/handler/transaction/pom.xml
+++ /dev/null
@@ -1,173 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.transactions</artifactId>
- <packaging>jar</packaging>
- <version>1.5.0-SNAPSHOT</version>
- <name>iPOJO Transaction Handler Test Suite</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- <version>${ipojo.core.release}</version>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.transaction</groupId>
- <artifactId>geronimo-transaction-service</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.transaction</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- </dependency>
- <!-- Pax Exam API: -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- </dependency>
- <!-- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a default
- container that uses [Pax Runner] for implementing the container requirements: -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- </dependency>
- <!-- If your test code is based on JUnit you will have to have the Junit
- support artifact: -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
- <!-- Tinybundles -->
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-service</artifactId>
- <version>1.4</version>
- <exclusions>
- <exclusion>
- <artifactId>jmxtools</artifactId>
- <groupId>com.sun.jdmk</groupId>
- </exclusion>
- <exclusion>
- <artifactId>jmxri</artifactId>
- <groupId>com.sun.jmx</groupId>
- </exclusion>
- <exclusion>
- <artifactId>mail</artifactId>
- <groupId>javax.mail</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- </dependencies>
-
- <repositories>
- <repository>
- <id>ops4j.releases</id>
- <name>OPS4J Release</name>
- <url> http://repository.ops4j.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
deleted file mode 100644
index c88a261..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.*;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.transaction.test.component.ComponentUsingAnnotations;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestAnnotations {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( TinyBundles.withBnd());
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(ComponentUsingAnnotations.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"TransactionAnnotationTest")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "annotations.jar"), new File(TEST, "annotation.xml")) );
-
-
- Option[] opt = options(
-
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/")
- );
- return opt;
- }
-
- @Test
- public void annotations() {
- Element elem = IPOJOHelper.getMetadata(getBundle(), "org.apache.felix.ipojo.transaction.test.component.ComponentUsingAnnotations");
- Assert.assertNotNull(elem);
-
- Element tr = elem.getElements("transaction", "org.apache.felix.ipojo.transaction")[0];
- Assert.assertEquals("transaction", tr.getAttribute("field"));
-
- Assert.assertNull(tr.getAttribute("oncommit"));
- Assert.assertNull(tr.getAttribute("onrollback"));
-
- Element[] methods = tr.getElements();
- Assert.assertEquals(4, methods.length);
-
- Element m1 = getElementByMethod(methods, "doSomethingBad");
- Assert.assertNotNull(m1);
-
- Element m2 = getElementByMethod(methods, "doSomethingBad2");
- Assert.assertNotNull(m2);
- Assert.assertEquals("required", m2.getAttribute("propagation"));
-
- Element m3 = getElementByMethod(methods, "doSomethingGood");
- Assert.assertNotNull(m3);
- Assert.assertEquals("supported", m3.getAttribute("propagation"));
- Assert.assertEquals("{java.lang.Exception}", m3.getAttribute("norollbackfor"));
-
- Element m4 = getElementByMethod(methods, "doSomethingLong");
- Assert.assertNotNull(m4);
- Assert.assertEquals("1000", m4.getAttribute("timeout"));
- Assert.assertEquals("true", m4.getAttribute("exceptiononrollback"));
- }
-
- private Element getElementByMethod(Element[] e, String m) {
- for(Element elem : e) {
- if(m.equals(elem.getAttribute("method"))) {
- return elem;
- }
- }
- Assert.fail("Method " + m + " not found");
- return null;
- }
-
- private Bundle getBundle() {
- for(Bundle b : context.getBundles()) {
- System.out.println(b.getSymbolicName());
- if ("TransactionAnnotationTest".equals(b.getSymbolicName())) {
- return b;
- }
- }
- Assert.fail("Cannot find the tested bundle");
- return null;
- }
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
deleted file mode 100644
index a916973..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestInstallation {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
-// try {
-// StreamUtils.copy(service, new FileOutputStream(new File(ROOT, "service.jar")));
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"RequiredTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
-
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
- return opt;
- }
-
- @Test
- public void install() throws NotSupportedException, SystemException, IllegalStateException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException, InvalidSyntaxException {
- Bundle[] bundles = context.getBundles();
- for (Bundle b : bundles) {
- Assert.assertTrue(b.getSymbolicName(), b.getState() == Bundle.ACTIVE);
- }
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- // Transaction Service available
- osgi.isServiceAvailable(TransactionManager.class.getName());
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Assert.assertNotNull(tm.getTransaction());
- tm.commit();
-
- tm.begin();
- Assert.assertNotNull(tm.getTransaction());
- tm.rollback();
-
- // Handler exposed
- ServiceReference ref = osgi.getServiceReference(HandlerFactory.class.getName(), "(&(handler.name=transaction)(handler.namespace=org.apache.felix.ipojo.transaction))");
- Assert.assertNotNull(ref);
-
- // Create an install of the components
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference[] refs = context.getAllServiceReferences(CheckService.class.getName(), "(instance.name=" + under.getInstanceName() +")");
-
-// ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(refs);
-
- ((CheckService) osgi.getServiceObject(refs[0])).doSomethingGood();
- }
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
deleted file mode 100644
index 4a2e173..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestInvalidation {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"RequiredTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
-
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
- return opt;
- }
-
-
-
-
- @Test
- public void testInvalidation() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- final ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
-
- Thread thread = new Thread (new Runnable() {
- public void run() {
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- prov.dispose();
- }
- });
-
- thread.start();
-
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingLong(); // 5s, so prov should be disposed during this time and under becomes invalid
-
- Assert.assertEquals(ComponentInstance.INVALID, under.getState());
-
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.rollback();
- }
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
deleted file mode 100644
index ed305fb..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
+++ /dev/null
@@ -1,435 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestMandatory {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"MandatoryTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml")) );
-
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
- return opt;
- }
-
-
- @Test(expected=RuntimeException.class)
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Fail !
- }
-
- @Test
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
- }
-
- @Test(expected=RuntimeException.class)
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Fail, RTE thrown before the other exception
- }
-
- @Test(expected=RollbackException.class)
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.commit(); // Throws a rollback exception.
- }
-
- @Test
- public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.rollback();
- }
-
- @Test(expected=RuntimeException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2(); // Throws a RTE
- }
-
- @Test
- public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-
- @Test(expected=RuntimeException.class)
- public void testOkOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingGood(); // Throws a RTE.
-
- }
-
- @Test
- public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
- @Test(expected=RuntimeException.class)
- public void testExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad(); // Thows a RTE.
-
- }
-
- @Test
- public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- try {
- t.commit(); // Throw a rollback exception.
- } catch (RollbackException e) {
- // Expected
- } catch (Throwable e) {
- Assert.fail(e.getMessage()); // Unexpected
- }
-
- Assert.assertNotNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(1, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastRolledBack());
- }
-
- @Test(expected=RuntimeException.class)
- public void testExpectedExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad2();
-
-
- }
-
- @Test
- public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("mandatory-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
deleted file mode 100644
index 64fc423..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
+++ /dev/null
@@ -1,209 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestNever {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"NeverTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "never.jar"), new File(TEST, "never.xml")) );
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
- return opt;
- }
-
-
- @Test
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("never-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
- }
-
- @Test(expected=RuntimeException.class)
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("never-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- cs.doSomethingGood(); // Fail
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("never-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // Throws an NPE
- }
-
- @Test
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("never-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad(); // Fail
- Assert.fail("RuntimeException expected");
- } catch(RuntimeException e) {
- Assert.assertTrue(e instanceof RuntimeException);
- }
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.rollback();
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("never-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
- }
-
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
deleted file mode 100644
index 7978e9e..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
+++ /dev/null
@@ -1,440 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestNotSupported {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"NotSupportedTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml")) );
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
- return opt;
- }
-
-
- @Test
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = ((CheckService) osgi.getServiceObject(ref));
- cs.doSomethingGood();
- // No transaction.
- }
-
- @Test
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction(); // Is executed in the transaction despite it's not supported.
- Assert.assertSame(t2, t);
- t.commit();
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
- }
-
- @Test
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
-
- t.commit(); // Ok.
- }
-
- @Test
- public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No impact on the transaction.
-
- t.rollback(); // Ok.
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
- }
-
- @Test
- public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-
- @Test
- public void testOkOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingGood();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus()); // No effect on the transaction
-
- try {
- t.commit(); // Throw a rollback exception.
- } catch (RollbackException e) {
- // Expected
- } catch (Throwable e) {
- Assert.fail(e.getMessage()); // Unexpected
- }
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad2();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("notsupported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
deleted file mode 100644
index 52629e0..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
+++ /dev/null
@@ -1,445 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestRequires {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"RequiresTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
- return opt;
- }
-
-
- @Test
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
- }
-
- @Test
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
- }
-
- @Test(expected=RollbackException.class)
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.commit(); // Throw a rollback exception.
- }
-
- @Test
- public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.rollback();
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
- }
-
- @Test
- public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-
- @Test
- public void testOkOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingGood();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad();
-
- Assert.assertNotNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(1, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- try {
- t.commit(); // Throw a rollback exception.
- } catch (RollbackException e) {
- // Expected
- } catch (Throwable e) {
- Assert.fail(e.getMessage()); // Unexpected
- }
-
- Assert.assertNotNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(1, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastRolledBack());
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad2();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requires-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
deleted file mode 100644
index e1e554c..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestRequiresNew {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
-
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"RequiresNewTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml")) );
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
-
- return opt;
- }
-
-
- @Test
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Ok
- }
-
- @Test
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertNotSame(t2, t); // Two different transactions
- // Check that t2 is commited => no transaction
- Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
- t.commit();
- }
-
- @Test
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- try {
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // throws an exception on rollback
- Assert.fail("Exception expected on rollback");
- } catch (IllegalStateException e) {
- // Ok.
- } catch (Exception e) {
- Assert.fail("IllegalStateException expected on rollback");
- }
- }
-
- @Test
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("IllegalStateException expected"); // throws an exception on rollback
- } catch(Exception e) {
- Assert.assertTrue(e instanceof IllegalStateException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertNotSame(t2, t);
- // Check that t2 is rolledback
- Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
- }
-
- @Test
- public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertNotSame(t2, t);
- Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
deleted file mode 100644
index 4bc653d..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
+++ /dev/null
@@ -1,447 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.repository;
-
-import java.io.File;
-import java.io.InputStream;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
-import org.apache.felix.ipojo.transaction.test.component.FooImpl;
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.ow2.chameleon.testing.helpers.IPOJOHelper;
-import org.ow2.chameleon.testing.helpers.OSGiHelper;
-import static org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOBuilder.withiPOJO;
-
-@RunWith( JUnit4TestRunner.class )
-public class TestSupported {
-
- @Inject
- private BundleContext context;
-
- private OSGiHelper osgi;
-
- private IPOJOHelper ipojo;
- public static final File ROOT = new File("target/tmp");
- public static final File TEST = new File("src/test/resources");
-
-
- @Before
- public void init() {
- osgi = new OSGiHelper(context);
- ipojo = new IPOJOHelper(context);
- }
-
- @After
- public void stop() {
- ipojo.dispose();
- osgi.dispose();
- }
-
- @Configuration
- public static Option[] configure() {
- ROOT.mkdirs();
-
- InputStream service = TinyBundles.newBundle()
- .add(CheckService.class)
- .add(Foo.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
-
- InputStream fooimpl = TinyBundles.newBundle()
- .add(FooImpl.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build( withiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
-
- InputStream test = TinyBundles.newBundle()
- .add(FooDelegator.class)
- .set(Constants.BUNDLE_SYMBOLICNAME,"SupportedTransactionPropagation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction;version=1.1")
- .build( withiPOJO(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml")) );
-
- Option[] opt = options(
- provision(
- mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.transaction").artifactId("geronimo-transaction-service").version(asInProject()),
- mavenBundle().groupId("org.ow2.chameleon.testing").artifactId("osgi-helpers").versionAsInProject()
- ),
- provision(
- service,
- fooimpl,
- test
- ),
- repository("http://maven.ow2.org/maven2-snapshot/"),
- new Customizer() {
- @Override
- public InputStream customizeTestProbe( InputStream testProbe )
- {
- return TinyBundles.modifyBundle(testProbe)
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .build();
- }
- });
-
-
- return opt;
- }
-
-
- @Test
- public void testOkOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = ((CheckService) osgi.getServiceObject(ref));
- cs.doSomethingGood();
- // No transaction.
- }
-
- @Test
- public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
- }
-
- @Test(expected=RollbackException.class)
- public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.commit(); // Throw a rollback exception.
- }
-
- @Test
- public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- t.rollback();
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransaction() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
- }
-
- @Test
- public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-ok");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
- }
-
- @Test
- public void testOkOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingGood();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- cs.doSomethingGood();
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
- @Test(expected=NullPointerException.class)
- public void testExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad();
- Assert.fail("NullPointerException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof NullPointerException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
-
- try {
- t.commit(); // Throw a rollback exception.
- } catch (RollbackException e) {
- // Expected
- } catch (Throwable e) {
- Assert.fail(e.getMessage()); // Unexpected
- }
-
- Assert.assertNotNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(1, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastRolledBack());
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testExpectedExceptionOutsideTransactionWithCallback() {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
-
- cs.doSomethingBad2();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNull(cs.getLastCommitted());
- Assert.assertEquals(0, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
- }
-
- @Test
- public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
- ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
- ComponentInstance under = ipojo.createComponentInstance("supported-cb");
-
- Assert.assertEquals(ComponentInstance.VALID, prov.getState());
- Assert.assertEquals(ComponentInstance.VALID, under.getState());
-
- ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
-
- osgi.waitForService(TransactionManager.class.getName(), null, 5000);
- CheckService cs = (CheckService) osgi.getServiceObject(ref);
- TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
- tm.begin();
- Transaction t = tm.getTransaction();
- try {
- cs.doSomethingBad2();
- Assert.fail("UnsupportedOperationException expected");
- } catch(Exception e) {
- Assert.assertTrue(e instanceof UnsupportedOperationException);
- }
- Transaction t2 = cs.getCurrentTransaction();
- Assert.assertSame(t2, t);
- Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
-
- t.commit();
-
- Assert.assertNull(cs.getLastRolledBack());
- Assert.assertNotNull(cs.getLastCommitted());
- Assert.assertEquals(1, cs.getNumberOfCommit());
- Assert.assertEquals(0, cs.getNumberOfRollback());
-
- Assert.assertSame(t, cs.getLastCommitted());
- }
-
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java
deleted file mode 100644
index d2db5f1..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/ComponentUsingAnnotations.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.felix.ipojo.transaction.test.component;
-
-import javax.transaction.Transaction;
-
-import org.apache.felix.ipojo.annotations.Component;
-
-@Component
-@org.apache.felix.ipojo.transaction.Transaction(field="transaction")
-public class ComponentUsingAnnotations {
-
- Transaction transaction;
-
-
- @org.apache.felix.ipojo.transaction.Transactional
- public void doSomethingBad() throws NullPointerException {
- }
-
- @org.apache.felix.ipojo.transaction.Transactional(propagation="required")
- public void doSomethingBad2() throws UnsupportedOperationException {
-
- }
-
- @org.apache.felix.ipojo.transaction.Transactional(propagation="supported", norollbackfor= {"java.lang.Exception"})
- public void doSomethingGood() {
-
- }
-
- @org.apache.felix.ipojo.transaction.Transactional(timeout=1000, exceptiononrollback=true)
- public void doSomethingLong() {
-
- }
-
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
deleted file mode 100644
index 7f8665b..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.apache.felix.ipojo.transaction.test.component;
-
-import javax.transaction.Transaction;
-
-import org.apache.felix.ipojo.transaction.test.service.CheckService;
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-
-public class FooDelegator implements CheckService {
-
- private Foo foo;
-
- private int commit;
-
- private int rollback;
-
- Transaction transaction;
-
- Transaction lastCommitted;
-
- Transaction lastRolledback;
-
- Transaction current;
-
-
- public void onCommit(String method) {
- commit ++;
- }
-
- public void onRollback(String method, Exception e) {
- rollback ++;
- }
-
- public void doSomethingBad() throws NullPointerException {
- current = transaction;
- foo.doSomethingBad();
- }
-
- public void doSomethingBad2() throws UnsupportedOperationException {
- current = transaction;
- foo.doSomethingBad2();
-
- }
-
- public void doSomethingGood() {
- current = transaction;
- foo.doSomethingGood();
- }
-
- public void doSomethingLong() {
- current = transaction;
- foo.doSomethingLong();
- }
-
- public Transaction getCurrentTransaction() {
- return current;
- }
-
- public int getNumberOfCommit() {
- return commit;
- }
-
- public int getNumberOfRollback() {
- return rollback;
- }
-
- public Transaction getLastRolledBack() {
- return lastRolledback;
- }
-
- public Transaction getLastCommitted() {
- return lastCommitted;
- }
-
- public void onRollback(Transaction t) {
- lastRolledback = t;
- rollback ++;
- }
-
-
- public void onCommit(Transaction t) {
- lastCommitted = t;
- commit ++;
- }
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java
deleted file mode 100644
index addb9f3..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.felix.ipojo.transaction.test.component;
-
-import org.apache.felix.ipojo.transaction.test.service.Foo;
-
-public class FooImpl implements Foo {
-
- public void doSomethingBad() throws NullPointerException {
- throw new NullPointerException("NULL");
- }
-
- public void doSomethingBad2() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Expected exception");
-
- }
-
- public void doSomethingGood() {
- // Good...
- }
-
- public void doSomethingLong() {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java
deleted file mode 100644
index bb95994..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/CheckService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.felix.ipojo.transaction.test.service;
-
-import javax.transaction.Transaction;
-
-public interface CheckService {
-
- public void doSomethingGood();
-
- public void doSomethingBad() throws NullPointerException;
-
- public void doSomethingBad2() throws UnsupportedOperationException;
-
- public void doSomethingLong();
-
- public int getNumberOfCommit();
-
- public int getNumberOfRollback();
-
- public Transaction getCurrentTransaction();
-
- public Transaction getLastRolledBack();
-
- public Transaction getLastCommitted();
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java
deleted file mode 100644
index b1ba75a..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/service/Foo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.transaction.test.service;
-
-public interface Foo {
-
- public void doSomethingGood();
-
- public void doSomethingBad() throws NullPointerException;
-
- public void doSomethingBad2() throws UnsupportedOperationException;
-
- public void doSomethingLong();
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/resources/annotation.xml b/ipojo/tests/handler/transaction/src/test/resources/annotation.xml
deleted file mode 100644
index d1aa123..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/annotation.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
-
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/foo.xml b/ipojo/tests/handler/transaction/src/test/resources/foo.xml
deleted file mode 100644
index 19f1ed8..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/foo.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<ipojo>
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooImpl">
- <provides/>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml b/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml
deleted file mode 100644
index eb743bf..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/mandatory.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood" propagation="mandatory"/>
- <transactional method="getCurrentTransaction" propagation="mandatory"/>
- <transactional method="doSomethingBad" propagation="mandatory"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
- <transactional method="doSomethingLong" propagation="mandatory"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood" propagation="mandatory"/>
- <transactional method="getCurrentTransaction" propagation="mandatory"/>
- <transactional method="doSomethingBad" propagation="mandatory"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
- <transactional method="doSomethingLong" propagation="mandatory"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/never.xml b/ipojo/tests/handler/transaction/src/test/resources/never.xml
deleted file mode 100644
index 8170a46..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/never.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood" propagation="never"/>
- <transactional method="getCurrentTransaction" propagation="never"/>
- <transactional method="doSomethingBad" propagation="never"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
- <transactional method="doSomethingLong" propagation="never"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood" propagation="never"/>
- <transactional method="getCurrentTransaction" propagation="never"/>
- <transactional method="doSomethingBad" propagation="never"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
- <transactional method="doSomethingLong" propagation="never"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml b/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml
deleted file mode 100644
index 7a471c8..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/notsupported.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood" propagation="notsupported"/>
- <transactional method="getCurrentTransaction" propagation="notsupported"/>
- <transactional method="doSomethingBad" propagation="notsupported"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
- <transactional method="doSomethingLong" propagation="notsupported"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood" propagation="notsupported"/>
- <transactional method="getCurrentTransaction" propagation="notsupported"/>
- <transactional method="doSomethingBad" propagation="notsupported"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
- <transactional method="doSomethingLong" propagation="notsupported"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/requires.xml b/ipojo/tests/handler/transaction/src/test/resources/requires.xml
deleted file mode 100644
index 20a5844..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/requires.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood"/>
- <transactional method="getCurrentTransaction"/>
- <transactional method="doSomethingBad"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
- <transactional method="doSomethingLong"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood"/>
- <transactional method="getCurrentTransaction"/>
- <transactional method="doSomethingBad"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
- <transactional method="doSomethingLong"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml b/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml
deleted file mode 100644
index 30d2ad6..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/requiresnew.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood" propagation="requiresnew"/>
- <transactional method="getCurrentTransaction" propagation="requiresnew"/>
- <transactional method="doSomethingBad" propagation="requiresnew" exceptiononrollback="true"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
- <transactional method="doSomethingLong" propagation="requiresnew"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood" propagation="requiresnew"/>
- <transactional method="getCurrentTransaction" propagation="requiresnew"/>
- <transactional method="doSomethingBad" propagation="requiresnew"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
- <transactional method="doSomethingLong" propagation="requiresnew"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/transaction/src/test/resources/supported.xml b/ipojo/tests/handler/transaction/src/test/resources/supported.xml
deleted file mode 100644
index b45a7f1..0000000
--- a/ipojo/tests/handler/transaction/src/test/resources/supported.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-ok">
- <provides/>
- <requires field="foo"/>
- <tr:transaction field="transaction">
- <transactional method="doSomethingGood" propagation="supported"/>
- <transactional method="getCurrentTransaction" propagation="supported"/>
- <transactional method="doSomethingBad" propagation="supported"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
- <transactional method="doSomethingLong" propagation="supported"/>
- </tr:transaction>
- </component>
-
- <component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-cb">
- <provides/>
- <requires field="foo" />
- <tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
- <transactional method="doSomethingGood" propagation="supported"/>
- <transactional method="getCurrentTransaction" propagation="supported"/>
- <transactional method="doSomethingBad" propagation="supported"/>
- <transactional method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
- <transactional method="doSomethingLong" propagation="supported"/>
- </tr:transaction>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/handler/whiteboard/pom.xml b/ipojo/tests/handler/whiteboard/pom.xml
deleted file mode 100644
index 025f7c0..0000000
--- a/ipojo/tests/handler/whiteboard/pom.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.wbp.snapshot}</version>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO White Board Pattern Handler Test Suite</name>
- <artifactId>tests.whiteboard</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.whiteboard</artifactId>
- <version>${ipojo.wbp.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Private-Package>org.apache.felix.ipojo.test,
- org.apache.felix.ipojo.test.scenarios.util</Private-Package>
- <Test-Suite>org.apache.felix.ipojo.test.WbpTests</Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- <metadata>
- <![CDATA[
- <ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
- xmlns:wbp="org.apache.felix.ipojo.whiteboard">
- <component classname="org.apache.felix.ipojo.test.FooProvider" name="fooprovider">
- <provides>
- <property field="foo" value="foo"/>
- </provides>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.FooWhiteBoardPattern" name="under-providers">
- <wbp:wbp
- filter="(objectclass=org.apache.felix.ipojo.test.FooService)"
- onArrival="onArrival" onDeparture="onDeparture" onModification="onModification"
- />
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.FooWhiteBoardPattern" name="under-properties">
- <wbp:wbp filter="(foo=foo)" onArrival="onArrival" onDeparture="onDeparture"
- onModification="onModification"
- />
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.FooWhiteBoardPattern" name="under-providers-2">
- <wbp:whiteboards>
- <wbp:wbp
- filter="(objectclass=org.apache.felix.ipojo.test.FooService)"
- onArrival="onArrival" onDeparture="onDeparture" onModification="onModification"
- />
- </wbp:whiteboards>
- <provides/>
- </component>
-
- <component classname="org.apache.felix.ipojo.test.FooWhiteBoardPattern" name="under-providers-lifecycle">
- <wbp:wbp
- filter="(objectclass=org.apache.felix.ipojo.test.FooService)"
- onArrival="onArrival" onDeparture="onDeparture" onModification="onModification"
- />
- <provides/>
- <callback transition="validate" method="start"/>
- <callback transition="invalidate" method="stop"/>
- </component>
- </ipojo>
- ]]>
- </metadata>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooProvider.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooProvider.java
deleted file mode 100644
index 5a996cd..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooProvider.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test;
-
-public class FooProvider implements FooService {
-
- public String foo;
-
- public void foo() {
- if (foo.equals("foo")) {
- foo = "bar";
- } else {
- foo = "foo";
- }
- }
-
-}
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooService.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooService.java
deleted file mode 100644
index 0040354..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test;
-
-public interface FooService {
-
- public void foo();
-
-}
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooWhiteBoardPattern.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooWhiteBoardPattern.java
deleted file mode 100644
index 4974e45..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/FooWhiteBoardPattern.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.felix.ipojo.test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.ServiceReference;
-
-public class FooWhiteBoardPattern implements Observable {
-
- List list = new ArrayList();
- int modifications = 0;
-
- long validate_time = 0;
- long first_arrival_time = 0;
- long first_departure_time = 0;
- long invalidate_time = 0;
-
- public void onArrival(ServiceReference ref) {
- if (first_arrival_time == 0) {
- first_arrival_time = System.currentTimeMillis();
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- list.add(ref);
- }
-
- public void onDeparture(ServiceReference ref) {
- list.remove(ref);
- if (first_departure_time == 0) {
- first_departure_time = System.currentTimeMillis();
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- }
-
- public void onModification(ServiceReference ref) {
- modifications = modifications + 1;
- }
-
- public Map getObservations() {
- Map map = new HashMap();
- map.put("list", list);
- map.put("modifications", new Integer(modifications));
- map.put("validate", new Long(validate_time));
- map.put("invalidate", new Long(invalidate_time));
- map.put("arrival", new Long(first_arrival_time));
- map.put("departure", new Long(first_departure_time));
- return map;
- }
-
- public void start() {
- if (validate_time == 0) {
- validate_time = System.currentTimeMillis();
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- }
-
- public void stop() {
- if (invalidate_time == 0) {
- invalidate_time = System.currentTimeMillis();
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- }
-
-
-}
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/Observable.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/Observable.java
deleted file mode 100644
index 94d7787..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/Observable.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.felix.ipojo.test;
-
-import java.util.Map;
-
-public interface Observable {
-
- public Map getObservations();
-
-}
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/WbpTests.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/WbpTests.java
deleted file mode 100644
index 0206900..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/WbpTests.java
+++ /dev/null
@@ -1,281 +0,0 @@
-package org.apache.felix.ipojo.test;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class WbpTests extends OSGiTestCase {
-
- Factory provFactory;
- Factory factory, factory2, factory3, factory4;
-
- public void setUp() {
- provFactory = Utils.getFactoryByName(context, "fooprovider");
- factory = Utils.getFactoryByName(context, "under-providers");
- factory2 = Utils.getFactoryByName(context, "under-properties");
- factory3 = Utils.getFactoryByName(context, "under-providers-lifecycle");
- factory4 = Utils.getFactoryByName(context, "under-providers-2");
- }
-
- public void tearDown() {
-
- }
-
- public void testServiceProviders() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = factory.createComponentInstance(new Properties());
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, Observable.class.getName(), ci.getInstanceName());
- assertNotNull("Check Observable availability", ref);
- Observable obs = (Observable) context.getService(ref);
-
- Map map = obs.getObservations();
- assertEquals("Check empty list" , ((List) map.get("list")).size(), 0);
-
- Properties p1 = new Properties();
- p1.put("foo", "foo");
- ComponentInstance prov1 = provFactory.createComponentInstance(p1);
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
-
- Properties p2 = new Properties();
- p2.put("foo", "foo");
- ComponentInstance prov2 = provFactory.createComponentInstance(p2);
-
- map = obs.getObservations();
- assertEquals("Check list #2" , ((List) map.get("list")).size(), 2);
-
- prov1.stop();
-
- map = obs.getObservations();
- assertEquals("(1) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov2.stop();
-
- map = obs.getObservations();
- assertEquals("(2) Check list #0" , ((List) map.get("list")).size(), 0);
-
- prov2.start();
-
- map = obs.getObservations();
- assertEquals("(3) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov1.start();
-
- map = obs.getObservations();
- assertEquals("(4) Check list #2" , ((List) map.get("list")).size(), 2);
-
- prov1.dispose();
-
- map = obs.getObservations();
- assertEquals("(5) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov2.dispose();
-
- map = obs.getObservations();
- assertEquals("(6) Check list #0" , ((List) map.get("list")).size(), 0);
-
- context.ungetService(ref);
- ci.dispose();
- }
-
- public void testPropertiesProviders() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = factory2.createComponentInstance(new Properties());
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, Observable.class.getName(), ci.getInstanceName());
- assertNotNull("Check Observable availability", ref);
- Observable obs = (Observable) context.getService(ref);
-
- Map map = obs.getObservations();
- assertEquals("Check empty list" , ((List) map.get("list")).size(), 0);
-
- Properties p1 = new Properties();
- p1.put("foo", "foo");
- ComponentInstance prov1 = provFactory.createComponentInstance(p1);
- ServiceReference ref1 = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov1.getInstanceName());
- FooService fs1 = (FooService) context.getService(ref1);
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
-
- Properties p2 = new Properties();
- p2.put("foo", "foo");
- ComponentInstance prov2 = provFactory.createComponentInstance(p2);
- ServiceReference ref2 = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov2.getInstanceName());
- FooService fs2 = (FooService) context.getService(ref2);
-
- map = obs.getObservations();
- assertEquals("Check list #2" , ((List) map.get("list")).size(), 2);
-
- fs1.foo();
-
- map = obs.getObservations();
- assertEquals("(1) Check list #1" , ((List) map.get("list")).size(), 1);
-
- fs2.foo();
-
- map = obs.getObservations();
- assertEquals("(2) Check list #0" , ((List) map.get("list")).size(), 0);
-
- fs2.foo();
-
- map = obs.getObservations();
- assertEquals("(3) Check list #1" , ((List) map.get("list")).size(), 1);
-
- fs1.foo();
-
- map = obs.getObservations();
- assertEquals("(4) Check list #2" , ((List) map.get("list")).size(), 2);
-
- prov1.dispose();
-
- map = obs.getObservations();
- assertEquals("(5) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov2.dispose();
-
- map = obs.getObservations();
- assertEquals("(6) Check list #0" , ((List) map.get("list")).size(), 0);
-
- context.ungetService(ref1);
- context.ungetService(ref2);
- context.ungetService(ref);
- ci.dispose();
- }
-
- public void testModifications() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = factory.createComponentInstance(new Properties());
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, Observable.class.getName(), ci.getInstanceName());
- assertNotNull("Check Observable availability", ref);
- Observable obs = (Observable) context.getService(ref);
-
- Map map = obs.getObservations();
- assertEquals("Check empty list" , ((List) map.get("list")).size(), 0);
-
- Properties p1 = new Properties();
- p1.put("foo", "foo");
- ComponentInstance prov1 = provFactory.createComponentInstance(p1);
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
- assertEquals("Check modification #0" , ((Integer) map.get("modifications")).intValue(), 0);
-
- ServiceReference ref2 = Utils.getServiceReference(context, FooService.class.getName(), null);
- assertNotNull("Check FooService availability", ref2);
-
- FooService fs = (FooService) context.getService(ref2);
- fs.foo();
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
- assertEquals("Check modification #1 (" + map.get("modifications")+")" , ((Integer) map.get("modifications")).intValue(), 1);
-
- fs.foo();
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
- assertEquals("Check modification #2" , ((Integer) map.get("modifications")).intValue(), 2);
-
- prov1.dispose();
- map = obs.getObservations();
- assertEquals("Check list #0" , ((List) map.get("list")).size(), 0);
- assertEquals("Check modification #2" , ((Integer) map.get("modifications")).intValue(), 2);
-
- context.ungetService(ref);
- context.ungetService(ref2);
- ci.dispose();
- }
-
- public void testLifecycleCompliance() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // First expose a service.
- Properties p1 = new Properties();
- p1.put("foo", "foo");
- ComponentInstance prov1 = provFactory.createComponentInstance(p1);
-
- ComponentInstance ci = factory3.createComponentInstance(new Properties());
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, Observable.class.getName(), ci.getInstanceName());
- assertNotNull("Check Observable availability", ref);
- Observable obs = (Observable) context.getService(ref);
-
- Map map = obs.getObservations();
- // Check time
- Long validate = (Long) map.get("validate");
- Long arrival = (Long) map.get("arrival");
-
- // Validate must be call before.
- assertTrue(validate.longValue() + " <?> " + arrival.longValue(), validate.longValue() < arrival.longValue());
-
- prov1.dispose();
- ci.dispose();
-
- }
-
- public void testServiceProvidersWhiteWhiteboards() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- ComponentInstance ci = factory4.createComponentInstance(new Properties());
-
- ServiceReference ref = Utils.getServiceReferenceByName(context, Observable.class.getName(), ci.getInstanceName());
- assertNotNull("Check Observable availability", ref);
- Observable obs = (Observable) context.getService(ref);
-
- Map map = obs.getObservations();
- assertEquals("Check empty list" , ((List) map.get("list")).size(), 0);
-
- Properties p1 = new Properties();
- p1.put("foo", "foo");
- ComponentInstance prov1 = provFactory.createComponentInstance(p1);
-
- map = obs.getObservations();
- assertEquals("Check list #1" , ((List) map.get("list")).size(), 1);
-
- Properties p2 = new Properties();
- p2.put("foo", "foo");
- ComponentInstance prov2 = provFactory.createComponentInstance(p2);
-
- map = obs.getObservations();
- assertEquals("Check list #2" , ((List) map.get("list")).size(), 2);
-
- prov1.stop();
-
- map = obs.getObservations();
- assertEquals("(1) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov2.stop();
-
- map = obs.getObservations();
- assertEquals("(2) Check list #0" , ((List) map.get("list")).size(), 0);
-
- prov2.start();
-
- map = obs.getObservations();
- assertEquals("(3) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov1.start();
-
- map = obs.getObservations();
- assertEquals("(4) Check list #2" , ((List) map.get("list")).size(), 2);
-
- prov1.dispose();
-
- map = obs.getObservations();
- assertEquals("(5) Check list #1" , ((List) map.get("list")).size(), 1);
-
- prov2.dispose();
-
- map = obs.getObservations();
- assertEquals("(6) Check list #0" , ((List) map.get("list")).size(), 0);
-
- context.ungetService(ref);
- ci.dispose();
- }
-}
diff --git a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index d2239d9..0000000
--- a/ipojo/tests/handler/whiteboard/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,261 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-}
diff --git a/ipojo/tests/integration-tests/pom.xml b/ipojo/tests/integration-tests/pom.xml
deleted file mode 100644
index 3c01ba9..0000000
--- a/ipojo/tests/integration-tests/pom.xml
+++ /dev/null
@@ -1,282 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>org.apache.felix.ipojo.integration-tests</artifactId>
- <name>iPOJO Integration Tests</name>
- <version>1.5.0-SNAPSHOT</version>
-
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin
- </artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <hideOutputs>true</hideOutputs>
- <logService>false</logService>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.4.3</version>
- <configuration>
- <showSucess>true</showSucess>
- <reportsDirectories>
- <param>target/junit4osgi-reports</param>
- </reportsDirectories>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
- <dependencies>
- <!-- Manipulation -->
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.manipulation.metadata</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.manipulation</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.manipulation.primitives</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.manipulation.creation</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.manipulation.java5</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Core -->
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.annotations</artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.bad.configurations
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.configuration
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.external.handlers
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.factories</artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.lifecycle.callback
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.lifecycle.controller
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.ps</artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.lifecycle.controller
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency.bindingpolicy
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency.comparator
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.service.dependency.filter
- </artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <artifactId>tests.core.ps.strategy</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
-
-
- <!-- Composite -->
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite </artifactId>
- <version>${ipojo.composite.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite.service.import-export</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite.service.instance</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.composite.service.providing</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- External handlers -->
-
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.eventadmin.handler</artifactId>
- <version>${ipojo.eah.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.temporal </artifactId>
- <version>${ipojo.temporal.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.whiteboard </artifactId>
- <version>${ipojo.wbp.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <!-- Utility bundles -->
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.whiteboard</artifactId>
- <version>${ipojo.wbp.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.temporal</artifactId>
- <version>${ipojo.temporal.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>
- <version>${ipojo.eah.snapshot}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.eventadmin</artifactId>
- <version>1.2.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.2.8</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ipojo.tests</groupId>
- <artifactId>tests.core.configadmin</artifactId>
- <version>${ipojo.core.snapshot}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/ipojo/tests/manipulator/creation/pom.xml b/ipojo/tests/manipulator/creation/pom.xml
deleted file mode 100644
index 455fee8..0000000
--- a/ipojo/tests/manipulator/creation/pom.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Creation Manipulation Test Suite</name>
- <artifactId>tests.manipulation.creation</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.manipulator.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.manipulation.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <configuration>
- <org.osgi.http.port>8083</org.osgi.http.port>
- </configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ASimpleParentClass.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ASimpleParentClass.java
deleted file mode 100644
index ef42322..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ASimpleParentClass.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ASimpleParentClass {
-
- protected String name;
-
- public ASimpleParentClass() {
- name = "hello";
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java
deleted file mode 100644
index 40c5a6a..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class CallSuperConstructor extends ParentClass {
-
- public CallSuperConstructor() {
- super("test");
- System.out.println("plop");
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithBC.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithBC.java
deleted file mode 100644
index b8335aa..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithBC.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.osgi.framework.BundleContext;
-
-public class CallSuperConstructorWithBC extends ParentClassWithBC {
-
- public CallSuperConstructorWithBC(BundleContext bc) {
- super("bc", bc, "bundle");
- String message = "plop-bc";
- System.out.println(message);
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
deleted file mode 100644
index e147d09..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructorWithNew.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class CallSuperConstructorWithNew extends ParentClass {
-
- public CallSuperConstructorWithNew() {
- super(new StringBuffer("test"));
- System.out.println("plop");
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperSuperConstructorWithNew.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperSuperConstructorWithNew.java
deleted file mode 100644
index 6f0892f..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperSuperConstructorWithNew.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class CallSuperSuperConstructorWithNew extends ParentClass2 {
-
- public CallSuperSuperConstructorWithNew() {
- super(new String("test"));
- System.out.println("plop");
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 7fea38d..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructor.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructor.java
deleted file mode 100644
index 59f2ef7..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-
-public class NoEmptyConstructor implements CheckService {
-
-
- private String name;
-
- public NoEmptyConstructor(final String n) {
- name = n;
- }
-
- public boolean check() {
- return name != null;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- if (name == null) {
- props.put("name", "NULL");
- } else {
- props.put("name", name);
- }
- return props;
- }
-
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructorWithParentClass.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructorWithParentClass.java
deleted file mode 100644
index 409692b..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/NoEmptyConstructorWithParentClass.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-
-public class NoEmptyConstructorWithParentClass extends ASimpleParentClass implements CheckService {
-
- public NoEmptyConstructorWithParentClass(final String n) {
- name = n;
- }
-
- public boolean check() {
- return name != null;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- if (name == null) {
- props.put("name", "NULL");
- } else {
- props.put("name", name);
- }
- return props;
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
deleted file mode 100644
index 5b6b99f..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass {
-
- private String name;
-
- public ParentClass(final String n) {
- name = n;
- }
-
- public ParentClass(final StringBuffer n) {
- name = n.toString();
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass2.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass2.java
deleted file mode 100644
index 39bea4e..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass2.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class ParentClass2 extends SuperParentClass {
-
- public ParentClass2(String n) {
- super(n);
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClassWithBC.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClassWithBC.java
deleted file mode 100644
index 8902d43..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClassWithBC.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.osgi.framework.BundleContext;
-
-public class ParentClassWithBC {
-
- private BundleContext bc;
-
- public ParentClassWithBC(String foo, BundleContext bc, String bar) {
- this.bc = bc;
- System.out.println(foo + " : " + this.bc + "(" + bar + ")");
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java
deleted file mode 100644
index b31278a..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-
-public class SeveralConstructors implements CheckService {
-
-
- private String name;
-
- public SeveralConstructors(){
- this("hello world");
- }
-
- public SeveralConstructors(final String n) {
- name = n;
- }
-
- public boolean check() {
- return name != null;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("name", name);
- return props;
- }
-
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SuperParentClass.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SuperParentClass.java
deleted file mode 100644
index 2b87f4a..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SuperParentClass.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class SuperParentClass {
-
- private String name;
-
- public SuperParentClass(final String n) {
- System.out.println("Hello from super super !");
- name = n;
- }
-
- public SuperParentClass(final StringBuffer n) {
- name = n.toString();
- }
-
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
deleted file mode 100644
index 11db1fa..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ManipulationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Manipulation Creation Test Suite", bc);
- ots.addTestSuite(POJOCreation.class);
- ots.addTestSuite(SeveralConstructorTest.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
deleted file mode 100644
index bd30524..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.FooProviderType1;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Check the different method to create POJO object.
- */
-public class POJOCreation extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- private ComponentInstance ci_lazzy;
- private ComponentInstance ci_immediate;
- private ComponentInstance ci_immediate_singleton;
-
- private Architecture lazzyArch;
- private Architecture immeArch;
- private Architecture immeArchSing;
-
-
- private ComponentInstance ci_lazzy_sing;
- private ComponentInstance ci_lazzy_sev;
-
- private Architecture lazzyArchSing;
- private Architecture lazzyArchSev;
- private ComponentInstance ci_lazzy_singM;
- private ComponentInstance ci_lazzy_sevM;
-
- private Architecture lazzyArchSingM;
- private Architecture lazzyArchSevM;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
-
- String factName = "ManipulationCreation-FooProviderType-1";
- String compName = "FooProvider-1";
- ci_lazzy = helper.createComponentInstance(factName ,compName);
-
- String factName2 = "ManipulationCreation-ImmediateFooProviderType";
- String compName2 = "FooProvider-2";
- ci_immediate = helper.createComponentInstance(factName2, compName2);
-
- String factName3 = "ManipulationCreation-ImmediateFooProviderTypeSingleton";
- String compName3 = "FooProvider-3";
- ci_immediate_singleton = helper.createComponentInstance(factName3, compName3);
-
- String factName4 = "ManipulationCreation-FooProviderType-1-Sing";
- String compName4 = "FooProvider-1-Sing";
- ci_lazzy_sing = helper.createComponentInstance(factName4, compName4);
-
- String factName5 = "ManipulationCreation-FooProviderType-1-Sev";
- String compName5 = "FooProvider-1-Sev";
- ci_lazzy_sev = helper.createComponentInstance(factName5, compName5);
-
- String factName6 = "ManipulationCreation-FooProviderType-1-SingM";
- String compName6 = "FooProvider-1-SingM";
- ci_lazzy_singM = helper.createComponentInstance(factName6, compName6);
-
- String factName7 = "ManipulationCreation-FooProviderType-1-SevM";
- String compName7 = "FooProvider-1-SevM";
- ci_lazzy_sevM = helper.createComponentInstance(factName7, compName7);
-
- lazzyArch = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName+")");
- immeArch = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName2+")");
- immeArchSing = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName3+")");
- lazzyArchSing = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName4+")");
- lazzyArchSev = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName5+")");
- lazzyArchSingM = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName6+")");
- lazzyArchSevM = (Architecture) getServiceObject(Architecture.class.getName(), "(architecture.instance="+compName7+")");
- }
-
- public void tearDown() {
- lazzyArch = null;
- immeArch = null;
- immeArchSing = null;
- lazzyArchSing = null;
- lazzyArchSev = null;
- lazzyArchSingM = null;
- lazzyArchSevM = null;
- helper.dispose();
- }
-
- /**
- * Check lazy creation.
- */
- public void testLazyCreation() {
- assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check lazy and singleton creation.
- */
- public void testLazyCreationSingleton() {
- assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSing.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sing.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy_sing.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArchSing.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check lazy and "several" creation.
- */
- public void testLazyCreationSeveral() {
- assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSev.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sev.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy_sev.getInstanceName() + " is available", ref);
- FooService fs = (FooService) getServiceObject(ref);
- FooService fs2 = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertTrue("Check the FooService invocation-2", fs2.foo());
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArchSev.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check immediate creation.
- */
- public void testImmediateCreation() {
- assertEquals("Check that one object is created ", 1, ((PrimitiveInstanceDescription) immeArch.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_immediate.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_immediate.getInstanceName() + " is available", ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) immeArch.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check bundle context injection.
- */
- public void testBundleContext() {
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- Properties p = fs.fooProps();
- assertNotNull("Check the bundle context", p.get("context"));
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Test immediate singleton creation.
- */
- public void testImmediateSingletonCreation() {
- assertEquals("Check that one object is created ", 1, ((PrimitiveInstanceDescription) immeArchSing.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_immediate_singleton.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_immediate_singleton.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) immeArchSing.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check creation through a factory method.
- * (lazy & singleton creation)
- */
- public void testLazyCreationSingletonM() {
- assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSingM.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_singM.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy_singM.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- FooService fs2 = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertTrue("Check the FooService invocation", fs2.foo());
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArchSingM.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Check creation through a factory method.
- * (lazy & several creation)
- */
- public void testLazyCreationSeveralM() {
- assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
- ServiceReference ref= helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sevM.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy_sevM.getInstanceName() + " is available",ref);
- FooService fs = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation", fs.foo());
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
- FooService fs2 = (FooService) getServiceObject(ref);
- assertTrue("Check the FooService invocation-2", fs2.foo());
- // Only one object as the getService method is called only once (service factory) despite the policy="method".
- assertEquals("Check the creation of 1 object",1, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
- }
-
- /**
- * Test a custom constructor.
- * Not manipulated.
- */
- public void testCustomConstuctor() {
- FooService fs = new FooProviderType1(0, "foo", getContext());
- Properties props = fs.fooProps();
- assertEquals("Check bar", 0, ((Integer) props.get("bar")).intValue());
- assertEquals("Check foo", "foo", props.get("foo"));
- assertEquals("Check context", getContext(), props.get("context"));
- }
-
- public void testSuperCall() {
- try {
- helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructor");
- } catch (Throwable e) {
- fail(e.getMessage());
- }
- }
-
- public void testSuperCallWithNew() {
- try {
- helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithNew");
- } catch (Throwable e) {
- fail(e.getMessage());
- }
- }
-
- public void testSuperSuperCallWithNew() {
- try {
- helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperSuperConstructorWithNew");
- } catch (Throwable e) {
- fail(e.getMessage());
- }
- }
-
- public void testSuperCallWithBC() {
- try {
- helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithBC");
- } catch (Throwable e) {
- fail(e.getMessage());
- }
- }
-
-
-
-}
\ No newline at end of file
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java
deleted file mode 100644
index f2c8ddf..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.ipojo.ComponentInstance;
-
-public class SeveralConstructorTest extends OSGiTestCase {
-
- private IPOJOHelper helper;
-
- private ComponentInstance ci, ci2, ci3;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- ci = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.SeveralConstructors");
- ci2 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.NoEmptyConstructor");
- ci3 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.NoEmptyConstructorWithParentClass");
-
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
-
- public void testSeveralConstructor() {
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), ci.getInstanceName());
- CheckService cs = (CheckService) getServiceObject(ref);
- assertTrue("Check assignation", cs.check());
- String name = (String) cs.getProps().get("name");
- assertEquals("Check message", "hello world", name);
- //assertNull("Check message", name);
- }
-
- public void testNoEmptyConstructor() {
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), ci2.getInstanceName());
- CheckService cs = (CheckService) getServiceObject(ref);
- assertFalse("Check assignation", cs.check());
- String name = (String) cs.getProps().get("name");
- assertEquals("Check message", "NULL", name);
- }
-
- public void testNoEmptyConstructorWithAParentClass() {
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), ci3.getInstanceName());
- CheckService cs = (CheckService) getServiceObject(ref);
- assertTrue("Check assignation", cs.check()); // super set name to "hello"
- String name = (String) cs.getProps().get("name");
- assertEquals("Check message", "hello", name);
- }
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
deleted file mode 100644
index 5f5b74b..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service.A123;
-
-public interface CheckService2 {
-
- public boolean check();
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
deleted file mode 100644
index dfe2b9c..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
deleted file mode 100644
index ef7e1ee..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
deleted file mode 100644
index f1e8dc0..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
deleted file mode 100644
index 1bb177c..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface Plop {
-
- Object getPlop();
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
deleted file mode 100644
index cd61e3b..0000000
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface PrimitiveManipulationTestService {
-
- byte getByte();
- void setByte(byte b);
-
- short getShort();
- void setShort(short s);
-
- int getInt();
- void setInt(int i);
-
- long getLong();
- void setLong(long l);
-
- float getFloat();
- void setFloat(float f);
-
- double getDouble();
- void setDouble(double d);
-
- char getChar();
- void setChar(char c);
-
- boolean getBoolean();
- void setBoolean(boolean b);
-
- // Array types
- byte[] getBytes();
- void setBytes(byte[] bs);
-
- short[] getShorts();
- void setShorts(short[] ss);
-
- int[] getInts();
- void setInts(int is[]);
-
- long[] getLongs();
- void setLongs(long[] ls);
-
- float[] getFloats();
- void setFloats(float[] fs);
-
- double[] getDoubles();
- void setDoubles(double[] ds);
-
- char[] getChars();
- void setChars(char[] cs);
-
- boolean[] getBooleans();
- void setBooleans(boolean[] bs);
-
- // This method has been added to test an issue when autoboxing.
- void setLong(long l, String s);
-
-}
diff --git a/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml b/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
deleted file mode 100644
index c8cd937..0000000
--- a/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Simple provider used for manipulation analysis -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Non lazzy service provider, to check instantiation -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-ImmediateFooProviderType" immediate="true"
- architecture="true">
- <provides />
- </component>
-
- <!-- Type checking different creation policy -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-FooProviderType-1-Sing" factory-method="singleton"
- architecture="true">
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-FooProviderType-1-Sev" factory-method="several"
- architecture="true">
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-FooProviderType-1-SingM" factory-method="singleton"
- architecture="true">
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-FooProviderType-1-SevM" factory-method="several"
- architecture="true">
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationCreation-ImmediateFooProviderTypeSingleton" immediate="true"
- factory-method="singleton" architecture="true">
- <provides />
- </component>
-
-
- <!-- Try calling super constructors -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructor" immediate="true"/>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithNew" immediate="true"/>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithBC" immediate="true"/>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperSuperConstructorWithNew" immediate="true"/>
-
- <!-- Several constructors -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.SeveralConstructors">
- <provides/>
- </component>
- <!-- No Empty constructor -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.NoEmptyConstructor">
- <provides/>
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.NoEmptyConstructorWithParentClass">
- <provides/>
- </component>
-</ipojo>
diff --git a/ipojo/tests/manipulator/manipulation/pom.xml b/ipojo/tests/manipulator/manipulation/pom.xml
deleted file mode 100644
index df6095a..0000000
--- a/ipojo/tests/manipulator/manipulation/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Manipulation Test Suite</name>
- <artifactId>tests.manipulation</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.manipulator.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.manipulation.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/manipulator/manipulation/src/main/ipojo/metadata.xml b/ipojo/tests/manipulator/manipulation/src/main/ipojo/metadata.xml
deleted file mode 100644
index b3e0262..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/ipojo/metadata.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Simple provider used for manipulation analysis -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Manipulation-FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Non lazzy service provider, to check instantiation -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="Manipulation-ImmediateFooProviderType" immediate="true"
- architecture="true">
- <provides />
- </component>
-
- <!-- Nested & Inner classes -->
- <component name="inners" classname="org.apache.felix.ipojo.test.scenarios.component.InnerClasses">
- <provides>
- <property field="privateObject"/>
- <property field="privateInt"/>
-
- <property field="protectedObject"/>
- <property field="protectedInt"/>
-
- <property field="packageObject"/>
- <property field="packageInt"/>
-
- <property field="publicObject"/>
- <property field="publicInt"/>
- </provides>
- </component>
-</ipojo>
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 7fea38d..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InnerClasses.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InnerClasses.java
deleted file mode 100644
index 4bee70e..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/InnerClasses.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-
-public class InnerClasses implements CheckService {
-
- private String privateObject;
- private int privateInt;
-
- protected String protectedObject;
- protected int protectedInt;
-
- String packageObject;
- int packageInt;
-
- public String publicObject;
- public int publicInt;
-
- private String nonObject = "not-managed";
- private int nonInt = 5;
-
- private static int staticint = 6;
-
- public boolean check() {
- return true;
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("publicInner", new PublicNested().doSomething());
- props.put("packageInner", new PackageNested().doSomething());
- props.put("protectedInner", new ProtectedNested().doSomething());
- props.put("privateInner", new PrivateNested().doSomething());
- props.put("constructorInner", new ConstructorNested().doSomething());
- props.put("staticInner", new StaticNested().doSomething());
-
- Job anonymous = new Job() {
- public Map doSomething() {
- Map map = new HashMap();
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- return map;
- }
- };
-
- props.put("anonymous", anonymous.doSomething());
- props.put("public", new PublicNested());
-
-
- return props;
- }
-
- private class PrivateNested implements Job {
- public Map doSomething() {
- Map map = new HashMap();
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- return map;
- }
- }
-
- public class PublicNested implements Job {
- public Map doSomething() {
- Map map = new HashMap();
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- return map;
- }
- }
-
- class PackageNested implements Job {
- public Map doSomething() {
- Map map = new HashMap();
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- return map;
- }
- }
-
- protected class ProtectedNested implements Job {
- public Map doSomething() {
- Map map = new HashMap();
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- return map;
- }
- }
-
- protected static class StaticNested implements Job {
- private Map map = new HashMap();
-
- public Map doSomething() {
- map.put("static", new Boolean(true));
- map.put("staticint", new Integer(staticint));
- return map;
- }
- }
-
- protected class ConstructorNested implements Job {
- Map map = new HashMap();
- public ConstructorNested() {
- map.put("publicObject", publicObject);
- map.put("publicInt", new Integer(publicInt));
- map.put("packageObject", packageObject);
- map.put("packageInt", new Integer(packageInt));
- map.put("protectedObject", protectedObject);
- map.put("protectedInt", new Integer(protectedInt));
- map.put("privateObject", privateObject);
- map.put("privateInt", new Integer(privateInt));
- map.put("nonObject", nonObject);
- map.put("nonInt", new Integer(nonInt));
- }
-
- public Map doSomething() {
- return map;
- }
- }
-
-
-}
-
-interface Job {
- public Map doSomething();
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java
deleted file mode 100644
index a0761e0..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.FooProviderType1;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Test exception handling. POJO exception must be propagated.
- */
-public class ExceptionTest extends OSGiTestCase {
-
- private ComponentInstance ci_lazzy;
-
- private ServiceReference lazzyRef;
- private ServiceReference immRef;
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
-
- String factName = "Manipulation-FooProviderType-1";
- String compName = "FooProvider-1";
- ci_lazzy = helper.createComponentInstance(factName, compName);
-
- String factName2 = "Manipulation-ImmediateFooProviderType";
- String compName2 = "FooProvider-2";
- helper.createComponentInstance(factName2, compName2);
-
- lazzyRef = getServiceReference(Architecture.class.getName(), "(architecture.instance="+compName+")");
- immRef = getServiceReference(Architecture.class.getName(), "(architecture.instance="+compName2+")");
-
- assertNotNull("LazzyRef", lazzyRef);
- assertNotNull("ImmRef", immRef);
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
-
- /**
- * Check that the exception is correctly propagated.
- */
- public void testException() {
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",ref);
- FooProviderType1 fs = (FooProviderType1) getServiceObject(ref);
- try {
- fs.testException();
- fail("The method must returns an exception");
- } catch(Exception e) {
- // OK
- }
- }
-
- /**
- * Check that the exception is correctly catch by the POJO.
- */
- public void testTry() {
- ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
- assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",ref);
- FooProviderType1 fs = (FooProviderType1) getServiceObject(ref);
- try {
- fs.testTry();
- } catch(Exception e) {
- fail("The method has returned an exception");
- }
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java
deleted file mode 100644
index 88144c0..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Pojo;
-import org.apache.felix.ipojo.PrimitiveInstanceDescription;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Check the getComponentInstance method on a POJO
- */
-public class GetComponentInstanceTest extends OSGiTestCase {
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- /**
- * Check if a pojo can correctly be cast in POJO.
- * Check the getComponentInstance method.
- */
- public void testGetComponentInstance() {
- String factName = "Manipulation-FooProviderType-1";
- String compName = "FooProvider-1";
- ServiceReference ref = null;
-
- // Get the factory to create a component instance
- Factory fact = helper.getFactory(factName);
- assertNotNull("Cannot find the factory FooProvider-1", fact);
-
- Properties props = new Properties();
- props.put("instance.name",compName);
- ComponentInstance ci = null;
- try {
- ci = fact.createComponentInstance(props);
- } catch (Exception e1) { fail(e1.getMessage()); }
-
- assertEquals("Check instance name", compName, ci.getInstanceName());
-
- // Get a FooService provider
- ref = helper.getServiceReferenceByName(FooService.class.getName(), compName);
-
- assertNotNull("FS not available", ref);
-
- // Get foo object
- FooService fs = (FooService) getServiceObject(ref);
-
- // Cast to POJO
- Pojo pojo = (Pojo) fs;
-
- // GetComponentInstance
- ComponentInstance instance = pojo.getComponentInstance();
- assertEquals("Check component instance name", instance.getInstanceName(), compName);
- assertEquals("Check component factory name", instance.getFactory().getName(), factName);
- assertNotNull("Instance description not null", instance.getInstanceDescription());
- PrimitiveInstanceDescription id = (PrimitiveInstanceDescription) instance.getInstanceDescription();
- assertTrue("Check instance state", id.getState() == ComponentInstance.VALID);
- assertEquals("Check created pojo count", id.getCreatedObjects().length, 1);
- assertEquals("Check instance description name", id.getName(), compName);
-
- ci.dispose();
-
- // Check that there is no more FooService
- ref = getServiceReference(FooService.class.getName());
- assertNull("FS available, but component instance stopped", ref);
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
deleted file mode 100644
index fe91774..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ManipulationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Manipulation Test Suite", bc);
- ots.addTestSuite(GetComponentInstanceTest.class);
- ots.addTestSuite(ExceptionTest.class);
- ots.addTestSuite(NestedClassesTests.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/NestedClassesTests.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/NestedClassesTests.java
deleted file mode 100644
index e076b6a..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/NestedClassesTests.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.component.InnerClasses;
-import org.apache.felix.ipojo.test.scenarios.component.InnerClasses.PublicNested;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-import org.osgi.framework.ServiceReference;
-
-public class NestedClassesTests extends OSGiTestCase {
-
- private ComponentInstance instance;
- private CheckService service;
-
- IPOJOHelper helper;
-
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Properties map = new Properties();
- map.put("publicObject", "publicObject");
- map.put("publicInt", new Integer(0));
- map.put("packageObject", "packageObject");
- map.put("packageInt", new Integer(1));
- map.put("protectedObject", "protectedObject");
- map.put("protectedInt", new Integer(2));
- map.put("privateObject", "privateObject");
- map.put("privateInt", new Integer(3));
- map.put("nonObject", "nonObject");
- map.put("nonInt", new Integer(4));
- instance = helper.createComponentInstance("inners", map);
-
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
- assertNotNull("Check service availability", ref);
- service = (CheckService) getServiceObject(ref);
- }
-
- public void tearDown() {
- helper.dispose();
- service = null;
- }
-
- public void testPrivateInnerClass() {
- Map data = (Map) service.getProps().get("privateInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testProtectedInnerClass() {
- Map data = (Map) service.getProps().get("protectedInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testPackageInnerClass() {
- Map data = (Map) service.getProps().get("packageInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testPublicInnerClass() {
- Map data = (Map) service.getProps().get("publicInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testConstructorInnerClass() {
- Map data = (Map) service.getProps().get("constructorInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testStaticInnerClass() {
- Map data = (Map) service.getProps().get("staticInner");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check static", new Boolean(true), data.get("static"));
- assertEquals("Check static int", new Integer(6), data.get("staticint"));
-
- }
-
- public void testAnonymousInnerClass() {
- Map data = (Map) service.getProps().get("anonymous");
- assertNotNull("Check data existency", data);
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
- public void testInnerAccess() {
- Map map = (Map) service.getProps();
- assertNotNull("Check map existency", map);
-
- InnerClasses.PublicNested p = (PublicNested) map.get("public");
- Map data = p.doSomething();
-
- assertEquals("Check public object", "publicObject", data.get("publicObject"));
- assertEquals("Check public int", new Integer(0), data.get("publicInt"));
- assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
- assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
- assertEquals("Check package object", "packageObject", data.get("packageObject"));
- assertEquals("Check package int", new Integer(1), data.get("packageInt"));
- assertEquals("Check private object", "privateObject", data.get("privateObject"));
- assertEquals("Check private int", new Integer(3), data.get("privateInt"));
- assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
- assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
-
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
deleted file mode 100644
index 5f5b74b..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service.A123;
-
-public interface CheckService2 {
-
- public boolean check();
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
deleted file mode 100644
index dfe2b9c..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
deleted file mode 100644
index ef7e1ee..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
deleted file mode 100644
index f1e8dc0..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
deleted file mode 100644
index 1bb177c..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface Plop {
-
- Object getPlop();
-
-}
diff --git a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
deleted file mode 100644
index cd61e3b..0000000
--- a/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface PrimitiveManipulationTestService {
-
- byte getByte();
- void setByte(byte b);
-
- short getShort();
- void setShort(short s);
-
- int getInt();
- void setInt(int i);
-
- long getLong();
- void setLong(long l);
-
- float getFloat();
- void setFloat(float f);
-
- double getDouble();
- void setDouble(double d);
-
- char getChar();
- void setChar(char c);
-
- boolean getBoolean();
- void setBoolean(boolean b);
-
- // Array types
- byte[] getBytes();
- void setBytes(byte[] bs);
-
- short[] getShorts();
- void setShorts(short[] ss);
-
- int[] getInts();
- void setInts(int is[]);
-
- long[] getLongs();
- void setLongs(long[] ls);
-
- float[] getFloats();
- void setFloats(float[] fs);
-
- double[] getDoubles();
- void setDoubles(double[] ds);
-
- char[] getChars();
- void setChars(char[] cs);
-
- boolean[] getBooleans();
- void setBooleans(boolean[] bs);
-
- // This method has been added to test an issue when autoboxing.
- void setLong(long l, String s);
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/pom.xml b/ipojo/tests/manipulator/manipulator-java5/pom.xml
deleted file mode 100644
index 7c68ac9..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/pom.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Manipulation Test Suite For Java 5</name>
- <artifactId>tests.manipulation.java5</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.manipulator.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.manipulation.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-junit4osgi-plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java
deleted file mode 100644
index efdc265..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import org.apache.felix.ipojo.test.scenarios.component.Marker.Type;
-
-public class Annotation {
-
- @Marker(name="marker", type=Type.BAR,
- sub=@SubMarker(subname="foo"),
- arrayOfObjects={"foo", "bar", "baz"},
- arrayOfAnnotations= {@SubMarker(subname="foo")}
- )
- @SubMarker(subname="bar")
- @Invisible
- public void doSomething() {
- System.out.println("Foo ...");
- }
-
- @Marker(name="marker", type=Type.BAR,
- sub=@SubMarker(subname="foo"),
- arrayOfObjects={"foo", "bar", "baz"},
- arrayOfAnnotations= {@SubMarker(subname="foo")}
- )
- @SubMarker(subname="bar")
- @Invisible
- public Annotation() {
-
- }
-
- public void doSomethingWithParams(@Marker(name="marker", type=Type.BAR,
- sub=@SubMarker(subname="foo"),
- arrayOfObjects={"foo", "bar", "baz"},
- arrayOfAnnotations= {@SubMarker(subname="foo")}) String foo,
- @Invisible String bar,
- @bla @SubMarker(subname = "baz") String baz) {
- System.out.println("Foo ...");
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @interface bla {
-
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
deleted file mode 100644
index 83f050c..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-public class FooServiceImpl implements FooService {
-
- public boolean foo() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Properties fooProps() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean getBoolean() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public double getDouble() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getInt() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public long getLong() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Boolean getObject() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java
deleted file mode 100644
index 2026df9..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public @interface Invisible {
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
deleted file mode 100644
index fb273c5..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-
-
-public class Manipulation23Tester implements PrimitiveManipulationTestService {
-
- // Integer types
- byte b = 1;
- short s = 1;
- int i = 1;
- long l = 1;
-
- // Floatting types
- double d = 1.1;
- float f = 1.1f;
-
- // Character
- char c = 'a';
-
- // Boolean
- boolean bool = false;
-
- // Integer arrays
- byte[] bs = new byte[] {0,1,2};
- short[] ss = new short[] {0,1,2};
- int[] is = new int[] {0,1,2};
- long[] ls = new long[] {0,1,2};
-
- double[] ds = new double[] {0.0, 1.1, 2.2};
- float[] fs = new float[] {0.0f, 1.1f, 2.2f};
-
- char[] cs = new char[] {'a', 'b', 'c'};
-
- boolean[] bools = new boolean[] {false, true, false};
-
- public boolean getBoolean() { return bool; }
-
- public boolean[] getBooleans() { return bools; }
-
- public byte getByte() { return b; }
-
- public byte[] getBytes() { return bs; }
-
- public char getChar() { return c; }
-
- public char[] getChars() { return cs; }
-
- public double getDouble() { return d; }
-
- public double[] getDoubles() { return ds; }
-
- public float getFloat() { return f; }
-
- public float[] getFloats() { return fs; }
-
- public int getInt() { return i; }
-
- public int[] getInts() { return is; }
-
- public long getLong() { return l; }
-
- public long[] getLongs() { return ls; }
-
- public short getShort() { return s; }
-
- public short[] getShorts() { return ss; }
-
- public void setBoolean(boolean b) { this.bool = b; }
-
- public void setBooleans(boolean[] bs) { this.bools = bs; }
-
- public void setByte(byte b) { this.b = b; }
-
- public void setBytes(byte[] bs) { this.bs = bs; }
-
- public void setChar(char c) { this.c = c; }
-
- public void setChars(char[] cs) { this.cs = cs; }
-
- public void setDouble(double d) { this.d = d; }
-
- public void setDoubles(double[] ds) { this.ds = ds; }
-
- public void setFloat(float f) { this.f = f; }
-
- public void setFloats(float[] fs) { this.fs = fs; }
-
- public void setInt(int i) { this.i = i; }
-
- public void setInts(int[] is) { this.is = is; }
-
- public void setLong(long l) { this.l = l; }
-
- public void setLongs(long[] ls) { this.ls = ls; }
-
- public void setShort(short s) { this.s = s; }
-
- public void setShorts(short[] ss) { this.ss = ss; }
-
- // This method has been added to test an issue when autoboxing.
- public void setLong(long l, String s) {
- this.l = l;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java
deleted file mode 100644
index 98252eb..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Marker {
-
- String name();
-
- String[] arrayOfObjects();
-
- SubMarker sub();
-
- SubMarker[] arrayOfAnnotations();
-
- Type type();
-
- public enum Type {FOO, BAR, BAZ};
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java
deleted file mode 100644
index 005dc0c..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.Plop;
-//TODO this test requires source compatibility 1.5
-public class PlopImpl implements Plop {
-
- public String getPlop() {
- return "plop";
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java
deleted file mode 100644
index 4ee14b9..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface SubMarker {
-
- String subname();
-
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
deleted file mode 100644
index cc8e3b3..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-public class TestTypedList implements CheckService {
-
- private List<FooService> list;
-
- public boolean check() {
- return ! list.isEmpty();
- }
-
- public Properties getProps() {
- Properties props = new Properties();
- if (list != null) {
- props.put("list", list);
-
- int i = 0;
- for (FooService fs : list) {
- props.put(i, fs.foo());
- i++;
- }
- }
-
- return props;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java
deleted file mode 100644
index 81b8831..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.component.Marker;
-import org.apache.felix.ipojo.test.scenarios.component.SubMarker;
-
-public class Annotation extends OSGiTestCase {
-
- private Class clazz;
-
- public void setUp() {
- try {
- clazz = getContext().getBundle().
- loadClass("org.apache.felix.ipojo.test.scenarios.component.Annotation");
- } catch (ClassNotFoundException e) {
- fail("Cannot load the annotation class : " + e.getMessage());
- }
- }
-
- public void testAnnotationOnMethod() {
- Method method = null;
- try {
- method = this.clazz.getMethod("doSomething", new Class[0]);
- } catch (Exception e) {
- fail("Cannot find the doSomething method : " + e.getMessage());
- }
- assertNotNull("Check method existence", method);
-
- java.lang.annotation.Annotation[] annotations = method.getDeclaredAnnotations();
- assertNotNull("Check annotations size - 1", annotations);
- assertEquals("Check annotations size - 2", 2, annotations.length); // Invisible is not visible
-
- /*
- @Marker(name="marker", type=Type.BAR,
- sub=@SubMarker(subname="foo"),
- arrayOfObjects={"foo", "bar", "baz"},
- arrayOfAnnotations= {@SubMarker(subname="foo")}
- )
- @SubMarker(subname="bar")
- @Invisible
- */
-
- Marker marker = getMarkerAnnotation(annotations);
- assertNotNull("Check marker", marker);
-
- assertEquals("Check marker name", "marker", marker.name());
- assertEquals("Check marker type", Marker.Type.BAR, marker.type());
- assertEquals("Check sub marker attribute", "foo", marker.sub().subname());
- assertEquals("Check objects [0]", "foo", marker.arrayOfObjects()[0]);
- assertEquals("Check objects [1]", "bar", marker.arrayOfObjects()[1]);
- assertEquals("Check objects [2]", "baz", marker.arrayOfObjects()[2]);
- assertEquals("Check annotations[0]", "foo", marker.arrayOfAnnotations()[0].subname());
-
- SubMarker sub = getSubMarkerAnnotation(annotations);
- assertNotNull("Check submarker", sub);
- assertEquals("Check submarker", "bar", sub.subname());
-
- }
-
- public void testAnnotationOnConstructor() {
- Constructor method = null;
- try {
- method = clazz.getConstructor(new Class[0]);
- } catch (Exception e) {
- fail("Cannot find the constructor method : " + e.getMessage());
- }
- assertNotNull("Check method existence", method);
-
- java.lang.annotation.Annotation[] annotations = method.getDeclaredAnnotations();
- assertNotNull("Check annotations size - 1", annotations);
- assertEquals("Check annotations size - 2", 2, annotations.length); // Invisible is not visible
-
- /*
- @Marker(name="marker", type=Type.BAR,
- sub=@SubMarker(subname="foo"),
- arrayOfObjects={"foo", "bar", "baz"},
- arrayOfAnnotations= {@SubMarker(subname="foo")}
- )
- @SubMarker(subname="bar")
- @Invisible
- */
-
- Marker marker = getMarkerAnnotation(annotations);
- assertNotNull("Check marker", marker);
-
- assertEquals("Check marker name", "marker", marker.name());
- assertEquals("Check marker type", Marker.Type.BAR, marker.type());
- assertEquals("Check sub marker attribute", "foo", marker.sub().subname());
- assertEquals("Check objects [0]", "foo", marker.arrayOfObjects()[0]);
- assertEquals("Check objects [1]", "bar", marker.arrayOfObjects()[1]);
- assertEquals("Check objects [2]", "baz", marker.arrayOfObjects()[2]);
- assertEquals("Check annotations[0]", "foo", marker.arrayOfAnnotations()[0].subname());
-
- SubMarker sub = getSubMarkerAnnotation(annotations);
- assertNotNull("Check submarker", sub);
- assertEquals("Check submarker", "bar", sub.subname());
- }
-
- public void testParameterAnnotations() {
- Method method = null;
- try {
- method = this.clazz.getMethod("doSomethingWithParams", new Class[] {String.class, String.class, String.class});
- } catch (Exception e) {
- fail("Cannot find the doSomethingWithParams method : " + e.getMessage());
- }
- assertNotNull("Check method existence", method);
-
- java.lang.annotation.Annotation[][] annotations = method.getParameterAnnotations();
- assertNotNull("Check annotations size - 1", annotations);
- assertEquals("Check annotations size - 3", 3, annotations.length);
-
- // Check internals
- // First parameter (foo)
- java.lang.annotation.Annotation[] fooAnns = annotations[0];
- assertEquals("Check fooAnns length", 1, fooAnns.length);
- Marker marker = (Marker) fooAnns[0];
- assertNotNull("Check marker", marker);
- assertEquals("Check marker name", "marker", marker.name());
- assertEquals("Check marker type", Marker.Type.BAR, marker.type());
- assertEquals("Check sub marker attribute", "foo", marker.sub().subname());
- assertEquals("Check objects [0]", "foo", marker.arrayOfObjects()[0]);
- assertEquals("Check objects [1]", "bar", marker.arrayOfObjects()[1]);
- assertEquals("Check objects [2]", "baz", marker.arrayOfObjects()[2]);
- assertEquals("Check annotations[0]", "foo", marker.arrayOfAnnotations()[0].subname());
-
- // Second parameter (bar), no annotation (invisible)
- java.lang.annotation.Annotation[] barAnns = annotations[1];
- assertEquals("Check barAnns length", 0, barAnns.length);
-
- // Third parameter (baz), two annotations
- java.lang.annotation.Annotation[] bazAnns = annotations[2];
- System.out.println(Arrays.toString(bazAnns));
- assertEquals("Check bazAnns length", 2, bazAnns.length);
- }
-
- private Marker getMarkerAnnotation(java.lang.annotation.Annotation[] annotations) {
- for (int i = 0; i < annotations.length; i++) {
- if (annotations[i].annotationType().getName().equals("org.apache.felix.ipojo.test.scenarios.component.Marker")) {
- return (Marker) annotations[i];
- }
- }
- return null;
- }
-
- private SubMarker getSubMarkerAnnotation(java.lang.annotation.Annotation[] annotations) {
- for (int i = 0; i < annotations.length; i++) {
- if (annotations[i].annotationType().getName().equals("org.apache.felix.ipojo.test.scenarios.component.SubMarker")) {
- return (SubMarker) annotations[i];
- }
- }
- return null;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java
deleted file mode 100644
index 871356a..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-import org.osgi.framework.ServiceReference;
-
-public class Boxing extends OSGiTestCase {
-
- ComponentInstance instance; // Instance under test
-
- PrimitiveManipulationTestService prim;
-
- ServiceReference prim_ref;
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- Properties p1 = new Properties();
- p1.put("instance.name","primitives");
- instance = helper.createComponentInstance("ManipulationPrimitives5-PrimitiveManipulationTester", p1);
- assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
- prim_ref = helper.getServiceReferenceByName(PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
- assertNotNull("Check prim availability", prim_ref);
- prim = (PrimitiveManipulationTestService) getServiceObject(prim_ref);
- }
-
- public void tearDown() {
- helper.dispose();
- prim = null;
- }
-
- public void testLongFromObject() {
- assertEquals("Check - 1", prim.getLong(), 1);
- Long l = new Long(2);
- prim.setLong(l);
- assertEquals("Check - 2", prim.getLong(), 2);
- }
-
- public void testLongFromObject2() {
- assertEquals("Check - 1", prim.getLong(), 1);
- Long l = new Long(2);
- prim.setLong(l, "ss");
- assertEquals("Check - 2", prim.getLong(), 2);
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java
deleted file mode 100644
index aefa7cf..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.Plop;
-import org.osgi.framework.ServiceReference;
-
-public class DuplicateMethod extends OSGiTestCase {
-
-
- public void testDuplicateMethod() {
- IPOJOHelper helper = new IPOJOHelper(this);
- helper.createComponentInstance("plopimpl", "plop");
- ServiceReference ref = helper.getServiceReferenceByName(Plop.class.getName(), "plop");
- assertNotNull("Check plop", ref);
- Plop plop = (Plop) getServiceObject(ref);
- Object o = plop.getPlop();
- assertEquals("Check result", "plop", o);
- helper.dispose();
- }
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
deleted file mode 100644
index 3cf22a3..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ManipulationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Manipulation Test Suite for Java 5", bc);
- ots.addTestSuite(DuplicateMethod.class);
- ots.addTestSuite(Boxing.class);
- ots.addTestSuite(Annotation.class);
- ots.addTestSuite(TypedList.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
deleted file mode 100644
index 72395c9..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class TypedList extends OSGiTestCase {
-
- ComponentInstance foo1, foo2;
- ComponentInstance checker;
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- foo1 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl", "foo1");
- foo2 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl", "foo2");
- checker = helper.createComponentInstance("TypedList", "checker");
- foo1.stop();
- foo2.stop();
- }
-
- public void tearDown() {
- helper.dispose();
- }
-
- public void testTypedList() {
- ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), checker.getInstanceName());
- CheckService check = (CheckService) getServiceObject(ref);
- assertNotNull("Checker availability", check);
- // Check without providers
- assertFalse("Empty list", check.check());
-
- // Start the first provider
- foo1.start();
- assertTrue("List with one element", check.check());
- Properties props = check.getProps();
- List<FooService> list = (List<FooService>) props.get("list");
- assertEquals("Check size - 1", 1, list.size());
-
- // Start the second provider
- foo2.start();
- assertTrue("List with two element", check.check());
- props = check.getProps();
- list = (List<FooService>) props.get("list");
- assertEquals("Check size - 2", 2, list.size());
-
- // Stop the first one
- foo1.stop();
- assertTrue("List with one element (2)", check.check());
- props = check.getProps();
- list = (List<FooService>) props.get("list");
- assertEquals("Check size - 3", 1, list.size());
- }
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
deleted file mode 100644
index dfe2b9c..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
deleted file mode 100644
index ef7e1ee..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
deleted file mode 100644
index f1e8dc0..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
deleted file mode 100644
index 1bb177c..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface Plop {
-
- Object getPlop();
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
deleted file mode 100644
index cd61e3b..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface PrimitiveManipulationTestService {
-
- byte getByte();
- void setByte(byte b);
-
- short getShort();
- void setShort(short s);
-
- int getInt();
- void setInt(int i);
-
- long getLong();
- void setLong(long l);
-
- float getFloat();
- void setFloat(float f);
-
- double getDouble();
- void setDouble(double d);
-
- char getChar();
- void setChar(char c);
-
- boolean getBoolean();
- void setBoolean(boolean b);
-
- // Array types
- byte[] getBytes();
- void setBytes(byte[] bs);
-
- short[] getShorts();
- void setShorts(short[] ss);
-
- int[] getInts();
- void setInts(int is[]);
-
- long[] getLongs();
- void setLongs(long[] ls);
-
- float[] getFloats();
- void setFloats(float[] fs);
-
- double[] getDoubles();
- void setDoubles(double[] ds);
-
- char[] getChars();
- void setChars(char[] cs);
-
- boolean[] getBooleans();
- void setBooleans(boolean[] bs);
-
- // This method has been added to test an issue when autoboxing.
- void setLong(long l, String s);
-
-}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml b/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
deleted file mode 100644
index a2ff517..0000000
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
-
- <!-- Check duplicate method issue -->
- <component classname="org.apache.felix.ipojo.test.scenarios.component.PlopImpl"
- name="plopimpl">
- <provides></provides>
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"
- name="ManipulationPrimitives5-PrimitiveManipulationTester"
- architecture="true">
- <provides />
- </component>
- <component classname="org.apache.felix.ipojo.test.scenarios.component.Annotation"
- name="Manipulation-Annotations" />
-
-
- <!-- Typed list -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl">
- <provides />
- </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.TestTypedList" name="TypedList">
- <provides/>
- <requires field="list" optional="true" specification="org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService"/>
- </component>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/manipulator/metadata/pom.xml b/ipojo/tests/manipulator/metadata/pom.xml
deleted file mode 100644
index 4eb056b..0000000
--- a/ipojo/tests/manipulator/metadata/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Manipulation Metadata Test Suite</name>
- <artifactId>tests.manipulation.metadata</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.manipulator.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.manipulation.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Child.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Child.java
deleted file mode 100644
index bc1e310..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Child.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class Child extends Parent {
-
- public Child(String s) {
- super(s);
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
deleted file mode 100644
index e49ede4..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-public class FooBarProviderType1 implements FooService, BarService {
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- return new Properties();
- }
-
- public boolean bar() {
- return true;
- }
-
- public Properties getProps() {
- return new Properties();
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
deleted file mode 100644
index 7fea38d..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.BundleContext;
-
-public class FooProviderType1 implements FooService {
-
- private int m_bar;
- private String m_foo;
-
- private BundleContext m_context;
-
- private static FooProviderType1 singleton;
- private static int count = 0;
-
- private static FooProviderType1 singleton(BundleContext bc) {
- if (singleton == null) {
- count++;
- singleton = new FooProviderType1(bc);
- }
- return singleton;
- }
-
- public static FooProviderType1 several(BundleContext bc) {
- count++;
- return new FooProviderType1(bc);
- }
-
- public FooProviderType1(BundleContext bc) {
- if (bc ==null) {
- throw new RuntimeException("Injected bundle context null");
- }
- m_context = bc;
- }
-
- public boolean foo() {
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("bar", new Integer(m_bar));
- if(m_foo != null) {
- p.put("foo", m_foo);
- }
- p.put("context", m_context);
-
- p.put("count", new Integer(count));
- return p;
- }
-
- public void testException() throws Exception {
- String a = "foobarbaz";
- throw new Exception("foo"+a);
- }
-
- public void testTry() {
- String a = "foo";
- a.charAt(0);
- }
-
- public void testTry2(String s) {
- String a = "foo";
- a.charAt(0);
- }
-
- private void nexttry(String s) {
- try {
- s += "foo";
- } catch(RuntimeException e) {
-
- }
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
- /**
- * Custom constructor.
- * @param bar
- * @param foo
- * @param bc
- */
- public FooProviderType1(int bar, String foo, BundleContext bc) {
- m_bar = bar;
- m_foo = foo;
- m_context = bc;
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
deleted file mode 100644
index d5a9c87..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-public class FooProviderTypeDyn implements FooService {
-
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
-
- public boolean foo() {
- intProp = 3;
- boolProp = true;
- if(strProp.equals("foo")) { strProp = "bar"; }
- else { strProp = "foo"; }
- strAProp = new String[] {"foo", "bar", "baz"};
- intAProp = new int[] {3, 2, 1};
- return true;
- }
-
- public Properties fooProps() {
- Properties p = new Properties();
- p.put("intProp", new Integer(intProp));
- p.put("boolProp", new Boolean(boolProp));
- p.put("strProp", strProp);
- p.put("strAProp", strAProp);
- p.put("intAProp", intAProp);
- return p;
- }
-
- public boolean getBoolean() { return true; }
-
- public double getDouble() { return 1.0; }
-
- public int getInt() { return 1; }
-
- public long getLong() { return 1; }
-
- public Boolean getObject() { return new Boolean(true); }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
deleted file mode 100644
index fb273c5..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-
-
-public class Manipulation23Tester implements PrimitiveManipulationTestService {
-
- // Integer types
- byte b = 1;
- short s = 1;
- int i = 1;
- long l = 1;
-
- // Floatting types
- double d = 1.1;
- float f = 1.1f;
-
- // Character
- char c = 'a';
-
- // Boolean
- boolean bool = false;
-
- // Integer arrays
- byte[] bs = new byte[] {0,1,2};
- short[] ss = new short[] {0,1,2};
- int[] is = new int[] {0,1,2};
- long[] ls = new long[] {0,1,2};
-
- double[] ds = new double[] {0.0, 1.1, 2.2};
- float[] fs = new float[] {0.0f, 1.1f, 2.2f};
-
- char[] cs = new char[] {'a', 'b', 'c'};
-
- boolean[] bools = new boolean[] {false, true, false};
-
- public boolean getBoolean() { return bool; }
-
- public boolean[] getBooleans() { return bools; }
-
- public byte getByte() { return b; }
-
- public byte[] getBytes() { return bs; }
-
- public char getChar() { return c; }
-
- public char[] getChars() { return cs; }
-
- public double getDouble() { return d; }
-
- public double[] getDoubles() { return ds; }
-
- public float getFloat() { return f; }
-
- public float[] getFloats() { return fs; }
-
- public int getInt() { return i; }
-
- public int[] getInts() { return is; }
-
- public long getLong() { return l; }
-
- public long[] getLongs() { return ls; }
-
- public short getShort() { return s; }
-
- public short[] getShorts() { return ss; }
-
- public void setBoolean(boolean b) { this.bool = b; }
-
- public void setBooleans(boolean[] bs) { this.bools = bs; }
-
- public void setByte(byte b) { this.b = b; }
-
- public void setBytes(byte[] bs) { this.bs = bs; }
-
- public void setChar(char c) { this.c = c; }
-
- public void setChars(char[] cs) { this.cs = cs; }
-
- public void setDouble(double d) { this.d = d; }
-
- public void setDoubles(double[] ds) { this.ds = ds; }
-
- public void setFloat(float f) { this.f = f; }
-
- public void setFloats(float[] fs) { this.fs = fs; }
-
- public void setInt(int i) { this.i = i; }
-
- public void setInts(int[] is) { this.is = is; }
-
- public void setLong(long l) { this.l = l; }
-
- public void setLongs(long[] ls) { this.ls = ls; }
-
- public void setShort(short s) { this.s = s; }
-
- public void setShorts(short[] ss) { this.ss = ss; }
-
- // This method has been added to test an issue when autoboxing.
- public void setLong(long l, String s) {
- this.l = l;
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Multiconstructor.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Multiconstructor.java
deleted file mode 100644
index e9a51af..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Multiconstructor.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class Multiconstructor {
-
- public Multiconstructor(String s1, String s2) {
- this(s1, s2, -1);
- }
-
- public Multiconstructor(String s1, int s2) {
- this(s1, "" + s2, s2);
- }
-
- public Multiconstructor(String s1, String s2, int i) {
- //...
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
deleted file mode 100644
index 79dc2ef..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import java.util.Properties;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-import org.osgi.framework.ServiceReference;
-
-public class MultipleCheckService implements CheckService {
-
- FooService fs[];
-
- int simpleB = 0;
-
- int objectB = 0;
-
- int refB = 0;
-
- int bothB = 0;
-
- int simpleU = 0;
-
- int objectU = 0;
-
- int refU = 0;
-
- int bothU = 0;
-
- public boolean check() {
- boolean r = fs.length != 0;
- for (int i = 0; i < fs.length; i++) {
- r = r & fs[i].foo();
- }
- return r;
- }
-
- private boolean getBoolean() {
- return check();
- }
-
- private int getInt() {
- int r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- private long getLong() {
- long r = 0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getLong();
- }
- return r;
- }
-
- private double getDouble() {
- double r = 0.0;
- for (int i = 0; i < fs.length; i++) {
- r = r + fs[i].getInt();
- }
- return r;
- }
-
- protected Object doNothing(Object o, String s) {
- return null;
- }
-
- // private Object getObject() {
- // boolean r = true;
- // for(int i = 0; i < fs.length; i++) {
- // r = r && ((Boolean) fs[i].getObject()).booleanValue();
- // }
- // return new Boolean(r);
- // }
-
- public Properties getProps() {
- Properties props = new Properties();
- props.put("result", new Boolean(check()));
- props.put("voidB", new Integer(simpleB));
- props.put("objectB", new Integer(objectB));
- props.put("refB", new Integer(refB));
- props.put("bothB", new Integer(bothB));
- props.put("voidU", new Integer(simpleU));
- props.put("objectU", new Integer(objectU));
- props.put("refU", new Integer(refU));
- props.put("bothU", new Integer(bothU));
- props.put("boolean", new Boolean(getBoolean()));
- props.put("int", new Integer(getInt()));
- props.put("long", new Long(getLong()));
- props.put("double", new Double(getDouble()));
-
- return props;
- }
-
- public void voidBind() {
- simpleB++;
- }
-
- public void voidUnbind() {
- simpleU++;
- }
-
- public void objectBind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectB++;
- }
- }
-
- public void objectUnbind(FooService o) {
- if (o != null && o instanceof FooService) {
- objectU++;
- }
- }
-
- public void refBind(ServiceReference sr) {
- if (sr != null) {
- refB++;
- }
- }
-
- public void refUnbind(ServiceReference sr) {
- if (sr != null) {
- refU++;
- }
- }
-
- public void bothBind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothB++;
- }
- }
-
- public void bothUnbind(FooService o, ServiceReference sr) {
- if (o != null && o instanceof FooService && sr != null) {
- bothU++;
- }
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Parent.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Parent.java
deleted file mode 100644
index feaaff1..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Parent.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.component;
-
-public class Parent {
-
- private String s;
-
- public Parent(String s) {
- this.s = s;
- }
-
- public String getS() {
- return s;
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java
deleted file mode 100644
index f1a0e39..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.apache.felix.ipojo.parser.ParseUtils;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-/**
- * Check manipulation metadata written in the manifest.
- */
-public class ManipulationMetadata extends OSGiTestCase {
-
- public void testGetMetadata() {
- String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getManipulationForComponent(elem, "ManipulationMetadata-FooProviderType-1");
- assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
- }
-
- public void testInterface() {
- String comp_name = "ManipulationMetadata-FooProviderType-1";
- Element manip = getManipulationForComponent(comp_name);
- Element[] itf = manip.getElements("Interface");
- assertEquals("Check interfaces number", itf.length, 1);
- assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
- }
-
- public void testInterfaces() {
- String comp_name = "ManipulationMetadata-FooBarProviderType-1";
- Element manip = getManipulationForComponent(comp_name);
- Element[] itf = manip.getElements("Interface");
- assertEquals("Check interfaces number", itf.length, 2);
- assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
- assertEquals("Check itf name", itf[1].getAttribute("name"), BarService.class.getName());
- }
-
- public void testFields() {
- String comp_name = "ManipulationMetadata-FooProviderType-Dyn";
- Element manip = getManipulationForComponent(comp_name);
- Element[] fields = manip.getElements("field");
- assertEquals("Check field count " + fields.length, fields.length, 5);
- /*
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
- */
-
- Element field;
-
- field = getFieldFromName(manip, "intProp");
- assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intProp");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
-
- field = getFieldFromName(manip, "strProp");
- assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strProp");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String");
-
- field = getFieldFromName(manip, "strAProp");
- assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strAProp");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String[]");
-
- field = getFieldFromName(manip, "intAProp");
- assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intAProp");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
-
- field = getFieldFromName(manip, "boolProp");
- assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "boolProp");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
- }
-
- public void testPrimitivesFields() {
- String comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
- Element manip = getManipulationForComponent(comp_name);
- Element[] fields = manip.getElements("Field");
- assertEquals("Check field count", fields.length, 16);
- /*
- byte b = 1;
- short s = 1;
- int i = 1;
- long l = 1;
- double d = 1.1;
- float f = 1.1f;
- char c = 'a';
- boolean bool = false;
- byte[] bs = new byte[] {0,1,2};
- short[] ss = new short[] {0,1,2};
- int[] is = new int[] {0,1,2};
- long[] ls = new long[] {0,1,2};
- double[] ds = new double[] {0.0, 1.1, 2.2};
- float[] fs = new float[] {0.0f, 1.1f, 2.2f};
- char[] cs = new char[] {'a', 'b', 'c'};
- boolean[] bools = new boolean[] {false, true, false};
- */
- Element field;
-
- field = getFieldFromName(manip, "b");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte");
- field = getFieldFromName(manip, "s");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short");
- field = getFieldFromName(manip, "i");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
- field = getFieldFromName(manip, "l");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long");
- field = getFieldFromName(manip, "d");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double");
- field = getFieldFromName(manip, "f");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float");
- field = getFieldFromName(manip, "c");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char");
- field = getFieldFromName(manip, "bool");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
-
- field = getFieldFromName(manip, "bs");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte[]");
- field = getFieldFromName(manip, "ss");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short[]");
- field = getFieldFromName(manip, "is");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
- field = getFieldFromName(manip, "ls");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long[]");
- field = getFieldFromName(manip, "ds");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double[]");
- field = getFieldFromName(manip, "fs");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float[]");
- field = getFieldFromName(manip, "cs");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char[]");
- field = getFieldFromName(manip, "bools");
- assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean[]");
- }
-
- public void testNoArgMethod() {
- String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
- Element manip = getManipulationForComponent(comp_name);
- Element method = getMethodFromName(manip, "check");
- assertFalse("Check no args", method.containsAttribute("arguments"));
- assertEquals("Check return", method.getAttribute("return"), "boolean");
- }
-
- public void testOneArgsMethod() {
- String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
- Element manip = getManipulationForComponent(comp_name);
- Element method = getMethodFromName(manip, "refBind");
- assertEquals("Check args", method.getAttribute("arguments"), "{org.osgi.framework.ServiceReference}");
- assertEquals("Check args count", 1, ParseUtils.parseArrays("{org.osgi.framework.ServiceReference}").length);
- assertFalse("Check return", method.containsAttribute("return"));
- }
-
- public void testTwoArgsMethod() {
- String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
- Element manip = getManipulationForComponent(comp_name);
- Element method = getMethodFromName(manip, "doNothing");
- assertEquals("Check args", method.getAttribute("arguments"), "{java.lang.Object,java.lang.String}");
- assertEquals("Check args count", 2, ParseUtils.parseArrays("{java.lang.Object,java.lang.String}").length);
- assertEquals("Check return", method.getAttribute("return"), "java.lang.Object");
- }
-
- private Element getManipulationForComponent(Element metadata, String comp_name) {
- Element[] comps = metadata.getElements("component");
- for(int i = 0; i < comps.length; i++) {
- if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
- return comps[i].getElements("manipulation")[0];
- }
- }
- return null;
- }
-
- private Element getManipulationForComponent(String comp_name) {
- String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
- Element manip = getManipulationForComponent(elem, comp_name);
- assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
- return manip;
- }
-
- private Element getMethodFromName(Element manip, String name) {
- Element methods[] = manip.getElements("Method");
- for(int i = 0; i < methods.length; i++) {
- if(methods[i].containsAttribute("name") && methods[i].getAttribute("name").equals(name)) {
- return methods[i];
- }
- }
- fail("Method " + name + " not found");
- return null;
- }
-
- private Element getFieldFromName(Element manip, String name) {
- Element fields[] = manip.getElements("Field");
- for(int i = 0; i < fields.length; i++) {
- if(fields[i].containsAttribute("name") && fields[i].getAttribute("name").equals(name)) {
- return fields[i];
- }
- }
- fail("Field " + name + " not found");
- return null;
- }
-
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java
deleted file mode 100644
index cdb9c94..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.FieldMetadata;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.MethodMetadata;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.apache.felix.ipojo.parser.PojoMetadata;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
-
-public class ManipulationMetadataAPI extends OSGiTestCase {
-
- PojoMetadata FooProviderType1, FooBarProviderType1, FooProviderTypeDyn, PrimitiveManipulationTester, SimpleMultipleCheckServiceProvider;
-
- public void setUp() {
- String comp_name = "ManipulationMetadata-FooProviderType-1";
- FooProviderType1 = getManipulationMetadataForComponent(comp_name);
-
- comp_name = "ManipulationMetadata-FooBarProviderType-1";
- FooBarProviderType1 = getManipulationMetadataForComponent(comp_name);
-
- comp_name = "ManipulationMetadata-FooProviderType-Dyn";
- FooProviderTypeDyn = getManipulationMetadataForComponent(comp_name);
-
- comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
- PrimitiveManipulationTester = getManipulationMetadataForComponent(comp_name);
-
- comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
- SimpleMultipleCheckServiceProvider = getManipulationMetadataForComponent(comp_name);
- }
-
- public void testGetMetadata() {
- String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getMetadataForComponent(elem, "ManipulationMetadata-FooProviderType-1");
- assertNotNull("Check manipulation metadata not null for " + "Manipulation-FooProviderType-1", manip);
- PojoMetadata mm;
- try {
- mm = new PojoMetadata(manip);
- assertNotNull("Check mm not null", mm);
- } catch (ConfigurationException e) {
- fail("The creation of pojo metadata has failed");
- }
- }
-
- public void testInterface() {
- PojoMetadata manip = FooProviderType1;
-
- String[] itf = manip.getInterfaces();
- assertEquals("Check interfaces number", itf.length, 1);
- assertEquals("Check itf name", itf[0], FooService.class.getName());
-
- assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
- assertFalse("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
- }
-
- public void testInterfaces() {
- PojoMetadata manip = FooBarProviderType1;
- String[] itf = manip.getInterfaces();
- assertEquals("Check interfaces number", itf.length, 2);
- assertEquals("Check itf name", itf[0], FooService.class.getName());
- assertEquals("Check itf name", itf[1], BarService.class.getName());
-
- assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
- assertTrue("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
- }
-
- public void testFields() {
- PojoMetadata manip = FooProviderTypeDyn;
-
- FieldMetadata[] fields = manip.getFields();
- assertEquals("Check field count + " + fields.length, fields.length, 5);
- /*
- private int intProp;
- private String strProp;
- private String[] strAProp;
- private int[] intAProp;
- private boolean boolProp;
- */
-
- FieldMetadata field;
-
- field = manip.getField("intProp");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
- assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "int");
-
- field = manip.getField("intProp", "int");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
-
- field = manip.getField("intProp", "long");
- assertNull("Check bad field", field);
-
- field = manip.getField("strProp");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
- assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "java.lang.String");
-
- field = manip.getField("strProp", "String");
- assertNull("Check bad field", field);
-
- field = manip.getField("strProp", "java.lang.String");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
-
- field = manip.getField("strAProp");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
- assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + FieldMetadata.getReflectionType(field.getFieldType()), FieldMetadata.getReflectionType(field.getFieldType()), "[Ljava.lang.String;");
-
- field = manip.getField("strAProp", "java.lang.String[]");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
-
- field = manip.getField("strAProp", "String[]");
- assertNull("Check bad field", field);
-
- field = manip.getField("intAProp");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
- assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + FieldMetadata.getReflectionType(field.getFieldType()), FieldMetadata.getReflectionType(field.getFieldType()), "[I");
-
- field = manip.getField("intAProp", "int[]");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
-
- field = manip.getField("intAProp", "String[]");
- assertNull("Check bad field", field);
-
- field = manip.getField("boolProp");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
- assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "boolean");
-
- field = manip.getField("boolProp", "boolean");
- assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
-
- field = manip.getField("boolProp", "bool");
- assertNull("Check bad field", field);
- }
-
- public void testPrimitivesFields() {
- PojoMetadata manip = PrimitiveManipulationTester;
- FieldMetadata[] fields = manip.getFields();
- assertEquals("Check field count", fields.length, 16);
-
- FieldMetadata field;
-
- field = manip.getField("b");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte");
- field = manip.getField("s");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short");
- field = manip.getField("i");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
- field = manip.getField("l");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long");
- field = manip.getField("d");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double");
- field = manip.getField("f");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float");
- field = manip.getField("c");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char");
- field = manip.getField("bool");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
-
- field = manip.getField("bs");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte[]");
- field = manip.getField("ss");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short[]");
- field = manip.getField("is");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
- field = manip.getField("ls");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long[]");
- field = manip.getField("ds");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double[]");
- field = manip.getField("fs");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float[]");
- field = manip.getField("cs");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char[]");
- field = manip.getField("bools");
- assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean[]");
- }
-
- public void testNoArgMethod() {
- PojoMetadata manip = SimpleMultipleCheckServiceProvider;
- MethodMetadata method = manip.getMethod("check");
- assertEquals("Check no args", method.getMethodArguments().length, 0);
- assertEquals("Check return", method.getMethodReturn(), "boolean");
-
- method = manip.getMethod("check", new String[0]);
- assertEquals("Check no args", method.getMethodArguments().length, 0);
- assertEquals("Check return", method.getMethodReturn(), "boolean");
- }
-
- public void testOneArgsMethod() {
- PojoMetadata manip = SimpleMultipleCheckServiceProvider;
- MethodMetadata method = manip.getMethods("refBind")[0];
- assertEquals("Check args count", method.getMethodArguments().length, 1);
- assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
- assertEquals("Check return", method.getMethodReturn(), "void");
-
- method = manip.getMethod("refBind", new String[] {"org.osgi.framework.ServiceReference"});
- assertEquals("Check args count", method.getMethodArguments().length, 1);
- assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
- assertEquals("Check return", method.getMethodReturn(), "void");
- }
-
- public void testTwoArgsMethod() {
- PojoMetadata manip = SimpleMultipleCheckServiceProvider;
- MethodMetadata method = manip.getMethods("doNothing")[0];
- assertEquals("Check args count", 2, method.getMethodArguments().length);
- assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
- assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
- assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
-
- method = manip.getMethod("doNothing", new String[] {"java.lang.Object", "java.lang.String"});
- assertEquals("Check args count", 2, method.getMethodArguments().length);
- assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
- assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
- assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
- }
-
- private Element getMetadataForComponent(Element metadata, String comp_name) {
- Element[] comps = metadata.getElements("component");
- for(int i = 0; i < comps.length; i++) {
- if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
- return comps[i];
- }
- if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
- return comps[i];
- }
- }
- return null;
- }
-
-
- private PojoMetadata getManipulationMetadataForComponent(String comp_name) {
- String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
- Element elem = null;
- try {
- elem = ManifestMetadataParser.parseHeaderMetadata(header);
- } catch (ParseException e) {
- fail("Parse Exception when parsing iPOJO-Component");
- }
-
- assertNotNull("Check elem not null", elem);
-
- Element manip = getMetadataForComponent(elem, comp_name);
- assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
- try {
- return new PojoMetadata(manip);
- } catch (ConfigurationException e) {
- fail("The creation of pojo metadata for " + comp_name + " has failed");
- return null;
- }
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
deleted file mode 100644
index c782bbc..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ManipulationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Manipulation Metadata Test Suite", bc);
- ots.addTestSuite(ManipulationMetadata.class);
- ots.addTestSuite(ManipulationMetadataAPI.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
deleted file mode 100644
index 5f5b74b..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service.A123;
-
-public interface CheckService2 {
-
- public boolean check();
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
deleted file mode 100644
index dfe2b9c..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
deleted file mode 100644
index ef7e1ee..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
deleted file mode 100644
index f1e8dc0..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
deleted file mode 100644
index 1bb177c..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface Plop {
-
- Object getPlop();
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
deleted file mode 100644
index cd61e3b..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface PrimitiveManipulationTestService {
-
- byte getByte();
- void setByte(byte b);
-
- short getShort();
- void setShort(short s);
-
- int getInt();
- void setInt(int i);
-
- long getLong();
- void setLong(long l);
-
- float getFloat();
- void setFloat(float f);
-
- double getDouble();
- void setDouble(double d);
-
- char getChar();
- void setChar(char c);
-
- boolean getBoolean();
- void setBoolean(boolean b);
-
- // Array types
- byte[] getBytes();
- void setBytes(byte[] bs);
-
- short[] getShorts();
- void setShorts(short[] ss);
-
- int[] getInts();
- void setInts(int is[]);
-
- long[] getLongs();
- void setLongs(long[] ls);
-
- float[] getFloats();
- void setFloats(float[] fs);
-
- double[] getDoubles();
- void setDoubles(double[] ds);
-
- char[] getChars();
- void setChars(char[] cs);
-
- boolean[] getBooleans();
- void setBooleans(boolean[] bs);
-
- // This method has been added to test an issue when autoboxing.
- void setLong(long l, String s);
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index bcec3d5..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-//import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/manipulator/metadata/src/main/resources/metadata.xml b/ipojo/tests/manipulator/metadata/src/main/resources/metadata.xml
deleted file mode 100644
index df45f15..0000000
--- a/ipojo/tests/manipulator/metadata/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
- <!-- Simple provider used for manipulation analysis -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
- name="ManipulationMetadata-FooProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Provider providing 2 services -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"
- name="ManipulationMetadata-FooBarProviderType-1" architecture="true">
- <provides />
- </component>
-
- <!-- Provider with dynamic property -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
- name="ManipulationMetadata-FooProviderType-Dyn" architecture="true">
- <provides>
- <property name="int" field="intProp" value="2" />
- <property name="boolean" field="boolProp" value="false" />
- <property name="string" field="strProp" value="foo" />
- <property name="strAProp" field="strAProp"
- value="[foo, bar]" />
- <property name="intAProp" field="intAProp" value="[ 1,2,3]" />
- </provides>
- </component>
-
- <!-- Manipulation -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"
- name="ManipulationMetadata-PrimitiveManipulationTester" architecture="true">
- <provides />
- </component>
-
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="ManipulationMetadata-SimpleMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" />
- <provides />
- </component>
-
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.Child">
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.Multiconstructor">
- </component>
-</ipojo>
diff --git a/ipojo/tests/manipulator/primitives/pom.xml b/ipojo/tests/manipulator/primitives/pom.xml
deleted file mode 100644
index 921bc1c..0000000
--- a/ipojo/tests/manipulator/primitives/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Primitive Manipulation Test Suite</name>
- <artifactId>tests.manipulation.primitives</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>${ipojo.manipulator.snapshot}</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.manipulation.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${project.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java
deleted file mode 100644
index 019980f..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component.A123;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-
-
-public class Manipulation23Tester implements PrimitiveManipulationTestService {
-
-
- // Integer types
- byte b = 1;
- short s = 1;
- int i = 1;
- long l = 1;
-
- // Floatting types
- double d = 1.1;
- float f = 1.1f;
-
- // Character
- char c = 'a';
-
- // Boolean
- boolean bool = false;
-
- // Integer arrays
- byte[] bs = new byte[] {0,1,2};
- short[] ss = new short[] {0,1,2};
- int[] is = new int[] {0,1,2};
- long[] ls = new long[] {0,1,2};
-
- double[] ds = new double[] {0.0, 1.1, 2.2};
- float[] fs = new float[] {0.0f, 1.1f, 2.2f};
-
- char[] cs = new char[] {'a', 'b', 'c'};
-
- boolean[] bools = new boolean[] {false, true, false};
-
- public boolean getBoolean() { return bool; }
-
- public boolean[] getBooleans() { return bools; }
-
- public byte getByte() { return b; }
-
- public byte[] getBytes() { return bs; }
-
- public char getChar() { return c; }
-
- public char[] getChars() { return cs; }
-
- public double getDouble() { return d; }
-
- public double[] getDoubles() { return ds; }
-
- public float getFloat() { return f; }
-
- public float[] getFloats() { return fs; }
-
- public int getInt() { return i; }
-
- public int[] getInts() { return is; }
-
- public long getLong() { return l; }
-
- public long[] getLongs() { return ls; }
-
- public short getShort() { return s; }
-
- public short[] getShorts() { return ss; }
-
- public void setBoolean(boolean b) { this.bool = b; }
-
- public void setBooleans(boolean[] bs) { this.bools = bs; }
-
- public void setByte(byte b) { this.b = b; }
-
- public void setBytes(byte[] bs) { this.bs = bs; }
-
- public void setChar(char c) { this.c = c; }
-
- public void setChars(char[] cs) { this.cs = cs; }
-
- public void setDouble(double d) { this.d = d; }
-
- public void setDoubles(double[] ds) { this.ds = ds; }
-
- public void setFloat(float f) { this.f = f; }
-
- public void setFloats(float[] fs) { this.fs = fs; }
-
- public void setInt(int i) { this.i = i; }
-
- public void setInts(int[] is) { this.is = is; }
-
- public void setLong(long l) { this.l = l; }
-
- public void setLongs(long[] ls) { this.ls = ls; }
-
- public void setShort(short s) { this.s = s; }
-
- public void setShorts(short[] ss) { this.ss = ss; }
-
- public void setLong(long l, String s) {
- this.l = l;
- }
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
deleted file mode 100644
index 29415ea..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.component;
-
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-
-
-public class Manipulation23Tester implements PrimitiveManipulationTestService {
-
- // Integer types
- byte b = 1;
- short s = 1;
- int i = 1;
- long l = 1;
-
- // Floatting types
- double d = 1.1;
- float f = 1.1f;
-
- // Character
- char c = 'a';
-
- // Boolean
- boolean bool = false;
-
- // Integer arrays
- byte[] bs = new byte[] {0,1,2};
- short[] ss = new short[] {0,1,2};
- int[] is = new int[] {0,1,2};
- long[] ls = new long[] {0,1,2};
-
- double[] ds = new double[] {0.0, 1.1, 2.2};
- float[] fs = new float[] {0.0f, 1.1f, 2.2f};
-
- char[] cs = new char[] {'a', 'b', 'c'};
-
- boolean[] bools = new boolean[] {false, true, false};
-
- public boolean getBoolean() { return bool; }
-
- public boolean[] getBooleans() { return bools; }
-
- public byte getByte() { return b; }
-
- public byte[] getBytes() { return bs; }
-
- public char getChar() { return c; }
-
- public char[] getChars() { return cs; }
-
- public double getDouble() { return d; }
-
- public double[] getDoubles() { return ds; }
-
- public float getFloat() { return f; }
-
- public float[] getFloats() { return fs; }
-
- public int getInt() { return i; }
-
- public int[] getInts() { return is; }
-
- public long getLong() { return l; }
-
- public long[] getLongs() { return ls; }
-
- public short getShort() { return s; }
-
- public short[] getShorts() { return ss; }
-
- public void setBoolean(boolean b) { this.bool = b; }
-
- public void setBooleans(boolean[] bs) { this.bools = bs; }
-
- public void setByte(byte b) { this.b = b; }
-
- public void setBytes(byte[] bs) { this.bs = bs; }
-
- public void setChar(char c) { this.c = c; }
-
- public void setChars(char[] cs) { this.cs = cs; }
-
- public void setDouble(double d) { this.d = d; }
-
- public void setDoubles(double[] ds) { this.ds = ds; }
-
- public void setFloat(float f) { this.f = f; }
-
- public void setFloats(float[] fs) { this.fs = fs; }
-
- public void setInt(int i) { this.i = i; }
-
- public void setInts(int[] is) { this.is = is; }
-
- public void setLong(long l) { this.l = l; }
-
- public void setLongs(long[] ls) { this.ls = ls; }
-
- public void setShort(short s) { this.s = s; }
-
- public void setShorts(short[] ss) {
- this.ss = new short[ss.length];
- for (int i = 0; i < ss.length; i++) {
- this.ss[i] = ss[i];
- }
- }
-
- // This method has been added to test an issue when autoboxing.
- public void setLong(long l, String s) {
- this.l = l;
- }
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
deleted file mode 100644
index e8116d2..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import junit.framework.Test;
-
-import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
-import org.osgi.framework.BundleContext;
-
-public class ManipulationTestSuite {
-
- public static Test suite(BundleContext bc) {
- OSGiTestSuite ots = new OSGiTestSuite("Primitive Manipulation Test Suite", bc);
- ots.addTestSuite(PrimitiveTypeTest.class);
- ots.addTestSuite(PrimitiveTypeTest2.class);
- return ots;
- }
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
deleted file mode 100644
index c6907cd..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-
-/**
- * Check the manipulation of primitive type (boxed and unboxed).
- */
-public class PrimitiveTypeTest extends OSGiTestCase {
-
- PrimitiveManipulationTestService prim;
-
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- ComponentInstance instance = helper.createComponentInstance("ManipulationPrimitives-PrimitiveManipulationTester");
- assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
- prim = (PrimitiveManipulationTestService) getServiceObject(PrimitiveManipulationTestService.class.getName(), "(instance.name=" + instance.getInstanceName() + ")");
- assertNotNull("Check prim availability", prim);
- }
-
- public void tearDown() {
- helper.dispose();
- prim = null;
- }
-
- public void testByte() {
- assertEquals("Check - 1", prim.getByte(), 1);
- prim.setByte((byte) 2);
- assertEquals("Check - 2", prim.getByte(), 2);
- }
-
- public void testShort() {
- assertEquals("Check - 1", prim.getShort(), 1);
- prim.setShort((short) 2);
- assertEquals("Check - 2", prim.getShort(), 2);
- }
-
- public void testInt() {
- assertEquals("Check - 1", prim.getInt(), 1);
- prim.setInt((int) 2);
- assertEquals("Check - 2", prim.getInt(), 2);
- }
-
- public void testLong() {
- assertEquals("Check - 1", prim.getLong(), 1);
- prim.setLong((long) 2);
- assertEquals("Check - 2", prim.getLong(), 2);
- }
-
- public void testFloat() {
- assertEquals("Check - 1", prim.getFloat(), 1.1f);
- prim.setFloat(2.2f);
- assertEquals("Check - 2", prim.getFloat(), 2.2f);
- }
-
- public void testDouble() {
- assertEquals("Check - 1", prim.getDouble(), 1.1);
- prim.setDouble(2.2);
- assertEquals("Check - 2", prim.getDouble(), 2.2);
- }
-
- public void testBoolean() {
- assertFalse("Check - 1", prim.getBoolean());
- prim.setBoolean(true);
- assertTrue("Check - 2", prim.getBoolean());
- }
-
- public void testChar() {
- assertEquals("Check - 1", prim.getChar(), 'a');
- prim.setChar('b');
- assertEquals("Check - 2", prim.getChar(), 'b');
- }
-
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
deleted file mode 100644
index 81b99a7..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
-import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Check the manipulation of primitive type (boxed and unboxed).
- * The targeted implementation contains numbers.
- */
-public class PrimitiveTypeTest2 extends OSGiTestCase {
-
- PrimitiveManipulationTestService prim;
- IPOJOHelper helper;
-
- public void setUp() {
- helper = new IPOJOHelper(this);
- ComponentInstance instance = helper.createComponentInstance("ManipulationPrimitives-PrimitiveManipulationTesterA");
- assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
- ServiceReference ref = helper.getServiceReferenceByName(PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
- assertNotNull("Check prim availability", ref);
- prim = (PrimitiveManipulationTestService) getServiceObject(ref);
- }
-
- public void tearDown() {
- prim = null;
- helper.dispose();
- }
-
- public void testByte() {
- assertEquals("Check - 1", prim.getByte(), 1);
- prim.setByte((byte) 2);
- assertEquals("Check - 2", prim.getByte(), 2);
- }
-
- public void testShort() {
- assertEquals("Check - 1", prim.getShort(), 1);
- prim.setShort((short) 2);
- assertEquals("Check - 2", prim.getShort(), 2);
- }
-
- public void testInt() {
- assertEquals("Check - 1", prim.getInt(), 1);
- prim.setInt((int) 2);
- assertEquals("Check - 2", prim.getInt(), 2);
- }
-
- public void testLong() {
- assertEquals("Check - 1", prim.getLong(), 1);
- prim.setLong((long) 2);
- assertEquals("Check - 2", prim.getLong(), 2);
- }
-
- public void testLong2() {
- assertEquals("Check - 1", prim.getLong(), 1);
- prim.setLong(2, "ss");
- assertEquals("Check - 2", prim.getLong(), 2);
- }
-
-
-
- public void testFloat() {
- assertEquals("Check - 1", prim.getFloat(), 1.1f);
- prim.setFloat(2.2f);
- assertEquals("Check - 2", prim.getFloat(), 2.2f);
- }
-
- public void testDouble() {
- assertEquals("Check - 1", prim.getDouble(), 1.1);
- prim.setDouble(2.2);
- assertEquals("Check - 2", prim.getDouble(), 2.2);
- }
-
- public void testBoolean() {
- assertFalse("Check - 1", prim.getBoolean());
- prim.setBoolean(true);
- assertTrue("Check - 2", prim.getBoolean());
- }
-
- public void testChar() {
- assertEquals("Check - 1", prim.getChar(), 'a');
- prim.setChar('b');
- assertEquals("Check - 2", prim.getChar(), 'b');
- }
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
deleted file mode 100644
index 5f5b74b..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service.A123;
-
-public interface CheckService2 {
-
- public boolean check();
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
deleted file mode 100644
index dfe2b9c..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface BarService {
-
- public boolean bar();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
deleted file mode 100644
index ef7e1ee..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface CheckService {
-
- public static final String foo = "foo";
-
- public boolean check();
-
- public Properties getProps();
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
deleted file mode 100644
index f1e8dc0..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-import java.util.Properties;
-
-public interface FooService {
-
- boolean foo();
-
- Properties fooProps();
-
- Boolean getObject();
-
- boolean getBoolean();
-
- int getInt();
-
- long getLong();
-
- double getDouble();
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
deleted file mode 100644
index 1bb177c..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface Plop {
-
- Object getPlop();
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
deleted file mode 100644
index cd61e3b..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.manipulation.service;
-
-public interface PrimitiveManipulationTestService {
-
- byte getByte();
- void setByte(byte b);
-
- short getShort();
- void setShort(short s);
-
- int getInt();
- void setInt(int i);
-
- long getLong();
- void setLong(long l);
-
- float getFloat();
- void setFloat(float f);
-
- double getDouble();
- void setDouble(double d);
-
- char getChar();
- void setChar(char c);
-
- boolean getBoolean();
- void setBoolean(boolean b);
-
- // Array types
- byte[] getBytes();
- void setBytes(byte[] bs);
-
- short[] getShorts();
- void setShorts(short[] ss);
-
- int[] getInts();
- void setInts(int is[]);
-
- long[] getLongs();
- void setLongs(long[] ls);
-
- float[] getFloats();
- void setFloats(float[] fs);
-
- double[] getDoubles();
- void setDoubles(double[] ds);
-
- char[] getChars();
- void setChars(char[] cs);
-
- boolean[] getBooleans();
- void setBooleans(boolean[] bs);
-
- // This method has been added to test an issue when autoboxing.
- void setLong(long l, String s);
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
deleted file mode 100644
index bcec3d5..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.test.scenarios.util;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerManagerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-//import org.apache.felix.ipojo.composite.CompositeManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class Utils {
-
- public static Factory getFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
- if (refs == null) {
- System.err.println("Cannot get the factory " + factoryName);
- return null;
- }
- return (HandlerManagerFactory) bc.getService(refs[0]);
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- // if(fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- e.printStackTrace();
- Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- return null;
- }
- // }
- // else {
- // System.err.println("Configuration not accepted by : " + factoryName);
- // return null;
- // }
- }
-
- public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) {
- System.err.println("Factory " + factoryName + " not found");
- return null;
- }
-
- try {
- Properties props = new Properties();
- props.put("instance.name",name);
- return fact.createComponentInstance(props);
- } catch (Exception e) {
- System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
- ServiceReference[] refs = null;
- String filter = "(" + "service.pid" + "=" + pid + ")";
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
- return null;
- }
- }
-
- public static Object getServiceObject(BundleContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
-// public static ServiceContext getServiceContext(ComponentInstance ci) {
-// if (ci instanceof CompositeManager) {
-// return ((CompositeManager) ci).getServiceContext();
-// } else {
-// throw new RuntimeException("Cannot get the service context form an non composite instance");
-// }
-// }
-
- public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
- ServiceReference[] refs;
- try {
- refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
- if (refs == null) { return null; }
- return ((Factory) bc.getService(refs[0]));
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
- return null;
- }
- }
-
- public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
- Factory fact = getFactoryByName(bc, factoryName);
-
- if (fact == null) { return null; }
-
- if (fact.isAcceptable(configuration)) {
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return null;
- }
- } else {
- System.err.println("Configuration not accepted by : " + factoryName);
- return null;
- }
- }
-
- public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
- ServiceReference[] refs = null;
- String filter = null;
- if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- try {
- refs = bc.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- System.err.println("Invalid Filter : " + filter);
- }
- if (refs == null) {
- return null;
- } else {
- return refs[0];
- }
- }
-
- public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
- ServiceReference ref = getServiceReference(bc, itf, filter);
- if (ref != null) {
- return bc.getService(ref);
- } else {
- return null;
- }
- }
-
- public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bc, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bc.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- public static boolean contains(String string, String[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] != null && array[i].equals(string)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean contains(int value, int[] array) {
- for (int i = 0; array != null && i < array.length; i++) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml b/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml
deleted file mode 100644
index b66c91b..0000000
--- a/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<ipojo
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo"
->
-
- <!-- Manipulation -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"
- name="ManipulationPrimitives-PrimitiveManipulationTester" architecture="true">
- <provides />
- </component>
-
- <!-- Manipulation with numbers -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.A123.Manipulation23Tester"
- name="ManipulationPrimitives-PrimitiveManipulationTesterA" architecture="true">
- <provides />
- </component>
-
-
-</ipojo>
diff --git a/ipojo/tests/online-manipulator/pom.xml b/ipojo/tests/online-manipulator/pom.xml
deleted file mode 100644
index 8e8ae03..0000000
--- a/ipojo/tests/online-manipulator/pom.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.online.manipulator.test</artifactId>
- <version>1.7.0-SNAPSHOT</version>
- <name>Online Manipulator Test</name>
- <packaging>jar</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <!--
- Pax Exam API:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- During runtime Pax Exam will discover the OSGi container to use by
- searching metadata available into classpath. Pax Exam comes with a
- default container that uses [Pax Runner] for implementing the
- container requirements:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default
- </artifactId>
- <version>1.2.0</version>
- </dependency>
- <!--
- If your test code is based on JUnit you will have to have the Junit
- support artifact:
- -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <type>jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OSGiHelper.java b/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OSGiHelper.java
deleted file mode 100644
index d8c639e..0000000
--- a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OSGiHelper.java
+++ /dev/null
@@ -1,456 +0,0 @@
-package org.apache.felix.ipojo.online.manipulator.test;
-
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-
-public class OSGiHelper {
-
- /**
- * The bundle context.
- */
- private BundleContext context;
-
- /**
- * List of get references.
- */
- private List<ServiceReference> m_references = new ArrayList<ServiceReference>();
-
- public OSGiHelper(BundleContext context) {
- this.context = context;
- }
-
- public void dispose() {
- // Unget services
- for (int i = 0; i < m_references.size(); i++) {
- context.ungetService((ServiceReference) m_references.get(i));
- }
- m_references.clear();
- }
-
- /**
- * Gets the Bundle Context.
- * @return the bundle context.
- */
- public BundleContext getContext() {
- return context;
- }
-
- /**
- * Returns the service object of a service provided by the specified bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the specified bundle, offering the
- * specified interface and matching the given filter.
- */
- public static Object getServiceObject(Bundle bundle, String itf,
- String filter) {
- ServiceReference ref = getServiceReference(bundle, itf, filter);
- if (ref != null) {
- return bundle.getBundleContext().getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the specified bundle, offering
- * the specified interface and matching the given filter.
- */
- public static Object[] getServiceObjects(Bundle bundle, String itf,
- String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bundle.getBundleContext().getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the specified bundle, offering
- * the specified interface and matching the given filter. If no
- * service is found, {@code null} is returned.
- */
- public static ServiceReference getServiceReference(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs.length != 0) {
- return refs[0];
- } else {
- // No service found
- return null;
- }
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailable(String itf) {
- ServiceReference ref = getServiceReference(itf, null);
- return ref != null;
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @param pid the service pid
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailableByPID(String itf, String pid) {
- ServiceReference ref = getServiceReferenceByPID(itf, pid);
- return ref != null;
- }
-
- /**
- * Returns the service reference of the service provided by the specified
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given persistent ID.
- */
- public static ServiceReference getServiceReferenceByPID(Bundle bundle,
- String itf, String pid) {
- String filter = "(" + "service.pid" + "=" + pid + ")";
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- throw new IllegalStateException(
- "A service lookup by PID returned several providers ("
- + refs.length + ")" + " for " + itf + " with pid="
- + pid);
- }
- }
-
- /**
- * Returns the service reference of all the services provided in the
- * specified bundle, offering the specified interface and matching the given
- * filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the specified bundle,
- * offering the specified interface and matching the given filter.
- * If no service matches, an empty array is returned.
- */
- public static ServiceReference[] getServiceReferences(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- // Get all the service references
- refs = bundle.getBundleContext().getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get service references: " + e.getMessage());
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- /**
- * Returns the service object of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object getServiceObject(String itf, String filter) {
- ServiceReference ref = getServiceReference(itf, filter);
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service object associated with this service reference.
- *
- * @param ref service reference
- * @return the service object.
- */
- public Object getServiceObject(ServiceReference ref) {
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object[] getServiceObjects(String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- m_references.add(refs[i]);
- list[i] = context.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf, String filter) {
- return getServiceReference(context.getBundle(), itf, filter);
- }
-
- /**
- * Returns the service reference of a service provided offering the
- * specified interface.
- *
- * @param itf the interface provided by the searched service.
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf) {
- return getServiceReference(context.getBundle(), itf, null);
- }
-
- /**
- * Returns the service reference of the service provided by the local
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the local bundle, offering the specified
- * interface and having the given persistent ID.
- */
- public ServiceReference getServiceReferenceByPID(String itf, String pid) {
- return getServiceReferenceByPID(context.getBundle(), itf, pid);
- }
-
- /**
- * Returns the service reference of all the services provided in the local
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the local bundle, offering
- * the specified interface and matching the given filter. If no
- * service matches, an empty array is returned.
- */
- public ServiceReference[] getServiceReferences(String itf, String filter) {
- return getServiceReferences(context.getBundle(), itf, filter);
- }
-
- /**
- * Gets the package admin exposed by the framework.
- * Fails if the package admin is not available.
- * @return the package admin service.
- */
- public PackageAdmin getPackageAdmin() {
- PackageAdmin pa = (PackageAdmin) getServiceObject(PackageAdmin.class.getName(), null);
- if (pa == null) {
- fail("No package admin available");
- }
- return pa;
- }
-
- /**
- * Refresh the packages.
- * Fails if the package admin service is not available.
- */
- public void refresh() {
- getPackageAdmin().refreshPackages(null);
- }
-
- /**
- * Waits for a service. Fails on timeout.
- * If timeout is set to 0, it sets the timeout to 10s.
- * @param itf the service interface
- * @param filter the filter
- * @param timeout the timeout
- */
- public void waitForService(String itf, String filter, long timeout) {
- if (timeout == 0) {
- timeout = 10000; // Default 10 secondes.
- }
- ServiceReference[] refs = getServiceReferences(itf, filter);
- long begin = System.currentTimeMillis();
- if (refs.length != 0) {
- return;
- } else {
- while(refs.length == 0) {
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // Interrupted
- }
- long now = System.currentTimeMillis();
-
- if ((now - begin) > timeout) {
- fail("Timeout ... no services matching with the request after " + timeout + "ms");
- }
- refs = getServiceReferences(itf, filter);
- }
- }
- }
-
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @return the installed bundle
- */
- public Bundle installBundle(String url) {
- try {
- return context.installBundle(url);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @param stream input stream containing the bundle
- * @return the installed bundle
- */
- public Bundle installBundle(String url, InputStream stream) {
- try {
- return context.installBundle(url, stream);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url) {
- Bundle bundle = installBundle(url);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @param stream input stream containing the bundle
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url, InputStream stream) {
- Bundle bundle = installBundle(url, stream);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Get the bundle by its id.
- * @param bundleId the bundle id.
- * @return the bundle with the given id.
- */
- public Bundle getBundle(long bundleId) {
- return context.getBundle(bundleId);
- }
-
- /**
- * Gets a bundle by its symbolic name.
- * Fails if no bundle matches.
- * @param name the symbolic name of the bundle
- * @return the bundle object.
- */
- public Bundle getBundle(String name) {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (name.equals(bundles[i].getSymbolicName())) {
- return bundles[i];
- }
- }
- fail("No bundles with the given symbolic name " + name);
- return null; // should not happen
- }
-
-}
diff --git a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OnlineManipulatorTest.java b/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OnlineManipulatorTest.java
deleted file mode 100644
index 11ae242..0000000
--- a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/OnlineManipulatorTest.java
+++ /dev/null
@@ -1,360 +0,0 @@
-package org.apache.felix.ipojo.online.manipulator.test;
-
-
-import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.test.online.components.Consumer;
-import org.apache.felix.ipojo.test.online.components.MyProvider;
-import org.apache.felix.ipojo.online.manipulator.test.service.Hello;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.io.StreamUtils;
-import org.ops4j.pax.exam.Customizer;
-import org.ops4j.pax.exam.Inject;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.ops4j.pax.swissbox.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-
-@RunWith(JUnit4TestRunner.class)
-public class OnlineManipulatorTest {
-
-
- private static File TMP = new File("target/tmp-bundle");
-
- @Inject
- BundleContext context;
-
- private OSGiHelper helper;
-
-
- /*
- * <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.online.manipulator</artifactId>
- <version>1.3.0-SNAPSHOT</version>
-
- */
-
- @Configuration
- public static Option[] configure() throws IOException {
-
-
- String providerWithMetadata = providerWithMetadata();
- String providerWithMetadataInMetaInf = providerWithMetadataInMetaInf();
- String providerWithoutMetadata = providerWithoutMetadata();
- String consumerWithMetadata = consumerWithMetadata();
- String consumerWithoutMetadata = consumerWithoutMetadata();
-
- return options(
- frameworks(
- felix(),
- equinox(),
- knopflerfish() //KF does not export an XML parser.
- ),
- provision(
- mavenBundle()
- .groupId("org.apache.felix")
- .artifactId("org.apache.felix.ipojo")
- .version(asInProject())
- ),
-
- provision(
- newBundle()
- .add(Hello.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "ServiceInterface")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build()
- ),
- systemProperty("providerWithMetadata").value(providerWithMetadata),
- systemProperty("providerWithMetadataInMetaInf").value(providerWithMetadataInMetaInf),
- systemProperty("providerWithoutMetadata").value(providerWithoutMetadata),
- systemProperty("consumerWithMetadata").value(consumerWithMetadata),
- systemProperty("consumerWithoutMetadata").value(consumerWithoutMetadata),
-
- new Customizer() {
- @Override
- public InputStream customizeTestProbe(InputStream testProbe) {
- return TinyBundles.modifyBundle(testProbe).set(Constants.IMPORT_PACKAGE,
- "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
- }
-
- }
- );
-
- }
-
- @Before
- public void before() {
- helper = new OSGiHelper(context);
- }
-
- @After
- public void after() {
- helper.dispose();
- }
-
- private static File getTemporaryFile(String name) throws IOException {
- if (!TMP.exists()) {
- TMP.mkdirs();
- TMP.deleteOnExit();
- }
- File file = File.createTempFile(name, ".jar", TMP);
- //File file = new File(TMP, name + ".jar");
- if (file.exists()) {
- file.delete();
- }
- file.deleteOnExit();
- return file;
- }
-
- @Test
- public void installProviderWithMetadata1() throws BundleException, InvalidSyntaxException, Exception {
- String url = context.getProperty("providerWithMetadata");
- Assert.assertNotNull(url);
- Bundle bundle = context.installBundle("ipojo:" + url);
- bundle.start();
-
- assertBundle("Provider");
-
- helper.waitForService(Hello.class.getName(), null, 5000);
- assertValidity();
- Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
- }
-
-
- @Test
- public void installProviderWithMetadata2() throws BundleException, InvalidSyntaxException, IOException {
- String url = context.getProperty("providerWithMetadataInMetaInf");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url).start();
- assertBundle("Provider");
- helper.waitForService(Hello.class.getName(), null, 5000);
- assertValidity();
- Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
- }
-
- @Test
- public void installProviderWithoutMetadata() throws BundleException, InvalidSyntaxException, IOException {
- String url = context.getProperty("providerWithoutMetadata");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url).start();
- assertBundle("Provider");
- helper.waitForService(Hello.class.getName(), null, 5000);
- assertValidity();
- Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
- }
-
- @Test
- public void installConsumerWithMetadata() throws BundleException, InvalidSyntaxException, IOException {
- String url = context.getProperty("providerWithoutMetadata");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url).start();
- assertBundle("Provider");
-
- String url2 = context.getProperty("consumerWithMetadata");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url2).start();
- assertBundle("Consumer");
- helper.waitForService(Hello.class.getName(), null, 5000);
- // Wait for activation.
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- assertValidity();
- Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
- }
-
- @Test
- public void installConsumerWithoutMetadata() throws BundleException, InvalidSyntaxException, IOException {
- String url = context.getProperty("providerWithMetadataInMetaInf");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url).start();
- assertBundle("Provider");
- helper.waitForService(Hello.class.getName(), null, 5000);
-
- String url2 = context.getProperty("consumerWithoutMetadata");
- Assert.assertNotNull(url);
- context.installBundle("ipojo:" + url2).start();
- assertBundle("Consumer");
- // Wait for activation.
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- assertValidity();
- Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
- }
-
- /**
- * Gets a regular bundle containing metadata file
- *
- * @return the url of the bundle
- * @throws IOException
- */
- public static String providerWithMetadata() throws IOException {
- InputStream is = newBundle()
- .add("metadata.xml", OnlineManipulatorTest.class.getClassLoader().getResource("provider.xml"))
- .add(MyProvider.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
-
- File out = getTemporaryFile("providerWithMetadata");
- StreamUtils.copyStream(is, new FileOutputStream(out), true);
- return out.toURI().toURL().toExternalForm();
- }
-
- /**
- * Gets a regular bundle containing metadata file in the META-INF directory
- *
- * @return the url of the bundle
- * @throws IOException
- */
- public static String providerWithMetadataInMetaInf() throws IOException {
- InputStream is = newBundle()
- .add("META-INF/metadata.xml", OnlineManipulatorTest.class.getClassLoader().getResource("provider.xml"))
- .add(MyProvider.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
-
- File out = getTemporaryFile("providerWithMetadataInMetaInf");
- StreamUtils.copyStream(is, new FileOutputStream(out), true);
- return out.toURI().toURL().toExternalForm();
- }
-
- /**
- * Gets a provider bundle which does not contain the metadata file.
- *
- * @return the url of the bundle + metadata
- * @throws IOException
- */
- public static String providerWithoutMetadata() throws IOException {
- InputStream is = newBundle()
- //.addResource("metadata.xml", this.getClass().getClassLoader().getResource("provider.xml"))
- .add(MyProvider.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
-
- File out = getTemporaryFile("providerWithoutMetadata");
- StreamUtils.copyStream(is, new FileOutputStream(out), true);
- String url = out.toURI().toURL().toExternalForm();
-
- return url + "!" + OnlineManipulatorTest.class.getClassLoader().getResource("provider.xml");
- }
-
- /**
- * Gets a consumer bundle using annotation containing the instance
- * declaration in the metadata.
- *
- * @return the url of the bundle
- * @throws IOException
- */
- public static String consumerWithMetadata() throws IOException {
- InputStream is = newBundle()
- .add("metadata.xml", OnlineManipulatorTest.class.getClassLoader().getResource("consumer.xml"))
- .add(Consumer.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "Consumer")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
-
- File out = getTemporaryFile("consumerWithMetadata");
- StreamUtils.copyStream(is, new FileOutputStream(out), true);
- return out.toURI().toURL().toExternalForm();
- }
-
- /**
- * Gets a consumer bundle using annotation that does not contain
- * metadata
- *
- * @return the url of the bundle + metadata
- * @throws IOException
- */
- public static String consumerWithoutMetadata() throws IOException {
- InputStream is = newBundle()
- .add(Consumer.class)
- .set(Constants.BUNDLE_SYMBOLICNAME, "Consumer")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.online.manipulator.test.service")
- .build();
-
- File out = getTemporaryFile("consumerWithoutMetadata");
- StreamUtils.copyStream(is, new FileOutputStream(out), true);
- String url = out.toURI().toURL().toExternalForm();
-
- return url + "!" + OnlineManipulatorTest.class.getClassLoader().getResource("consumer.xml");
- }
-
-
- public void dumpServices() throws InvalidSyntaxException {
- ServiceReference[] refs = context.getAllServiceReferences(null, null);
- System.out.println(" === Services === ");
- for (ServiceReference ref : refs) {
- String[] itf = (String[]) ref.getProperty(Constants.OBJECTCLASS);
- System.out.println(itf[0]);
- }
- System.out.println("====");
- }
-
- public void dumpBundles() throws InvalidSyntaxException {
- Bundle[] bundles = context.getBundles();
- System.out.println(" === Bundles === ");
- for (Bundle bundle : bundles) {
- String sn = bundle.getSymbolicName();
- System.out.println(sn);
- }
- System.out.println("====");
- }
-
- private void assertBundle(String sn) {
- for (Bundle bundle : context.getBundles()) {
- if (bundle.getSymbolicName().equals(sn)
- && bundle.getState() == Bundle.ACTIVE) {
- return;
- }
-
- }
- Assert.fail("Cannot find the bundle " + sn);
- }
-
- private void assertValidity() {
- try {
- ServiceReference[] refs = context.getServiceReferences(Architecture.class.getName(), null);
- Assert.assertNotNull(refs);
- for (int i = 0; i < refs.length; i++) {
- InstanceDescription id = ((Architecture) context.getService(refs[i])).getInstanceDescription();
- int state = id.getState();
- Assert.assertEquals("State of " + id.getName(), ComponentInstance.VALID, state);
- }
- } catch (InvalidSyntaxException e) {
- Assert.fail(e.getMessage());
- }
-
- }
-
-
-}
diff --git a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/Consumer.java b/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/Consumer.java
deleted file mode 100644
index 9c77b1c..0000000
--- a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/Consumer.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.felix.ipojo.test.online.components;
-
-import org.apache.felix.ipojo.annotations.Component;
-import org.apache.felix.ipojo.annotations.Requires;
-import org.apache.felix.ipojo.online.manipulator.test.service.Hello;
-
-@Component
-public class Consumer {
-
- @Requires
- private Hello hello;
-
- public Consumer() {
- System.out.println(hello.sayHello());
- }
-
-}
diff --git a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/MyProvider.java b/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/MyProvider.java
deleted file mode 100644
index 595c199..0000000
--- a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/impl/MyProvider.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.apache.felix.ipojo.test.online.components;
-
-import org.apache.felix.ipojo.online.manipulator.test.service.Hello;
-
-public class MyProvider implements Hello {
-
- public String sayHello() {
- return "Hello";
- }
-
-}
diff --git a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/service/Hello.java b/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/service/Hello.java
deleted file mode 100644
index c785fbf..0000000
--- a/ipojo/tests/online-manipulator/src/test/java/org/apache/felix/ipojo/online/manipulator/test/service/Hello.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.apache.felix.ipojo.online.manipulator.test.service;
-
-public interface Hello {
-
- public String sayHello();
-
-}
diff --git a/ipojo/tests/online-manipulator/src/test/resources/consumer.xml b/ipojo/tests/online-manipulator/src/test/resources/consumer.xml
deleted file mode 100644
index b075f7b..0000000
--- a/ipojo/tests/online-manipulator/src/test/resources/consumer.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<ipojo>
-<instance component="org.apache.felix.ipojo.test.online.components.Consumer"/>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/online-manipulator/src/test/resources/provider.xml b/ipojo/tests/online-manipulator/src/test/resources/provider.xml
deleted file mode 100644
index 0192784..0000000
--- a/ipojo/tests/online-manipulator/src/test/resources/provider.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<ipojo>
-<component classname="org.apache.felix.ipojo.test.online.components.MyProvider">
- <provides/>
-</component>
-<instance component="org.apache.felix.ipojo.test.online.components.MyProvider"/>
-</ipojo>
\ No newline at end of file
diff --git a/ipojo/tests/pom.xml b/ipojo/tests/pom.xml
deleted file mode 100644
index 448c1b4..0000000
--- a/ipojo/tests/pom.xml
+++ /dev/null
@@ -1,241 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <name>Apache Felix iPOJO Tests</name>
- <packaging>pom</packaging>
-
- <repositories>
- <repository>
- <releases>
- <enabled>false</enabled>
- </releases>
- <id>ow2.snapshots</id>
- <name>OW2 Snapshot Repository</name>
- <url>http://maven.ow2.org/maven2-snapshot/</url>
- </repository>
-
- <repository>
- <id>apache.snapshots</id>
- <name>snapshot plugins</name>
- <url>http://repository.apache.org/snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>apache.plugins.snapshots</id>
- <name>snapshot plugins</name>
- <url>http://repository.apache.org/snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
- <properties>
- <ipojo.core.release>1.8.2</ipojo.core.release>
- <ipojo.core.snapshot>1.9.0-SNAPSHOT</ipojo.core.snapshot>
-
- <ipojo.api.release>1.6.0</ipojo.api.release>
- <ipojo.api.snapshot>1.7.0-SNAPSHOT</ipojo.api.snapshot>
-
- <ipojo.composite.release>1.8.2</ipojo.composite.release>
- <ipojo.composite.snapshot>1.9.0-SNAPSHOT</ipojo.composite.snapshot>
-
- <ipojo.eah.release>1.6.0</ipojo.eah.release>
- <ipojo.eah.snapshot>1.9.0-SNAPSHOT</ipojo.eah.snapshot>
- <ipojo.temporal.snapshot>1.7.0-SNAPSHOT</ipojo.temporal.snapshot>
- <ipojo.wbp.snapshot>1.6.1-SNAPSHOT</ipojo.wbp.snapshot>
-
- <ipojo.manipulator.release>1.8.6</ipojo.manipulator.release>
- <ipojo.manipulator.snapshot>1.9.0-SNAPSHOT</ipojo.manipulator.snapshot>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.annotations</artifactId>
- <version>${ipojo.core.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.api</artifactId>
- <version>${ipojo.api.release}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.composite</artifactId>
- <version>${ipojo.composite.snapshot}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
- <version>${ipojo.manipulator.release}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.handler.whiteboard</artifactId>
- <version>1.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- <version>1.4.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>tinybundles-ipojo</artifactId>
- <version>0.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ow2.chameleon.testing</groupId>
- <artifactId>osgi-helpers</artifactId>
- <version>0.2.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <modules>
- <module>manipulator/manipulation</module>
- <module>manipulator/metadata</module>
- <module>manipulator/primitives</module>
- <module>manipulator/creation</module>
- <module>core/factories</module>
- <module>core/lifecycle-controller</module>
- <module>core/service-providing</module>
- <module>core/lifecycle-callback</module>
- <module>core/service-dependency</module>
- <module>core/service-dependency-bindingpolicy</module>
- <module>core/service-dependency-filter</module>
- <module>core/service-dependency-comparator</module>
- <module>core/service-providing-strategies</module>
- <module>core/service-providing-inheritance</module>
- <module>core/service-dependency-optional</module>
- <module>core/configuration</module>
- <module>core/handler</module>
- <module>core/external-handlers</module>
- <module>core/bad-configurations</module>
- <module>core/logger</module>
- <module>core/factory-version</module>
- <module>composite/composite-runtime</module>
- <module>composite/import-export</module>
- <module>composite/service-instance</module>
- <module>composite/service-providing</module>
- <module>handler/temporal</module>
- <module>handler/whiteboard</module>
- <module>handler/eventadmin</module>
- <module>core/configadmin</module>
- <module>api</module>
- <module>online-manipulator</module>
- </modules>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${ipojo.manipulator.snapshot}</version>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.0.1</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <target>1.5</target>
- <source>1.5</source>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>java5</id>
- <activation>
- <jdk>1.5</jdk>
- </activation>
- <modules>
- <module>core/annotations</module>
- <module>manipulator/manipulator-java5</module>
- <module>handler/jmx</module>
- <module>handler/transaction</module>
- </modules>
- </profile>
- <profile>
- <id>java6</id>
- <activation>
- <jdk>1.6</jdk>
- </activation>
- <modules>
- <module>core/annotations</module>
- <module>manipulator/manipulator-java5</module>
- <module>handler/jmx</module>
- <module>handler/transaction</module>
- </modules>
- </profile>
-
- <profile>
- <id>integration-tests</id>
- <modules>
- <module>integration-tests</module>
- </modules>
- </profile>
- </profiles>
-
-</project>