openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1477491 - /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java
Date Tue, 30 Apr 2013 07:31:52 GMT
Author: rmannibucau
Date: Tue Apr 30 07:31:52 2013
New Revision: 1477491

URL: http://svn.apache.org/r1477491
Log:
adding a test for not final produced beans

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java
      - copied, changed from r1477480, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java
(from r1477480, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java&r1=1477480&r2=1477491&rev=1477491&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/NamedProducerTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/StringProducerTest.java
Tue Apr 30 07:31:52 2013
@@ -18,44 +18,39 @@
  */
 package org.apache.webbeans.newtests.producer;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
-public class NamedProducerTest extends AbstractUnitTest
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.Bean;
+
+public class StringProducerTest extends AbstractUnitTest
 {
 
-    @Ignore
     @Test
     public void testNamedProducer()
     {
-        Collection<String> beanXmls = new ArrayList<String>();
-        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        startContainer(StringProducer.class);
 
-        beanClasses.add(ProducerBean.class);
-        beanClasses.add(ConsumerBean.class);
+        final Bean<?> bean = getBeanManager().getBeans(String.class).iterator().next();
+        final CreationalContext<?> context = getBeanManager().createCreationalContext(bean);
+        final String produced = String.class.cast(getBeanManager().getReference(bean, String.class,
context));
         
-        startContainer(beanClasses, beanXmls);        
-
-        Bean<?> consumerBean = getBeanManager().getBeans(ConsumerBean.class).iterator().next();
-        CreationalContext<?> context = getBeanManager().createCreationalContext(consumerBean);
-        ConsumerBean consumer = (ConsumerBean) getBeanManager().getReference(consumerBean,
ConsumerBean.class, context);
-        
-        Assert.assertEquals("name1", consumer.getName1());
-        Assert.assertEquals("name2", consumer.getName2());
-        Assert.assertEquals(true, consumer.isName3());
-        Assert.assertEquals("name4", consumer.getName4());
-        Assert.assertEquals("name5", consumer.getName5());
-        Assert.assertEquals(true, consumer.isName6());
+        Assert.assertEquals("string", produced);
         
         shutDownContainer();       
         
     }
+
+    public static class StringProducer
+    {
+        @Produces
+        public String produces()
+        {
+            return "string";
+        }
+    }
+
 }



Mime
View raw message