felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1380117 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
Date Mon, 03 Sep 2012 02:57:19 GMT
Author: fmeschbe
Date: Mon Sep  3 02:57:18 2012
New Revision: 1380117

URL: http://svn.apache.org/viewvc?rev=1380117&view=rev
Log:
FELIX-3648 Fail validation if an updated method is declared in a DS 1.0 or DS 1.1 namespaced
declaration.

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java?rev=1380117&r1=1380116&r2=1380117&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
Mon Sep  3 02:57:18 2012
@@ -22,7 +22,6 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.felix.scr.impl.helper.Logger;
-import org.osgi.service.log.LogService;
 
 /**
  * Information associated to a dependency
@@ -494,11 +493,8 @@ public class ReferenceMetadata
         // updated method is only supported in namespace xxx and later
         if ( m_updated != null && !componentMetadata.isDS11Felix() )
         {
-            logger
-                .log( LogService.LOG_WARNING,
-                    "Ignoring updated method definition, DS 1.1-felix or later namespace
required", componentMetadata,
-                    null );
-            m_updated = null;
+            // FELIX-3648 validation must fail (instead of just ignore)
+            throw componentMetadata.validationFailure( "updated method declaration requires
DS 1.2 or later namespace " );
         }
 
         m_validated = true;

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java?rev=1380117&r1=1380116&r2=1380117&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
Mon Sep  3 02:57:18 2012
@@ -474,12 +474,8 @@ public class ComponentMetadataTest exten
         final ComponentMetadata cm3 = createComponentMetadata( Boolean.TRUE, null );
         cm3.addDependency( rm3 );
 
-        // validates fine (though logging a warning) and sets field to null
-        cm3.validate( logger );
-
-        assertTrue( "Expected warning for unsupported updated method name",
-            logger.messageContains( "Ignoring updated method definition" ) );
-        assertNull( rm3.getUpdated() );
+        // according to DS 1.2 must fail validation (FELIX-3648)
+        failDS10Validation( cm3, "updated", logger );
     }
 
 
@@ -491,12 +487,8 @@ public class ComponentMetadataTest exten
         final ComponentMetadata cm3 = createComponentMetadata11( Boolean.TRUE, null );
         cm3.addDependency( rm3 );
 
-        // validates fine (though logging a warning) and sets field to null
-        cm3.validate( logger );
-
-        assertTrue( "Expected warning for unsupported updated method name",
-            logger.messageContains( "Ignoring updated method definition" ) );
-        assertNull( rm3.getUpdated() );
+        // according to DS 1.2 must fail validation (FELIX-3648)
+        failDS10Validation( cm3, "updated", logger );
     }
 
 
@@ -515,6 +507,21 @@ public class ComponentMetadataTest exten
     }
 
 
+    public void test_reference_updated_ds12()
+    {
+        // updated method accepted for DS 1.2
+        final ReferenceMetadata rm3 = createReferenceMetadata( "test" );
+        rm3.setUpdated( "my_updated_method" );
+        final ComponentMetadata cm3 = createComponentMetadata( XmlHandler.DS_VERSION_1_2,
Boolean.TRUE, null );
+        cm3.addDependency( rm3 );
+
+        // validates fine and logs no message
+        cm3.validate( logger );
+
+        assertEquals( "my_updated_method", rm3.getUpdated() );
+    }
+
+
     public void test_duplicate_implementation_ds10()
     {
         final ComponentMetadata cm = createComponentMetadata( Boolean.TRUE, null );
@@ -710,7 +717,7 @@ public class ComponentMetadataTest exten
         {
             // expected
         }
-        
+
         cm = createComponentMetadata12( null, null );
         try
         {
@@ -730,16 +737,16 @@ public class ComponentMetadataTest exten
         doTest_get_configuration_pid_method(XmlHandler.DS_VERSION_1_1);
         doTest_get_configuration_pid_method(XmlHandler.DS_VERSION_1_2);
     }
-    
+
     private void doTest_get_configuration_pid_method(int specVersion)
-    {            
+    {
         // Make sure that getConfigurationPid returns the default component name (implementation
class name).
         // We only do this kind of test if spec is greater than ds 1.0, because in ds 1.0,
the component name is mandatory.
         if (specVersion > XmlHandler.DS_VERSION_1_0)
         {
             ComponentMetadata cm = new ComponentMetadata( specVersion );
             try
-            {          
+            {
                 cm.setImplementationClassName("implementation.class");
                 cm.setName( null );
                 cm.validate( logger );
@@ -750,14 +757,14 @@ public class ComponentMetadataTest exten
             }
             String pid = cm.getConfigurationPid();
             assertNotNull( "Expect non-null configuration pid when component name is not
specified", pid );
-            assertEquals( "Expect configuration-pid to be equals to component implementation",

+            assertEquals( "Expect configuration-pid to be equals to component implementation",
                           "implementation.class", cm.getConfigurationPid() );
         }
-        
+
         // Make sure that getConfigurationPid returns the name of the component, if specified
         ComponentMetadata cm = new ComponentMetadata( specVersion );
         try
-        {     
+        {
             cm.setImplementationClassName("implementation.class");
             cm.setName("my.component.name");
             cm.validate( logger );
@@ -768,7 +775,7 @@ public class ComponentMetadataTest exten
         }
         String pid = cm.getConfigurationPid();
         assertNotNull( "Expect non-null configuration pid when component name is specified",
pid );
-        assertEquals( "Expect configuration-pid to be equals to component name", 
+        assertEquals( "Expect configuration-pid to be equals to component name",
                       "my.component.name", cm.getConfigurationPid() );
     }
 



Mime
View raw message