Updates doc folders with new changelog files and update embedded documentation
Adds the ASM licence in the manipulator project
The maven-ipojo-plugin's architype targets the latest released version.
Adds a visibility test in the composite test suite.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@703957 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java
new file mode 100644
index 0000000..7067245
--- /dev/null
+++ b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instance/InstanceScopeTest.java
@@ -0,0 +1,77 @@
+package org.apache.felix.ipojo.test.composite.instance;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.composite.CompositeFactory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.composite.service.CheckService;
+import org.apache.felix.ipojo.test.composite.util.Utils;
+import org.apache.felix.ipojo.test.instance.service.Service;
+import org.osgi.framework.ServiceReference;
+
+public class InstanceScopeTest extends OSGiTestCase {
+    
+    CompositeFactory factory;
+    ComponentInstance instance;
+    
+    public void setUp() {
+        factory = (CompositeFactory) Utils.getFactoryByName(context, "SCOPE-scope");
+        assertNotNull("Factory", factory);
+        try {
+            instance = factory.createComponentInstance(null);
+        } catch (Exception e) {
+            fail("Fail instantiation : " + e.getMessage());
+        }
+       
+
+    }
+    
+    public void tearDown() {
+        instance.dispose();
+        instance = null;
+    }
+    
+    public void testScope() {
+        ServiceReference ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", ref);
+        Architecture arch = (Architecture) context.getService(ref);
+        assertTrue("Validity", arch.getInstanceDescription().getState() == ComponentInstance.VALID);
+        
+        // Get internal service
+        ServiceContext sc = Utils.getServiceContext(instance);
+        ServiceReference ref2 = Utils.getServiceReference(sc, CheckService.class.getName(), null);
+        assertNotNull("Check CheckService availability", ref2);
+        CheckService svc = (CheckService) sc.getService(ref2);
+        Properties props = svc.getProps();
+        assertEquals("Check props - 1", 1, ((Integer) props.get("1")).intValue());
+        assertEquals("Check props - 2", 2, ((Integer) props.get("2")).intValue());
+        assertEquals("Check props - 3", 3, ((Integer) props.get("3")).intValue());
+        
+    }
+    
+    public void testGlobalUnavailability() {
+        ServiceReference ref2 = Utils.getServiceReference(context, Service.class.getName(), null);
+        assertNull("Check Service unavailability", ref2);
+    }
+    
+    public void testScopeUnvailability() {
+        CompositeFactory factory2 = (CompositeFactory) Utils.getFactoryByName(context, "SCOPE-badscope");
+        assertNotNull("Factory", factory2);
+        ComponentInstance instance2 = null;
+        try {
+            instance2 = factory2.createComponentInstance(null);
+        } catch (Exception e) {
+            fail("Fail instantiation : " + e.getMessage());
+        }
+        //System.out.println(instance2.getInstanceDescription().getDescription());
+        
+        assertEquals("Check invalidity", ComponentInstance.INVALID, instance2.getState());
+ 
+    }
+    
+    
+
+}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java
index 796bb62..8fa0dce 100644
--- a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java
+++ b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/composite/instantiator/InstantiatorTestSuite.java
@@ -21,6 +21,7 @@
 import junit.framework.Test;

 

 import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;

+import org.apache.felix.ipojo.test.composite.instance.InstanceScopeTest;

 import org.apache.felix.ipojo.test.composite.instance.SimpleInstance;

 import org.osgi.framework.BundleContext;

 

@@ -34,6 +35,7 @@
 		ots.addTestSuite(OptionalMultipleInstantiation.class);

 		ots.addTestSuite(ConfigurableInstantiation.class);

 		ots.addTestSuite(SimpleInstance.class);

+		ots.addTestSuite(InstanceScopeTest.class);

 		return ots;

 	}

 

diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java
new file mode 100644
index 0000000..d6abe0a
--- /dev/null
+++ b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceConsumer.java
@@ -0,0 +1,27 @@
+package org.apache.felix.ipojo.test.instance;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.composite.service.CheckService;
+import org.apache.felix.ipojo.test.instance.service.Service;
+
+public class ServiceConsumer implements CheckService {
+    
+    private Service service;
+    private Properties props = new Properties();
+    
+    public ServiceConsumer() {
+       props.put("1", new Integer(service.count()));
+       props.put("2", new Integer(service.count()));
+       props.put("3", new Integer(service.count()));
+    }
+
+    public boolean check() {
+       return service.count() > 0;
+    }
+
+    public Properties getProps() {
+        return props;
+    }
+
+}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java
new file mode 100644
index 0000000..7c12a12
--- /dev/null
+++ b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/ServiceProvider.java
@@ -0,0 +1,15 @@
+package org.apache.felix.ipojo.test.instance;
+
+import org.apache.felix.ipojo.test.instance.service.Service;
+
+
+public class ServiceProvider implements Service {
+
+    private int i = 0;
+    
+    public int count() {
+        i++;
+        return i;
+    }
+
+}
diff --git a/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java
new file mode 100644
index 0000000..4c64172
--- /dev/null
+++ b/ipojo/tests/composite/service-instance/src/main/java/org/apache/felix/ipojo/test/instance/service/Service.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.instance.service;
+
+public interface Service {
+    
+    public int count();
+
+}
diff --git a/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml b/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml
index ff00ef1..8a20486 100644
--- a/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml
+++ b/ipojo/tests/composite/service-instance/src/main/resources/metadata.xml
@@ -56,5 +56,20 @@
 			<property name="strAProp" value="{a,b,c}"/>

 		</instance>

 	</comp:composite>

-

+	

+	<!-- Scope test -->

+	<component name="SCOPE-provider" classname="org.apache.felix.ipojo.test.instance.ServiceProvider">

+		<provides/>

+	</component>

+	<component name="SCOPE-cons" classname="org.apache.felix.ipojo.test.instance.ServiceConsumer">

+		<provides/>

+		<requires field="service"/>

+	</component>

+	<comp:composite name="SCOPE-scope">

+		<instance component="SCOPE-provider"/>

+		<instance component="SCOPE-cons"/>

+	</comp:composite>

+	<comp:composite name="SCOPE-badscope">

+		<instance component="SCOPE-cons"/>

+	</comp:composite>

 </ipojo>