openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r823919 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/inject/impl/ main/java/org/apache/webbeans/util/ test/java/org/ap...
Date Sat, 10 Oct 2009 18:43:10 GMT
Author: gerdogdu
Date: Sat Oct 10 18:43:09 2009
New Revision: 823919

URL: http://svn.apache.org/viewvc?rev=823919&view=rev
Log:
Adding @Named qualifier for injection points. Adding tests.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
  (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.annotation;
+
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.inject.Named;
+
+/**
+ * Named literal.
+ * 
+ * @version $Rev$ $Date$
+ *
+ */
+public class NamedLiteral extends AnnotationLiteral<Named> implements Named
+{
+    private String value;
+
+    @Override
+    public String value()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NamedLiteral.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=823919&r1=823918&r2=823919&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Sat Oct 10 18:43:09 2009
@@ -15,6 +15,8 @@
 
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=823919&r1=823918&r2=823919&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Sat Oct 10 18:43:09 2009
@@ -34,6 +34,7 @@
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 
 /**
  * Injection point resolver class. 
@@ -105,9 +106,10 @@
      * @throws If bean is not avialable in the current deployment for given injection
      */
     public void checkInjectionPoints(InjectionPoint injectionPoint)
-    {
-        Type type = injectionPoint.getType();
+    {        
+        WebBeansUtil.checkInjectionPointNamedQualifier(injectionPoint);
         
+        Type type = injectionPoint.getType();        
         Class<?> clazz = null;
         
         if (type instanceof ParameterizedType)
@@ -145,7 +147,7 @@
         
     }
     
-
+        
     /**
      * Returns bean for injection point.
      * 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=823919&r1=823918&r2=823919&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
Sat Oct 10 18:43:09 2009
@@ -30,7 +30,9 @@
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
 
+import org.apache.webbeans.annotation.NamedLiteral;
 import org.apache.webbeans.inject.xml.XMLInjectionModelType;
 import org.apache.webbeans.inject.xml.XMLInjectionPointModel;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
@@ -111,14 +113,48 @@
         return false;
     }
 
+    /**
+     * Gets injected point instance.
+     * @param owner owner of the injection point
+     * @param annots annotations of the injection point
+     * @param type type of the injection point
+     * @param member member of the injection point
+     * @param annotated annotated instance of injection point
+     * @return injection point instance
+     */
     private static InjectionPoint getGenericInjectionPoint(Bean<?> owner, Annotation[]
annots, Type type, Member member,Annotated annotated)
     {
         InjectionPointImpl injectionPoint = null;
 
-        Annotation[] bindingAnnots = AnnotationUtil.getQualifierAnnotations(annots);
+        Annotation[] qualifierAnnots = AnnotationUtil.getQualifierAnnotations(annots);
+        
+        //@Named update for injection fields!
+        if(member instanceof Field)
+        {
+            for(int i=0;i<qualifierAnnots.length;i++)
+            {
+                Annotation qualifier = qualifierAnnots[i];
+                if(qualifier.annotationType().equals(Named.class))
+                {
+                    Named named = (Named)qualifier;
+                    String value = named.value();
+                    
+                    if(value == null || value.equals(""))
+                    {
+                        NamedLiteral namedLiteral = new NamedLiteral();
+                        namedLiteral.setValue(member.getName());
+                        qualifierAnnots[i] = namedLiteral;
+                    }
+                    
+                    break;
+                }
+            }            
+        }    
+        
+        
         injectionPoint = new InjectionPointImpl(owner, type, member, annotated);
 
-        addAnnotation(injectionPoint, bindingAnnots, true);
+        addAnnotation(injectionPoint, qualifierAnnots, true);
 
         return injectionPoint;
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=823919&r1=823918&r2=823919&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sat Oct 10 18:43:09 2009
@@ -2028,4 +2028,34 @@
         
         return false;
     }
+    
+    public static void checkInjectionPointNamedQualifier(InjectionPoint injectionPoint)
+    {
+        Set<Annotation> qualifierset = injectionPoint.getQualifiers();
+        Named namedQualifier = null;
+        for(Annotation qualifier : qualifierset)
+        {
+            if(qualifier.annotationType().equals(Named.class))
+            {
+                namedQualifier = (Named)qualifier;
+                break;
+            }
+        }
+        
+        if(namedQualifier != null)
+        {
+            String value = namedQualifier.value();
+            
+            if(value == null || value.equals(""))
+            {
+                Member member = injectionPoint.getMember();
+                if(!(member instanceof Field))
+                {
+                    throw new WebBeansConfigurationException("Injection point type : " +
injectionPoint + " can not define @Named qualifier without value!");
+                }
+            }
+        }        
+        
+    }
+    
 }
\ No newline at end of file

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,25 @@
+/*
+ * 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.test.component.inject.named;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.webbeans.test.component.IPayment;
+
+public class NamedFieldWithNamedValue
+{
+    private @Inject @Named("payment") IPayment paymentProcessor;
+    
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithNamedValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,25 @@
+/*
+ * 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.test.component.inject.named;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.webbeans.test.component.IPayment;
+
+public class NamedFieldWithoutNamedValue
+{
+    private @Inject @Named IPayment paymentProcessor;
+    
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedFieldWithoutNamedValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,28 @@
+/*
+ * 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.test.component.inject.named;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.webbeans.test.component.IPayment;
+
+public class NamedOtherWithNamedValue
+{    
+    @Inject
+    public NamedOtherWithNamedValue(@Named("value") IPayment payment)
+    {
+        
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithNamedValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,28 @@
+/*
+ * 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.test.component.inject.named;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.webbeans.test.component.IPayment;
+
+public class NamedOtherWithoutNamedValue
+{    
+    @Inject
+    public NamedOtherWithoutNamedValue(@Named IPayment payment)
+    {
+        
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/inject/named/NamedOtherWithoutNamedValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java?rev=823919&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
Sat Oct 10 18:43:09 2009
@@ -0,0 +1,137 @@
+/*
+ * 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.test.unittests.inject.named;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
+
+import org.apache.webbeans.container.InjectionResolver;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.inject.impl.InjectionPointFactory;
+import org.apache.webbeans.test.component.IPayment;
+import org.apache.webbeans.test.component.inject.named.NamedFieldWithNamedValue;
+import org.apache.webbeans.test.component.inject.named.NamedFieldWithoutNamedValue;
+import org.apache.webbeans.test.component.inject.named.NamedOtherWithNamedValue;
+import org.apache.webbeans.test.component.inject.named.NamedOtherWithoutNamedValue;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class NamedTests extends TestContext
+{
+    public NamedTests()
+    {
+        super(NamedTests.class.getName());
+    }
+    
+    @Before
+    public void init()
+    {
+        super.init();
+    }
+    
+    
+    @Test
+    public void testFieldWithNamedValue() throws Exception
+    {
+        Bean<NamedFieldWithNamedValue> bean = defineSimpleWebBean(NamedFieldWithNamedValue.class);
+        Field field = NamedFieldWithNamedValue.class.getDeclaredField("paymentProcessor");
+        
+        InjectionPoint point =InjectionPointFactory.getFieldInjectionPointData(bean, field);
+        
+        WebBeansUtil.checkInjectionPointNamedQualifier(point);
+        
+        String value = qulifier(point);
+        
+        Assert.assertEquals("payment", value);
+    }
+    
+    @Test
+    public void testFieldWithoutNamedValue() throws Exception
+    {
+        Bean<NamedFieldWithoutNamedValue> bean = defineSimpleWebBean(NamedFieldWithoutNamedValue.class);
+        Field field = NamedFieldWithoutNamedValue.class.getDeclaredField("paymentProcessor");
+        
+        InjectionPoint point =InjectionPointFactory.getFieldInjectionPointData(bean, field);
+        
+        WebBeansUtil.checkInjectionPointNamedQualifier(point);
+        
+        String value = qulifier(point);
+        
+        Assert.assertEquals("paymentProcessor", value);
+        
+    }
+    
+    @Test
+    public void testOtherWithNamedValue() throws Exception
+    {
+        Bean<NamedOtherWithNamedValue> bean = defineSimpleWebBean(NamedOtherWithNamedValue.class);
+        Constructor<?> constructor = NamedOtherWithNamedValue.class.getDeclaredConstructor(new
Class<?>[]{IPayment.class});
+        
+        InjectionPoint point =InjectionPointFactory.getConstructorInjectionPointData(bean,
constructor).get(0);
+        
+        WebBeansUtil.checkInjectionPointNamedQualifier(point);
+        
+        String value = qulifier(point);
+        
+        Assert.assertEquals("value", value);
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testOtherWithoutNamedValue() throws Exception
+    {
+        Bean<NamedOtherWithoutNamedValue> bean = defineSimpleWebBean(NamedOtherWithoutNamedValue.class);
+        Constructor<?> constructor = NamedOtherWithoutNamedValue.class.getDeclaredConstructor(new
Class<?>[]{IPayment.class});
+        
+        InjectionPoint point =InjectionPointFactory.getConstructorInjectionPointData(bean,
constructor).get(0);
+                
+        String value = qulifier(point);
+        
+        Assert.assertEquals("", value);
+        
+        WebBeansUtil.checkInjectionPointNamedQualifier(point);
+
+    }
+    
+    
+    private String qulifier(InjectionPoint injectionPoint)
+    {
+        Set<Annotation> qualifierset = injectionPoint.getQualifiers();
+        Named namedQualifier = null;
+        for(Annotation qualifier : qualifierset)
+        {
+            if(qualifier.annotationType().equals(Named.class))
+            {
+                namedQualifier = (Named)qualifier;
+                break;
+            }
+        }
+        
+        if(namedQualifier != null)
+        {
+            return namedQualifier.value();
+        }
+        
+        return null;
+    } 
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message