[FELIX-4350] Add disable integration test
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1549666 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java b/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
new file mode 100644
index 0000000..57c5959
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
@@ -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)
+ {
+ }
+ }
+
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java b/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java
new file mode 100644
index 0000000..f4423e8
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/Felix4350Component.java
@@ -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() {
+ }
+
+}
diff --git a/scr/src/test/resources/integration_test_FELIX_4350.xml b/scr/src/test/resources/integration_test_FELIX_4350.xml
new file mode 100644
index 0000000..ad4ae42
--- /dev/null
+++ b/scr/src/test/resources/integration_test_FELIX_4350.xml
@@ -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>