openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r802590 - /incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java
Date Sun, 09 Aug 2009 20:43:12 GMT
Author: struberg
Date: Sun Aug  9 20:43:12 2009
New Revision: 802590

URL: http://svn.apache.org/viewvc?rev=802590&view=rev
Log:
OWB-122 cleanup test code 

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java?rev=802590&r1=802589&r2=802590&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/containertests/ComponentResolutionByTypeTest.java
Sun Aug  9 20:43:12 2009
@@ -13,14 +13,20 @@
  */
 package org.apache.webbeans.test.containertests;
 
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
 import javax.servlet.ServletContext;
 
+import junit.framework.Assert;
+
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.test.annotation.binding.AnnotationWithBindingMember;
 import org.apache.webbeans.test.annotation.binding.AnnotationWithNonBindingMember;
 import org.apache.webbeans.test.component.BindingComponent;
 import org.apache.webbeans.test.component.NonBindingComponent;
 import org.apache.webbeans.test.servlet.TestContext;
+import org.junit.Before;
 import org.junit.Test;
 
 public class ComponentResolutionByTypeTest extends TestContext
@@ -37,17 +43,18 @@
     public @AnnotationWithNonBindingMember(value = "C", arg1 = "arg11", arg2 = "arg21")
     NonBindingComponent s5 = null;
 
-    private static BeanManagerImpl cont = BeanManagerImpl.getManager();
+    private BeanManagerImpl cont;
     private static final String CLAZZ_NAME = ComponentResolutionByTypeTest.class.getName();
 
     public ComponentResolutionByTypeTest()
     {
         super(CLAZZ_NAME);
     }
-
+    
+    @Before
     public void init()
     {
-
+        cont = BeanManagerImpl.getManager();
     }
 
     public void endTests(ServletContext ctx)
@@ -55,121 +62,36 @@
         cont = null;
     }
 
-    public void startTests(ServletContext ctx)
-    {
-
-        try
-        {
-            testBindingTypeNonOk();
-            testBindingTypeOk();
-            testNonBindingTypeNonOk();
-            testNonBindingTypeOk1();
-            testNonBindingTypeOk2();
-
-        }
-        catch (Throwable e)
-        {
-
-        }
-    }
-
     @Test
-    public void startTests()
-    {
-
-        try
-        {
-            testBindingTypeNonOk();
-            testBindingTypeOk();
-            testNonBindingTypeNonOk();
-            testNonBindingTypeOk1();
-            testNonBindingTypeOk2();
-
-        }
-        catch (Throwable e)
-        {
-
-        }
-    }
-
     public void testBindingTypeOk() throws Throwable
     {
-        try
-        {
-            cont.resolveByType(BindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s1").getAnnotations());
-            pass("testBindingTypeOk");
-
-        }
-        catch (Throwable e)
-        {
-            fail("testBindingTypeOk");
-
-        }
-
+        cont.resolveByType(BindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s1").getAnnotations());
     }
 
+    @Test
     public void testBindingTypeNonOk() throws Throwable
     {
-        try
-        {
-            cont.resolveByType(BindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s2").getAnnotations());
-            fail("testBindingTypeNonOk");
-
-        }
-        catch (Throwable e)
-        {
-            pass("testBindingTypeNonOk");
-
-        }
-
+        cont.resolveByType(BindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s2").getAnnotations());
     }
 
+    @Test
     public void testNonBindingTypeOk1() throws Throwable
     {
-        try
-        {
-            cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s3").getAnnotations());
-            pass("testNonBindingTypeOk1");
-
-        }
-        catch (Throwable e)
-        {
-            fail("testNonBindingTypeOk1");
-
-        }
-
+        cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s3").getAnnotations());
     }
 
+    @Test
     public void testNonBindingTypeOk2() throws Throwable
     {
-        try
-        {
-            cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s4").getAnnotations());
-            pass("testNonBindingTypeOk2");
-
-        }
-        catch (Throwable e)
-        {
-            fail("testNonBindingTypeOk2");
-
-        }
-
+        Set<Bean<?>> beans = cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s4").getAnnotations());
+        Assert.assertNotNull(beans);
+        Assert.assertTrue(beans.isEmpty());
     }
 
+    @Test
     public void testNonBindingTypeNonOk() throws Throwable
     {
-        try
-        {
-            cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s5").getAnnotations());
-            fail("testNonBindingTypeNonOk");
-
-        }
-        catch (Throwable e)
-        {
-            pass("testNonBindingTypeNonOk");
-
-        }
-
+        cont.resolveByType(NonBindingComponent.class, ComponentResolutionByTypeTest.class.getDeclaredField("s5").getAnnotations());
     }
 
 }



Mime
View raw message