felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1637722 - in /felix/trunk/metatype/src: main/java/org/apache/felix/metatype/AD.java main/java/org/apache/felix/metatype/MetaDataReader.java test/java/org/apache/felix/metatype/MetaDataReaderTest.java
Date Sun, 09 Nov 2014 19:30:33 GMT
Author: djencks
Date: Sun Nov  9 19:30:32 2014
New Revision: 1637722

URL: http://svn.apache.org/r1637722
Log:
FELIX-4687 support proposed R6 metatype 1.3 namespace

Modified:
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/AD.java
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
    felix/trunk/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/AD.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/AD.java?rev=1637722&r1=1637721&r2=1637722&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/AD.java (original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/AD.java Sun Nov  9 19:30:32
2014
@@ -317,7 +317,7 @@ public class AD extends OptionalAttribut
         {
             return AttributeDefinition.BYTE;
         }
-        else if ("Char".equals(typeString))
+        else if ("Character".equals(typeString) || "Char".equals(typeString))
         {
             return AttributeDefinition.CHARACTER;
         }

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java?rev=1637722&r1=1637721&r2=1637722&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java (original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java Sun Nov
 9 19:30:32 2014
@@ -62,17 +62,22 @@ public class MetaDataReader
      * Specification 4.2. We still have to support this namespace for
      * backwards compatibility.
      */
-    private static final String NAMESPACE_1_0 = "http://www.osgi.org/xmlns/metatype/v1.0.0";
+    static final String NAMESPACE_1_0 = "http://www.osgi.org/xmlns/metatype/v1.0.0";
 
     /**
      * The XML Namespace for Metatype 1.1 descriptors.
      */
-    private static final String NAMESPACE_1_1 = "http://www.osgi.org/xmlns/metatype/v1.1.0";
+    static final String NAMESPACE_1_1 = "http://www.osgi.org/xmlns/metatype/v1.1.0";
 
     /**
      * The XML Namespace for Metatype 1.2 descriptors.
      */
-    private static final String NAMESPACE_1_2 = "http://www.osgi.org/xmlns/metatype/v1.2.0";
+    static final String NAMESPACE_1_2 = "http://www.osgi.org/xmlns/metatype/v1.2.0";
+
+    /**
+     * The XML Namespace for Metatype 1.2 descriptors.
+     */
+    static final String NAMESPACE_1_3 = "http://www.osgi.org/xmlns/metatype/v1.3.0";
 
     /** The XML parser used to read the XML documents */
     private KXmlParser parser = new KXmlParser();
@@ -151,8 +156,11 @@ public class MetaDataReader
     private void checkMetatypeNamespace() throws IOException
     {
         final String namespace = this.parser.getNamespace();
-        if ( namespace != null && namespace.length() > 0 && !NAMESPACE_1_0.equals(
namespace )
-            && !NAMESPACE_1_1.equals( namespace ) && !NAMESPACE_1_2.equals(
namespace ) )
+        if ( namespace != null && namespace.length() > 0 && 
+            !NAMESPACE_1_0.equals( namespace ) &&
+            !NAMESPACE_1_1.equals( namespace ) &&
+            !NAMESPACE_1_2.equals( namespace ) &&
+            !NAMESPACE_1_3.equals( namespace ) )
         {
             throw new IOException( "Unsupported Namespace " + namespace );
         }

Modified: felix/trunk/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java?rev=1637722&r1=1637721&r2=1637722&view=diff
==============================================================================
--- felix/trunk/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java (original)
+++ felix/trunk/metatype/src/test/java/org/apache/felix/metatype/MetaDataReaderTest.java Sun
Nov  9 19:30:32 2014
@@ -85,7 +85,7 @@ public class MetaDataReaderTest extends 
 
     public void testWithNamespace_1_0_0() throws IOException, XmlPullParserException
     {
-        String empty = "<metatype:MetaData xmlns:metatype=\"http://www.osgi.org/xmlns/metatype/v1.0.0\"
"
+        String empty = "<metatype:MetaData xmlns:metatype=\"" + MetaDataReader.NAMESPACE_1_0
+ "\" "
             + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ></metatype:MetaData>";
         MetaData mti = read( empty );
 
@@ -97,7 +97,7 @@ public class MetaDataReaderTest extends 
 
     public void testWithNamespace_1_1_0() throws IOException, XmlPullParserException
     {
-        String empty = "<metatype:MetaData xmlns:metatype=\"http://www.osgi.org/xmlns/metatype/v1.1.0\"
"
+        String empty = "<metatype:MetaData xmlns:metatype=\"" + MetaDataReader.NAMESPACE_1_1
+ "\" "
             + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ></metatype:MetaData>";
         MetaData mti = read( empty );
 
@@ -109,7 +109,19 @@ public class MetaDataReaderTest extends 
 
     public void testWithNamespace_1_2_0() throws IOException, XmlPullParserException
     {
-        String empty = "<metatype:MetaData xmlns:metatype=\"http://www.osgi.org/xmlns/metatype/v1.1.0\"
"
+        String empty = "<metatype:MetaData xmlns:metatype=\"" + MetaDataReader.NAMESPACE_1_2
+ "\" "
+            + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ></metatype:MetaData>";
+        MetaData mti = read( empty );
+
+        assertNotNull( mti );
+        assertNull( mti.getLocalePrefix() );
+        assertNull( mti.getObjectClassDefinitions() );
+    }
+
+
+    public void testWithNamespace_1_3_0() throws IOException, XmlPullParserException
+    {
+        String empty = "<metatype:MetaData xmlns:metatype=\"" + MetaDataReader.NAMESPACE_1_3
+ "\" "
             + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ></metatype:MetaData>";
         MetaData mti = read( empty );
 
@@ -188,6 +200,27 @@ public class MetaDataReaderTest extends 
 
     public void testSingleOCDSingleRequiredAttr() throws IOException, XmlPullParserException
     {
+        testSingleOCDSingleRequiredAttr("String", AttributeDefinition.STRING, MetaDataReader.NAMESPACE_1_0);
+        testSingleOCDSingleRequiredAttr("String", AttributeDefinition.STRING, MetaDataReader.NAMESPACE_1_1);
+        testSingleOCDSingleRequiredAttr("String", AttributeDefinition.STRING, MetaDataReader.NAMESPACE_1_2);
+        testSingleOCDSingleRequiredAttr("String", AttributeDefinition.STRING, MetaDataReader.NAMESPACE_1_3);
+
+        testSingleOCDSingleRequiredAttr("Char", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_0);
+        testSingleOCDSingleRequiredAttr("Char", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_1);
+        testSingleOCDSingleRequiredAttr("Char", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_2);
+        testSingleOCDSingleRequiredAttr("Char", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_3);
+        
+        testSingleOCDSingleRequiredAttr("Character", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_0);
+        testSingleOCDSingleRequiredAttr("Character", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_1);
+        testSingleOCDSingleRequiredAttr("Character", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_2);
+        testSingleOCDSingleRequiredAttr("Character", AttributeDefinition.CHARACTER, MetaDataReader.NAMESPACE_1_3);
+
+    }
+
+
+    private void testSingleOCDSingleRequiredAttr(String adType, int typeCode,
+        String namespace) throws IOException
+    {
         String ocdName = "ocd0";
         String ocdId = "id.ocd0";
         String ocdDescription = "ocd0 description";
@@ -195,14 +228,13 @@ public class MetaDataReaderTest extends 
         String adId = "id.ad0";
         String adName = "ad0";
         String adDescription = "ad0 description";
-        String adType = "String";
         int adCardinality = 789;
         String adDefault = "    a    ,   b    ,    c    ";
 
-        String empty = "<MetaData>" + "<OCD id=\"" + ocdId + "\" name=\"" + ocdName
+ "\" description=\""
+        String empty = "<metatype:MetaData xmlns:metatype=\"" + namespace + "\">" +
"<OCD id=\"" + ocdId + "\" name=\"" + ocdName + "\" description=\""
             + ocdDescription + "\">" + "<AD id=\"" + adId + "\" name=\"" + adName +
"\" type=\"" + adType
             + "\" description=\"" + adDescription + "\" cardinality=\"" + adCardinality +
"\" default=\"" + adDefault
-            + "\">" + "</AD>" + "</OCD>" + "</MetaData>";
+            + "\">" + "</AD>" + "</OCD>" + "</metatype:MetaData>";
         MetaData mti = read( empty );
 
         assertNull( mti.getLocalePrefix() );
@@ -218,7 +250,7 @@ public class MetaDataReaderTest extends 
         assertEquals( adId, ad.getID() );
         assertEquals( adName, ad.getName() );
         assertEquals( adDescription, ad.getDescription() );
-        assertEquals( AttributeDefinition.STRING, ad.getType() );
+        assertEquals( typeCode, ad.getType() );
         assertEquals( adCardinality, ad.getCardinality() );
         assertNotNull( ad.getDefaultValue() );
         assertEquals( 3, ad.getDefaultValue().length );



Mime
View raw message