felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r620325 [1/2] - in /felix/sandbox/clement/ipojo: arch/src/main/java/org/apache/felix/ipojo/arch/ core/src/main/java/org/apache/felix/ipojo/ core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ core/src/main/java/org/apache/feli...
Date Sun, 10 Feb 2008 20:58:01 GMT
Author: clement
Date: Sun Feb 10 12:57:57 2008
New Revision: 620325

URL: http://svn.apache.org/viewvc?rev=620325&view=rev
Log:
Example group id changes to becomes ipojo.examples.
Junit4OSGi project structure change to separate the framework of the junit shell command, add the swing runner.
Clean some classes.


Added:
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/   (with props)
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/metadata.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/pom.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/resources/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/   (with props)
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestSuite.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestCase.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestOSGiTestSuite.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestCase.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/test/TestTestSuite.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/resources/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/   (with props)
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/resources/
Removed:
    felix/sandbox/clement/ipojo/examples/junit4osgi/src/
Modified:
    felix/sandbox/clement/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/NullableObject.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java
    felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml
    felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client.annotation/pom.xml
    felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.client/pom.xml
    felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl.annotation/pom.xml
    felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.impl/pom.xml
    felix/sandbox/clement/ipojo/examples/tutorial-maven/hello.service/pom.xml
    felix/sandbox/clement/ipojo/metadata/src/main/java/org/apache/felix/ipojo/metadata/Element.java
    felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/IPOJOTestSuite.java

Modified: felix/sandbox/clement/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java (original)
+++ felix/sandbox/clement/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java Sun Feb 10 12:57:57 2008
@@ -132,10 +132,15 @@
             List names = (List) field.get(null);
             out.println("Number of living instances : " + names.size());
             out.println("Created instances : " + names);
-        } catch (Exception e) {
+        } catch(SecurityException e) {
+            out.println("Cannot compute stats : " + e.getMessage());
+        } catch (IllegalArgumentException e) {
+            out.println("Cannot compute stats : " + e.getMessage());
+        } catch (IllegalAccessException e) {
+            out.println("Cannot compute stats : " + e.getMessage());
+        } catch (NoSuchFieldException e) {
             out.println("Cannot compute stats : " + e.getMessage());
         }
-        
         
     }
 

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java Sun Feb 10 12:57:57 2008
@@ -129,8 +129,14 @@
     public ComponentInstance createInstance(Dictionary configuration, IPojoContext context, HandlerManager[] handlers) throws org.apache.felix.ipojo.ConfigurationException {
         InstanceManager instance = new InstanceManager(this, context, handlers);
         instance.configure(m_componentMetadata, configuration);
-        instance.start();
-        return instance;
+        try {
+            instance.start();
+            return instance;
+        } catch (IllegalStateException e) {
+            // An exception occurs during the start method.
+            throw new ConfigurationException(e.getMessage());
+        }
+        
     }
 
     /**
@@ -170,11 +176,7 @@
             if (m_classLoader == null) {
                 m_classLoader = new FactoryClassloader();
             }
-            try {
-                return m_classLoader.defineClass(m_componentClassName, m_clazz, null);
-            } catch (Exception e) {
-                throw new ClassNotFoundException("[Bundle " + m_context.getBundle().getBundleId() + "] Cannot define the class : " + className, e);
-            }
+            return m_classLoader.defineClass(m_componentClassName, m_clazz, null);
         }
         return m_context.getBundle().loadClass(className);
     }
@@ -232,9 +234,10 @@
         Element[] elems = m_componentMetadata.getElements();
         for (int i = 0; i < elems.length; i++) {
             Element current = elems[i]; 
-            if (current.getName().equals("manipulation")) { continue; }
-            RequiredHandler hi = new RequiredHandler(current.getName(), current.getNameSpace());
-            if (! list.contains(hi)) { list.add(hi); }
+            if (! "manipulation".equals(current.getName())) {
+                RequiredHandler hi = new RequiredHandler(current.getName(), current.getNameSpace());
+                if (! list.contains(hi)) { list.add(hi); }
+            }
         }
         
         // Add architecture if architecture != 'false'
@@ -373,7 +376,7 @@
          * @return : the loaded class
          * @throws ClassNotFoundException : the class to load is not found
          */
-        protected Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
+        protected synchronized Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
             return m_context.getBundle().loadClass(name);
         }
     }

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java Sun Feb 10 12:57:57 2008
@@ -297,10 +297,11 @@
     private void createAbstractFactory(Bundle bundle, Element cm) {
         ManagedAbstractFactoryType factoryType = null;
         // First, look for factory-type (component, handler, composite ...)
-        for (int i = 0; factoryType == null && i < m_abstractFactoryTypes.size(); i++) {
+        for (int i = 0; i < m_abstractFactoryTypes.size(); i++) {
             ManagedAbstractFactoryType ft = (ManagedAbstractFactoryType) m_abstractFactoryTypes.get(i);
             if (ft.m_type.equals(cm.getName())) {
                 factoryType = ft;
+                break;
             }
         }
         

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java Sun Feb 10 12:57:57 2008
@@ -111,7 +111,7 @@
     /**
      * Start all the instance managers.
      */
-    public void starting() {      
+    public synchronized void starting() {      
         if (m_requiredHandlers.size() != 0) {
             try {
                 String filter = "(&(" + Handler.HANDLER_TYPE_PROPERTY + "=" + PrimitiveHandler.HANDLER_TYPE + ")" 
@@ -131,7 +131,7 @@
      * This method does not disposed created instances.
      * These instances will be disposed by the instance managers.
      */
-    public void stopping() {
+    public synchronized void stopping() {
         if (m_tracker != null) {
             m_tracker.close();
             m_tracker = null;

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java Sun Feb 10 12:57:57 2008
@@ -242,8 +242,8 @@
             m_instancesName.add(n);
             m_componentInstances.put(n, instance);
             return instance;
-        } catch (Exception e) {
-            m_logger.log(Logger.ERROR, e.getMessage());
+        } catch (ConfigurationException e) {
+            m_logger.log(Logger.ERROR, e.getMessage(), e);
             throw new ConfigurationException(e.getMessage(), m_factoryName);
         }
     }
@@ -549,9 +549,13 @@
      */
     protected void computeFactoryState() {
         boolean isValid = true;
-        for (int i = 0; isValid && i < m_requiredHandlers.size(); i++) {
+        for (int i = 0; i < m_requiredHandlers.size(); i++) {
             RequiredHandler hi = (RequiredHandler) m_requiredHandlers.get(i);
-            isValid = hi.getReference() != null;
+            if (hi.getReference() == null) {
+                isValid = false;
+                break;
+            }
+            
         }
         
         if (isValid) {
@@ -703,11 +707,17 @@
          * @see java.lang.Object#equals(java.lang.Object)
          */
         public boolean equals(Object o) {
-            if (m_namespace == null) {
-                return ((RequiredHandler) o).m_name.equalsIgnoreCase(m_name) && ((RequiredHandler) o).m_namespace == null;
+            if (o instanceof RequiredHandler) {
+                RequiredHandler req = (RequiredHandler) o;
+                if (m_namespace == null) {
+                    return req.m_name.equalsIgnoreCase(m_name) && req.m_namespace == null;
+                } else {
+                    return req.m_name.equalsIgnoreCase(m_name) && m_namespace.equalsIgnoreCase(req.m_namespace);
+                }
             } else {
-                return ((RequiredHandler) o).m_name.equalsIgnoreCase(m_name) && m_namespace.equalsIgnoreCase(((RequiredHandler) o).m_namespace);
+                return false;
             }
+            
         }
         
         /**

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java Sun Feb 10 12:57:57 2008
@@ -52,7 +52,7 @@
      * Name of the component type implementation class.
      */
     protected String m_className;
-    
+
     /**
      * Handler list.
      */
@@ -62,12 +62,12 @@
      * Component state (STOPPED at the beginning).
      */
     protected int m_state = STOPPED;
-    
+
     /**
      * Instance State Listener List.
      */
     protected List m_instanceListeners = null;
-    
+
     /**
      * Parent factory (ComponentFactory).
      */
@@ -82,7 +82,7 @@
      * Map [field, handler list] storing handlers interested by the field.
      */
     private Map m_fieldRegistration = new HashMap();
-    
+
     /**
      * Map [method identifier, handler list] storing handlers interested by the method.
      */
@@ -97,28 +97,28 @@
      * Instances of the components.
      */
     private List m_pojoObjects;
-    
+
     /**
      * Factory method.
      * Contains the name of the static method used to create POJO objects. 
      */
     private String m_factoryMethod = null;
 
-   /**
-    * Is the component instance state changing?
-    */
+    /**
+     * Is the component instance state changing?
+     */
     private boolean m_inTransition = false;
-    
+
     /**
      * Queue of stored state changed. 
      */
     private List m_stateQueue = new ArrayList();
-    
+
     /**
      * Map of [field, value], storing POJO field value.
      */
     private Map m_map = new HashMap();
-    
+
     /**
      * Map method [id=>method].
      */
@@ -147,13 +147,13 @@
      */
     public void configure(Element cm, Dictionary configuration) throws ConfigurationException {
         m_className = cm.getAttribute("className");
-        
+
         // Add the name
         m_name = (String) configuration.get("name");
-        
+
         // Get the factory method if presents.
         m_factoryMethod = (String) cm.getAttribute("factory-method");
-        
+
         // Create the standard handlers and add these handlers to the list
         for (int i = 0; i < m_handlers.length; i++) {
             m_handlers[i].init(this, cm, configuration);
@@ -205,9 +205,7 @@
     public Handler getHandler(String name) {
         for (int i = 0; i < m_handlers.length; i++) {
             HandlerFactory fact = (HandlerFactory) m_handlers[i].getHandler().getHandlerManager().getFactory();
-            if (fact.getHandlerName().equals(name)) {
-                return m_handlers[i].getHandler();
-            }
+            if (fact.getHandlerName().equals(name)) { return m_handlers[i].getHandler(); }
         }
         return null;
     }
@@ -218,8 +216,8 @@
     public synchronized void start() {
         if (m_state != STOPPED) { // Instance already started
             return;
-        } 
-        
+        }
+
         for (int i = 0; i < m_handlers.length; i++) {
             m_handlers[i].addInstanceStateListener(this);
             try {
@@ -230,13 +228,13 @@
                 throw e;
             }
         }
-        
+
         for (int i = 0; i < m_handlers.length; i++) {
             if (m_handlers[i].getState() != VALID) {
                 setState(INVALID);
                 return;
             }
-            
+
         }
         setState(VALID);
     }
@@ -245,20 +243,18 @@
      * Stop the instance manager.
      */
     public synchronized void stop() {
-        if (m_state == STOPPED) {
-            return;
-        } // Instance already stopped
-        
+        if (m_state == STOPPED) { return; } // Instance already stopped
+
         setState(INVALID);
-        
+
         m_state = STOPPED;
-        
+
         // Stop all the handlers
         for (int i = m_handlers.length - 1; i > -1; i--) {
             m_handlers[i].removeInstanceStateListener(this);
             m_handlers[i].stop();
         }
-        
+
         m_pojoObjects = null;
 
         if (m_instanceListeners != null) {
@@ -267,7 +263,7 @@
             }
         }
     }
-    
+
     /** 
      * Dispose the instance.
      * @see org.apache.felix.ipojo.ComponentInstance#dispose()
@@ -276,20 +272,20 @@
         if (m_state > STOPPED) { // Valid or invalid
             stop();
         }
-        
+
         m_state = DISPOSED;
-        
+
         if (m_instanceListeners != null) {
             for (int i = 0; i < m_instanceListeners.size(); i++) {
                 ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, DISPOSED);
             }
             m_instanceListeners = null;
         }
-        
+
         for (int i = m_handlers.length - 1; i > -1; i--) {
             m_handlers[i].dispose();
         }
-        
+
         m_handlers = new HandlerManager[0];
         m_factory.disposed(this);
         m_map.clear();
@@ -298,7 +294,7 @@
         m_clazz = null;
         m_inTransition = false;
     }
-    
+
     /**
      * Set the state of the component instance.
      * if the state changed call the stateChanged(int) method on the handlers.
@@ -308,10 +304,10 @@
      */
     public synchronized void setState(int state) {
         if (m_inTransition) {
-            m_stateQueue.add(new Integer(state)); 
+            m_stateQueue.add(new Integer(state));
             return;
         }
-        
+
         if (m_state != state) {
             m_inTransition = true;
 
@@ -342,16 +338,16 @@
                     return;
                 }
             }
-            
+
             if (m_instanceListeners != null) {
                 for (int i = 0; i < m_instanceListeners.size(); i++) {
                     ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, state);
                 }
             }
         }
-        
+
         m_inTransition = false;
-        if (! m_stateQueue.isEmpty()) {
+        if (!m_stateQueue.isEmpty()) {
             int newState = ((Integer) (m_stateQueue.remove(0))).intValue();
             setState(newState);
         }
@@ -374,7 +370,7 @@
     public boolean isStarted() {
         return m_state > STOPPED;
     }
-    
+
     /**
      * Register an instance state listener.
      * @param listener : listener to register.
@@ -426,7 +422,7 @@
             return;
         }
     }
-    
+
     /**
      * Get the array of object created by the instance.
      * @return the created instance of the component instance.
@@ -446,9 +442,9 @@
         if (m_clazz == null) {
             load();
         }
-        
+
         Object instance = null;
-        
+
         if (m_factoryMethod != null) {
             try {
                 // Build the pojo object with the factory-method.
@@ -478,7 +474,7 @@
                 method.setAccessible(true);
                 method.invoke(instance, new Object[] { this });
                 onExit(null, m_className, instance);
-                
+
             } catch (SecurityException e) {
                 // Error : invocation failed
                 m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> Cannot invoke the factory-method : " + e.getMessage());
@@ -502,7 +498,6 @@
                 stop();
             }
 
-
         } else {
             // No factory-method, we use the constructor.
             try {
@@ -522,7 +517,7 @@
                         instance = cst.newInstance(new Object[] { this });
                         onExit(null, m_className, instance);
                     }
-                } 
+                }
             } catch (IllegalAccessException e) {
                 m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> The POJO constructor is not accessible : " + e.getMessage());
                 stop();
@@ -549,14 +544,14 @@
         if (m_pojoObjects == null) {
             m_pojoObjects = new ArrayList(1);
         }
-        if (! m_pojoObjects.contains(instance)) {
+        if (!m_pojoObjects.contains(instance)) {
             m_pojoObjects.add(instance);
             // Call createInstance on Handlers :
             for (int i = 0; i < m_handlers.length; i++) {
                 ((PrimitiveHandler) m_handlers[i].getHandler()).onCreation(instance);
             }
         }
-        
+
         return instance;
     }
 
@@ -566,9 +561,7 @@
      * @return the instance of the component instance to use for singleton component
      */
     public synchronized Object getPojoObject() {
-        if (m_pojoObjects == null) {
-            return createPojoObject();
-        }
+        if (m_pojoObjects == null) { return createPojoObject(); }
         return m_pojoObjects.get(0);
     }
 
@@ -598,9 +591,7 @@
             } else {
                 PrimitiveHandler[] list = (PrimitiveHandler[]) m_fieldRegistration.get(fields[i].getFieldName());
                 for (int j = 0; j < list.length; j++) {
-                    if (list[j] == h) {
-                        return;
-                    }
+                    if (list[j] == h) { return; }
                 }
                 PrimitiveHandler[] newList = new PrimitiveHandler[list.length + 1];
                 System.arraycopy(list, 0, newList, 0, list.length);
@@ -609,18 +600,16 @@
             }
         }
         for (int i = 0; methods != null && i < methods.length; i++) {
-            if (m_methodRegistration == null) { 
+            if (m_methodRegistration == null) {
                 m_methodRegistration = new HashMap();
                 m_methodRegistration.put(methods[i].getMethodIdentifier(), new PrimitiveHandler[] { h });
-            } else { 
+            } else {
                 PrimitiveHandler[] list = (PrimitiveHandler[]) m_methodRegistration.get(methods[i].getMethodIdentifier());
                 if (list == null) {
                     m_methodRegistration.put(methods[i].getMethodIdentifier(), new PrimitiveHandler[] { h });
                 } else {
                     for (int j = 0; j < list.length; j++) {
-                        if (list[j] == h) {
-                            return;
-                        }
+                        if (list[j] == h) { return; }
                     }
                     PrimitiveHandler[] newList = new PrimitiveHandler[list.length + 1];
                     System.arraycopy(list, 0, newList, 0, list.length);
@@ -629,7 +618,7 @@
                 }
             }
         }
-        
+
     }
 
     /**
@@ -652,25 +641,25 @@
                 continue; // Non-binding case (default implementation).
             } else {
                 if (result != initialValue) {
-                    if ((handlerResult != null && ! handlerResult.equals(result)) || (result != null && handlerResult == null)) {
+                    if ((handlerResult != null && !handlerResult.equals(result)) || (result != null && handlerResult == null)) {
                         m_factory.getLogger().log(Logger.WARNING, "A conflict was detected on the injection of " + fieldName + " - return the last value from " + list[i].getHandlerManager().getInstanceName());
                     }
                 }
                 result = handlerResult;
             }
         }
-        
-        if ((result != null && ! result.equals(initialValue)) || (result == null && initialValue != null)) {
+
+        if ((result != null && !result.equals(initialValue)) || (result == null && initialValue != null)) {
             // A change occurs => notify the change
             m_map.put(fieldName, result);
             for (int i = 0; list != null && i < list.length; i++) {
                 list[i].onSet(null, fieldName, result);
             }
         }
-        
-        return result;        
+
+        return result;
     }
-    
+
     /**
      * Dispatch entry method event on registered handler.
      * @param pojo : the pojo object on which method is invoked.
@@ -699,7 +688,7 @@
             list[i].onExit(pojo, getMethodById(methodId), e);
         }
     }
-    
+
     /**
      * Dispatch error method event on registered handler.
      * The given returned object is an instance of Exception if the method has launched an exception.
@@ -715,7 +704,7 @@
             list[i].onError(pojo, getMethodById(methodId), e);
         }
     }
-    
+
     /**
      * Get method object by id.
      * TODO : improve algorithm
@@ -754,7 +743,7 @@
      */
     public void onSet(Object pojo, String fieldName, Object objectValue) {
         Object o = m_map.get(fieldName);
-        if ((o != null && ! o.equals(objectValue)) || (o == null && objectValue != null)) {
+        if ((o != null && !o.equals(objectValue)) || (o == null && objectValue != null)) {
             m_map.put(fieldName, objectValue);
             PrimitiveHandler[] list = (PrimitiveHandler[]) m_fieldRegistration.get(fieldName);
             for (int i = 0; list != null && i < list.length; i++) {
@@ -771,11 +760,11 @@
     public BundleContext getContext() {
         return m_context;
     }
-    
+
     public BundleContext getGlobalContext() {
         return ((IPojoContext) m_context).getGlobalContext();
     }
-    
+
     public ServiceContext getLocalServiceContext() {
         return ((IPojoContext) m_context).getServiceContext();
     }
@@ -801,9 +790,7 @@
         if (m_state == INVALID) {
             // Try to revalidate the instance ofter reconfiguration
             for (int i = 0; i < m_handlers.length; i++) {
-                if (m_handlers[i].getState() != VALID) {
-                    return;
-                }
+                if (m_handlers[i].getState() != VALID) { return; }
             }
             setState(VALID);
         }
@@ -826,7 +813,7 @@
      */
     public synchronized void stateChanged(ComponentInstance instance, int newState) {
         if (m_state <= STOPPED) { return; }
-        
+
         // Update the component state if necessary
         if (newState == INVALID && m_state == VALID) {
             // Need to update the state to UNRESOLVED
@@ -840,9 +827,9 @@
             }
             setState(VALID);
             return;
-        }        
+        }
     }
-    
+
     /**
      * Get the list of registered fields.
      * This method is invoked by the POJO itself.
@@ -855,7 +842,7 @@
             return null;
         }
     }
-    
+
     /**
      * Get the list of registered methods.
      * This method is invoked by the POJO itself.

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java Sun Feb 10 12:57:57 2008
@@ -145,7 +145,7 @@
             }
         }
     }
-    
+
     /**
      * Set the type for type array.
      * @param type : the string descriptor of the type (must end by [] )
@@ -203,7 +203,6 @@
         }
     }
 
-    
     public String getName() {
         return m_name;
     }
@@ -263,7 +262,7 @@
             }
         }
     }
-    
+
     /**
      * Test if the given value is assignable to the given type.
      * @param type : class of the type
@@ -275,30 +274,14 @@
             return true;
         } else if (type.isPrimitive()) {
             // Manage all boxing types.
-            if (value instanceof Boolean && type.equals(Boolean.TYPE)) {
-                return true;
-            }
-            if (value instanceof Byte && type.equals(Byte.TYPE)) {
-                return true;
-            }
-            if (value instanceof Short && type.equals(Short.TYPE)) {
-                return true;
-            }
-            if (value instanceof Integer && type.equals(Integer.TYPE)) {
-                return true;
-            }
-            if (value instanceof Long && type.equals(Long.TYPE)) {
-                return true;
-            }
-            if (value instanceof Float && type.equals(Float.TYPE)) {
-                return true;
-            }
-            if (value instanceof Double && type.equals(Double.TYPE)) {
-                return true;
-            }
-            if (value instanceof Character && type.equals(Character.TYPE)) {
-                return true;
-            }
+            if (value instanceof Boolean && Boolean.TYPE.equals(type)) { return true; }
+            if (value instanceof Byte && Byte.TYPE.equals(type)) { return true; }
+            if (value instanceof Short && Short.TYPE.equals(type)) { return true; }
+            if (value instanceof Integer && Integer.TYPE.equals(type)) { return true; }
+            if (value instanceof Long && Long.TYPE.equals(type)) { return true; }
+            if (value instanceof Float && Float.TYPE.equals(type)) { return true; }
+            if (value instanceof Double && Double.TYPE.equals(type)) { return true; }
+            if (value instanceof Character && Character.TYPE.equals(type)) { return true; }
             return false;
         } else {
             // Else return false.
@@ -314,14 +297,14 @@
      * @throws ConfigurationException occurs when the object cannot be created.
      */
     public static Object create(Class type, String strValue) throws ConfigurationException {
-        if (type.equals(Boolean.TYPE)) { return new Boolean(strValue); }
-        if (type.equals(Byte.TYPE)) { return new Byte(strValue); }
-        if (type.equals(Short.TYPE)) { return new Short(strValue); }
-        if (type.equals(Integer.TYPE)) { return new Integer(strValue); }
-        if (type.equals(Long.TYPE)) { return new Long(strValue); }
-        if (type.equals(Float.TYPE)) { return new Float(strValue); }
-        if (type.equals(Double.TYPE)) { return new Double(strValue); }
-        if (type.equals(Character.TYPE)) { return new Character(strValue.charAt(0)); }
+        if (Boolean.TYPE.equals(type)) { return new Boolean(strValue); }
+        if (Byte.TYPE.equals(type)) { return new Byte(strValue); }
+        if (Short.TYPE.equals(type)) { return new Short(strValue); }
+        if (Integer.TYPE.equals(type)) { return new Integer(strValue); }
+        if (Long.TYPE.equals(type)) { return new Long(strValue); }
+        if (Float.TYPE.equals(type)) { return new Float(strValue); }
+        if (Double.TYPE.equals(type)) { return new Double(strValue); }
+        if (Character.TYPE.equals(type)) { return new Character(strValue.charAt(0)); }
 
         // Array :
         if (type.isArray()) { return createArrayObject(type.getComponentType(), ParseUtils.parseArrays(strValue)); }
@@ -354,56 +337,56 @@
      * @throws ConfigurationException occurs when the array cannot be created correctly
      */
     public static Object createArrayObject(Class interntype, String[] values) throws ConfigurationException {
-        if (interntype.equals(Boolean.TYPE)) {
+        if (Boolean.TYPE.equals(interntype)) {
             boolean[] bool = new boolean[values.length];
             for (int i = 0; i < values.length; i++) {
                 bool[i] = new Boolean(values[i]).booleanValue();
             }
             return bool;
         }
-        if (interntype.equals(Byte.TYPE)) {
+        if (Byte.TYPE.equals(interntype)) {
             byte[] byt = new byte[values.length];
             for (int i = 0; i < values.length; i++) {
                 byt[i] = new Byte(values[i]).byteValue();
             }
             return byt;
         }
-        if (interntype.equals(Short.TYPE)) {
+        if (Short.TYPE.equals(interntype)) {
             short[] shor = new short[values.length];
             for (int i = 0; i < values.length; i++) {
                 shor[i] = new Short(values[i]).shortValue();
             }
             return shor;
         }
-        if (interntype.equals(Integer.TYPE)) {
+        if (Integer.TYPE.equals(interntype)) {
             int[] in = new int[values.length];
             for (int i = 0; i < values.length; i++) {
                 in[i] = new Integer(values[i]).intValue();
             }
             return in;
         }
-        if (interntype.equals(Long.TYPE)) {
+        if (Long.TYPE.equals(interntype)) {
             long[] ll = new long[values.length];
             for (int i = 0; i < values.length; i++) {
                 ll[i] = new Long(values[i]).longValue();
             }
             return ll;
         }
-        if (interntype.equals(Float.TYPE)) {
+        if (Float.TYPE.equals(interntype)) {
             float[] fl = new float[values.length];
             for (int i = 0; i < values.length; i++) {
                 fl[i] = new Float(values[i]).floatValue();
             }
             return fl;
         }
-        if (interntype.equals(Double.TYPE)) {
+        if (Double.TYPE.equals(interntype)) {
             double[] dl = new double[values.length];
             for (int i = 0; i < values.length; i++) {
                 dl[i] = new Double(values[i]).doubleValue();
             }
             return dl;
         }
-        if (interntype.equals(Character.TYPE)) {
+        if (Character.TYPE.equals(interntype)) {
             char[] dl = new char[values.length];
             for (int i = 0; i < values.length; i++) {
                 dl[i] = values[i].toCharArray()[0];

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java Sun Feb 10 12:57:57 2008
@@ -330,7 +330,7 @@
             Object value = np.get(name);
             boolean found = false;
             // Check if the name is a configurable property
-            for (int i = 0; !found && i < m_configurableProperties.length; i++) {
+            for (int i = 0; i < m_configurableProperties.length; i++) {
                 if (m_configurableProperties[i].getName().equals(name)) {
                     // Check if the value has changed
                     if (m_configurableProperties[i].getValue() == null || !m_configurableProperties[i].getValue().equals(value)) {
@@ -343,7 +343,7 @@
                         }
                     }
                     found = true;
-                    // Else do nothing
+                    break;
                 }
             }
             if (!found) {

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java Sun Feb 10 12:57:57 2008
@@ -102,16 +102,17 @@
     protected void searchMethod() {
         if (m_argument != null) {
             Method[] methods = m_dependency.getHandler().getInstanceManager().getClazz().getDeclaredMethods();
-            for (int i = 0; m_methodObj == null && i < methods.length; i++) {
+            for (int i = 0; i < methods.length; i++) {
                 // First check the method name
                 if (methods[i].getName().equals(m_method)) {
                     // Check arguments
                     Class[] clazzes = methods[i].getParameterTypes();
                     if (clazzes.length == m_argument.length) { // Test size to avoid useless loop
                         boolean ok = true;
-                        for (int j = 0; ok && j < m_argument.length; j++) {
+                        for (int j = 0; j < m_argument.length; j++) {
                             if (!m_argument[j].equals(clazzes[j].getName())) {
                                 ok = false;
+                                break;
                             }
                         }
                         if (ok) {
@@ -143,7 +144,7 @@
     private void searchParentMethod() {
         // look at parent classes
         Method[] methods = m_dependency.getHandler().getInstanceManager().getClazz().getMethods();
-        for (int i = 0; m_methodObj == null && i < methods.length; i++) {
+        for (int i = 0; i < methods.length; i++) {
             // First check the method name
             if (methods[i].getName().equals(m_method)) {
                 // Check arguments

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/NullableObject.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/NullableObject.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/NullableObject.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/NullableObject.java Sun Feb 10 12:57:57 2008
@@ -26,41 +26,42 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class NullableObject implements InvocationHandler {
-    
+
     /**
      * Default boolean value.
      */
     private static final Boolean DEFAULT_BOOLEAN = Boolean.FALSE;
+
     /**
      * Default byte value.
      */
     private static final Byte DEFAULT_BYTE = new Byte((byte) 0);
-    
+
     /**
      * Default short value.
      */
     private static final Short DEFAULT_SHORT = new Short((short) 0);
-    
+
     /**
      * Default integer value.
      */
     private static final Integer DEFAULT_INT = new Integer(0);
-    
+
     /**
      * Default long value.
      */
     private static final Long DEFAULT_LONG = new Long(0);
-    
+
     /**
      * Default float value.
      */
     private static final Float DEFAULT_FLOAT = new Float(0.0f);
-    
+
     /**
      * Default double value.
      */
     private static final Double DEFAULT_DOUBLE = new Double(0.0);
-    
+
     /**
      * Invokes a method on this null object. The method will return a default
      * value without doing anything.
@@ -72,19 +73,19 @@
      */
     public Object invoke(Object proxy, Method method, Object[] args) {
         Class returnType = method.getReturnType();
-        if (returnType.equals(Boolean.TYPE)) {
+        if (Boolean.TYPE.equals(returnType)) {
             return DEFAULT_BOOLEAN;
-        } else if (returnType.equals(Byte.TYPE)) {
+        } else if (Byte.TYPE.equals(returnType)) {
             return DEFAULT_BYTE;
-        } else if (returnType.equals(Short.TYPE)) {
+        } else if (Short.TYPE.equals(returnType)) {
             return DEFAULT_SHORT;
-        } else if (returnType.equals(Integer.TYPE)) {
+        } else if (Integer.TYPE.equals(returnType)) {
             return DEFAULT_INT;
-        } else if (returnType.equals(Long.TYPE)) {
+        } else if (Long.TYPE.equals(returnType)) {
             return DEFAULT_LONG;
-        } else if (returnType.equals(Float.TYPE)) {
+        } else if (Float.TYPE.equals(returnType)) {
             return DEFAULT_FLOAT;
-        } else if (returnType.equals(Double.TYPE)) {
+        } else if (Double.TYPE.equals(returnType)) {
             return DEFAULT_DOUBLE;
         } else {
             return null;

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java Sun Feb 10 12:57:57 2008
@@ -133,7 +133,7 @@
      */
     protected void set(Object o) {
         // Is the object is directly assignable to the property, affect it.
-        if (!(o instanceof String) || m_type.equals("java.lang.String")) {
+        if (!(o instanceof String) || "java.lang.String".equals(m_type)) {
             m_value = o;
         } else {
             // If the object is a String, we must recreate the object from the String form

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java Sun Feb 10 12:57:57 2008
@@ -200,6 +200,7 @@
             default:
                 m_handler.error("[" + m_handler.getInstanceManager().getClassName() + "] Unknown factory policy for " + m_serviceSpecification + " : " + m_factoryPolicy);
                 getInstanceManager().stop();
+                break;
         }
         return svc;
     }

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java Sun Feb 10 12:57:57 2008
@@ -52,7 +52,7 @@
         Element[] elems = m_elements[0].getElements();
         List list = new ArrayList();
         for (int i = 0; i < elems.length; i++) {
-            if (! elems[i].getName().equals("instance")) {
+            if (! "instance".equals( elems[i].getName() )) {
                 list.add(elems[i]);
             }
         }

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java Sun Feb 10 12:57:57 2008
@@ -168,9 +168,10 @@
         for (int i = 0; i < m_methods.length; i++) {
             if (m_methods[i].getMethodName().equalsIgnoreCase(name) && m_methods[i].getMethodArguments().length == types.length) {
                 boolean ok = true;
-                for (int j = 0; ok && j < types.length; j++) {
+                for (int j = 0; j < types.length; j++) {
                     if (! types[j].equals(m_methods[i].getMethodArguments()[j])) {
                         ok = false;
+                        break;
                     }
                 }
                 if (ok) { return m_methods[i]; }

Modified: felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java?rev=620325&r1=620324&r2=620325&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java (original)
+++ felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java Sun Feb 10 12:57:57 2008
@@ -144,20 +144,22 @@
      */
     protected void searchMethod() throws NoSuchMethodException {
         Method[] methods = m_manager.getClazz().getDeclaredMethods();
-        for (int i = 0; m_methodObj == null && i < methods.length; i++) {
+        for (int i = 0; i < methods.length; i++) {
             // First check the method name
             if (methods[i].getName().equals(m_method)) {
                 // Check arguments
                 Class[] clazzes = methods[i].getParameterTypes();
                 if (clazzes.length == m_args.length) { // Test size to avoid useless loop
                     boolean ok = true;
-                    for (int j = 0; ok && j < m_args.length; j++) {
+                    for (int j = 0; j < m_args.length; j++) {
                         if (!m_args[j].equals(clazzes[j].getName())) {
                             ok = false;
+                            break;
                         }
                     }
                     if (ok) {
                         m_methodObj = methods[i]; // It is the looked method.
+                        break;
                     } 
                 }
 
@@ -166,20 +168,22 @@
         
         if (m_methodObj == null) { //look at parent classes
             methods = m_manager.getClazz().getMethods();
-            for (int i = 0; m_methodObj == null && i < methods.length; i++) {
+            for (int i = 0; i < methods.length; i++) {
                 // First check the method name
                 if (methods[i].getName().equals(m_method)) {
                     // Check arguments
                     Class[] clazzes = methods[i].getParameterTypes();
                     if (clazzes.length == m_args.length) { // Test size to avoid useless loop
                         boolean ok = true;
-                        for (int j = 0; ok && j < m_args.length; j++) {
+                        for (int j = 0; j < m_args.length; j++) {
                             if (!m_args[j].equals(clazzes[j].getName())) {
                                 ok = false;
+                                break;
                             }
                         }
                         if (ok) {
                             m_methodObj = methods[i]; // It is the looked method.
+                            break;
                         } 
                     }
                 }

Propchange: felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Feb 10 12:57:57 2008
@@ -0,0 +1,5 @@
+.checkstyle
+.classpath
+.project
+bin
+target

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/metadata.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/metadata.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/metadata.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<iPOJO>	
+	<component className="org.apache.felix.ipojo.junit4osgi.command.JunitCommand" factory="false">
+		<requires field="runner"/>
+		<provides/>
+	</component>
+	<instance component="org.apache.felix.ipojo.junit4osgi.command.JunitCommand"/>
+</iPOJO>
\ No newline at end of file

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/pom.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/pom.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/pom.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,77 @@
+<project>
+	<parent>
+		<groupId>ipojo.examples</groupId>
+		<artifactId>Junit4Osgi</artifactId>
+		<version>0.7.6-SNAPSHOT</version>
+		<relativePath>../pom.xml</relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<name>Junit4Osgi-Felix-Command</name>
+	<artifactId>
+		org.apache.felix.ipojo.junit4osgi.felix-command
+	</artifactId>
+	<dependencies>
+		<dependency>
+			<groupId>${pom.groupId}</groupId>
+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+			<version>${pom.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.shell</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+		</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>
+				<version>1.2.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Bundle-Name>
+							iPOJO OSGi Junit Runner - Felix Command
+						</Bundle-Name>
+						<Bundle-SymbolicName>
+							${pom.artifactId}
+						</Bundle-SymbolicName>
+						<Private-Package>
+							org.apache.felix.ipojo.junit4osgi.command
+						</Private-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>${pom.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+						<configuration>
+							<ignoreAnnotations>true</ignoreAnnotations>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,111 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.junit4osgi.command;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestFailure;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;
+import org.apache.felix.shell.Command;
+
+/**
+ * Felix shell command. Allow to run tests.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class JunitCommand implements Command {
+
+    private OSGiJunitRunner runner;
+
+    private List<String> getNamesFromTests(List<Test> list) {
+        List<String> names = new ArrayList<String>(list.size());
+        for (int i = 0; i < list.size(); i++) {
+            if (list.get(i) instanceof TestCase) {
+                names.add(((TestCase) list.get(i)).getName());
+            }
+            if (list.get(i) instanceof TestSuite) {
+                String name = ((TestSuite) list.get(i)).getName();
+                if (name == null) {
+                    name = ((TestSuite) list.get(i)).toString();
+                }
+                names.add(name);
+            }
+        }
+        return names;
+    }
+
+    public void execute(String line, PrintStream out, PrintStream err) {
+        line = line.substring(getName().length()).trim();
+        List<TestResult> tr = null;
+        if (line.equals("all")) {
+            if (runner.getTests() == null) {
+                err.println("No tests to execute");
+                return;
+            } else {
+                out.println("Executing " + getNamesFromTests(runner.getTests()));
+                tr = runner.run();
+            }
+        } else {
+            try {
+                Long bundleId = new Long(line);
+                if (runner.getTests(bundleId) == null) {
+                    err.println("No tests to execute");
+                    return;
+                } else {
+                    out.println("Executing " + getNamesFromTests(runner.getTests(bundleId)));
+                    tr = runner.run(bundleId);
+                }
+            } catch (NumberFormatException e) {
+                System.err.println("Unable to parse id " + line);
+                return;
+            }
+        }
+
+        ListIterator<TestResult> it = tr.listIterator();
+        while (it.hasNext()) {
+            TestResult result = it.next();
+            if (result.failureCount() != 0) {
+                TestFailure fail = (TestFailure) result.failures().nextElement();
+                System.out.println(fail.trace());
+                return;
+            }
+        }
+
+    }
+
+    public String getName() {
+        return "junit";
+    }
+
+    public String getShortDescription() {
+        return "launch junit tests";
+    }
+
+    public String getUsage() {
+        return "junit";
+    }
+
+}

Propchange: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Feb 10 12:57:57 2008
@@ -0,0 +1,7 @@
+.checkstyle
+.classpath
+.externalToolBuilders
+.project
+.settings
+maven-eclipse.xml
+target

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<iPOJO xmlns:extender="org.apache.felix.ipojo.extender">
+	<Component className="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender">
+		<extender:extender extension="Test-Suite" onArrival="onBundleArrival" onDeparture="onBundleDeparture"/>
+		<callback transition="invalidate" method="stopping"/>
+		<provides/>
+	</Component>
+	<instance component="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender"/>
+</iPOJO>
\ No newline at end of file

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml Sun Feb 10 12:57:57 2008
@@ -0,0 +1,71 @@
+<project>
+  <parent>
+    <groupId>ipojo.examples</groupId>
+  	<artifactId>Junit4Osgi</artifactId>
+  	<version>0.7.6-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>bundle</packaging>
+  <name>Junit4Osgi</name>
+  <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.ipojo</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+    </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>
+        <version>1.2.0</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+          	<Bundle-Name>iPOJO OSGi Junit Runner</Bundle-Name>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Private-Package>org.apache.felix.ipojo.junit4osgi.impl, org.apache.felix.ipojo.junit4osgi.test</Private-Package>
+            <Export-Package>org.apache.felix.ipojo.junit4osgi, junit.*</Export-Package>
+            <Test-Suite>org.apache.felix.ipojo.junit4osgi.test.TestTestCase, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase, org.apache.felix.ipojo.junit4osgi.test.TestTestSuite, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestSuite</Test-Suite>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>maven-ipojo-plugin</artifactId>
+              <version>${pom.version}</version>
+		  <executions>
+          	<execution>
+            	<goals>
+	              <goal>ipojo-bundle</goal>
+               </goals>
+            <configuration>
+   				<ignoreAnnotations>true</ignoreAnnotations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+   </build>
+</project>

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,73 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.junit4osgi;
+
+import java.io.PrintStream;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+
+/**
+ * OSGi Junit Runner.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface OSGiJunitRunner {
+    
+    /**
+     * Set the output stream of the runner.
+     * @param ps : print stream.
+     */
+    void setResultPrinter(PrintStream ps);
+    
+    /**
+     * Run the tests.
+     * @return the list of TestResult.
+     */
+    List<TestResult>  run();
+    
+    /**
+     * Run the tests from the given bundle.
+     * @param bundleId : bundle containing the tests. 
+     * @return the list of the results.
+     */
+    List<TestResult> run(long bundleId);
+    
+    /**
+     * Get the list of available test suites.
+     * @return the list of test suites.
+     */
+    List<Test> getTests();
+    
+    /**
+     * Get the tests from the given bundle. 
+     * @param bundleId : bundle id.
+     * @return the list of test suites contained in the given bundle.
+     */
+    List<Test> getTests(long bundleId);
+    
+    /**
+     * Run the given test.
+     * @param test : test to execute.
+     * @return the result.
+     */
+    public TestResult run(Test test);
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,175 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.junit4osgi;
+
+import junit.framework.TestCase;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * OSGi Test Case.
+ * Allow the injection of the bundle context.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class OSGiTestCase extends TestCase {
+    
+    protected BundleContext context;
+    
+    public void setBundleContext(BundleContext bc) {
+        context = bc;
+    }
+    
+    /**
+     * Asserts that two doubles are equal.  If they are not
+     * an AssertionFailedError is thrown with the given message. 
+     */
+    static public void assertEquals(String message, double expected, double actual) {
+        if (Double.compare(expected, actual) != 0) {
+            fail(formatEqualsMessage(message, expected, actual));
+        }
+    }
+    
+    static String formatEqualsMessage(String message, Object expected, Object actual) {
+        String formatted = "";
+        if (message != null) {
+            formatted = message + " ";
+        }
+        return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
+    }
+    
+    static String formatNotEqualsMessage(String message, Object o1, Object o2) {
+        String formatted = "";
+        if (message != null) {
+            formatted = message + " ";
+        }
+        return formatted + "o1:<" + o1 + "> is equals to o2:<" + o2 + ">";
+    }
+    
+    static String formatContainsMessage(String message, Object[] array, Object txt) {
+        String formatted = "";
+        if (message != null) {
+            formatted = message + " ";
+        }
+        
+        String arr = null;
+        for (int i = 0; i < array.length; i++) {
+            if (arr == null) {
+                arr = "[" + array[i];
+            } else {
+                arr += "," + array[i];
+            }
+        }
+        arr += "]";
+        
+        return formatted + "array:" + arr + " does not contains:<" + txt + ">";
+    }
+    
+    static public void assertNotEquals(String message, Object o1, Object o2) {
+        if (o1.equals(o2)) {
+            fail(formatNotEqualsMessage(message, o1, o2));
+        }
+    }
+    
+    static public void assertContains(String message, String[] array, String txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i].equals(txt)) { return; }
+        }
+        fail(formatContainsMessage(message, array, txt));
+    }
+    
+    static public void assertContains(String message, byte[] array, int txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Byte[] bytes = new Byte[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Byte(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, short[] array, int txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Short[] bytes = new Short[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Short(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, int[] array, int txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Integer[] bytes = new Integer[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Integer(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, long[] array, long txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Long[] bytes = new Long[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Long(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, float[] array, float txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Float[] bytes = new Float[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Float(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, double[] array, double txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Double[] bytes = new Double[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Double(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+    static public void assertContains(String message, char[] array, char txt) {
+        for (int i = 0; i < array.length; i++) {
+            if (array[i] == txt) { return; }
+        }
+        Character[] bytes = new Character[array.length];
+        for (int i = 0; i < array.length; i++) {
+            bytes[i] = new Character(array[i]);
+        }
+        fail(formatContainsMessage(message, bytes, txt));
+    }
+    
+
+}

Added: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestSuite.java?rev=620325&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestSuite.java (added)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestSuite.java Sun Feb 10 12:57:57 2008
@@ -0,0 +1,90 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.junit4osgi;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * OSGi Test Suite.
+ * Allow the injection of the bundle context.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class OSGiTestSuite extends TestSuite {
+    
+    protected BundleContext context;
+    
+    public OSGiTestSuite(Class clazz, BundleContext bc) {
+       super(clazz);
+       context = bc;
+    }
+    
+    public OSGiTestSuite(BundleContext bc) {
+        super();
+        context = bc;
+    }
+    
+    public OSGiTestSuite(String name, BundleContext bc) {
+        super(name);
+        context = bc;
+    }
+    
+    public OSGiTestSuite(Class clazz, String name, BundleContext bc) {
+        super(clazz, name);
+        context = bc;
+    }
+    
+    public void setBundleContext(BundleContext bc) {
+        context = bc;
+    }
+    
+    /**
+     * Adds the tests from the given class to the suite
+     */
+    public void addTestSuite(Class testClass) {
+        if (OSGiTestCase.class.isAssignableFrom(testClass)) {
+            addTest(new OSGiTestSuite(testClass, context));
+        } else if (TestCase.class.isAssignableFrom(testClass)) {
+            addTest(new TestSuite(testClass));
+        } else {
+            System.out.println("Error : the " + testClass + " is not a valid test class");
+        }
+    }
+    
+    
+    public void runTest(Test test, TestResult result) {
+        if (test instanceof OSGiTestSuite) {
+            ((OSGiTestSuite) test).context = context;
+            test.run(result);
+        } else if (test instanceof OSGiTestCase) {
+            ((OSGiTestCase) test).context = context;
+            test.run(result);
+        } else {
+            test.run(result);
+        }
+        
+        
+    }
+
+}



Mime
View raw message