Author: cziegeler Date: Fri Jan 13 17:28:00 2017 New Revision: 1778639 URL: http://svn.apache.org/viewvc?rev=1778639&view=rev Log: Update field activation test
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/components/FieldActivatorComponent.java felix/trunk/osgi-r7/scr/src/test/resources/integration_test_field_activation_components.xml Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/components/FieldActivatorComponent.java URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/components/FieldActivatorComponent.java?rev=1778639&r1=1778638&r2=1778639&view=diff ============================================================================== --- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/components/FieldActivatorComponent.java (original) +++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/components/FieldActivatorComponent.java Fri Jan 13 17:28:00 2017 @@ -28,9 +28,9 @@ import org.osgi.service.component.Compon public class FieldActivatorComponent { public @interface Config { - String email() default "bar"; - int port() default 443; - long test() default 5; + String email() default "bar"; // property in component xml with value foo + int port() default 443; // property in component xml with value 80 + long test() default 5; // no property in component xml, will be 0 } private BundleContext bundle; @@ -41,7 +41,18 @@ public class FieldActivatorComponent private Config annotation; - public String test() + private boolean activated; + + private String activationTest; + + @SuppressWarnings("unused") + private void activator() { + // everything should be set here already + activationTest = check(); + activated = true; + } + + private String check() { if ( bundle == null ) { return "bundle is null"; @@ -76,4 +87,13 @@ public class FieldActivatorComponent return null; } + public String test() { + if ( !activated ) { + return "activate not called"; + } + if ( activationTest != null ) { + return "not set before activate: " + activationTest; + } + return check(); + } } Modified: felix/trunk/osgi-r7/scr/src/test/resources/integration_test_field_activation_components.xml URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/resources/integration_test_field_activation_components.xml?rev=1778639&r1=1778638&r2=1778639&view=diff ============================================================================== --- felix/trunk/osgi-r7/scr/src/test/resources/integration_test_field_activation_components.xml (original) +++ felix/trunk/osgi-r7/scr/src/test/resources/integration_test_field_activation_components.xml Fri Jan 13 17:28:00 2017 @@ -20,7 +20,7 @@ <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.4.0"> <!-- All fields exist --> - <scr:component name="FieldActivatorComponent.satisfied" enabled="false" + <scr:component name="FieldActivatorComponent.satisfied" enabled="false" activate="activator" activation-fields="bundle context config annotation"> <implementation class="org.apache.felix.scr.integration.components.FieldActivatorComponent" /> <service factory="false"> @@ -31,7 +31,7 @@ </scr:component> <!-- Field does not exist --> - <scr:component name="FieldActivatorComponent.unsatisfied" enabled="false" + <scr:component name="FieldActivatorComponent.unsatisfied" enabled="false" activate="activator" activation-fields="foo"> <implementation class="org.apache.felix.scr.integration.components.FieldActivatorComponent" /> <service factory="false"> @@ -40,7 +40,7 @@ </scr:component> <!-- Some exist, others not --> - <scr:component name="FieldActivatorComponent.partiallysatisfied" enabled="false" + <scr:component name="FieldActivatorComponent.partiallysatisfied" enabled="false" activate="activator" activation-fields="bundle context foo"> <implementation class="org.apache.felix.scr.integration.components.FieldActivatorComponent" /> <service factory="false">