You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2013/12/09 21:20:03 UTC
svn commit: r1549666 - in /felix/trunk/scr/src/test:
java/org/apache/felix/scr/integration/Felix4350Test.java
java/org/apache/felix/scr/integration/components/Felix4350Component.java
resources/integration_test_FELIX_4350.xml
Author: gnodet
Date: Mon Dec 9 20:20:03 2013
New Revision: 1549666
URL: http://svn.apache.org/r1549666
Log:
[FELIX-4350] Add disable integration test
Added:
felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java
felix/trunk/scr/src/test/resources/integration_test_FELIX_4350.xml
Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java?rev=1549666&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java Mon Dec 9 20:20:03 2013
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+package org.apache.felix.scr.integration;
+
+import javax.inject.Inject;
+
+import junit.framework.TestCase;
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.integration.components.SimpleComponent;
+import org.apache.felix.scr.integration.components.SimpleComponent2;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentInstance;
+
+/**
+ * This test validates the FELIX-4350 issue.
+ */
+@RunWith(JUnit4TestRunner.class)
+public class Felix4350Test extends ComponentTestBase
+{
+ static
+ {
+ // uncomment to enable debugging of this test class
+// paxRunnerVmOption = DEBUG_VM_OPTION;
+ descriptorFile = "/integration_test_FELIX_4350.xml";
+ restrictedLogging = true;
+ //comment to get debug logging if the test fails.
+// DS_LOGLEVEL = "warn";
+ }
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ @Test
+ @Ignore
+ public void test_unbind_while_activating_single_static()
+ {
+ doTest("SingleStatic");
+ }
+
+ @Test
+ @Ignore
+ public void test_unbind_while_activating_single_dynamic()
+ {
+ doTest("SingleDynamic");
+ }
+
+ @Test
+ @Ignore
+ public void test_unbind_while_activating_multiple_dynamic()
+ {
+ doTest("MultipleDynamic");
+ }
+
+ @Test
+ @Ignore
+ public void test_unbind_while_activating_multiple_static_greedy()
+ {
+ doTest("MultipleStaticGreedy");
+ }
+
+ @Test
+ @Ignore
+ public void test_unbind_while_activating_multiple_static_reluctant()
+ {
+ doTest("MultipleStaticReluctant");
+ }
+
+ protected void doTest(String componentName)
+ {
+ final Component main = findComponentByName(componentName);
+ TestCase.assertNotNull(main);
+
+ ServiceRegistration dep1Reg = bundleContext.registerService(SimpleComponent.class.getName(),
+ new ServiceFactory()
+ {
+ public Object getService(Bundle bundle, ServiceRegistration registration)
+ {
+ return new SimpleComponent();
+ }
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ {
+ }
+ }, null);
+ ServiceRegistration dep2Reg = bundleContext.registerService(SimpleComponent2.class.getName(),
+ new ServiceFactory()
+ {
+ public Object getService(Bundle bundle, ServiceRegistration registration)
+ {
+ delay(1000);
+ return new SimpleComponent2();
+ }
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ {
+ }
+ }, null);
+
+ main.enable();
+ delay(300);
+ dep1Reg.unregister();
+ delay(2000);
+
+ ComponentInstance mainCompInst = main.getComponentInstance();
+ TestCase.assertNull(mainCompInst);
+ }
+
+ protected static void delay(int millis)
+ {
+ try
+ {
+ Thread.sleep(millis);
+ }
+ catch (InterruptedException ie)
+ {
+ }
+ }
+
+}
Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java?rev=1549666&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java Mon Dec 9 20:20:03 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+package org.apache.felix.scr.integration.components;
+
+public class Felix4350Component {
+
+ private SimpleComponent component1;
+ private SimpleComponent2 component2;
+
+ public void bindComponent1(SimpleComponent component1) {
+ this.component1 = component1;
+ }
+
+ public void unbindComponent1(SimpleComponent component1) {
+ this.component1 = null;
+ }
+
+ public void bindComponent2(SimpleComponent2 component2) {
+ this.component2 = component2;
+ }
+
+ public void unbindComponent2(SimpleComponent2 component2) {
+ this.component2 = null;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
Added: felix/trunk/scr/src/test/resources/integration_test_FELIX_4350.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_FELIX_4350.xml?rev=1549666&view=auto
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_FELIX_4350.xml (added)
+++ felix/trunk/scr/src/test/resources/integration_test_FELIX_4350.xml Mon Dec 9 20:20:03 2013
@@ -0,0 +1,74 @@
+<?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. -->
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0">
+
+ <scr:component enabled='false' name='SingleStatic'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.Felix4350Component' />
+ <reference name='component1'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent'
+ cardinality='1..1' bind='bindComponent1' unbind='unbindComponent1' policy='static' />
+ <reference name='component2'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent2'
+ cardinality='1..1' bind='bindComponent2' unbind='unbindComponent2' policy='static' />
+ </scr:component>
+
+ <scr:component enabled='false' name='SingleDynamic'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.Felix4350Component' />
+ <reference name='component1'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent'
+ cardinality='1..1' bind='bindComponent1' unbind='unbindComponent1' policy='dynamic' />
+ <reference name='component2'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent2'
+ cardinality='1..1' bind='bindComponent2' unbind='unbindComponent2' policy='static' />
+ </scr:component>
+
+ <scr:component enabled='false' name='MultipleDynamic'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.Felix4350Component' />
+ <reference name='component1'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent'
+ cardinality='1..n' bind='bindComponent1' unbind='unbindComponent1' policy='dynamic' />
+ <reference name='component2'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent2'
+ cardinality='1..1' bind='bindComponent2' unbind='unbindComponent2' policy='static' />
+ </scr:component>
+
+ <scr:component enabled='false' name='MultipleStaticReluctant'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.Felix4350Component' />
+ <reference name='component1'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent'
+ cardinality='1..n' bind='bindComponent1' unbind='unbindComponent1' policy='static' />
+ <reference name='component2'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent2'
+ cardinality='1..1' bind='bindComponent2' unbind='unbindComponent2' policy='static' />
+ </scr:component>
+
+ <scr:component enabled='false' name='MultipleStaticGreedy'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.Felix4350Component' />
+ <reference name='component1'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent'
+ cardinality='1..n' bind='bindComponent1' unbind='unbindComponent1' policy='static' policy-option='greedy' />
+ <reference name='component2'
+ interface='org.apache.felix.scr.integration.components.SimpleComponent2'
+ cardinality='1..1' bind='bindComponent2' unbind='unbindComponent2' policy='static' />
+ </scr:component>
+
+</components>