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/10/02 23:51:24 UTC

svn commit: r1393203 - in /felix/trunk/scr/src/test: java/org/apache/felix/scr/integration/ java/org/apache/felix/scr/integration/components/felix3680/ resources/

Author: pderop
Date: Tue Oct  2 21:51:23 2012
New Revision: 1393203

URL: http://svn.apache.org/viewvc?rev=1393203&view=rev
Log:
Added integration test for the FELIX-3680 issue.

Added:
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java
    felix/trunk/scr/src/test/resources/integration_test_FELIX_3680.xml
Modified:
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1393203&r1=1393202&r2=1393203&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Tue Oct  2 21:51:23 2012
@@ -120,7 +120,7 @@ public abstract class ComponentTestBase
 
     @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 @@ public abstract class ComponentTestBase
              ),
              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 @@ public abstract class ComponentTestBase
                 .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());
 

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java Tue Oct  2 21:51:23 2012
@@ -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);
+        }        
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/A.java Tue Oct  2 21:51:23 2012
@@ -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()
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/B.java Tue Oct  2 21:51:23 2012
@@ -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
+{
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/C.java Tue Oct  2 21:51:23 2012
@@ -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
+{
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/D.java Tue Oct  2 21:51:23 2012
@@ -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
+{
+
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/E.java Tue Oct  2 21:51:23 2012
@@ -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
+{
+
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/F.java Tue Oct  2 21:51:23 2012
@@ -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)
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/G.java Tue Oct  2 21:51:23 2012
@@ -0,0 +1,8 @@
+package org.apache.felix.scr.integration.components.felix3680;
+
+public class G
+{
+    void bindH(H h)
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/H.java Tue Oct  2 21:51:23 2012
@@ -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)
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/I.java Tue Oct  2 21:51:23 2012
@@ -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)
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/J.java Tue Oct  2 21:51:23 2012
@@ -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)
+    {
+    }
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/K.java Tue Oct  2 21:51:23 2012
@@ -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
+{
+}

Added: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java (added)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680/Main.java Tue Oct  2 21:51:23 2012
@@ -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 "?";
+        }
+    }
+}

Added: felix/trunk/scr/src/test/resources/integration_test_FELIX_3680.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_FELIX_3680.xml?rev=1393203&view=auto
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_FELIX_3680.xml (added)
+++ felix/trunk/scr/src/test/resources/integration_test_FELIX_3680.xml Tue Oct  2 21:51:23 2012
@@ -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>