felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r833666 - in /felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration: ArchitectureTest.java ConfigurationTestSuite.java
Date Sat, 07 Nov 2009 09:57:14 GMT
Author: clement
Date: Sat Nov  7 09:57:14 2009
New Revision: 833666

URL: http://svn.apache.org/viewvc?rev=833666&view=rev
Log:
Provide test about FELIX-1741.
Check if the managed service pid is correclty set in the instance architecture.

Added:
    felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
  (with props)
Modified:
    felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java

Added: felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java?rev=833666&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
(added)
+++ felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
Sat Nov  7 09:57:14 2009
@@ -0,0 +1,107 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.configuration;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.handlers.configuration.ConfigurationHandlerDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+
+public class ArchitectureTest extends OSGiTestCase {
+
+    /**
+     * Instance where the ManagedServicePID is provided by the component type. 
+     */
+    ComponentInstance instance1;
+    /**
+     * Instance where the ManagedServicePID is provided by the instance. 
+     */
+    ComponentInstance instance2;
+    
+    /**
+     * Instance without configuration. 
+     */
+    ComponentInstance instance3;
+    
+    public void setUp() {
+        String type = "CONFIG-FooProviderType-4";
+        Properties p = new Properties();
+        p.put("instance.name","instance");
+        p.put("foo", "foo");
+        p.put("bar", "2");
+        p.put("baz", "baz");
+        instance1 = Utils.getComponentInstance(getContext(), type, p);
+        assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
+        
+        type = "CONFIG-FooProviderType-3";
+        Properties p1 = new Properties();
+        p1.put("instance.name","instance-2");
+        p1.put("foo", "foo");
+        p1.put("bar", "2");
+        p1.put("baz", "baz");
+        p1.put("managed.service.pid", "instance");
+        instance2 = Utils.getComponentInstance(getContext(), type, p1);
+        
+    }
+    
+    public void tearDown() {
+        instance1.dispose();
+        instance2.dispose();
+        instance1 = null;
+        instance2 = null;
+    }
+    
+    public void testArchitectureForInstance1() {
+        Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(),
"(architecture.instance=instance)");
+        assertNotNull(arch);
+        
+        // Test on String representation.
+        String desc = arch.getInstanceDescription().getDescription().toString();
+        assertTrue(desc.contains("managed.service.pid=\"FooProvider-3\""));
+        
+        // Test on handler description
+        ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
+        assertNotNull(hd);
+        
+        assertEquals(2, hd.getProperties().length);
+        assertEquals("FooProvider-3", hd.getManagedServicePid());
+
+    }
+    
+    public void testArchitectureForInstance2() {
+        Architecture arch = (Architecture) Utils.getServiceObject(context, Architecture.class.getName(),
"(architecture.instance=instance-2)");
+        assertNotNull(arch);
+        
+        // Test on String representation.
+        String desc = arch.getInstanceDescription().getDescription().toString();
+        assertTrue(desc.contains("managed.service.pid=\"instance\""));
+        
+        // Test on handler description
+        ConfigurationHandlerDescription hd = (ConfigurationHandlerDescription) arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:properties");
+        assertNotNull(hd);
+        
+        assertEquals(2, hd.getProperties().length);
+        assertEquals("instance", hd.getManagedServicePid());
+
+    }
+
+}

Propchange: felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ArchitectureTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java?rev=833666&r1=833665&r2=833666&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
(original)
+++ felix/trunk/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
Sat Nov  7 09:57:14 2009
@@ -25,21 +25,22 @@
 
 public class ConfigurationTestSuite {
 
-	public static Test suite(BundleContext bc) {
-		OSGiTestSuite ots = new OSGiTestSuite("Configuration Test Suite", bc);
-		ots.addTestSuite(SimpleProperties.class);
-		ots.addTestSuite(DynamicallyConfigurableProperties.class);
-		ots.addTestSuite(TestFieldProperties.class);
-		ots.addTestSuite(TestMethodProperties.class);
-		ots.addTestSuite(TestBothProperties.class);
-		ots.addTestSuite(TestSuperMethodProperties.class);
-		ots.addTestSuite(ManagedServiceConfigurableProperties.class);
-		ots.addTestSuite(TestComplexProperties.class);
-		ots.addTestSuite(TestPropertyModifier.class);
-		ots.addTestSuite(UpdatedMethod.class);
-		ots.addTestSuite(UpdatedMethodAndManagedServiceFactory.class);
-		ots.addTestSuite(UpdatedMethodAndManagedService.class);
-		return ots;
-	}
+    public static Test suite(BundleContext bc) {
+        OSGiTestSuite ots = new OSGiTestSuite("Configuration Test Suite", bc);
+        ots.addTestSuite(SimpleProperties.class);
+        ots.addTestSuite(DynamicallyConfigurableProperties.class);
+        ots.addTestSuite(TestFieldProperties.class);
+        ots.addTestSuite(TestMethodProperties.class);
+        ots.addTestSuite(TestBothProperties.class);
+        ots.addTestSuite(TestSuperMethodProperties.class);
+        ots.addTestSuite(ManagedServiceConfigurableProperties.class);
+        ots.addTestSuite(TestComplexProperties.class);
+        ots.addTestSuite(TestPropertyModifier.class);
+        ots.addTestSuite(UpdatedMethod.class);
+        ots.addTestSuite(UpdatedMethodAndManagedServiceFactory.class);
+        ots.addTestSuite(UpdatedMethodAndManagedService.class);
+        ots.addTestSuite(ArchitectureTest.class);
+        return ots;
+    }
 
 }



Mime
View raw message