[jboss-cvs] JBossAS SVN: r80300 - in projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 31 00:01:11 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-10-31 00:01:11 -0400 (Fri, 31 Oct 2008)
New Revision: 80300

Added:
   projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/Name.java
   projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/NameDefaults.java
Modified:
   projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java
Log:
JBMDR-51, add a test for the equals problem

Added: projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/Name.java
===================================================================
--- projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/Name.java	                        (rev 0)
+++ projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/Name.java	2008-10-31 04:01:11 UTC (rev 80300)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.annotation.factory.support;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Name
+{
+   public String type() default "";
+   public String subtype() default "";
+}

Added: projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/NameDefaults.java
===================================================================
--- projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/NameDefaults.java	                        (rev 0)
+++ projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/support/NameDefaults.java	2008-10-31 04:01:11 UTC (rev 80300)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.annotation.factory.support;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at Name(type="type", subtype="subtype")
+public class NameDefaults
+{
+   @Name(type="", subtype="")
+   public static class NAME_CLASS {}
+   @Name(type="", subtype="")
+   public static class NAME_CLASS2 {}
+   /** The ManagementComponent uninitialized default */
+   public static final Name COMP_TYPE = defaultNameType();
+   /**
+    * The unitialized/default ManagementComponent value
+    * @return The unitialized/default ManagementComponent value
+    */
+   public static synchronized Name defaultNameType()
+   {
+      Name name = NAME_CLASS.class.getAnnotation(Name.class);
+      return name;
+   }
+
+}

Modified: projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java
===================================================================
--- projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java	2008-10-31 02:59:46 UTC (rev 80299)
+++ projects/jboss-mdr/trunk/src/test/java/org/jboss/test/annotation/factory/test/AnnotationCreatorTest.java	2008-10-31 04:01:11 UTC (rev 80300)
@@ -29,6 +29,8 @@
 import org.jboss.test.ContainerTest;
 import org.jboss.test.annotation.factory.support.Complex;
 import org.jboss.test.annotation.factory.support.MyEnum;
+import org.jboss.test.annotation.factory.support.Name;
+import org.jboss.test.annotation.factory.support.NameDefaults;
 import org.jboss.test.annotation.factory.support.Simple;
 import org.jboss.test.annotation.factory.support.SimpleValue;
 
@@ -37,6 +39,7 @@
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision$
  */
+
 public abstract class AnnotationCreatorTest extends ContainerTest
 {
    public AnnotationCreatorTest(String name)
@@ -155,4 +158,22 @@
       {
       }
    }
+
+   public void testEquals()
+      throws Exception
+   {
+      String expr = "@"+Name.class.getName() + "(type=\"type\",subtype=\"subtype\")";
+      Name n0 = (Name) AnnotationCreator.createAnnotation(expr, Name.class);
+      getLog().debug("n0: "+n0);
+      Name n1 = NameDefaults.class.getAnnotation(Name.class);
+      getLog().debug("n1: "+n1);
+      assertEquals(n0, n1);
+
+      Name defaultName = NameDefaults.defaultNameType();
+      getLog().debug("defaultName: "+defaultName);
+      // The jdk annotation should not equal the defaultName
+      assertFalse(n1+" != "+defaultName, n1.equals(defaultName));
+      // The AnnotationCreator annotation should not equal the defaultName 
+      assertFalse(n0+" != "+defaultName, n0.equals(defaultName));
+   }
 }




More information about the jboss-cvs-commits mailing list