[weld-commits] Weld SVN: r6321 - in api/trunk/cdi: src/main/java/javax/enterprise/util and 7 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed May 26 17:06:32 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-05-26 17:06:31 -0400 (Wed, 26 May 2010)
New Revision: 6321

Added:
   api/trunk/cdi/src/test/java/
   api/trunk/cdi/src/test/java/org/
   api/trunk/cdi/src/test/java/org/jboss/
   api/trunk/cdi/src/test/java/org/jboss/cdi/
   api/trunk/cdi/src/test/java/org/jboss/cdi/api/
   api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/
   api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java
   api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/Foo.java
Modified:
   api/trunk/cdi/pom.xml
   api/trunk/cdi/src/main/java/javax/enterprise/util/AnnotationLiteral.java
Log:
WELD-530

Modified: api/trunk/cdi/pom.xml
===================================================================
--- api/trunk/cdi/pom.xml	2010-05-26 20:34:04 UTC (rev 6320)
+++ api/trunk/cdi/pom.xml	2010-05-26 21:06:31 UTC (rev 6321)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <parent>
@@ -52,6 +53,13 @@
          <groupId>javax.inject</groupId>
          <artifactId>javax.inject</artifactId>
       </dependency>
+
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng</artifactId>
+         <classifier>jdk15</classifier>
+      </dependency>
+
    </dependencies>
 
    <scm>

Modified: api/trunk/cdi/src/main/java/javax/enterprise/util/AnnotationLiteral.java
===================================================================
--- api/trunk/cdi/src/main/java/javax/enterprise/util/AnnotationLiteral.java	2010-05-26 20:34:04 UTC (rev 6320)
+++ api/trunk/cdi/src/main/java/javax/enterprise/util/AnnotationLiteral.java	2010-05-26 21:06:31 UTC (rev 6321)
@@ -132,6 +132,7 @@
       {
          string.append(getMembers()[i].getName()).append('=');
          Object value = invoke(getMembers()[i], this);
+         assertMemberValueNotNull(getMembers()[i], this, value);
          if (value instanceof boolean[]) 
          {
             appendInBraces(string, Arrays.toString((boolean[])value));
@@ -223,7 +224,9 @@
             for (Method member : getMembers())
             {
                Object thisValue = invoke(member, this);
+               assertMemberValueNotNull(member, this, thisValue);
                Object thatValue = invoke(member, that);
+               assertMemberValueNotNull(member, this, thatValue);
                if (thisValue instanceof byte[] && thatValue instanceof byte[])
                {
                   if ( !Arrays.equals((byte[])thisValue, (byte[])thatValue) ) return false;
@@ -279,6 +282,7 @@
       {
          int memberNameHashCode = 127 * member.getName().hashCode();
          Object value = invoke(member, this);
+         assertMemberValueNotNull(member, this, value);
          int memberValueHashCode;
          if (value instanceof boolean[])
          {
@@ -345,5 +349,13 @@
          throw new RuntimeException("Error checking value of member method " + method.getName() + " on " + method.getDeclaringClass(), e);
       }
    }
+   
+   private static void assertMemberValueNotNull(Method member, Annotation instance, Object value)
+   {
+      if (value == null)
+      {
+         throw new IllegalArgumentException("Annotation member " + instance.getClass().getName() + "." + member.getName() + " must not be null");
+      }
+   }
 
 }

Added: api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java
===================================================================
--- api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java	                        (rev 0)
+++ api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java	2010-05-26 21:06:31 UTC (rev 6321)
@@ -0,0 +1,34 @@
+package org.jboss.cdi.api.test;
+
+import org.jboss.cdi.api.test.Foo.FooLiteral;
+import org.testng.annotations.Test;
+
+ at Foo(name="pete")
+public class AnnotationLiteralTest
+{
+
+   @Test(expectedExceptions=IllegalArgumentException.class)
+   public void testNullMemberValueOnHashCode()
+   {
+      new FooLiteral(null).hashCode();      
+   }
+   
+   @Test(expectedExceptions=IllegalArgumentException.class)
+   public void testNullMemberValueOnEquals1()
+   {
+      new FooLiteral(null).equals(AnnotationLiteralTest.class.getAnnotation(Foo.class));      
+   }
+   
+   @Test(expectedExceptions=IllegalArgumentException.class)
+   public void testNullMemberValueOnEquals2()
+   {
+      new FooLiteral(null).equals(new FooLiteral(null));      
+   }
+   
+   @Test(expectedExceptions=IllegalArgumentException.class)
+   public void testNullMemberValueOnToString()
+   {
+      new FooLiteral(null).hashCode();      
+   }
+   
+}


Property changes on: api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/Foo.java
===================================================================
--- api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/Foo.java	                        (rev 0)
+++ api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/Foo.java	2010-05-26 21:06:31 UTC (rev 6321)
@@ -0,0 +1,31 @@
+package org.jboss.cdi.api.test;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Foo
+{
+   
+   public String name();
+   
+   public class FooLiteral extends AnnotationLiteral<Foo> implements Foo 
+   {
+      
+      private final String name;
+      
+      public FooLiteral(String name)
+      {
+         this.name = name;
+      }
+      
+      public String name()
+      {
+         return name;
+      }
+      
+   }
+
+}


Property changes on: api/trunk/cdi/src/test/java/org/jboss/cdi/api/test/Foo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the weld-commits mailing list