You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2012/06/06 12:37:32 UTC
svn commit: r1346815 -
/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
Author: pderop
Date: Wed Jun 6 10:37:32 2012
New Revision: 1346815
URL: http://svn.apache.org/viewvc?rev=1346815&view=rev
Log:
FELIX-3524: Added test_get_configuration_pid_method in order to validate that
ComponentMetadata.getConfigurationPid() never returns null if configuration-pid
is not specified in the component declaration.
Modified:
felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
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=1346815&r1=1346814&r2=1346815&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 Wed Jun 6 10:37:32 2012
@@ -724,6 +724,53 @@ public class ComponentMetadataTest exten
}
}
+ public void test_get_configuration_pid_method()
+ {
+ doTest_get_configuration_pid_method(XmlHandler.DS_VERSION_1_0);
+ 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 );
+ }
+ catch ( ComponentException ce )
+ {
+ fail( "Expect correct validation for unnamed component" );
+ }
+ 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",
+ "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 );
+ }
+ catch ( ComponentException ce )
+ {
+ fail( "Expect correct validation for named component" );
+ }
+ 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",
+ "my.component.name", cm.getConfigurationPid() );
+ }
public void test_property_character_ds11() throws ComponentException
{