openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1434475 - /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
Date Wed, 16 Jan 2013 23:15:28 GMT
Author: struberg
Date: Wed Jan 16 23:15:28 2013
New Revision: 1434475

URL: http://svn.apache.org/viewvc?rev=1434475&view=rev
Log:
OWB-344 fix another broken test ...

Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java?rev=1434475&r1=1434474&r2=1434475&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
Wed Jan 16 23:15:28 2013
@@ -18,56 +18,32 @@
  */
 package org.apache.webbeans.test.unittests.intercept;
 
-import java.util.List;
-
-import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.context.RequestScoped;
+import java.util.ArrayList;
+import java.util.Collection;
 
 import junit.framework.Assert;
-
-import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.component.ManagedBean;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.intercept.InterceptorData;
-import org.apache.webbeans.test.TestContext;
+import org.apache.webbeans.annotation.AnyLiteral;
+import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.test.component.CheckWithCheckPayment;
 import org.apache.webbeans.test.component.PreDestroyComponent;
-import org.junit.Before;
 import org.junit.Test;
 
-public class PreDestroyComponentTest extends TestContext
+public class PreDestroyComponentTest extends AbstractUnitTest
 {
-    BeanManager container = null;
-
-    public PreDestroyComponentTest()
-    {
-        super(PreDestroyComponentTest.class.getSimpleName());
-    }
-
-    @Before
-    public void init()
-    {
-        this.container = WebBeansContext.getInstance().getBeanManagerImpl();
-        super.init();
-    }
 
     @SuppressWarnings("unchecked")
     @Test
     public void testTypedComponent() throws Throwable
     {
-        clear();
-
-        defineManagedBean(CheckWithCheckPayment.class);
-        defineManagedBean(PreDestroyComponent.class);
-        List<AbstractOwbBean<?>> comps = getComponents();
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(CheckWithCheckPayment.class);
+        beanClasses.add(PreDestroyComponent.class);
 
-        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
-        contextFactory.initRequestContext(null);
+        startContainer(beanClasses, null);
 
-        Assert.assertEquals(2, comps.size());
-
-        CheckWithCheckPayment object = (CheckWithCheckPayment)getManager().getInstance(comps.get(0));
-        PreDestroyComponent object2 = (PreDestroyComponent)getManager().getInstance(comps.get(1));
+        CheckWithCheckPayment object = getInstance(CheckWithCheckPayment.class, new AnyLiteral());
+        PreDestroyComponent object2 = getInstance(PreDestroyComponent.class);
         
         object2.getP();
 
@@ -78,17 +54,13 @@ public class PreDestroyComponentTest ext
         CheckWithCheckPayment payment = (CheckWithCheckPayment) pcc.getP();
         payment.setValue(true);
 
-        ManagedBean<PreDestroyComponent> s = (ManagedBean<PreDestroyComponent>)
comps.get(1);
-        List<InterceptorData> stack = s.getInterceptorStack();
-
-        Assert.assertEquals(2, stack.size());
 
         Assert.assertNotNull(pcc.getP());
         Assert.assertSame(object.getValue(), payment.getValue());
 
         Assert.assertFalse(PreDestroyComponent.isDestroyed());
 
-        contextFactory.destroyRequestContext(null);
+        getLifecycle().getContextService().endContext(RequestScoped.class, null);
 
         Assert.assertTrue(PreDestroyComponent.isDestroyed());
     }



Mime
View raw message