openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1481408 - /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java
Date Sat, 11 May 2013 20:48:54 GMT
Author: dblevins
Date: Sat May 11 20:48:53 2013
New Revision: 1481408

URL: http://svn.apache.org/r1481408
Log:
OWB-858: AnnotatedTypeImpl not thread safe
Improved test case to use the BeanManager since there was some doubt this was a real issue.

Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java?rev=1481408&r1=1481407&r2=1481408&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/portable/AnnotatedTypeImplTest.java
Sat May 11 20:48:53 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.portable;
 
+import java.util.ArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -26,14 +27,16 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
 
-import org.apache.webbeans.config.WebBeansContext;
-import org.junit.Ignore;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 public class AnnotatedTypeImplTest
+    extends AbstractUnitTest
 {
     final int threads = 1000;
 
@@ -45,13 +48,48 @@ public class AnnotatedTypeImplTest
 
     final AtomicInteger exceptions = new AtomicInteger();
 
+    @Before
+    public void setup()
+    {
+        startContainer(new ArrayList<Class<?>>());
+    }
+
+    @Test
+    public void testCreateInjectionTarget()
+        throws Exception
+    {
+
+        final BeanManager beanManager = getBeanManager();
+        final AnnotatedType<Colors> annotatedType = beanManager.createAnnotatedType(Colors.class);
+
+        for (int i = 0; i < threads; i++)
+        {
+            new Runner(startingLine, startingPistol, exceptions, finishLine, annotatedType)
+            {
+                @Override
+                public void doit()
+                {
+                    beanManager.createInjectionTarget(annotatedType);
+                }
+            }.start();
+        }
+
+        assertTrue("Not all threads reported ready.", startingLine.await(30, TimeUnit.SECONDS));
+
+        startingPistol.countDown();
+
+        assertTrue("Not all threads finished.", finishLine.await(30, TimeUnit.SECONDS));
+
+        assertEquals(0, exceptions.get());
+    }
+
     @Test
     public void testGetFields()
         throws Exception
     {
 
-        final AnnotatedType<Colors> annotatedType =
-            new AnnotatedTypeImpl<Colors>(new WebBeansContext(), Colors.class, null);
+        final BeanManager beanManager = getBeanManager();
+        final AnnotatedType<Colors> annotatedType = beanManager.createAnnotatedType(Colors.class);
 
         for (int i = 0; i < threads; i++)
         {
@@ -62,6 +100,7 @@ public class AnnotatedTypeImplTest
                 {
                     for (AnnotatedField<? super Colors> field : annotatedType.getFields())
                     {
+
                     }
                 }
             }.start();
@@ -81,8 +120,8 @@ public class AnnotatedTypeImplTest
         throws Exception
     {
 
-        final AnnotatedType<Colors> annotatedType =
-            new AnnotatedTypeImpl<Colors>(new WebBeansContext(), Colors.class, null);
+        final BeanManager beanManager = getBeanManager();
+        final AnnotatedType<Colors> annotatedType = beanManager.createAnnotatedType(Colors.class);
 
         for (int i = 0; i < threads; i++)
         {
@@ -112,8 +151,8 @@ public class AnnotatedTypeImplTest
         throws Exception
     {
 
-        final AnnotatedType<Colors> annotatedType =
-            new AnnotatedTypeImpl<Colors>(new WebBeansContext(), Colors.class, null);
+        final BeanManager beanManager = getBeanManager();
+        final AnnotatedType<Colors> annotatedType = beanManager.createAnnotatedType(Colors.class);
 
         for (int i = 0; i < threads; i++)
         {



Mime
View raw message