openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r881965 - /incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
Date Wed, 18 Nov 2009 22:20:05 GMT
Author: struberg
Date: Wed Nov 18 22:20:05 2009
New Revision: 881965

URL: http://svn.apache.org/viewvc?rev=881965&view=rev
Log:
OWB-148 move the Extension test to the new testing framework

This way we can test if the 'real' events got fired!

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java?rev=881965&r1=881964&r2=881965&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
Wed Nov 18 22:20:05 2009
@@ -19,62 +19,64 @@
 package org.apache.webbeans.test.unittests.portable.events;
 
 import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
 
 import javax.enterprise.inject.spi.Bean;
 
 import junit.framework.Assert;
 
 import org.apache.webbeans.annotation.DefaultLiteral;
-import org.apache.webbeans.common.TestContext;
+import org.apache.webbeans.common.AbstractUnitTest;
 import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
 import org.apache.webbeans.test.component.library.BookShop;
 import org.apache.webbeans.test.component.portable.events.MyExtension;
+import org.apache.webbeans.test.component.producer.primitive.PrimitiveProducer;
 import org.apache.webbeans.test.mock.MockServletContext;
-import org.junit.Before;
 import org.junit.Test;
 
-public class ExtensionTest extends TestContext
+/**
+ * This test checks if an extension gets loaded correctly and
+ * if all specified events get fired.
+ */
+public class ExtensionTest extends AbstractUnitTest
 {
     public ExtensionTest()
     {
-        super(ExtensionTest.class.getName());
     }
 
-    @Before
-    public void init()
-    {
-        super.init();
-    }
-    
     @Test
     @SuppressWarnings("unchecked")
     public void testExtensionServices()
     {
         MyExtension.reset();
-        
-        ExtensionLoader.getInstance().loadExtensionServices();
-        
+
+        Collection<Class<?>> classes = new ArrayList<Class<?>>();
+        classes.add(BookShop.class);
+        classes.add(PrimitiveProducer.class);
+        startContainer(classes);
+
         MockServletContext servletContext = new MockServletContext();
         ContextFactory.initApplicationContext(servletContext);
 
-        Bean<MyExtension> extension = (Bean<MyExtension>)getManager().resolveByType(MyExtension.class,
new DefaultLiteral()).iterator().next();
+        Bean<MyExtension> extension = (Bean<MyExtension>) getBeanManager().getBeans(MyExtension.class,
new DefaultLiteral()).iterator().next();
         
-        MyExtension ext = getManager().getInstance(extension);
+        MyExtension ext = (MyExtension) getBeanManager().getReference(extension, MyExtension.class,
getBeanManager().createCreationalContext(extension));
         
         System.out.println(ext.toString());
         
-        defineManagedBean(BookShop.class);
-        
         Assert.assertNotNull(MyExtension.processAnnotatedTypeEvent);
-
-        //X TODO should work after fixing the test lifecycle Assert.assertNotNull(MyExtension.processBean);
-
-        //X TODO should work after fixing the test lifecycle Assert.assertNotNull(MyExtension.processObserverMethod);
+        Assert.assertNotNull(MyExtension.processBean);
+        Assert.assertNotNull(MyExtension.processObserverMethod);
+        Assert.assertNotNull(MyExtension.lastAfterBeanDiscovery);
+        Assert.assertNotNull(MyExtension.lastBeforeBeanDiscovery);
+        Assert.assertNotNull(MyExtension.afterDeploymentValidation);
+        Assert.assertNotNull(MyExtension.processInjectionTarget);
+        Assert.assertNotNull(MyExtension.processProducer);
         
         //Fire shut down
-        getManager().fireEvent(new BeforeShutdownImpl(), new Annotation[0]);
+        getBeanManager().fireEvent(new BeforeShutdownImpl(), new Annotation[0]);
 
         ContextFactory.destroyApplicationContext(servletContext);
         



Mime
View raw message