openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r916274 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/inject/instance/ main/java/org/apache/webbeans/util/ test/java/org/apache/w...
Date Thu, 25 Feb 2010 13:00:30 GMT
Author: struberg
Date: Thu Feb 25 13:00:29 2010
New Revision: 916274

URL: http://svn.apache.org/viewvc?rev=916274&view=rev
Log:
OWB-304 add test for broken behaviour

+ a few cleanup tasks

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/beans/InformationConsumerBean.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/typeliteral/TypeLiteralTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/GetterStringInjectorTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
Thu Feb 25 13:00:29 2010
@@ -25,6 +25,16 @@
 public class NamedLiteral extends AnnotationLiteral<Named> implements Named
 {
     private String value;
+    
+    public NamedLiteral()
+    {
+        
+    }
+
+    public NamedLiteral(String value)
+    {
+        this.value = value;
+    }
 
     @Override
     public String value()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorUtil.java
Thu Feb 25 13:00:29 2010
@@ -26,7 +26,6 @@
 import javax.enterprise.inject.spi.Decorator;
 
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
-import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Thu Feb 25 13:00:29 2010
@@ -38,6 +38,8 @@
  */
 class InstanceImpl<T> implements Instance<T>, Serializable
 {
+    private static final long serialVersionUID = -8401944412490389024L;
+
     /** Injected class type */
     private Type injectionClazz;
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
Thu Feb 25 13:00:29 2010
@@ -67,7 +67,6 @@
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.container.InjectionResolver;
-import org.apache.webbeans.decorator.DecoratorUtil;
 import org.apache.webbeans.decorator.DecoratorsManager;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.event.NotificationManager;
@@ -104,11 +103,9 @@
                     {
                         throw new WebBeansConfigurationException("There are more than one
constructor with @Inject annotation in annotation type : " + type);
                     }
-                    else
-                    {
-                        found = true;
-                        result = annConst;
-                    }                    
+                    
+                    found = true;
+                    result = annConst;
                 }
                 else
                 {
@@ -254,10 +251,7 @@
                     throw new UnsatisfiedResolutionException("Producer method component of
the disposal method : " + declaredMethod.getName() + " in class : " + annotatedMethod.getDeclaringType().getJavaClass()
+ "is not found");
                 }
 
-                else
-                {
-                    pr = (ProducerMethodBean<?>) foundBean;
-                }
+                pr = (ProducerMethodBean<?>) foundBean;
 
                 if (previous == null)
                 {
@@ -623,9 +617,8 @@
                             + ". Multiple disposes annotation.");
                 }
                 else
-                {
-                    found = true;
-                }
+
+                found = true;
             }
         }
         
@@ -728,12 +721,10 @@
                 {
                     throw new WebBeansConfigurationException("Maanged bean class : " + clazz.getName()
+ " can not define non-static, non-private final methods. Because it is annotated with at
least one @InterceptorBinding");
                 }
-                else
+
+                if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
                 {
-                    if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
-                    {
-                        throw new WebBeansConfigurationException("Method : " + method.getName()
+ "in managed bean class : " + clazz.getName() + " can not be defined as non-static, non-private
and final . Because it is annotated with at least one @InterceptorBinding");
-                    }
+                    throw new WebBeansConfigurationException("Method : " + method.getName()
+ "in managed bean class : " + clazz.getName() + " can not be defined as non-static, non-private
and final . Because it is annotated with at least one @InterceptorBinding");
                 }
             }
             

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/AbstractUnitTest.java
Thu Feb 25 13:00:29 2010
@@ -13,18 +13,21 @@
  */
 package org.apache.webbeans.newtests;
 
+import java.lang.annotation.Annotation;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Extension;
 
 import org.apache.webbeans.lifecycle.test.OpenWebBeansTestLifeCycle;
 import org.apache.webbeans.lifecycle.test.OpenWebBeansTestMetaDataDiscoveryService;
 import org.apache.webbeans.portable.events.ExtensionLoader;
-
+import org.junit.Assert;
 
 
 public abstract class AbstractUnitTest
@@ -95,6 +98,18 @@
         return this.testLifecycle.getBeanManager();
     }
     
+    @SuppressWarnings("unchecked")
+    protected <T> T getInstance(Class<T> type, Annotation... qualifiers)
+    {
+        Set<Bean<?>> beans = getBeanManager().getBeans(type, qualifiers);
+        Assert.assertNotNull(beans);
+        Assert.assertTrue("resolving bean with type" + type + " is ambiguous!", beans.size()
== 1);
+        
+        Bean<T> bean = (Bean<T>) beans.iterator().next();
+        
+        return (T) getBeanManager().getReference(bean, type, getBeanManager().createCreationalContext(bean));
+    }
+    
     protected URL getXMLUrl(String packageName, String fileName)
     {
         StringBuilder prefix = new StringBuilder(packageName.replace('.', '/'));

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/typeliteral/TypeLiteralTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/typeliteral/TypeLiteralTest.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/typeliteral/TypeLiteralTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/typeliteral/TypeLiteralTest.java
Thu Feb 25 13:00:29 2010
@@ -19,22 +19,16 @@
 package org.apache.webbeans.newtests.injection.typeliteral;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Set;
 
-import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.util.TypeLiteral;
 
-import junit.framework.Assert;
 
 import org.apache.webbeans.newtests.AbstractUnitTest;
-import org.apache.webbeans.newtests.injection.injectionpoint.beans.InjectionPointMetaDataOwner;
-import org.apache.webbeans.newtests.injection.injectionpoint.beans.LoggerInjectedBean;
 import org.junit.Test;
 
 public class TypeLiteralTest extends AbstractUnitTest

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/GetterStringInjectorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/GetterStringInjectorTest.java?rev=916274&r1=916273&r2=916274&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/GetterStringInjectorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/GetterStringInjectorTest.java
Thu Feb 25 13:00:29 2010
@@ -26,9 +26,11 @@
 
 import junit.framework.Assert;
 
+import org.apache.webbeans.annotation.NamedLiteral;
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.profields.beans.GetterStringFieldInjector;
 import org.apache.webbeans.newtests.profields.beans.GetterStringProducerBean;
+import org.apache.webbeans.newtests.profields.beans.InformationConsumerBean;
 import org.junit.Test;
 
 public class GetterStringInjectorTest extends AbstractUnitTest
@@ -42,6 +44,7 @@
         Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
         beanClasses.add(GetterStringProducerBean.class);
         beanClasses.add(GetterStringFieldInjector.class);
+        beanClasses.add(InformationConsumerBean.class);
         
         startContainer(beanClasses, beanXmls);   
         
@@ -50,6 +53,8 @@
         
         Assert.assertEquals("Sucess from getProducts",injector.getTestNamed3());
         
+        InformationConsumerBean icb = getInstance(InformationConsumerBean.class, new NamedLiteral("ProMethodNamed1"));
+        
         shutDownContainer();
     }
     

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/beans/InformationConsumerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/beans/InformationConsumerBean.java?rev=916274&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/beans/InformationConsumerBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/profields/beans/InformationConsumerBean.java
Thu Feb 25 13:00:29 2010
@@ -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.profields.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * This simply tests if actually injecting the String values
+ * from our fancy producer methods really works. 
+ */
+@ApplicationScoped
+public class InformationConsumerBean {
+
+    private  @Inject @Named("ProMethodNamed1") String proMethodString;
+    
+    public String getProMethodString()
+    {
+        return proMethodString;
+    }
+}



Mime
View raw message