You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/11/23 18:17:40 UTC

svn commit: r720011 [1/2] - in /felix/trunk/ipojo: examples/junit4osgi/ examples/junit4osgi/junit4osgi/ examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/ examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/...

Author: clement
Date: Sun Nov 23 09:17:38 2008
New Revision: 720011

URL: http://svn.apache.org/viewvc?rev=720011&view=rev
Log:
Add session to junit4osgi:
- services are automatically unget
- instances created with the iPOJO helper are automatically disposed

Add a log service implementation to the junit4osgi plugin to collected logged messages during test execution (as well as messages printed on System.out ans System.err).


Added:
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/LogServiceImpl.java
Removed:
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
    felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
    felix/trunk/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
Modified:
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/helpers/IPOJOHelper.java
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
    felix/trunk/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml
    felix/trunk/ipojo/examples/junit4osgi/pom.xml
    felix/trunk/ipojo/examples/junit4osgi/swing-runner/pom.xml
    felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
    felix/trunk/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticProps.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/StaticPropsReconfiguration.java
    felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
    felix/trunk/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java
    felix/trunk/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java
    felix/trunk/ipojo/tests/manipulator/manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/NestedClassesTests.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
    felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
    felix/trunk/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/metadata.xml?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/metadata.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/metadata.xml Sun Nov 23 09:17:38 2008
@@ -10,6 +10,8 @@
 			onArrival="onBundleArrival" onDeparture="onBundleDeparture" />
 		<callback transition="invalidate" method="stopping" />
 		<callback transition="validate" method="starting" />
+		<requires field="m_log" optional="true" 
+			default-implementation="org.apache.felix.ipojo.junit4osgi.impl.LogServiceImpl"/>
 		<provides />
 	</component>
 	<instance

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml Sun Nov 23 09:17:38 2008
@@ -78,7 +78,6 @@
 							org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase,
 							org.apache.felix.ipojo.junit4osgi.test.TestTestSuite,
 							org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestSuite,
-							org.apache.felix.ipojo.junit4osgi.test.MyTestCase
 						</Test-Suite>  -->
 					</instructions>
 				</configuration>

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java Sun Nov 23 09:17:38 2008
@@ -18,14 +18,15 @@
  */
 package org.apache.felix.ipojo.junit4osgi;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import junit.framework.TestCase;
 
-import org.apache.felix.ipojo.Factory;
 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;
 
 /**
  * OSGi Test Case. Allow the injection of the bundle context.
@@ -35,6 +36,23 @@
 public class OSGiTestCase extends TestCase {
 
 	protected BundleContext context;
+	
+	
+	private List references = new ArrayList();
+	
+    /**
+     * Extends runBare to release (unget) services after the teardown.
+     * @throws Throwable when an error occurs.
+     * @see junit.framework.TestCase#runBare()
+     */
+    public void runBare() throws Throwable {
+	    super.runBare();
+	    // Unget services
+	    for (int i = 0; i < references.size(); i++) {
+	        context.ungetService((ServiceReference) references.get(i));
+	    }
+	    references.clear();
+	}
 
 	public void setBundleContext(BundleContext bc) {
 		context = bc;
@@ -180,8 +198,6 @@
 		return false;
 	}
 
-	
-
 	private static String formatEqualsMessage(String message, Object expected,
 			Object actual) {
 		String formatted = "";
@@ -311,18 +327,6 @@
         ServiceReference ref = getServiceReference(itf, null);
         return ref != null;
     }
-
-	/**
-     * Checks if the service is available.
-     * @param itf the service interface
-     * @param 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;
-    }
     
     /**
      * Checks if the service is available.
@@ -371,33 +375,6 @@
 	
 
 	/**
-	 * 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 in 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 {
-			filter = "(" + "instance.name" + "=" + name + ")";
-		}
-		return getServiceReference(bundle, itf, filter);
-	}
-
-	
-
-	/**
 	 * Returns the service reference of all the services provided in the
 	 * specified bundle, offering the specified interface and matching the given
 	 * filter.
@@ -443,8 +420,32 @@
 	 *         specified interface and matching the given filter.
 	 */
 	public Object getServiceObject(String itf, String filter) {
-		return getServiceObject(context.getBundle(), itf, filter);
-	}
+		ServiceReference ref = getServiceReference(itf, filter);
+        if (ref != null) {
+            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) {
+            references.add(ref);
+            return context.getService(ref);
+        } else {
+            return null;
+        }
+    }
 
 	/**
 	 * Returns the service objects of the services provided by the local
@@ -458,8 +459,18 @@
 	 *         the specified interface and matching the given filter.
 	 */
 	public Object[] getServiceObjects(String itf, String filter) {
-		return getServiceObjects(context.getBundle(), itf, filter);
-	}
+	    ServiceReference[] refs = getServiceReferences(itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                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
@@ -476,6 +487,20 @@
 	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
@@ -494,21 +519,6 @@
 	}
 
 	/**
-	 * 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(context.getBundle(), itf, name);
-	}
-
-	/**
 	 * Returns the service reference of all the services provided in the
 	 * local bundle, offering the specified interface and matching the given
 	 * filter.

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/helpers/IPOJOHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/helpers/IPOJOHelper.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/helpers/IPOJOHelper.java (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/helpers/IPOJOHelper.java Sun Nov 23 09:17:38 2008
@@ -18,7 +18,9 @@
  */
 package org.apache.felix.ipojo.junit4osgi.helpers;
 
+import java.util.ArrayList;
 import java.util.Dictionary;
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.felix.ipojo.ComponentInstance;
@@ -26,6 +28,7 @@
 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.junit4osgi.OSGiTestCase;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.parser.ManifestMetadataParser;
@@ -41,9 +44,29 @@
     private BundleContext context;
     private OSGiTestCase testcase;
     
+    
+    private List instances;
+    
     public IPOJOHelper(OSGiTestCase tc) {
         testcase = tc;
         context = testcase.getBundleContext();
+        instances = new ArrayList();
+    }
+    
+    public void dispose() {
+        for (int i = 0; i < instances.size(); i++) {
+            ((ComponentInstance) instances.get(i)).dispose();
+        }
+        instances.clear();
+    }
+    
+    public ComponentInstance getInstanceByName(String name) {
+        for (int i = 0; i < instances.size(); i++) {
+            if (((ComponentInstance) instances.get(i)).getInstanceName().equals(name)) {
+                return (ComponentInstance) instances.get(i);
+            }
+        }
+        return null;
     }
     
     /**
@@ -232,8 +255,10 @@
      */
     public ComponentInstance createComponentInstance(String factoryName,
             String instanceName) {
-        return createComponentInstance(context.getBundle(), factoryName,
+        ComponentInstance ci = createComponentInstance(context.getBundle(), factoryName,
                 instanceName);
+        instances.add(ci);
+        return ci;
     }
 
     /**
@@ -248,8 +273,25 @@
      */
     public ComponentInstance createComponentInstance(String factoryName,
             Dictionary configuration) {
-        return createComponentInstance(context.getBundle(), factoryName,
+        ComponentInstance ci =  createComponentInstance(context.getBundle(), factoryName,
                 configuration);
+        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(context.getBundle(), factoryName,
+                (Dictionary) null);
+        instances.add(ci);
+        return ci;
     }
 
     /**
@@ -269,8 +311,10 @@
      */
     public ComponentInstance createComponentInstance(String factoryName,
             String instanceName, Dictionary configuration) {
-        return createComponentInstance(context.getBundle(), factoryName,
+        ComponentInstance ci = createComponentInstance(context.getBundle(), factoryName,
                 instanceName, configuration);
+        instances.add(ci);
+        return ci;
     }
 
     /**
@@ -614,6 +658,8 @@
         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 + ")";
         }
@@ -659,5 +705,59 @@
         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 in 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 OSGiTestCase.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(context.getBundle(), itf, name);
+    }
+    
+    /**
+     * Checks if the service is available.
+     * @param itf the service interface
+     * @param 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;
+    }
+    
 
 }

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java Sun Nov 23 09:17:38 2008
@@ -40,6 +40,7 @@
 import org.apache.felix.ipojo.parser.ParseUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
 
 /**
  * Detect test suite from installed bundles.
@@ -52,18 +53,20 @@
     private Map/*<Bundle, List<Class>>*/ m_suites = new HashMap/*<Bundle, List<Class>>*/();
 
     private ResultPrinter m_printer = new ResultPrinter(System.out);
+    
+    private LogService m_log;
 
     void onBundleArrival(Bundle bundle, String header) {
         String[] tss = ParseUtils.split(header, ",");
         for (int i = 0; i < tss.length; i++) {
             try {
                 if (tss[i].length() != 0) {
-                    System.out.println("Loading " + tss[i]);
+                    m_log.log(LogService.LOG_INFO, "Loading " + tss[i]);
                     Class/*<? extends Test>*/ clazz = bundle.loadClass(tss[i].trim());
                     addTestSuite(bundle, clazz);
                 }
             } catch (ClassNotFoundException e) {
-                System.err.println("The test suite " + tss[i] + " is not in the bundle " + bundle.getBundleId() + " : " + e.getMessage());
+                m_log.log(LogService.LOG_ERROR, "The test suite " + tss[i] + " is not in the bundle " + bundle.getBundleId() + " : " + e.getMessage());
             }
         }
     }
@@ -81,7 +84,7 @@
 
     private synchronized void removeTestSuites(Bundle bundle) {
         List list = (List) m_suites.remove(bundle);
-        System.out.println("Unload test suites " + list);
+        m_log.log(LogService.LOG_INFO, "Unload test suites " + list);
     }
 
     void onBundleDeparture(Bundle bundle) {
@@ -147,7 +150,7 @@
         }
 
         if (!Modifier.isStatic(suiteMethod.getModifiers())) {
-            System.err.println("Suite() method must be static");
+            m_log.log(LogService.LOG_ERROR, "Suite() method must be static");
             return null;
         }
         Test test = null;
@@ -158,10 +161,10 @@
                 test = (Test) suiteMethod.invoke(null, (Object[]) new Class[0]); // static method
             }
         } catch (InvocationTargetException e) {
-            System.err.println("Failed to invoke suite():" + e.getTargetException().toString());
+            m_log.log(LogService.LOG_ERROR, "Failed to invoke suite():" + e.getTargetException().toString());
             return null;
         } catch (IllegalAccessException e) {
-            System.err.println("Failed to invoke suite():" + e.toString());
+            m_log.log(LogService.LOG_ERROR, "Failed to invoke suite():" + e.toString());
             return null;
         }
 
@@ -225,12 +228,12 @@
     }
 
     public synchronized void stopping() {
-        System.out.println("Cleaning test suites ...");
+        m_log.log(LogService.LOG_INFO, "Cleaning test suites ...");
         m_suites.clear();
     }
     
     public void starting() {
-        System.out.println("Junit Extender starting ...");
+        m_log.log(LogService.LOG_INFO, "Junit Extender starting ...");
     }
 
     private BundleContext getBundleContext(Bundle bundle) {
@@ -264,13 +267,13 @@
             try {
                 return (BundleContext) meth.invoke(bundle, new Object[0]);
             } catch (IllegalArgumentException e) {
-                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                m_log.log(LogService.LOG_ERROR, "Cannot get the BundleContext by invoking " + meth.getName(), e);
                 return null;
             } catch (IllegalAccessException e) {
-                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                m_log.log(LogService.LOG_ERROR, "Cannot get the BundleContext by invoking " + meth.getName(), e);
                 return null;
             } catch (InvocationTargetException e) {
-                err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                m_log.log(LogService.LOG_ERROR, "Cannot get the BundleContext by invoking " + meth.getName(), e);
                 return null;
             }
         }
@@ -285,20 +288,16 @@
                 try {
                     return (BundleContext) fields[i].get(bundle);
                 } catch (IllegalArgumentException e) {
-                    err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                    m_log.log(LogService.LOG_ERROR, "Cannot get the BundleContext by invoking " + meth.getName(), e);
                     return null;
                 } catch (IllegalAccessException e) {
-                    err("Cannot get the BundleContext by invoking " + meth.getName(), e);
+                    m_log.log(LogService.LOG_ERROR, "Cannot get the BundleContext by invoking " + meth.getName(), e);
                     return null;
                 }
             }
         }
-        err("Cannot find the BundleContext for " + bundle.getSymbolicName(), null);
+        m_log.log(LogService.LOG_ERROR, "Cannot find the BundleContext for " + bundle.getSymbolicName(), null);
         return null;
     }
 
-    private void err(String s, Throwable e) {
-        System.err.println(s + " : " + e.getMessage());
-    }
-
 }

Added: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/LogServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/LogServiceImpl.java?rev=720011&view=auto
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/LogServiceImpl.java (added)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/LogServiceImpl.java Sun Nov 23 09:17:38 2008
@@ -0,0 +1,48 @@
+package org.apache.felix.ipojo.junit4osgi.impl;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+public class LogServiceImpl implements LogService {
+    
+    private String computeLogMessage(int level, String msg, Throwable exception) {
+        String message = null;
+        switch (level) {
+            case LogService.LOG_DEBUG:
+                message = "[DEBUG] " + msg;
+                break;
+            case LogService.LOG_ERROR:
+                message = "[ERROR] " + msg;
+                break;
+            case LogService.LOG_INFO:
+                message = "[INFO] " + msg;
+                break;
+            case LogService.LOG_WARNING:
+                message = "[WARNING] " + msg;
+                break;
+        }
+        
+        if (exception != null) {
+            message = message + " : " + exception.getMessage();
+        }
+        
+        return message;
+    }
+
+    public void log(int arg0, String arg1) {
+        System.err.println(computeLogMessage(arg0, arg1, null));
+    }
+
+    public void log(int arg0, String arg1, Throwable arg2) {
+        System.err.println(computeLogMessage(arg0, arg1, arg2));
+    }
+
+    public void log(ServiceReference arg0, int arg1, String arg2) {
+        System.err.println(computeLogMessage(arg1, arg2, null));
+    }
+
+    public void log(ServiceReference arg0, int arg1, String arg2, Throwable arg3) {
+        System.err.println(computeLogMessage(arg1, arg2, arg3));
+    }
+
+}

Modified: felix/trunk/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/maven-junit4osgi-plugin/pom.xml Sun Nov 23 09:17:38 2008
@@ -23,7 +23,7 @@
 	<artifactId>maven-junit4osgi-plugin</artifactId>
 	<packaging>maven-plugin</packaging>
 	<version>1.1.0-SNAPSHOT</version>
-	<name>maven-junit4osgi-plugin Maven Mojo</name>
+	<name>Junit4OSGi Maven Plugin</name>
 	<url>http://maven.apache.org</url>
 	<dependencies>
 		<dependency>
@@ -35,7 +35,6 @@
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
 			<version>3.8.1</version>
-			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>
@@ -66,7 +65,6 @@
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.ipojo</artifactId>
 			<version>1.1.0-SNAPSHOT</version>
-			<scope>runtime</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.felix</groupId>

Modified: felix/trunk/ipojo/examples/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/pom.xml?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/pom.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/pom.xml Sun Nov 23 09:17:38 2008
@@ -27,6 +27,7 @@
   <modules>
 		<module>junit4osgi</module>
 		<module>felix-command</module>
+		<module>maven-junit4osgi-plugin</module>
   </modules>
 
   <profiles>

Modified: felix/trunk/ipojo/examples/junit4osgi/swing-runner/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/swing-runner/pom.xml?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/swing-runner/pom.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/swing-runner/pom.xml Sun Nov 23 09:17:38 2008
@@ -66,6 +66,7 @@
 						<Private-Package>
 							org.apache.felix.ipojo.junit4osgi.command
 						</Private-Package>
+						<Import-Package>org.osgi.framework;version=1.3,*</Import-Package>
 					</instructions>
 				</configuration>
 			</plugin>

Modified: felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java (original)
+++ felix/trunk/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/jmx/JMXSimple.java Sun Nov 23 09:17:38 2008
@@ -1,12 +1,11 @@
 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)
+@org.apache.felix.ipojo.handlers.jmx.Config(domain="my-domain", usesMOSGi=false)
 public class JMXSimple {
 
     @Property(name="prop", notification=true, rights="w")

Modified: felix/trunk/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java (original)
+++ felix/trunk/ipojo/tests/core/service-dependency-comparator/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/comparator/ComparatorTestCase.java Sun Nov 23 09:17:38 2008
@@ -26,18 +26,17 @@
     }
     
     public void tearDown() {
-       dynInstance.dispose();
-       dpInstance.dispose();
+       helper.dispose();
     }
     
     public void testDynamic() {
-        ComponentInstance grade1 = createGrade(1);
+        createGrade(1);
         ComponentInstance grade2 = createGrade(2);
         
-        ServiceReference ref = getServiceReferenceByName(CheckService.class.getName(), dynInstance.getInstanceName());
+        ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), dynInstance.getInstanceName());
         assertNotNull("CS availability", ref);
         
-        CheckService cs = (CheckService) context.getService(ref);
+        CheckService cs = (CheckService) getServiceObject(ref);
         Properties result = cs.getProps();
         int fsGrade = ((Integer) result.get("fs")).intValue();
         int fs2Grade = ((Integer) result.get("fs2")).intValue();
@@ -51,7 +50,7 @@
         assertEquals("fss grade[0] -1", 2, fssGrades[0]);
         assertEquals("fss grade[1] -1", 1, fssGrades[1]);
         
-        ComponentInstance grade3 = createGrade(3);
+        createGrade(3);
         result = cs.getProps();
         fsGrade = ((Integer) result.get("fs")).intValue();
         fs2Grade = ((Integer) result.get("fs2")).intValue();
@@ -76,21 +75,16 @@
         assertEquals("fss grade size -3", 2, fssGrades.length);
         assertEquals("fss grade[0] -3", 1, fssGrades[0]);
         assertEquals("fss grade[1] -3", 3, fssGrades[1]);        
-        
-        context.ungetService(ref);
-        grade1.dispose();
-        grade2.dispose();
-        grade3.dispose();
     }
     
     public void testDynamicPriority() {
-        ComponentInstance grade1 = createGrade(1);
+        createGrade(1);
         ComponentInstance grade2 = createGrade(2);
         
-        ServiceReference ref = getServiceReferenceByName(CheckService.class.getName(), dpInstance.getInstanceName());
+        ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), dpInstance.getInstanceName());
         assertNotNull("CS availability", ref);
         
-        CheckService cs = (CheckService) context.getService(ref);
+        CheckService cs = (CheckService) getServiceObject(ref);
         Properties result = cs.getProps();
         int fsGrade = ((Integer) result.get("fs")).intValue();
         int fs2Grade = ((Integer) result.get("fs2")).intValue();
@@ -102,7 +96,7 @@
         assertEquals("fss grade[0] -1", 2, fssGrades[0]);
         assertEquals("fss grade[1] -1", 1, fssGrades[1]);
         
-        ComponentInstance grade3 = createGrade(3);
+        createGrade(3);
         result = cs.getProps();
         fsGrade = ((Integer) result.get("fs")).intValue();
         fs2Grade = ((Integer) result.get("fs2")).intValue();
@@ -127,11 +121,6 @@
         assertEquals("fss grade size -3", 2, fssGrades.length);
         assertEquals("fss grade[0] -3", 3, fssGrades[0]);
         assertEquals("fss grade[1] -3", 1, fssGrades[1]);        
-        
-        context.ungetService(ref);
-        grade1.dispose();
-        grade2.dispose();
-        grade3.dispose();
     }
     
     private ComponentInstance createGrade(int grade) {

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicProps.java Sun Nov 23 09:17:38 2008
@@ -20,25 +20,19 @@
 
 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.ps.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
 import org.osgi.framework.ServiceReference;
 
 public class DynamicProps extends OSGiTestCase {
 	
-	ComponentInstance fooProvider1;
-	ComponentInstance fooProvider2;
-	ComponentInstance fooProvider3;
-	ComponentInstance fooProvider4;
+	IPOJOHelper helper;
 
 	public void setUp() {
+	    helper = new IPOJOHelper(this);
 		String type = "PS-FooProviderType-Dyn";
-		
-		Properties p1 = new Properties();
-		p1.put("instance.name","FooProvider-1");
-		fooProvider1 = Utils.getComponentInstance(context, type, p1);
+		helper.createComponentInstance(type, "FooProvider-1");
 		
 		Properties p2 = new Properties();
 		p2.put("instance.name","FooProvider-2");
@@ -47,7 +41,7 @@
 		p2.put("string", new String("bar"));
 		p2.put("strAProp", new String[] {"bar", "foo"});
 		p2.put("intAProp", new int[] {1, 2, 3});
-		fooProvider2 = Utils.getComponentInstance(context, type, p2);
+		helper.createComponentInstance(type, p2);
 		
 		String type2 = "PS-FooProviderType-Dyn2";
 		Properties p3 = new Properties();
@@ -57,27 +51,20 @@
 		p3.put("string", new String(""));
 		p3.put("strAProp", new String[0]);
 		p3.put("intAProp", new int[0]);
-		fooProvider3 = Utils.getComponentInstance(context, type2, p3);
+		helper.createComponentInstance(type2, p3);
 		
         Properties p4 = new Properties();
         p4.put("instance.name","FooProvider-4");
-        fooProvider4 = Utils.getComponentInstance(context, type2, p4);
+        helper.createComponentInstance(type2, p4);
 		
 	}
 	
 	public void tearDown() {
-		fooProvider1.dispose();
-		fooProvider1 = null;
-		fooProvider2.dispose();
-		fooProvider2 = null;
-		fooProvider3.dispose();
-		fooProvider3 = null;
-		fooProvider4.dispose();
-		fooProvider4 = null;
+		helper.dispose();
 	}
 	
 	public void testProperties1() {
-		ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-1");
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-1");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -102,7 +89,7 @@
 		}
 		
 		// Invoke
-		FooService fs = (FooService) context.getService(sr);
+		FooService fs = (FooService) getServiceObject(sr);
 		assertTrue("invoke fs", fs.foo());
 		
 		// Re-check the property (change)
@@ -127,11 +114,10 @@
 		}
 		
 		fs = null;
-		context.ungetService(sr);
 	}
 	
 	public void testProperties2() {
-		ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-2");
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-2");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -156,7 +142,7 @@
 		}
 		
 		// Invoke
-		FooService fs = (FooService) context.getService(sr);
+		FooService fs = (FooService) getServiceObject(sr);
 		assertTrue("invoke fs", fs.foo());
 		
 		// Re-check the property (change)
@@ -181,11 +167,10 @@
 		}
 		
 		fs = null;
-		context.ungetService(sr);	
 	}
 	
 	public void testProperties3() {
-		ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -210,7 +195,7 @@
 		}
 		
 		// Invoke
-		FooService fs = (FooService) context.getService(sr);
+		FooService fs = (FooService) getServiceObject(sr);
 		assertTrue("invoke fs", fs.foo());
 		
 		// Re-check the property (change)
@@ -231,12 +216,10 @@
 		assertNull("Check intAProp hidding (no value)", intAProp);
 		
 		fs = null;
-		context.ungetService(sr);	
-
 	}
 
     public void testProperties4() {
-    	ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-4");
+    	ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -258,7 +241,7 @@
         }
     	
     	// Invoke
-    	FooService fs = (FooService) context.getService(sr);
+    	FooService fs = (FooService) getServiceObject(sr);
     	assertTrue("invoke fs", fs.foo());
     	
     	// Re-check the property (change)
@@ -278,9 +261,7 @@
     	}
     	assertNull("Check intAProp hidding (no value)", intAProp);
     	
-    	fs = null;
-    	context.ungetService(sr);	
-    
+    	fs = null;    
     }
 
 }

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/DynamicPropsReconfiguration.java Sun Nov 23 09:17:38 2008
@@ -23,8 +23,8 @@
 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.apache.felix.ipojo.test.scenarios.util.Utils;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -32,7 +32,10 @@
 public class DynamicPropsReconfiguration extends OSGiTestCase {
 	ComponentInstance fooProvider3, fooProvider4;
 	
-	public void setUp() {		
+	IPOJOHelper helper;
+
+    public void setUp() {
+        helper = new IPOJOHelper(this);		
 		String type2 = "PS-FooProviderType-Dyn2";
 		Properties p3 = new Properties();
 		p3.put("instance.name","FooProvider-3");
@@ -41,22 +44,17 @@
 		p3.put("string", new String(""));
 		p3.put("strAProp", new String[0]);
 		p3.put("intAProp", new int[0]);
-		fooProvider3 = Utils.getComponentInstance(context, type2, p3);
+		fooProvider3 = helper.createComponentInstance(type2, p3);
 		
-		Properties p4 = new Properties();
-        p4.put("instance.name","FooProvider-4");
-        fooProvider4 = Utils.getComponentInstance(context, type2, p4);
+        fooProvider4 = helper.createComponentInstance(type2, "FooProvider-4");
 	}
 	
 	public void tearDown() {
-		fooProvider3.dispose();
-		fooProvider3 = null;
-	    fooProvider4.dispose();
-	    fooProvider4 = null;
+		helper.dispose();
 	}
 	
 	public void testFactoryReconf() {
-    	ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -81,8 +79,8 @@
     	}
     	
     	// Reconfiguration
-    	ServiceReference fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-    	Factory fact = (Factory) context.getService(fact_ref);
+    	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));
@@ -96,7 +94,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -121,7 +119,7 @@
     	}	
     	
     	// Invoke
-    	FooService fs = (FooService) context.getService(sr);
+    	FooService fs = (FooService) getServiceObject(sr);
     	assertTrue("invoke fs", fs.foo());
     	
     	// Re-check the property (change)
@@ -142,8 +140,8 @@
     	assertNull("Check intAProp hidding (no value)", intAProp);
     	
     	//	Reconfiguration
-    	fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-    	fact = (Factory) context.getService(fact_ref);
+    	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));
@@ -157,7 +155,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -182,13 +180,11 @@
     	}	
     	
     	fact = null;
-    	context.ungetService(fact_ref);
     	fs = null;
-    	context.ungetService(sr);	
     }
 
     public void testFactoryReconfString() {
-		ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -213,8 +209,8 @@
 		}
 		
 		// Reconfiguration
-		ServiceReference fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-		Factory fact = (Factory) context.getService(fact_ref);
+		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");
@@ -228,7 +224,7 @@
 			fail("Unable to reconfigure the instance with : " + p3);
 		}
 		
-		sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -253,7 +249,7 @@
 		}	
 		
 		// Invoke
-		FooService fs = (FooService) context.getService(sr);
+		FooService fs = (FooService) getServiceObject(sr);
 		assertTrue("invoke fs", fs.foo());
 		
 		// Re-check the property (change)
@@ -274,8 +270,8 @@
 		assertNull("Check intAProp hidding (no value)", intAProp);
 		
 		//	Reconfiguration
-		fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-		fact = (Factory) context.getService(fact_ref);
+		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");
@@ -289,7 +285,7 @@
 			fail("Unable to reconfigure the instance with : " + p3);
 		}
 		
-		sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -314,13 +310,11 @@
 		}	
 		
 		fact = null;
-		context.ungetService(fact_ref);
 		fs = null;
-		context.ungetService(sr);	
 	}
 	
 	public void testMSFReconf() {
-		ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -345,8 +339,8 @@
 		}
 		
 		// Reconfiguration
-		ServiceReference fact_ref = Utils.getServiceReferenceByName(context, ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
-		ManagedServiceFactory fact = (ManagedServiceFactory) context.getService(fact_ref);
+		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));
@@ -359,7 +353,7 @@
 			fail("Unable to reconfigure the instance with : " + p3);
 		}
 		
-		sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -384,7 +378,7 @@
 		}	
 		
 		// Invoke
-		FooService fs = (FooService) context.getService(sr);
+		FooService fs = (FooService) getServiceObject(sr);
 		assertTrue("invoke fs", fs.foo());
 		
 		// Re-check the property (change)
@@ -405,8 +399,8 @@
 		assertNull("Check intAProp hidding (no value)", intAProp);
 		
 		//	Reconfiguration
-		fact_ref = Utils.getServiceReferenceByName(context, ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
-		fact = (ManagedServiceFactory) context.getService(fact_ref);
+		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));
@@ -419,7 +413,7 @@
 			fail("Unable to reconfigure the instance with : " + p3);
 		}
 		
-		sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+		sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
 		assertNotNull("Check the availability of the FS service", sr);
 		
 		// Check service properties
@@ -444,13 +438,11 @@
 		}	
 		
 		fact = null;
-		context.ungetService(fact_ref);
 		fs = null;
-		context.ungetService(sr);	
 	}
 
     public void testMSFReconfString() {
-    	ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -475,8 +467,8 @@
     	}
     	
     	// Reconfiguration
-    	ServiceReference fact_ref = Utils.getServiceReferenceByName(context, ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
-    	ManagedServiceFactory fact = (ManagedServiceFactory) context.getService(fact_ref);
+    	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");
@@ -489,7 +481,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -514,7 +506,7 @@
     	}	
     	
     	// Invoke
-    	FooService fs = (FooService) context.getService(sr);
+    	FooService fs = (FooService) getServiceObject(sr);
     	assertTrue("invoke fs", fs.foo());
     	
     	// Re-check the property (change)
@@ -535,8 +527,8 @@
     	assertNull("Check intAProp hidding (no value)", intAProp);
     	
     	//	Reconfiguration
-    	fact_ref = Utils.getServiceReferenceByName(context, ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
-    	fact = (ManagedServiceFactory) context.getService(fact_ref);
+    	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");
@@ -549,7 +541,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -574,13 +566,11 @@
     	}	
     	
     	fact = null;
-    	context.ungetService(fact_ref);
     	fs = null;
-    	context.ungetService(sr);	
     }
 
     public void testFactoryReconfNoValue() {
-    	ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-4");
+    	ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -602,8 +592,8 @@
         }
     	
     	// Reconfiguration
-    	ServiceReference fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-    	Factory fact = (Factory) context.getService(fact_ref);
+    	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));
@@ -617,7 +607,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-4");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-4");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -642,7 +632,7 @@
     	}	
     	
     	// Invoke
-    	FooService fs = (FooService) context.getService(sr);
+    	FooService fs = (FooService) getServiceObject(sr);
     	assertTrue("invoke fs", fs.foo());
     	
     	// Re-check the property (change)
@@ -663,8 +653,8 @@
     	assertNull("Check intAProp hidding (no value)", intAProp);
     	
     	//	Reconfiguration
-    	fact_ref = Utils.getServiceReferenceByName(context, Factory.class.getName() , "PS-FooProviderType-Dyn2");
-    	fact = (Factory) context.getService(fact_ref);
+    	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));
@@ -678,7 +668,7 @@
     		fail("Unable to reconfigure the instance with : " + p3);
     	}
     	
-    	sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+    	sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
     	assertNotNull("Check the availability of the FS service", sr);
     	
     	// Check service properties
@@ -703,9 +693,7 @@
     	}	
     	
     	fact = null;
-    	context.ungetService(fact_ref);
     	fs = null;
-    	context.ungetService(sr);	
     }
 
 }

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/Exposition.java Sun Nov 23 09:17:38 2008
@@ -18,13 +18,11 @@
  */
 package org.apache.felix.ipojo.test.scenarios.ps;
 
-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.ps.service.BarService;
 import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
 import org.osgi.framework.ServiceReference;
 
 public class Exposition extends OSGiTestCase {
@@ -35,26 +33,19 @@
 	private ComponentInstance fooBarProvider2;
 	private ComponentInstance fooBarProvider3;
 	
+	private IPOJOHelper helper;
+	
 	public void setUp(){ 
-		Properties p1 = new Properties();
-		p1.put("instance.name","fooProviderSimple");
-		fooProviderSimple = Utils.getComponentInstance(context, "PS-FooProviderType-1", p1);
-		
-		Properties p2 = new Properties();
-		p2.put("instance.name","fooProviderItf");
-		fooProviderItf = Utils.getComponentInstance(context, "PS-FooProviderType-itf", p2);
-		
-		Properties p3 = new Properties();
-		p3.put("instance.name","fooProviderItfs");
-		fooBarProvider = Utils.getComponentInstance(context, "PS-FooBarProviderType-1", p3);
-		
-		Properties p4 = new Properties();
-		p4.put("instance.name","fooProviderItfs2");
-		fooBarProvider2 = Utils.getComponentInstance(context, "PS-FooBarProviderType-2", p4);
-		
-		Properties p5 = new Properties();
-		p5.put("instance.name","fooProviderItfs3");
-		fooBarProvider3 = Utils.getComponentInstance(context, "PS-FooBarProviderType-3", p5);
+	    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);
@@ -65,113 +56,96 @@
 	}
 	
 	public void tearDown() {
-		fooProviderSimple.dispose();
-		fooProviderItf.dispose();
-		fooBarProvider.dispose();
-		fooBarProvider2.dispose();
-		fooBarProvider3.dispose();
-		fooProviderSimple = null;
-		fooProviderItf = null;
-		fooBarProvider = null;
-		fooBarProvider2 = null;
-		fooBarProvider3 = null;		
+	    helper.dispose();	
 	}
 	
 	public void testSimpleExposition() {
-		ServiceReference ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProviderSimple.getInstanceName());
+		ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderSimple.getInstanceName());
 		assertNotNull("Check the availability of the FS from "+fooProviderSimple.getInstanceName(), ref);
-		FooService fs = (FooService) context.getService(ref);
+		FooService fs = (FooService) getServiceObject(ref);
 		assertTrue("Check fs invocation", fs.foo());
 		fs = null;
-		context.ungetService(ref);
 		fooProviderSimple.stop();
-		ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProviderSimple.getInstanceName());
+		ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderSimple.getInstanceName());
 		assertNull("Check the absence of the FS from "+fooProviderSimple.getInstanceName(), ref);
 		
 	}
 	
 	public void testItfExposition() {
-		ServiceReference ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProviderItf.getInstanceName());
+		ServiceReference ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderItf.getInstanceName());
 		assertNotNull("Check the availability of the FS from "+fooProviderItf.getInstanceName(), ref);
-		FooService fs = (FooService) context.getService(ref);
+		FooService fs = (FooService) getServiceObject(ref);
 		assertTrue("Check fs invocation", fs.foo());
 		fs = null;
-		context.ungetService(ref);
 		fooProviderItf.stop();
 		
-		ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProviderItf.getInstanceName());
+		ref = helper.getServiceReferenceByName(FooService.class.getName(), fooProviderItf.getInstanceName());
 		assertNull("Check the absence of the FS from "+fooProviderItf.getInstanceName(), ref);
 	}
 	
 	public void testItfsExposition() {
-		ServiceReference refFoo = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider.getInstanceName());
+		ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider.getInstanceName());
 		assertNotNull("Check the availability of the FS from "+fooBarProvider.getInstanceName(), refFoo);
-		ServiceReference refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider.getInstanceName());
+		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) context.getService(refFoo);
+		FooService fs = (FooService) getServiceObject(refFoo);
 		assertTrue("Check fs invocation", fs.foo());
 		fs = null;
-		context.ungetService(refFoo);
 		
-		BarService bs = (BarService) context.getService(refBar);
+		BarService bs = (BarService) getServiceObject(refBar);
 		assertTrue("Check bs invocation", bs.bar());
 		bs = null;
-		context.ungetService(refBar);
 		
 		fooBarProvider.stop();
 		
-		refFoo = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider.getInstanceName());
-		refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider.getInstanceName());
+		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 = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider2.getInstanceName());
+		ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider2.getInstanceName());
 		assertNotNull("Check the availability of the FS from "+fooBarProvider2.getInstanceName(), refFoo);
-		ServiceReference refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider2.getInstanceName());
+		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) context.getService(refFoo);
+		FooService fs = (FooService) getServiceObject(refFoo);
 		assertTrue("Check fs invocation", fs.foo());
 		fs = null;
-		context.ungetService(refFoo);
 		
-		BarService bs = (BarService) context.getService(refBar);
+		BarService bs = (BarService) getServiceObject(refBar);
 		assertTrue("Check bs invocation", bs.bar());
 		bs = null;
-		context.ungetService(refBar);
 		
 		fooBarProvider2.stop();
 		
-		refFoo = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider2.getInstanceName());
-		refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider2.getInstanceName());
+		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 = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider3.getInstanceName());
+		ServiceReference refFoo = helper.getServiceReferenceByName(FooService.class.getName(), fooBarProvider3.getInstanceName());
 		assertNotNull("Check the availability of the FS from "+fooBarProvider3.getInstanceName(), refFoo);
-		ServiceReference refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider3.getInstanceName());
+		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) context.getService(refFoo);
+		FooService fs = (FooService) getServiceObject(refFoo);
 		assertTrue("Check fs invocation", fs.foo());
 		fs = null;
-		context.ungetService(refFoo);
 		
-		BarService bs = (BarService) context.getService(refBar);
+		BarService bs = (BarService) getServiceObject(refBar);
 		assertTrue("Check bs invocation", bs.bar());
 		bs = null;
-		context.ungetService(refBar);
 		
 		// Check properties
 		String baz1 = (String) refFoo.getProperty("baz");
@@ -182,8 +156,8 @@
 		
 		fooBarProvider3.stop();
 		
-		refFoo = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooBarProvider3.getInstanceName());
-		refBar = Utils.getServiceReferenceByName(context, BarService.class.getName(), fooBarProvider3.getInstanceName());
+		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);
 	}

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/InheritedTest.java Sun Nov 23 09:17:38 2008
@@ -21,27 +21,34 @@
 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.apache.felix.ipojo.test.scenarios.util.Utils;
 import org.osgi.framework.ServiceReference;
 
 public class InheritedTest extends OSGiTestCase {
     
     private Factory pi1, pi11, pi12, pi2, pi21, pi3;
     
+    private IPOJOHelper helper;
+    
     public void setUp() {
-        pi1 = Utils.getFactoryByName(context, "PS-PI1");
-        pi11 = Utils.getFactoryByName(context, "PS-PI1-1");
-        pi12 = Utils.getFactoryByName(context, "PS-PI1-2");
+        helper = new IPOJOHelper(this);
+        pi1 = helper.getFactory("PS-PI1");
+        pi11 = helper.getFactory("PS-PI1-1");
+        pi12 = helper.getFactory("PS-PI1-2");
         
-        pi2 = Utils.getFactoryByName(context, "PS-PI2");
-        pi21 = Utils.getFactoryByName(context, "PS-PI2-1");
+        pi2 = helper.getFactory("PS-PI2");
+        pi21 = helper.getFactory("PS-PI2-1");
         
-        pi3 = Utils.getFactoryByName(context, "PS-PI3");
+        pi3 = helper.getFactory("PS-PI3");
+    }
+    
+    public void tearDown() {
+        helper.dispose();
     }
     
     private boolean contains(String[] arr, String txt) {
@@ -101,87 +108,87 @@
     }
     
     public void testIP1() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi1.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi1.getName(), "ci");
         
-        ServiceReference ref1 = Utils.getServiceReferenceByName(context, ChildInterface.class.getName(), "ci");
+        ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
         assertNotNull("Check Child", ref1);
         
-        ServiceReference ref2 = Utils.getServiceReferenceByName(context, ParentInterface1.class.getName(), "ci");
+        ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
         assertNotNull("Check Parent1", ref2);
         
-        ServiceReference ref3 = Utils.getServiceReferenceByName(context, ParentInterface2.class.getName(), "ci");
+        ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
         assertNotNull("Check Parent2", ref3);
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
         ci.dispose();
     }
     
     public void testIP11() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi11.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi11.getName(), "ci");
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
         ci.dispose();
     }
     
     public void testIP12() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi12.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi12.getName(), "ci");
         
-        ServiceReference ref3 = Utils.getServiceReferenceByName(context, ParentInterface2.class.getName(), "ci");
+        ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
         assertNotNull("Check Parent2", ref3);
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
         ci.dispose();
     }
     
     public void testIP2() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi2.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi2.getName(), "ci");
         
-        ServiceReference ref1 = Utils.getServiceReferenceByName(context, ChildInterface.class.getName(), "ci");
+        ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
         assertNotNull("Check Child", ref1);
         
-        ServiceReference ref2 = Utils.getServiceReferenceByName(context, ParentInterface1.class.getName(), "ci");
+        ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
         assertNotNull("Check Parent1", ref2);
         
-        ServiceReference ref3 = Utils.getServiceReferenceByName(context, ParentInterface2.class.getName(), "ci");
+        ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
         assertNotNull("Check Parent2", ref3);
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
         ci.dispose();
     }
     
     public void testIP21() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi21.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi21.getName(), "ci");
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
         ci.dispose();
     }
     
     public void testIP3() {
-        ComponentInstance ci = Utils.getComponentInstanceByName(context, pi3.getName(), "ci");
+        ComponentInstance ci = helper.createComponentInstance( pi3.getName(), "ci");
         
-        ServiceReference ref1 = Utils.getServiceReferenceByName(context, ChildInterface.class.getName(), "ci");
+        ServiceReference ref1 = helper.getServiceReferenceByName( ChildInterface.class.getName(), "ci");
         assertNotNull("Check Child", ref1);
         
-        ServiceReference ref2 = Utils.getServiceReferenceByName(context, ParentInterface1.class.getName(), "ci");
+        ServiceReference ref2 = helper.getServiceReferenceByName( ParentInterface1.class.getName(), "ci");
         assertNotNull("Check Parent1", ref2);
         
-        ServiceReference ref3 = Utils.getServiceReferenceByName(context, ParentInterface2.class.getName(), "ci");
+        ServiceReference ref3 = helper.getServiceReferenceByName( ParentInterface2.class.getName(), "ci");
         assertNotNull("Check Parent2", ref3);
         
-        ServiceReference ref4 = Utils.getServiceReferenceByName(context, ParentParentInterface.class.getName(), "ci");
+        ServiceReference ref4 = helper.getServiceReferenceByName( ParentParentInterface.class.getName(), "ci");
         assertNotNull("Check PP", ref4);
         
-        ServiceReference ref5 = Utils.getServiceReferenceByName(context, FooService.class.getName(), "ci");
+        ServiceReference ref5 = helper.getServiceReferenceByName( FooService.class.getName(), "ci");
         assertNotNull("Check FS", ref5);
         
         ci.dispose();

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceArchitectureTest.java Sun Nov 23 09:17:38 2008
@@ -20,7 +20,6 @@
 
 import java.util.Properties;
 
-import org.apache.felix.ipojo.ComponentInstance;
 import org.apache.felix.ipojo.Factory;
 import org.apache.felix.ipojo.architecture.Architecture;
 import org.apache.felix.ipojo.architecture.HandlerDescription;
@@ -28,35 +27,37 @@
 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.apache.felix.ipojo.test.scenarios.util.Utils;
 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 = Utils.getFactoryByName(context, factName);
+		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 e) {
-			fail(e.getMessage());
-		}
 
-		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), "FooProvider-1");
+		helper.createComponentInstance(factName, compName);
+
+		ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);		
 		assertNotNull("Architecture not available", arch_ref);
 
-		Architecture arch = (Architecture) context.getService(arch_ref);
+		Architecture arch = (Architecture) getServiceObject(arch_ref);
 		InstanceDescription id = arch.getInstanceDescription();
 		
 		assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
@@ -85,8 +86,6 @@
 		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);
-		
-		ci.dispose();
 	}
 	
 	public void testProps() {
@@ -94,7 +93,7 @@
 		String compName = "FooProvider";
 		
 		// Get the factory to create a component instance
-		Factory fact = Utils.getFactoryByName(context, factName);
+		Factory fact = helper.getFactory( factName);
 		assertNotNull("Cannot find the factory FooProvider", fact);
 		
 		Properties props = new Properties();
@@ -102,15 +101,12 @@
 		props.put("foo", "foo");
 		props.put("bar", "2");
 		props.put("baz", "baz");
-		ComponentInstance ci = null;
-		try {
-			ci = fact.createComponentInstance(props);
-		} catch (Exception e) { fail(e.getMessage()); }
+		helper.createComponentInstance(factName, props);
 
-		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), compName);
+		ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
 		assertNotNull("Architecture not available", arch_ref);
 
-		Architecture arch = (Architecture) context.getService(arch_ref);
+		Architecture arch = (Architecture) getServiceObject(arch_ref);
 		InstanceDescription id = arch.getInstanceDescription();
 		
 		assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
@@ -144,7 +140,6 @@
 		assertEquals("Check bar property", prop.getProperty("bar"), "2");
 		assertEquals("Check baz property", prop.getProperty("baz"), "baz");
 		
-		ci.dispose();
 	}
 	
 	public void testDoubleProviding() {
@@ -152,22 +147,15 @@
 		String compName = "FooProvider";
 		
 		// Get the factory to create a component instance
-		Factory fact = Utils.getFactoryByName(context, factName);
+		Factory fact = helper.getFactory( factName);
 		assertNotNull("Cannot find the factory FooProvider", fact);
 		
-		Properties props = new Properties();
-		props.put("instance.name",compName);
-		ComponentInstance ci = null;
-		try {
-			ci = fact.createComponentInstance(props);
-		} catch (Exception e) {
-			fail(e.getMessage());
-		}
+		helper.createComponentInstance(factName, compName);
 
-		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), compName);
+		ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
 		assertNotNull("Architecture not available", arch_ref);
 
-		Architecture arch = (Architecture) context.getService(arch_ref);
+		Architecture arch = (Architecture) getServiceObject(arch_ref);
 		InstanceDescription id = arch.getInstanceDescription();
 		
 		assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
@@ -193,7 +181,6 @@
 		assertContains("Check provided service specs - 2", ps[0].getServiceSpecification(), BarService.class.getName());
 		assertEquals("Check Provided Service availability", ps[0].getState(), ProvidedServiceDescription.REGISTERED);
 		
-		ci.dispose();
 	}
 
     public void testPropsNoValue() {
@@ -201,20 +188,15 @@
     	String compName = "FooProvider";
     	
     	// Get the factory to create a component instance
-    	Factory fact = Utils.getFactoryByName(context, factName);
+    	Factory fact = helper.getFactory( factName);
     	assertNotNull("Cannot find the factory FooProvider", fact);
-    	
-    	Properties props = new Properties();
-    	props.put("instance.name",compName);
-    	ComponentInstance ci = null;
-    	try {
-    		ci = fact.createComponentInstance(props);
-    	} catch (Exception e) { fail(e.getMessage()); }
+    		
+        helper.createComponentInstance(factName, compName);
     
-    	ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), compName);
+    	ServiceReference arch_ref = helper.getServiceReferenceByName(Architecture.class.getName(), compName);
     	assertNotNull("Architecture not available", arch_ref);
     
-    	Architecture arch = (Architecture) context.getService(arch_ref);
+    	Architecture arch = (Architecture) getServiceObject(arch_ref);
     	InstanceDescription id = arch.getInstanceDescription();
     	
     	assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
@@ -245,8 +227,6 @@
     	assertEquals("Check instance.name property", prop.getProperty("instance.name"), compName);
     	assertEquals("Check factory.name property", prop.getProperty("factory.name"), factName);
 
-    	
-    	ci.dispose();
     }
 	
 }

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java?rev=720011&r1=720010&r2=720011&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/SimplePS.java Sun Nov 23 09:17:38 2008
@@ -18,63 +18,50 @@
  */
 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.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.InvalidSyntaxException;
 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[] refs = null;
+		ServiceReference ref = null;
 		
 		// Check that no Foo Service are available
-		try {
-			refs = context.getServiceReferences(FooService.class.getName(), null);
-		} catch (InvalidSyntaxException e) { fail("Service query failed : " + e); }
+		ref = getServiceReference(FooService.class.getName());
 		
-		assertNull("FS already available", refs);
+		assertNull("FS already available", ref);
 	
 		// Get the factory to create a component instance
-		Factory fact = Utils.getFactoryByName(context, factName);
+		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()); }		
+		helper.createComponentInstance(factName, compName);
 		
 		// Get a FooService provider
-		try {
-			refs = context.getServiceReferences(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
-		} catch (InvalidSyntaxException e) { fail("Service query failed (2) " + e); }
-		
-		assertNotNull("FS not available", refs);
+		ref = getServiceReference(FooService.class.getName(), "(" + "instance.name" + "=" + compName + ")");
+
+		assertNotNull("FS not available", ref);
 		
 		// Test foo invocation
-		FooService fs = (FooService) context.getService(refs[0]);
+		FooService fs = (FooService) getServiceObject(ref);
 		assertTrue("FooService invocation failed", fs.foo());
 		
-		// Unget the service
-		context.ungetService(refs[0]);
-		
-		ci.dispose();
+		helper.dispose();
+
 		
 		// Check that there is no more FooService
-		try {
-			refs = context.getServiceReferences(FooService.class.getName(), null);
-		} catch (InvalidSyntaxException e) { fail("Service query failed (3) : " + e.getMessage()); }
+		ref = getServiceReference(FooService.class.getName(), null);
+		
+		
+		assertNull("FS available, but component instance stopped", ref);
 		
-		assertNull("FS available, but component instance stopped", refs);
 	}
 
 }