felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1739518 - in /felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest: components/ tests/
Date Sat, 16 Apr 2016 21:41:32 GMT
Author: pderop
Date: Sat Apr 16 21:41:32 2016
New Revision: 1739518

URL: http://svn.apache.org/viewvc?rev=1739518&view=rev
Log:
FELIX-5236: Added a test case for the 5236 issue. Moved the assertEquals methods from Felix4357
to Utils class.

Added:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix5236.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix5236Test.java
Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4357.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Utils.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix4357Test.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4357.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4357.java?rev=1739518&r1=1739517&r2=1739518&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4357.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix4357.java
Sat Apr 16 21:41:32 2016
@@ -18,7 +18,8 @@
  */
 package org.apache.felix.dm.runtime.itest.components;
 
-import org.junit.Assert;
+import static org.apache.felix.dm.runtime.itest.components.Utils.assertArrayEquals;
+import static org.apache.felix.dm.runtime.itest.components.Utils.assertEquals;
 
 import org.apache.felix.dm.annotation.api.Component;
 import org.apache.felix.dm.annotation.api.Property;
@@ -73,57 +74,35 @@ public class Felix4357 {
     @Registered
     void registered(ServiceRegistration sr) {
         ServiceReference ref = sr.getReference();
-        assertEquals(ref, "v1", "s", 1);
-        assertArrayEquals(ref, "v2", new String[] {"s1", "s2"}, 2);        
-        assertArrayEquals(ref, "v3", new String[] {"s1", "s2"}, 3);                     
  
-        assertEquals(ref, "v4", new Long(1), 4);
-        assertEquals(ref, "v5", new Long(1), 5);
-        assertArrayEquals(ref, "v6", new Long[] { 1L, 2L } , 6);
-        assertEquals(ref, "v7", new Double(1), 7);
-        assertEquals(ref, "v8", new Double(1), 8);
-        assertArrayEquals(ref, "v9", new Double[] { 1.0, 2.0 } , 9);
-        assertEquals(ref, "v10", new Float(1), 10);
-        assertEquals(ref, "v11", new Float(1), 11);
-        assertArrayEquals(ref, "v12", new Float[] { 1.f, 2.f } , 12);
-        assertEquals(ref, "v13", new Integer(1), 13);
-        assertEquals(ref, "v14", new Integer(1), 14);
-        assertArrayEquals(ref, "v15", new Integer[] { 1, 2 } , 15);
-        assertEquals(ref, "v16", Byte.valueOf("65"), 16);
-        assertEquals(ref, "v17", Byte.valueOf("65"), 17);
-        assertArrayEquals(ref, "v18", new Byte[] { Byte.valueOf("65"), Byte.valueOf("66")
} , 18);
-        assertEquals(ref, "v19", Character.valueOf('A'), 19);
-        assertEquals(ref, "v20", Character.valueOf('A'), 20);
-        assertArrayEquals(ref, "v21", new Character[] { 'A', 'B' } , 21);
-        assertEquals(ref, "v22", Boolean.valueOf(true), 22);
-        assertEquals(ref, "v23", Boolean.valueOf(true), 23);
-        assertArrayEquals(ref, "v24", new Boolean[] { true, false } , 24);
-        assertEquals(ref, "v25", Short.valueOf((short) 1), 25);
-        assertEquals(ref, "v26", Short.valueOf((short) 1), 26);
-        assertArrayEquals(ref, "v27", new Short[] { 1, 2 } , 27);
-        assertEquals(ref, "v28", Character.valueOf('A'), 28);
-        assertEquals(ref, "v29", Character.valueOf('A'), 29);
-        assertArrayEquals(ref, "v30", new Character[] { 'A', 'B' } , 30);
-    }
-    
-    void assertEquals(ServiceReference ref, String property, Object expected, int step) {
-        Object value = ref.getProperty(property);
-        Assert.assertNotNull(value);
-        Assert.assertEquals(value.getClass(), expected.getClass());
-        Assert.assertEquals(value, expected);        
-        m_ensure.step(step);
-    }
-    
-    void assertArrayEquals(ServiceReference ref, String property, Object[] expected, int
step) {
-        Object values = ref.getProperty(property);
-        Assert.assertNotNull(values);
-        Assert.assertTrue(values.getClass().isArray());
-        Assert.assertEquals(values.getClass(), expected.getClass());
-        Object[] array = (Object[]) values;
-        Assert.assertEquals(array.length, expected.length);
-        for (int i = 0; i < array.length; i ++) {
-            Assert.assertEquals(array[i].getClass(), expected[i].getClass());
-            Assert.assertEquals(array[i], expected[i]);
-        }
-        m_ensure.step(step);
-    }
+        assertEquals(m_ensure, ref, "v1", "s", 1);
+        assertArrayEquals(m_ensure, ref, "v2", new String[] {"s1", "s2"}, 2);        
+        assertArrayEquals(m_ensure, ref, "v3", new String[] {"s1", "s2"}, 3);           
            
+        assertEquals(m_ensure, ref, "v4", new Long(1), 4);
+        assertEquals(m_ensure, ref, "v5", new Long(1), 5);
+        assertArrayEquals(m_ensure, ref, "v6", new Long[] { 1L, 2L } , 6);
+        assertEquals(m_ensure, ref, "v7", new Double(1), 7);
+        assertEquals(m_ensure, ref, "v8", new Double(1), 8);
+        assertArrayEquals(m_ensure, ref, "v9", new Double[] { 1.0, 2.0 } , 9);
+        assertEquals(m_ensure, ref, "v10", new Float(1), 10);
+        assertEquals(m_ensure, ref, "v11", new Float(1), 11);
+        assertArrayEquals(m_ensure, ref, "v12", new Float[] { 1.f, 2.f } , 12);
+        assertEquals(m_ensure, ref, "v13", new Integer(1), 13);
+        assertEquals(m_ensure, ref, "v14", new Integer(1), 14);
+        assertArrayEquals(m_ensure, ref, "v15", new Integer[] { 1, 2 } , 15);
+        assertEquals(m_ensure, ref, "v16", Byte.valueOf("65"), 16);
+        assertEquals(m_ensure, ref, "v17", Byte.valueOf("65"), 17);
+        assertArrayEquals(m_ensure, ref, "v18", new Byte[] { Byte.valueOf("65"), Byte.valueOf("66")
} , 18);
+        assertEquals(m_ensure, ref, "v19", Character.valueOf('A'), 19);
+        assertEquals(m_ensure, ref, "v20", Character.valueOf('A'), 20);
+        assertArrayEquals(m_ensure, ref, "v21", new Character[] { 'A', 'B' } , 21);
+        assertEquals(m_ensure, ref, "v22", Boolean.valueOf(true), 22);
+        assertEquals(m_ensure, ref, "v23", Boolean.valueOf(true), 23);
+        assertArrayEquals(m_ensure, ref, "v24", new Boolean[] { true, false } , 24);
+        assertEquals(m_ensure, ref, "v25", Short.valueOf((short) 1), 25);
+        assertEquals(m_ensure, ref, "v26", Short.valueOf((short) 1), 26);
+        assertArrayEquals(m_ensure, ref, "v27", new Short[] { 1, 2 } , 27);
+        assertEquals(m_ensure, ref, "v28", Character.valueOf('A'), 28);
+        assertEquals(m_ensure, ref, "v29", Character.valueOf('A'), 29);
+        assertArrayEquals(m_ensure, ref, "v30", new Character[] { 'A', 'B' } , 30);
+    }    
 }

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix5236.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix5236.java?rev=1739518&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix5236.java
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Felix5236.java
Sat Apr 16 21:41:32 2016
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.components;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.Registered;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.itest.util.Ensure;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Checks support of primitive types for @Property annotation.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component(provides=Felix5236.class)
+@Property(name="v1", value="s")
+public class Felix5236 {
+    public final static String ENSURE = "Felix5236";
+    
+    @ServiceDependency(filter = "(name=" + ENSURE + ")")
+    volatile Ensure m_ensure;
+    
+    @Registered
+    void registered(ServiceRegistration sr) {
+        ServiceReference ref = sr.getReference();
+        Utils.assertEquals(m_ensure, ref, "v1", "s", 1);
+    }
+}

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Utils.java?rev=1739518&r1=1739517&r2=1739518&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Utils.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/Utils.java
Sat Apr 16 21:41:32 2016
@@ -18,6 +18,10 @@
  */
 package org.apache.felix.dm.runtime.itest.components;
 
+import org.apache.felix.dm.itest.util.Ensure;
+import org.junit.Assert;
+import org.osgi.framework.ServiceReference;
+
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
@@ -38,4 +42,26 @@ public class Utils {
         };
         t.start();
     }
+        
+    public static void assertEquals(Ensure e, ServiceReference ref, String property, Object
expected, int step) {
+        Object value = ref.getProperty(property);
+        Assert.assertNotNull(value);
+        Assert.assertEquals(value.getClass(), expected.getClass());
+        Assert.assertEquals(value, expected);        
+        e.step(step);
+    }
+    
+    public static void assertArrayEquals(Ensure e, ServiceReference ref, String property,
Object[] expected, int step) {
+        Object values = ref.getProperty(property);
+        Assert.assertNotNull(values);
+        Assert.assertTrue(values.getClass().isArray());
+        Assert.assertEquals(values.getClass(), expected.getClass());
+        Object[] array = (Object[]) values;
+        Assert.assertEquals(array.length, expected.length);
+        for (int i = 0; i < array.length; i ++) {
+            Assert.assertEquals(array[i].getClass(), expected[i].getClass());
+            Assert.assertEquals(array[i], expected[i]);
+        }
+        e.step(step);
+    }
 }

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix4357Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix4357Test.java?rev=1739518&r1=1739517&r2=1739518&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix4357Test.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix4357Test.java
Sat Apr 16 21:41:32 2016
@@ -31,7 +31,7 @@ import org.osgi.framework.ServiceRegistr
  */
 public class Felix4357Test extends TestBase {
     
-    public void testPropertiesWithTypes() {
+    public void testSingleProperty() {
         Ensure e = new Ensure();
         ServiceRegistration sr = register(e, Felix4357.ENSURE);
         // wait for S to be started

Added: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix5236Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix5236Test.java?rev=1739518&view=auto
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix5236Test.java
(added)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/Felix5236Test.java
Sat Apr 16 21:41:32 2016
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.runtime.itest.tests;
+
+import org.apache.felix.dm.itest.util.Ensure;
+import org.apache.felix.dm.itest.util.TestBase;
+import org.apache.felix.dm.runtime.itest.components.Felix5236;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Test for FELIX-4357 issue: It validates the types of some service component properties
+ * defined with @Property annotation.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Felix5236Test extends TestBase {
+    
+    public void testPropertiesWithTypes() {
+        Ensure e = new Ensure();
+        ServiceRegistration sr = register(e, Felix5236.ENSURE);
+        e.waitForStep(1, 10000);
+        sr.unregister();
+    }
+}



Mime
View raw message