felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1164431 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java test/resources/components_properties_11.xml
Date Fri, 02 Sep 2011 09:30:40 GMT
Author: fmeschbe
Date: Fri Sep  2 09:30:39 2011
New Revision: 1164431

URL: http://svn.apache.org/viewvc?rev=1164431&view=rev
Log:
FELIX-3086 Missing support for DS 1.1 "Character" type name plus unit test

Added:
    felix/trunk/scr/src/test/resources/components_properties_11.xml   (with props)
Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java?rev=1164431&r1=1164430&r2=1164431&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
Fri Sep  2 09:30:39 2011
@@ -136,7 +136,8 @@ public class PropertyMetadata {
             }
             m_value = array;
         }
-        else if(m_type.equals("Char")) {
+        else if ( m_type.equals( "Char" ) || m_type.equals( "Character" ) ) {
+            // DS 1.1 changes the "Char" type to "Character", here we support both
             //TODO: verify if this is adequate for Characters
             char[] array = new char[valueList.size()];
             for (int i=0; i < array.length; i++) {

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java?rev=1164431&r1=1164430&r2=1164431&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/XmlHandlerTest.java Fri
Sep  2 09:30:39 2011
@@ -427,4 +427,32 @@ public class XmlHandlerTest extends Test
         // none found
         return null;
     }
+
+    public void test_properties_11() throws Exception
+    {
+        final List metadataList11 = readMetadata( "/components_properties_11.xml" );
+        assertEquals( "Component Descriptors", 1, metadataList11.size() );
+        final ComponentMetadata cm11 = ( ComponentMetadata ) metadataList11.get( 0 );
+
+        // dont validate this, we test the raw reading
+
+        // ds namespace
+        assertEquals( "DS Version 1.1", XmlHandler.DS_VERSION_1_1, cm11.getNamespaceCode()
);
+        assertTrue( "DS Version 1.1", cm11.isDS11() );
+
+        assertEquals( "component name", "DummyClass", cm11.getName() );
+        assertEquals( "component name", "DummyClass", cm11.getImplementationClassName() );
+
+        // property setting
+        final PropertyMetadata prop = getPropertyMetadata( cm11, "char_array_property" );
+        assertNotNull( "prop exists", prop );
+        assertEquals( "prop type", "Character", prop.getType() );
+        Object value = prop.getValue();
+        assertTrue( "prop arry", value instanceof char[] );
+        char[] chars = (char[]) value;
+        assertEquals( "prop number of values", 2, chars.length);
+        assertEquals( "prop value 0", 'a', chars[0] );
+        assertEquals( "prop value 1", 'b', chars[1] );
+    }
+
 }

Added: felix/trunk/scr/src/test/resources/components_properties_11.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/components_properties_11.xml?rev=1164431&view=auto
==============================================================================
--- felix/trunk/scr/src/test/resources/components_properties_11.xml (added)
+++ felix/trunk/scr/src/test/resources/components_properties_11.xml Fri Sep  2 09:30:39 2011
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> 
+  <implementation class="DummyClass" /> 
+  <property name="char_array_property" type="Character"> 
+    a 
+    b 
+  </property> 
+</scr:component> 

Propchange: felix/trunk/scr/src/test/resources/components_properties_11.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message