Added integration test for the FELIX-3680 issue.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1393203 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
index 4c0030f..71dea9d 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
@@ -120,7 +120,7 @@
@ProbeBuilder
public TestProbeBuilder extendProbe(TestProbeBuilder builder) {
- builder.setHeader("Export-Package", "org.apache.felix.scr.integration.components,org.apache.felix.scr.integration.components.activatesignature,org.apache.felix.scr.integration.components.circular,org.apache.felix.scr.integration.components.concurrency");
+ builder.setHeader("Export-Package", "org.apache.felix.scr.integration.components,org.apache.felix.scr.integration.components.activatesignature,org.apache.felix.scr.integration.components.circular,org.apache.felix.scr.integration.components.concurrency,org.apache.felix.scr.integration.components.felix3680");
builder.setHeader("Import-Package", "org.apache.felix.scr,org.apache.felix.scr.component;mandatory:=\"status\"; status=\"provisional\"");
builder.setHeader("Bundle-ManifestVersion", "2");
return builder;
@@ -146,7 +146,7 @@
),
junitBundles(),
systemProperty( "ds.factory.enabled" ).value( Boolean.toString( NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR ) ),
- systemProperty( "ds.loglevel" ).value( "debug" )
+ systemProperty( "ds.loglevel" ).value( "warn" )
);
final Option vmOption = ( paxRunnerVmOption != null ) ? CoreOptions.vmOption( paxRunnerVmOption ) : null;
@@ -390,7 +390,7 @@
.set(Constants.BUNDLE_SYMBOLICNAME, "simplecomponent")
.set(Constants.BUNDLE_VERSION, "0.0.11")
.set(Constants.IMPORT_PACKAGE,
- "org.apache.felix.scr.integration.components,org.apache.felix.scr.integration.components.activatesignature,org.apache.felix.scr.integration.components.circular,org.apache.felix.scr.integration.components.concurrency")
+ "org.apache.felix.scr.integration.components,org.apache.felix.scr.integration.components.activatesignature,org.apache.felix.scr.integration.components.circular,org.apache.felix.scr.integration.components.concurrency,org.apache.felix.scr.integration.components.felix3680")
.set("Service-Component", "OSGI-INF/components.xml")
.build(withBnd());
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java b/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
new file mode 100644
index 0000000..9fd3f5d
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
@@ -0,0 +1,103 @@
+/*
+ * 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 java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import javax.inject.Inject;
+
+import junit.framework.TestCase;
+
+import org.apache.felix.scr.Component;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogListener;
+import org.osgi.service.log.LogReaderService;
+import org.osgi.service.log.LogService;
+
+/**
+ * This test validates the FELIX-3680 issue.
+ */
+@RunWith(JUnit4TestRunner.class)
+public class Felix3680Test extends ComponentTestBase
+{
+ static
+ {
+ // uncomment to enable debugging of this test class
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
+ descriptorFile = "/integration_test_FELIX_3680.xml";
+ }
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ protected static void delay(int secs)
+ {
+ try
+ {
+ Thread.sleep(secs * 1000);
+ }
+ catch (InterruptedException ie)
+ {
+ }
+ }
+
+ @Test
+ public void test_concurrent_reference_bindings()
+ {
+ final Component main =
+ findComponentByName("org.apache.felix.scr.integration.components.felix3680.Main");
+ TestCase.assertNotNull(main);
+ main.enable();
+
+ delay(30);
+ for (Iterator it = log.foundWarnings().iterator(); it.hasNext();)
+ {
+ LogEntry entry = (LogEntry) it.next();
+ String message = entry.getMessage();
+ if (message.startsWith("Performed ") && message.endsWith(" tests."))
+ {
+ continue;
+ }
+ TestCase.fail("unexpected warning or error logged: " + message);
+ }
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java
new file mode 100644
index 0000000..24a3039
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java
@@ -0,0 +1,46 @@
+/*
+ * 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.felix3680;
+
+public class A
+{
+ void bindB(B b)
+ {
+ }
+
+ void bindC(C c)
+ {
+ }
+
+ void bindD(D d)
+ {
+ }
+
+ void bindE(E e)
+ {
+ }
+
+ void bindF(F f)
+ {
+ }
+
+ void start()
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java
new file mode 100644
index 0000000..d2e709f
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java
@@ -0,0 +1,23 @@
+/*
+ * 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.felix3680;
+
+public class B
+{
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java
new file mode 100644
index 0000000..2e8088e
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java
@@ -0,0 +1,23 @@
+/*
+ * 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.felix3680;
+
+public class C
+{
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java
new file mode 100644
index 0000000..4db5704
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java
@@ -0,0 +1,24 @@
+/*
+ * 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.felix3680;
+
+public class D
+{
+
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java
new file mode 100644
index 0000000..da238b3
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java
@@ -0,0 +1,24 @@
+/*
+ * 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.felix3680;
+
+public class E
+{
+
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java
new file mode 100644
index 0000000..f6cd544
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java
@@ -0,0 +1,26 @@
+/*
+ * 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.felix3680;
+
+public class F
+{
+ void bindG(G g)
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java
new file mode 100644
index 0000000..0bb3435
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java
@@ -0,0 +1,8 @@
+package org.apache.felix.scr.integration.components.felix3680;
+
+public class G
+{
+ void bindH(H h)
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java
new file mode 100644
index 0000000..db27d59
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java
@@ -0,0 +1,26 @@
+/*
+ * 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.felix3680;
+
+public class H
+{
+ void bindI(I i)
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java
new file mode 100644
index 0000000..1e0ef8b
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java
@@ -0,0 +1,26 @@
+/*
+ * 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.felix3680;
+
+public class I
+{
+ void bindJ(J j)
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java
new file mode 100644
index 0000000..50423eb
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java
@@ -0,0 +1,26 @@
+/*
+ * 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.felix3680;
+
+public class J
+{
+ void bindK(K k)
+ {
+ }
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java
new file mode 100644
index 0000000..0f50354
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java
@@ -0,0 +1,23 @@
+/*
+ * 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.felix3680;
+
+public class K
+{
+}
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java
new file mode 100644
index 0000000..7429ebb
--- /dev/null
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java
@@ -0,0 +1,270 @@
+/*
+ * 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.felix3680;
+
+import java.io.StringWriter;
+import java.util.LinkedHashSet;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.felix.scr.ScrService;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.log.LogService;
+
+public class Main implements Runnable
+{
+ private volatile ComponentContext _ctx;
+ private volatile AtomicInteger _counter = new AtomicInteger();
+ private volatile CountDownLatch _enabledLatch;
+ private volatile CountDownLatch _disabledLatch;
+ private volatile Random _rnd = new Random();
+ private volatile LogService _logService;
+ private ScrService _scr;
+ private volatile Thread _thread;
+ private volatile boolean _running;
+
+ /**
+ * Helper used to randomly enable or disable a list of components.
+ */
+ class EnableManager
+ {
+ String[] _componentNames;
+
+ EnableManager(String[] componentNames)
+ {
+ _componentNames = componentNames;
+ }
+
+ public void enableComponents(Executor exec)
+ {
+ enableOrDisable(exec, true);
+ }
+
+ public void disableComponents(Executor exec)
+ {
+ enableOrDisable(exec, false);
+ }
+
+ private void enableOrDisable(Executor exec, final boolean enable)
+ {
+ for (final int i : getRandomIndexes(_componentNames.length))
+ {
+ exec.execute(new Runnable()
+ {
+ public void run()
+ {
+ if (enable)
+ {
+ //_logService.log(LogService.LOG_INFO, "enabling component " + _componentNames[i]);
+ _ctx.enableComponent(_componentNames[i]);
+ _enabledLatch.countDown();
+ }
+ else
+ {
+ //_logService.log(LogService.LOG_INFO, "disabling component " + _componentNames[i]);
+ _ctx.disableComponent(_componentNames[i]);
+ _disabledLatch.countDown();
+ }
+ }
+ });
+ }
+ }
+
+ private Integer[] getRandomIndexes(int max)
+ {
+ Set<Integer> set = new LinkedHashSet<Integer>();
+ for (int i = 0; i < max; i++)
+ {
+ int n;
+ do
+ {
+ n = _rnd.nextInt(max);
+ } while (set.contains(n));
+ set.add(n);
+ }
+ for (int i = 0; i < max; i++)
+ {
+ if (!set.contains(i))
+ {
+ throw new IllegalStateException("invalid rnd indexes: " + set);
+ }
+ }
+ return set.toArray(new Integer[set.size()]);
+ }
+ }
+
+ void bindSCR(ScrService scr)
+ {
+ _scr = scr;
+ }
+
+ void bindLogService(LogService logService)
+ {
+ _logService = logService;
+ }
+
+ void bindA(ServiceReference sr)
+ {
+ A a = (A) sr.getBundle().getBundleContext().getService(sr);
+ if (a == null)
+ {
+ throw new IllegalStateException("bindA: bundleContext.getService returned null");
+ }
+ if (_counter.incrementAndGet() != 1)
+ {
+ throw new IllegalStateException("bindA: invalid counter value: " + _counter);
+ }
+ _enabledLatch.countDown();
+ }
+
+ void unbindA(ServiceReference sr)
+ {
+ if (_counter.decrementAndGet() != 0)
+ {
+ throw new IllegalStateException("unbindA: invalid counter value: " + _counter);
+ }
+ _disabledLatch.countDown();
+ }
+
+ void start(ComponentContext ctx)
+ {
+ _logService.log(LogService.LOG_INFO, "Main.start");
+ _ctx = ctx;
+ _running = true;
+ _thread = new Thread(this);
+ _thread.start();
+ }
+
+ void stop()
+ {
+ _running = false;
+ _thread.interrupt();
+ }
+
+ public void run()
+ {
+ Executor exec = Executors.newFixedThreadPool(50);
+ _logService.log(LogService.LOG_INFO, "Main.run");
+ int loop = 0;
+ while (_running)
+ {
+ ++loop;
+ if ((loop % 100) == 0)
+ {
+ _logService.log(LogService.LOG_WARNING, "Performed " + loop + " tests.");
+ }
+ _enabledLatch = new CountDownLatch(11);
+ _disabledLatch = new CountDownLatch(11);
+
+ EnableManager manager =
+ new EnableManager(new String[] { "B", "C", "D", "E", "F", "G", "H", "I", "J", "K" });
+ manager.enableComponents(exec);
+
+ try
+ {
+ if (!_enabledLatch.await(10000, TimeUnit.MILLISECONDS))
+ {
+ System.out.println("Did not get A injected timely ... see logs.txt");
+ _logService.log(LogService.LOG_ERROR, "enableLatch TIMEOUT");
+ dumpComponents();
+ System.exit(1);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ manager.disableComponents(exec);
+ try
+ {
+ if (!_disabledLatch.await(10000, TimeUnit.MILLISECONDS))
+ {
+ System.out.println("Could not disable components timely ... see logs.txt");
+ _logService.log(LogService.LOG_ERROR, "disableLatch TIMEOUT");
+ dumpComponents();
+ System.exit(1);
+ }
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+
+ private void dumpComponents()
+ {
+ StringWriter sw = new StringWriter();
+ dumpState(sw, "A");
+ dumpState(sw, "B");
+ dumpState(sw, "C");
+ dumpState(sw, "D");
+ dumpState(sw, "E");
+ dumpState(sw, "F");
+ dumpState(sw, "G");
+ dumpState(sw, "H");
+ dumpState(sw, "I");
+ dumpState(sw, "J");
+ dumpState(sw, "K");
+ _logService.log(LogService.LOG_WARNING, sw.toString());
+ }
+
+ private void dumpState(StringWriter sw, String name)
+ {
+ org.apache.felix.scr.Component a = _scr.getComponents(name)[0];
+ sw.append(name).append("[").append(getState(a)).append("] ");
+ }
+
+ private CharSequence getState(org.apache.felix.scr.Component c)
+ {
+ switch (c.getState()) {
+ case org.apache.felix.scr.Component.STATE_ACTIVATING:
+ return "activating";
+ case org.apache.felix.scr.Component.STATE_ACTIVE:
+ return "active";
+ case org.apache.felix.scr.Component.STATE_DEACTIVATING:
+ return "deactivating";
+ case org.apache.felix.scr.Component.STATE_DISABLED:
+ return "disabled";
+ case org.apache.felix.scr.Component.STATE_DISABLING:
+ return "disabling";
+ case org.apache.felix.scr.Component.STATE_DISPOSED:
+ return "disposed";
+ case org.apache.felix.scr.Component.STATE_DISPOSING:
+ return "disposing";
+ case org.apache.felix.scr.Component.STATE_ENABLED:
+ return "enabled";
+ case org.apache.felix.scr.Component.STATE_ENABLING:
+ return "enabling";
+ case org.apache.felix.scr.Component.STATE_FACTORY:
+ return "factory";
+ case org.apache.felix.scr.Component.STATE_REGISTERED:
+ return "registered";
+ case org.apache.felix.scr.Component.STATE_UNSATISFIED:
+ return "unsatisfied";
+ default:
+ return "?";
+ }
+ }
+}
diff --git a/scr/src/test/resources/integration_test_FELIX_3680.xml b/scr/src/test/resources/integration_test_FELIX_3680.xml
new file mode 100644
index 0000000..f458148
--- /dev/null
+++ b/scr/src/test/resources/integration_test_FELIX_3680.xml
@@ -0,0 +1,155 @@
+<?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.1.0">
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='A' activate='start'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.A' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.A' />
+ </service>
+ <reference name='b'
+ interface='org.apache.felix.scr.integration.components.felix3680.B'
+ bind='bindB' />
+ <reference name='c'
+ interface='org.apache.felix.scr.integration.components.felix3680.C'
+ bind='bindC' />
+ <reference name='d'
+ interface='org.apache.felix.scr.integration.components.felix3680.D'
+ cardinality='0..n' bind='bindD' policy='dynamic' />
+ <reference name='e'
+ interface='org.apache.felix.scr.integration.components.felix3680.E'
+ cardinality='0..n' bind='bindE' policy='dynamic' />
+ <reference name='f'
+ interface='org.apache.felix.scr.integration.components.felix3680.F'
+ bind='bindF' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.0.0'
+ name='B' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.B' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.B' />
+ </service>
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.0.0'
+ name='C' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.C' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.C' />
+ </service>
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.0.0'
+ name='D' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.D' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.D' />
+ </service>
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.0.0'
+ name='E' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.E' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.E' />
+ </service>
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='F' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.F' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.F' />
+ </service>
+ <reference name='g'
+ interface='org.apache.felix.scr.integration.components.felix3680.G'
+ bind='bindG' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='G' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.G' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.G' />
+ </service>
+ <reference name='h'
+ interface='org.apache.felix.scr.integration.components.felix3680.H'
+ bind='bindH' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='H' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.H' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.H' />
+ </service>
+ <reference name='i'
+ interface='org.apache.felix.scr.integration.components.felix3680.I'
+ bind='bindI' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='I' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.I' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.I' />
+ </service>
+ <reference name='j'
+ interface='org.apache.felix.scr.integration.components.felix3680.J'
+ cardinality='1..n' bind='bindJ' policy='dynamic' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='J' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.J' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.J' />
+ </service>
+ <reference name='k'
+ interface='org.apache.felix.scr.integration.components.felix3680.K'
+ cardinality='1..n' bind='bindK' policy='dynamic' />
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.0.0'
+ name='K' enabled='false'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.K' />
+ <service>
+ <provide interface='org.apache.felix.scr.integration.components.felix3680.K' />
+ </service>
+ </scr:component>
+
+ <scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
+ name='org.apache.felix.scr.integration.components.felix3680.Main'
+ activate='start' deactivate='stop'>
+ <implementation
+ class='org.apache.felix.scr.integration.components.felix3680.Main' />
+ <reference name='a'
+ interface='org.apache.felix.scr.integration.components.felix3680.A'
+ cardinality='0..n' bind='bindA' unbind='unbindA' policy='dynamic' />
+ <reference name='logService' interface='org.osgi.service.log.LogService'
+ bind='bindLogService' />
+ <reference name='sCR' interface='org.apache.felix.scr.ScrService'
+ bind='bindSCR' />
+ </scr:component>
+</components>