openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1308092 - in /openwebbeans/trunk/webbeans-impl/src/test: java/org/apache/webbeans/newtests/concepts/alternatives/common/ java/org/apache/webbeans/newtests/concepts/alternatives/tests/ resources/org/apache/webbeans/newtests/concepts/alterna...
Date Sun, 01 Apr 2012 12:58:42 GMT
Author: struberg
Date: Sun Apr  1 12:58:41 2012
New Revision: 1308092

URL: http://svn.apache.org/viewvc?rev=1308092&view=rev
Log:
OWB-658 further improve our Alternative tests

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java
  (contents, props changed)
      - copied, changed from r1308084, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer2.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
  (contents, props changed)
      - copied, changed from r1308084, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
  (contents, props changed)
      - copied, changed from r1308071, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative1Test.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
  (props changed)
      - copied unchanged from r1303760, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest5.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer2.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative1Test.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative2Test.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest5.xml
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/Pencil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerFieldTest.java

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java
(from r1308084, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer2.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer2.java&r1=1308084&r2=1308092&rev=1308092&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer2.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java
Sun Apr  1 12:58:41 2012
@@ -26,7 +26,7 @@ import javax.enterprise.inject.Produces;
  * AND also an @Alternative on the producer method
  */
 @Alternative
-public class AlternativeBeanProducer2
+public class AlternativeOnClassAndProducerMethodBean
 {
 
     @Produces
@@ -34,7 +34,7 @@ public class AlternativeBeanProducer2
     @QualifierProducerBased
     public IProducedBean generateBean2()
     {
-        return new ProducedBean("alternative2", this);
+        return new ProducedBean("AlternativeOnClassAndProducerMethodBean", this);
     }
 
 }

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassAndProducerMethodBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
(from r1308084, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer1.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer1.java&r1=1308084&r2=1308092&rev=1308092&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBeanProducer1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
Sun Apr  1 12:58:41 2012
@@ -26,13 +26,13 @@ import javax.enterprise.inject.Produces;
  * This one has the @Alternative on the class and NOT on the producer method
  */
 @Alternative
-public class AlternativeBeanProducer1
+public class AlternativeOnClassOnlyBean
 {
 
     @Produces
     @QualifierProducerBased
     public IProducedBean generateBean1()
     {
-        return new ProducedBean("alternative1", this);
+        return new ProducedBean("AlternativeOnClassOnlyBean", this);
     }
 }

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnClassOnlyBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java?rev=1308092&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeOnProducerMethodOnlyBean.java
Sun Apr  1 12:58:41 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.concepts.alternatives.common;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Produces;
+
+/**
+ * This one has the @Alternative ONLY on the producer method
+ */
+public class AlternativeOnProducerMethodOnlyBean
+{
+
+    @Produces
+    @Alternative
+    @QualifierProducerBased
+    public IProducedBean generateBean2()
+    {
+        return new ProducedBean("AlternativeOnProducerMethodOnlyBean", this);
+    }
+
+}

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/Pencil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/Pencil.java?rev=1308092&r1=1308091&r2=1308092&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/Pencil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/Pencil.java
Sun Apr  1 12:58:41 2012
@@ -18,7 +18,13 @@
  */
 package org.apache.webbeans.newtests.concepts.alternatives.common;
 
+
 public class Pencil
 {
+    private int nr = 42;
 
+    public int getNr()
+    {
+        return nr;
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerFieldTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerFieldTest.java?rev=1308092&r1=1308091&r2=1308092&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerFieldTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerFieldTest.java
Sun Apr  1 12:58:41 2012
@@ -45,19 +45,38 @@ public class AlternativeOnProducerFieldT
     @Test
     public void testProducerFieldAlternativeNotEnabled()
     {
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(PencilProducerBean.class);
+        beanClasses.add(Pencil.class);
+        
+        startContainer(beanClasses, null);
+
+        Set<Bean<?>> beans = getBeanManager().getBeans(Pencil.class, new AnnotationLiteral<Pen>(){});
+        Assert.assertEquals(0, beans.size());
+
+        shutDownContainer();
+    }
+
+    @Test
+    public void testProducerFieldAlternativeEnabled()
+    {
         Collection<String> beanXmls = new ArrayList<String>();
         beanXmls.add(getXmlPath(PACKAGE_NAME, "AlternativeOnProducerFieldTest"));
-        
+
         Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
         beanClasses.add(PencilProducerBean.class);
         beanClasses.add(Pencil.class);
-        
-        startContainer(beanClasses, beanXmls);        
-        
+
+        startContainer(beanClasses, beanXmls);
+
         Set<Bean<?>> beans = getBeanManager().getBeans(Pencil.class, new AnnotationLiteral<Pen>(){});
         Assert.assertEquals(1, beans.size());
-        
+        Pencil pencil = getInstance(Pencil.class, new AnnotationLiteral<Pen>(){});
+        Assert.assertNotNull(pencil);
+        Assert.assertEquals(42, pencil.getNr());
+
         shutDownContainer();
     }
-    
+
 }

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
(from r1308071, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative1Test.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative1Test.java&r1=1308071&r2=1308092&rev=1308092&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/Alternative1Test.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
Sun Apr  1 12:58:41 2012
@@ -26,23 +26,24 @@ import javax.enterprise.util.AnnotationL
 import junit.framework.Assert;
 
 import org.apache.webbeans.newtests.AbstractUnitTest;
-import org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeBeanProducer1;
+import org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassAndProducerMethodBean;
+import org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassOnlyBean;
 import org.apache.webbeans.newtests.concepts.alternatives.common.DefaultBeanProducer;
 import org.apache.webbeans.newtests.concepts.alternatives.common.IProducedBean;
 import org.apache.webbeans.newtests.concepts.alternatives.common.QualifierProducerBased;
 import org.junit.Test;
 
-public class Alternative1Test  extends AbstractUnitTest {
+public class AlternativeTest extends AbstractUnitTest {
 
     @Test
     @SuppressWarnings("unchecked")
-    public void testDisposerMethodInAlternativeBean()
+    public void testAlternativeOnClassOnlyBean()
     {
         Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
         beanClasses.add(DefaultBeanProducer.class);
 
         // available but not enabled in beans.xml
-        beanClasses.add(AlternativeBeanProducer1.class);
+        beanClasses.add(AlternativeOnClassOnlyBean.class);
         
         startContainer(beanClasses, null);
 
@@ -58,4 +59,31 @@ public class Alternative1Test  extends A
         shutDownContainer();
         
     }
+
+    @Test
+    public void testAlternativeOnClassAndProducerMethodBean()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(DefaultBeanProducer.class);
+
+        // available but not enabled in beans.xml
+        beanClasses.add(AlternativeOnClassAndProducerMethodBean.class);
+
+        startContainer(beanClasses, beanXmls);
+
+        Annotation[] anns = new Annotation[1];
+        anns[0] = new AnnotationLiteral<QualifierProducerBased>()
+        {
+        };
+
+        IProducedBean producedBean = getInstance(IProducedBean.class, anns);
+        Assert.assertNotNull(producedBean);
+        Assert.assertEquals("default", producedBean.getProducerType());
+
+        shutDownContainer();
+    }
+
+
 }

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnClassAndProducerMethod.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml?rev=1308092&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeOnProducerMethodOnly.xml
Sun Apr  1 12:58:41 2012
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans>
+    <alternatives>
+        <class>org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeBeanProducer4</class>
+    </alternatives>
+</beans>



Mime
View raw message