[seam-commits] Seam SVN: r13571 - in sandbox/encore/core/src: main/java/org/jboss/encore/grammar/java/ast and 8 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 6 14:43:48 EDT 2010


Author: lincolnthree
Date: 2010-08-06 14:43:46 -0400 (Fri, 06 Aug 2010)
New Revision: 13571

Added:
   sandbox/encore/core/src/test/java/org/jboss/encore/test/
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldAnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldVisibilityTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassAnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassVisibilityTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodVisibilityTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/AnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/VisibilityTest.java
Removed:
   sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/AnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/ClassAnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java
   sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java
Modified:
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Field.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/AnnotationAccessor.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/MethodFinderVisitor.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/TypeDeclarationFinderVisitor.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/FieldImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ImportImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/JavaClassImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/MethodImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ValuePairImpl.java
   sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/util/Strings.java
Log:
Implemented equals() and hashCode() on all impl types. Field types may now be set. Collections returned by getEtc*() methods now return unmodifiable collections.

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Field.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Field.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Field.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -31,5 +31,21 @@
  */
 public interface Field extends Mutable, Internal, VisibilityScoped<Field>, AnnotationTarget<Field>
 {
+   String getName();
 
+   Field setName(String name);
+
+   String getType();
+
+   Field setType(Class<?> clazz);
+
+   Field setType(String type);
+
+   String getStringInitializer();
+
+   String getLiteralInitializer();
+
+   Field setLiteralInitializer(String value);
+
+   Field setStringInitializer(String value);
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/AnnotationAccessor.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/AnnotationAccessor.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/AnnotationAccessor.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -23,6 +23,7 @@
 package org.jboss.encore.grammar.java.ast;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.jdt.core.dom.BodyDeclaration;
@@ -69,7 +70,7 @@
          }
       }
 
-      return result;
+      return Collections.unmodifiableList(result);
    }
 
    public <T extends AnnotationTarget<?>> T removeAnnotation(T target, BodyDeclaration body, Annotation annotation)

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/MethodFinderVisitor.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/MethodFinderVisitor.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/MethodFinderVisitor.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.jdt.core.dom.ASTNode;
@@ -50,7 +51,7 @@
 
    public List<MethodDeclaration> getMethods()
    {
-      return methods;
+      return Collections.unmodifiableList(methods);
    }
 
    public TypeDeclaration getParent()

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/TypeDeclarationFinderVisitor.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/TypeDeclarationFinderVisitor.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/TypeDeclarationFinderVisitor.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -23,6 +23,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.jdt.core.dom.ASTVisitor;
@@ -46,7 +47,7 @@
 
    public List<TypeDeclaration> getTypeDeclarations()
    {
-      return types;
+      return Collections.unmodifiableList(types);
    }
 
 }
\ No newline at end of file

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -22,6 +22,7 @@
 package org.jboss.encore.grammar.java.impl;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.jdt.core.dom.AST;
@@ -170,7 +171,7 @@
       {
          result.add(new ValuePairImpl(DEFAULT_VALUE, getLiteralValue()));
       }
-      return result;
+      return Collections.unmodifiableList(result);
    }
 
    @Override
@@ -273,7 +274,7 @@
          SingleMemberAnnotation anno = (SingleMemberAnnotation) temp.getAnnotations().get(0).getInternal();
 
          Expression expression = anno.getValue();
-         sa.setValue((Expression) ASTNode.copySubtree(annotation.getAST(), expression));
+         sa.setValue((Expression) ASTNode.copySubtree(ast, expression));
       }
       else
       {
@@ -318,13 +319,13 @@
    @Override
    public Annotation setStringValue(String value)
    {
-      return setLiteralValue("\"" + value + "\"");
+      return setLiteralValue(Strings.enquote(value));
    }
 
    @Override
    public Annotation setStringValue(String name, String value)
    {
-      return setLiteralValue(name, "\"" + value + "\"");
+      return setLiteralValue(name, Strings.enquote(value));
    }
 
    @Override
@@ -373,4 +374,43 @@
       }
    }
 
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((annotation == null) ? 0 : annotation.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      AnnotationImpl other = (AnnotationImpl) obj;
+      if (annotation == null)
+      {
+         if (other.annotation != null)
+         {
+            return false;
+         }
+      }
+      else if (!annotation.equals(other.annotation))
+      {
+         return false;
+      }
+      return true;
+   }
+
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/FieldImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/FieldImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/FieldImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -26,12 +26,19 @@
 
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.Expression;
 import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
 import org.jboss.encore.grammar.java.Annotation;
 import org.jboss.encore.grammar.java.Field;
 import org.jboss.encore.grammar.java.JavaClass;
 import org.jboss.encore.grammar.java.JavaParser;
 import org.jboss.encore.grammar.java.ast.AnnotationAccessor;
+import org.jboss.encore.grammar.java.ast.ModifierAccessor;
+import org.jboss.encore.grammar.java.util.Strings;
 
 /**
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
@@ -40,6 +47,7 @@
 public class FieldImpl implements Field
 {
    private static AnnotationAccessor util = new AnnotationAccessor();
+   private final ModifierAccessor ma = new ModifierAccessor();
 
    private JavaClass parent;
    private AST ast;
@@ -87,91 +95,272 @@
       return field;
    }
 
+   /*
+    * Annotation Modifiers
+    */
    @Override
+   public Annotation addAnnotation()
+   {
+      return util.addAnnotation(this, field);
+   }
+
+   @Override
+   public Annotation addAnnotation(Class<?> clazz)
+   {
+      return util.addAnnotation(this, field, clazz);
+   }
+
+   @Override
+   public Annotation addAnnotation(final String className)
+   {
+      return util.addAnnotation(this, field, className);
+   }
+
+   @Override
+   public List<Annotation> getAnnotations()
+   {
+      return util.getAnnotations(this, field);
+   }
+
+   @Override
+   public Field removeAnnotation(Annotation annotation)
+   {
+      return util.removeAnnotation(this, field, annotation);
+   }
+
+   @Override
+   public String toString()
+   {
+      return field.toString();
+   }
+
+   /*
+    * Visibility Modifiers
+    */
+
+   @Override
    public boolean isPackagePrivate()
    {
-      return false;
+      return (!isPublic() && !isPrivate() && !isProtected());
    }
 
    @Override
    public Field setPackagePrivate()
    {
-      return null;
+      ma.clearVisibility(field);
+      return this;
    }
 
    @Override
    public boolean isPublic()
    {
-      return false;
+      return ma.hasModifier(field, ModifierKeyword.PUBLIC_KEYWORD);
    }
 
    @Override
    public Field setPublic()
    {
-      return null;
+      ma.clearVisibility(field);
+      ma.addModifier(field, ModifierKeyword.PUBLIC_KEYWORD);
+      return this;
    }
 
    @Override
    public boolean isPrivate()
    {
-      return false;
+      return ma.hasModifier(field, ModifierKeyword.PRIVATE_KEYWORD);
    }
 
    @Override
    public Field setPrivate()
    {
-      return null;
+      ma.clearVisibility(field);
+      ma.addModifier(field, ModifierKeyword.PRIVATE_KEYWORD);
+      return this;
    }
 
    @Override
    public boolean isProtected()
    {
-      return false;
+      return ma.hasModifier(field, ModifierKeyword.PROTECTED_KEYWORD);
    }
 
    @Override
    public Field setProtected()
    {
-      return null;
+      ma.clearVisibility(field);
+      ma.addModifier(field, ModifierKeyword.PROTECTED_KEYWORD);
+      return this;
    }
 
+   @Override
+   public String getName()
+   {
+      String result = null;
+      for (Object f : field.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
+            result = frag.getName().getFullyQualifiedName();
+            break;
+         }
+      }
+      return result;
+   }
+
+   @Override
+   public Field setName(String name)
+   {
+      for (Object f : field.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
+            frag.setName(ast.newSimpleName(name));
+            break;
+         }
+      }
+      return this;
+   }
+
+   @Override
+   public String getType()
+   {
+      Object type = field.getStructuralProperty(FieldDeclaration.TYPE_PROPERTY);
+      return type.toString();
+   }
+
+   @Override
+   public Field setType(Class<?> clazz)
+   {
+      return setType(clazz.getSimpleName());
+   }
+
+   @Override
+   public Field setType(String type)
+   {
+      Name name = ast.newName(Strings.tokenizeClassName(type));
+      SimpleType st = ast.newSimpleType(name);
+      field.setType(st);
+      return this;
+   }
+
    /*
-    * Annotation Modifiers
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.encore.grammar.java.Field#getInitializer()
     */
    @Override
-   public Annotation addAnnotation()
+   public String getLiteralInitializer()
    {
-      return util.addAnnotation(this, field);
+      String result = null;
+      for (Object f : field.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
+            result = frag.getInitializer().toString();
+            break;
+         }
+      }
+      return result;
    }
 
    @Override
-   public Annotation addAnnotation(Class<?> clazz)
+   public String getStringInitializer()
    {
-      return util.addAnnotation(this, field, clazz);
+      String result = null;
+      for (Object f : field.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
+            result = Strings.unquote(frag.getInitializer().toString());
+            break;
+         }
+      }
+      return result;
    }
 
    @Override
-   public Annotation addAnnotation(final String className)
+   public Field setLiteralInitializer(String value)
    {
-      return util.addAnnotation(this, field, className);
+      String stub = "public class Stub { private Field stub = " + value + " }";
+      JavaClass temp = JavaParser.parse(stub);
+      FieldDeclaration internal = (FieldDeclaration) temp.getFields().get(0).getInternal();
+
+      for (Object f : internal.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            VariableDeclarationFragment tempFrag = (VariableDeclarationFragment) f;
+            VariableDeclarationFragment localFrag = getFragment(field);
+            localFrag.setInitializer((Expression) ASTNode.copySubtree(ast, tempFrag.getInitializer()));
+            break;
+         }
+      }
+
+      return this;
    }
 
    @Override
-   public List<Annotation> getAnnotations()
+   public Field setStringInitializer(String value)
    {
-      return util.getAnnotations(this, field);
+      return setLiteralInitializer(Strings.enquote(value));
    }
 
+   private VariableDeclarationFragment getFragment(FieldDeclaration field)
+   {
+      VariableDeclarationFragment result = null;
+      for (Object f : field.fragments())
+      {
+         if (f instanceof VariableDeclarationFragment)
+         {
+            result = (VariableDeclarationFragment) f;
+            break;
+         }
+      }
+      return result;
+   }
+
    @Override
-   public Field removeAnnotation(Annotation annotation)
+   public int hashCode()
    {
-      return util.removeAnnotation(this, field, annotation);
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((field == null) ? 0 : field.hashCode());
+      return result;
    }
 
    @Override
-   public String toString()
+   public boolean equals(Object obj)
    {
-      return field.toString();
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      FieldImpl other = (FieldImpl) obj;
+      if (field == null)
+      {
+         if (other.field != null)
+         {
+            return false;
+         }
+      }
+      else if (!field.equals(other.field))
+      {
+         return false;
+      }
+      return true;
    }
 
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ImportImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ImportImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ImportImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -26,6 +26,7 @@
 import org.eclipse.jdt.core.dom.ImportDeclaration;
 import org.jboss.encore.grammar.java.Import;
 import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.util.Strings;
 
 /**
  * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
@@ -67,7 +68,7 @@
    @Override
    public Import setName(final String name)
    {
-      imprt.setName(ast.newName(tokenizeClassName(name)));
+      imprt.setName(ast.newName(Strings.tokenizeClassName(name)));
       return this;
    }
 
@@ -96,9 +97,42 @@
       return imprt;
    }
 
-   private String[] tokenizeClassName(final String className)
+   @Override
+   public int hashCode()
    {
-      String[] result = className.split("\\.");
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((imprt == null) ? 0 : imprt.hashCode());
       return result;
    }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      ImportImpl other = (ImportImpl) obj;
+      if (imprt == null)
+      {
+         if (other.imprt != null)
+         {
+            return false;
+         }
+      }
+      else if (!imprt.equals(other.imprt))
+      {
+         return false;
+      }
+      return true;
+   }
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/JavaClassImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/JavaClassImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/JavaClassImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -23,6 +23,7 @@
 
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.jdt.core.dom.AST;
@@ -221,7 +222,7 @@
          results.add(new ImportImpl(this, i));
       }
 
-      return results;
+      return Collections.unmodifiableList(results);
    }
 
    /*
@@ -256,7 +257,7 @@
          result.add(new FieldImpl(this, field));
       }
 
-      return result;
+      return Collections.unmodifiableList(result);
    }
 
    @Override
@@ -297,7 +298,7 @@
       {
          result.add(new MethodImpl(this, methodDeclaration));
       }
-      return result;
+      return Collections.unmodifiableList(result);
    }
 
    @Override
@@ -508,7 +509,7 @@
    }
 
    @Override
-   public boolean equals(final Object obj)
+   public boolean equals(Object obj)
    {
       if (this == obj)
       {

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/MethodImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/MethodImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/MethodImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -44,11 +44,11 @@
 public class MethodImpl implements Method
 {
    private static AnnotationAccessor util = new AnnotationAccessor();
+   private final ModifierAccessor ma = new ModifierAccessor();
 
    private JavaClass parent = null;
    private AST ast = null;
    private CompilationUnit cu = null;
-   private final ModifierAccessor ma = new ModifierAccessor();
    private final MethodDeclaration method;
 
    private void init(final JavaClass parent)
@@ -168,6 +168,47 @@
    }
 
    @Override
+   public String getReturnType()
+   {
+      String result = null;
+      if (!isConstructor() && (method.getReturnType2() != null))
+      {
+         result = method.getReturnType2().toString();
+      }
+      return result;
+   }
+
+   @Override
+   public Method setReturnType(final Class<?> type)
+   {
+      return setReturnType(type.getSimpleName());
+   }
+
+   @Override
+   public Method setReturnType(final String type)
+   {
+      method.setReturnType2(ast.newSimpleType(ast.newSimpleName(type)));
+      return this;
+   }
+
+   @Override
+   public boolean isReturnTypeVoid()
+   {
+      return getReturnType() == null;
+   }
+
+   @Override
+   public Method setReturnTypeVoid()
+   {
+      method.setReturnType2(null);
+      return this;
+   }
+
+   /*
+    * Abstract Modifiers
+    */
+
+   @Override
    public boolean isAbstract()
    {
       return ma.hasModifier(method, ModifierKeyword.ABSTRACT_KEYWORD);
@@ -211,6 +252,10 @@
       return this;
    }
 
+   /*
+    * Visibility Modifiers
+    */
+
    @Override
    public boolean isPackagePrivate()
    {
@@ -266,44 +311,11 @@
       return this;
    }
 
-   @Override
-   public String getReturnType()
-   {
-      String result = null;
-      if (!isConstructor() && (method.getReturnType2() != null))
-      {
-         result = method.getReturnType2().toString();
-      }
-      return result;
-   }
+   /*
+    * Interfaces
+    */
 
    @Override
-   public Method setReturnType(final Class<?> type)
-   {
-      return setReturnType(type.getSimpleName());
-   }
-
-   @Override
-   public Method setReturnType(final String type)
-   {
-      method.setReturnType2(ast.newSimpleType(ast.newSimpleName(type)));
-      return this;
-   }
-
-   @Override
-   public boolean isReturnTypeVoid()
-   {
-      return getReturnType() == null;
-   }
-
-   @Override
-   public Method setReturnTypeVoid()
-   {
-      method.setReturnType2(null);
-      return this;
-   }
-
-   @Override
    public String toString()
    {
       return method.toString();
@@ -327,12 +339,11 @@
       final int prime = 31;
       int result = 1;
       result = prime * result + ((method == null) ? 0 : method.hashCode());
-      result = prime * result + ((parent == null) ? 0 : parent.hashCode());
       return result;
    }
 
    @Override
-   public boolean equals(final Object obj)
+   public boolean equals(Object obj)
    {
       if (this == obj)
       {
@@ -358,17 +369,6 @@
       {
          return false;
       }
-      if (parent == null)
-      {
-         if (other.parent != null)
-         {
-            return false;
-         }
-      }
-      else if (!parent.equals(other.parent))
-      {
-         return false;
-      }
       return true;
    }
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ValuePairImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ValuePairImpl.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/ValuePairImpl.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -60,4 +60,55 @@
       return Strings.unquote(getLiteralValue());
    }
 
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((name == null) ? 0 : name.hashCode());
+      result = prime * result + ((value == null) ? 0 : value.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+      {
+         return true;
+      }
+      if (obj == null)
+      {
+         return false;
+      }
+      if (getClass() != obj.getClass())
+      {
+         return false;
+      }
+      ValuePairImpl other = (ValuePairImpl) obj;
+      if (name == null)
+      {
+         if (other.name != null)
+         {
+            return false;
+         }
+      }
+      else if (!name.equals(other.name))
+      {
+         return false;
+      }
+      if (value == null)
+      {
+         if (other.value != null)
+         {
+            return false;
+         }
+      }
+      else if (!value.equals(other.value))
+      {
+         return false;
+      }
+      return true;
+   }
+
 }

Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/util/Strings.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/util/Strings.java	2010-08-06 18:13:16 UTC (rev 13570)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/util/Strings.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -39,4 +39,24 @@
       }
       return result;
    }
+
+   public static String enquote(String value)
+   {
+      String result = null;
+      if (value != null)
+      {
+         result = "\"" + value + "\"";
+      }
+      return result;
+   }
+
+   public static String[] tokenizeClassName(final String className)
+   {
+      String[] result = null;
+      if (className != null)
+      {
+         result = className.split("\\.");
+      }
+      return result;
+   }
 }

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java (from rev 13560, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java)

Deleted: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/AnnotationTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/AnnotationTest.java	2010-08-05 12:31:27 UTC (rev 13560)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/AnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.encore.grammar.java;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- */
-public abstract class AnnotationTest
-{
-   private AnnotationTarget<?> target;
-
-   public void setTarget(AnnotationTarget<?> target)
-   {
-      this.target = target;
-   }
-
-   @Before
-   public void reset()
-   {
-      resetTests();
-   }
-
-   public abstract void resetTests();
-
-   @Test
-   public void testParseAnnotation() throws Exception
-   {
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(3, annotations.size());
-      assertEquals("deprecation", annotations.get(1).getStringValue());
-      assertEquals("deprecation", annotations.get(1).getStringValue("value"));
-      assertEquals("value", annotations.get(1).getValues().get(0).getName());
-      assertEquals("deprecation", annotations.get(1).getValues().get(0).getStringValue());
-
-      assertEquals("unchecked", annotations.get(2).getStringValue("value"));
-      assertEquals("unchecked", annotations.get(2).getStringValue());
-      assertEquals("value", annotations.get(2).getValues().get(0).getName());
-      assertEquals("unchecked", annotations.get(2).getValues().get(0).getStringValue());
-   }
-
-   @Test
-   public void testAddAnnotation() throws Exception
-   {
-      int size = target.getAnnotations().size();
-      target.addAnnotation().setName("RequestScoped");
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 1, annotations.size());
-      assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
-   }
-
-   @Test
-   public void testAddAnnotationByClass() throws Exception
-   {
-      int size = target.getAnnotations().size();
-      target.addAnnotation(Test.class);
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 1, annotations.size());
-      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
-      target.applyChanges();
-      assertTrue(target.toString().contains("@" + Test.class.getName()));
-   }
-
-   @Test
-   public void testAddAnnotationByName() throws Exception
-   {
-      int size = target.getAnnotations().size();
-      target.addAnnotation("RequestScoped");
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 1, annotations.size());
-      assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
-      target.applyChanges();
-      assertTrue(target.toString().contains("@RequestScoped"));
-   }
-
-   @Test
-   public void testCanAddAnnotationDuplicate() throws Exception
-   {
-      int size = target.getAnnotations().size();
-      target.addAnnotation(Test.class);
-      target.addAnnotation(Test.class);
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 2, annotations.size());
-      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
-      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 2).getName());
-      target.applyChanges();
-      String pattern = "@" + Test.class.getName() + " " + "@" + Test.class.getName();
-      assertTrue(target.toString().contains(pattern));
-   }
-
-   @Test(expected = IllegalArgumentException.class)
-   public void testCannotAddAnnotationWithIllegalName() throws Exception
-   {
-      target.addAnnotation("sdf*(&#$%");
-   }
-
-   @Test
-   public void testAddLiteralValue() throws Exception
-   {
-      int size = target.getAnnotations().size();
-
-      target.addAnnotation(Test.class).setLiteralValue("435");
-      target.applyChanges();
-
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 1, annotations.size());
-
-      Annotation annotation = annotations.get(annotations.size() - 1);
-      assertEquals(Test.class.getName(), annotation.getName());
-      assertEquals("435", annotation.getLiteralValue());
-   }
-
-   @Test
-   public void testAddObjectValue() throws Exception
-   {
-      int size = target.getAnnotations().size();
-
-      target.addAnnotation(Test.class).setLiteralValue("expected", "RuntimeException.class").setLiteralValue("foo", "bar");
-      target.applyChanges();
-
-      List<Annotation> annotations = target.getAnnotations();
-      assertEquals(size + 1, annotations.size());
-
-      Annotation annotation = annotations.get(annotations.size() - 1);
-      assertEquals(Test.class.getName(), annotation.getName());
-      assertEquals(null, annotation.getLiteralValue());
-      assertEquals("RuntimeException.class", annotation.getLiteralValue("expected"));
-      assertEquals("bar", annotation.getLiteralValue("foo"));
-   }
-
-   @Test
-   public void testAddValueConvertsToNormalAnnotation() throws Exception
-   {
-      target.addAnnotation(Test.class).setLiteralValue("RuntimeException.class");
-      target.applyChanges();
-      Annotation annotation = target.getAnnotations().get(target.getAnnotations().size() - 1);
-
-      assertEquals("RuntimeException.class", annotation.getLiteralValue());
-      assertTrue(annotation.isSingleValue());
-
-      annotation.setLiteralValue("foo", "bar");
-      assertFalse(annotation.isSingleValue());
-      assertTrue(annotation.isNormal());
-
-      assertEquals("RuntimeException.class", annotation.getLiteralValue());
-      assertEquals("RuntimeException.class", annotation.getLiteralValue("value"));
-      assertEquals("bar", annotation.getLiteralValue("foo"));
-   }
-
-   @Test
-   public void testAnnotationBeginsAsMarker() throws Exception
-   {
-      Annotation anno = target.addAnnotation(Test.class);
-      assertTrue(anno.isMarker());
-      assertFalse(anno.isSingleValue());
-      assertFalse(anno.isNormal());
-
-      anno.setLiteralValue("\"Foo!\"");
-      assertFalse(anno.isMarker());
-      assertTrue(anno.isSingleValue());
-      assertFalse(anno.isNormal());
-
-      anno.setStringValue("bar", "Foo!");
-      assertFalse(anno.isMarker());
-      assertFalse(anno.isSingleValue());
-      assertTrue(anno.isNormal());
-
-      assertEquals("\"Foo!\"", anno.getLiteralValue("bar"));
-      assertEquals("Foo!", anno.getStringValue("bar"));
-
-      anno.removeAllValues();
-      assertTrue(anno.isMarker());
-      assertFalse(anno.isSingleValue());
-      assertFalse(anno.isNormal());
-   }
-
-   @Test
-   public void testRemoveAllValues() throws Exception
-   {
-      target.addAnnotation(Test.class).setLiteralValue("expected", "RuntimeException.class");
-      target.applyChanges();
-
-      List<Annotation> annotations = target.getAnnotations();
-      Annotation annotation = annotations.get(annotations.size() - 1);
-      annotation.removeAllValues();
-
-      assertEquals(0, annotation.getValues().size());
-   }
-}

Deleted: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/ClassAnnotationTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/ClassAnnotationTest.java	2010-08-05 12:31:27 UTC (rev 13560)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/ClassAnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.encore.grammar.java;
-
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- */
-public class ClassAnnotationTest extends AnnotationTest
-{
-   @Override
-   public void resetTests()
-   {
-      InputStream stream = ClassAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedClassFile.java");
-      JavaClass javaClass = JavaParser.parse(stream);
-      setTarget(javaClass);
-   }
-}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldAnnotationTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/FieldAnnotationTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldAnnotationTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldAnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.Field;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.test.grammar.java.common.AnnotationTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class FieldAnnotationTest extends AnnotationTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = FieldAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedField.java");
+      Field field = JavaParser.parse(stream).getFields().get(0);
+      setTarget(field);
+   }
+}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/FieldTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.Field;
+import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class FieldTest
+{
+   private InputStream stream;
+   private JavaClass javaClass;
+   private Field field;
+
+   @Before
+   public void reset()
+   {
+      stream = FieldTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedField.java");
+      javaClass = JavaParser.parse(stream);
+      field = javaClass.getFields().get(javaClass.getFields().size() - 1);
+   }
+
+   @Test
+   public void testParse() throws Exception
+   {
+      assertTrue(field instanceof Field);
+      assertEquals("field", field.getName());
+      assertEquals("String", field.getType());
+   }
+
+   @Test
+   public void testSetName() throws Exception
+   {
+      assertEquals("field", field.getName());
+      field.setName("newName");
+      field.applyChanges();
+      assertTrue(field.toString().contains("newName;"));
+      assertEquals("newName", field.getName());
+   }
+
+   @Test
+   public void testSetType() throws Exception
+   {
+      assertEquals("field", field.getName());
+      field.setType(FieldTest.class);
+      field.applyChanges();
+      assertTrue(field.toString().contains("FieldTest"));
+      assertEquals(FieldTest.class.getSimpleName(), field.getType());
+   }
+
+   @Test
+   public void testSetTypeString() throws Exception
+   {
+      assertEquals("field", field.getName());
+      field.setType("FooBarType");
+      field.applyChanges();
+      assertTrue(field.toString().contains("FooBarType"));
+      assertEquals("FooBarType", field.getType());
+   }
+
+   @Test
+   public void testAddField() throws Exception
+   {
+      javaClass.addField("public Boolean flag = false;");
+      Field fld = javaClass.getFields().get(javaClass.getFields().size() - 1);
+      fld.applyChanges();
+
+      assertTrue(fld.toString().contains("Boolean"));
+      assertEquals("Boolean", fld.getType());
+      assertEquals("flag", fld.getName());
+      assertEquals("false", fld.getLiteralInitializer());
+   }
+
+   @Test
+   public void testAddFieldInitializerLiteral() throws Exception
+   {
+      javaClass.addField("public int flag;").setLiteralInitializer("1234").setPrivate();
+      Field fld = javaClass.getFields().get(javaClass.getFields().size() - 1);
+      fld.applyChanges();
+
+      assertEquals("int", fld.getType());
+      assertEquals("flag", fld.getName());
+      assertEquals("1234", fld.getLiteralInitializer());
+      assertEquals("1234", fld.getStringInitializer());
+      assertEquals("private int flag=1234;", fld.toString().trim());
+   }
+
+   @Test
+   public void testAddFieldInitializerString() throws Exception
+   {
+      javaClass.addField("public String flag;").setStringInitializer("american");
+      Field fld = javaClass.getFields().get(javaClass.getFields().size() - 1);
+      fld.applyChanges();
+
+      assertEquals("String", fld.getType());
+      assertEquals("flag", fld.getName());
+      assertEquals("\"american\"", fld.getLiteralInitializer());
+      assertEquals("american", fld.getStringInitializer());
+      assertEquals("public String flag=\"american\";", fld.toString().trim());
+   }
+
+   @Test
+   public void testAddQualifiedFieldType() throws Exception
+   {
+      javaClass.addField().setName("flag").setType(String.class.getName()).setStringInitializer("american").setPrivate();
+      Field fld = javaClass.getFields().get(javaClass.getFields().size() - 1);
+      fld.applyChanges();
+
+      assertEquals(String.class.getName(), fld.getType());
+      assertEquals("flag", fld.getName());
+      assertEquals("\"american\"", fld.getLiteralInitializer());
+      assertEquals("american", fld.getStringInitializer());
+      assertEquals("private java.lang.String flag=\"american\";", fld.toString().trim());
+   }
+}

Added: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldVisibilityTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldVisibilityTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/FieldVisibilityTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.Field;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.test.grammar.java.common.VisibilityTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class FieldVisibilityTest extends VisibilityTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = FieldVisibilityTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedField.java");
+      Field field = JavaParser.parse(stream).getFields().get(0);
+      setTarget(field);
+   }
+}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassAnnotationTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassAnnotationTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassAnnotationTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassAnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.test.grammar.java.common.AnnotationTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class JavaClassAnnotationTest extends AnnotationTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = JavaClassAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedClass.java");
+      JavaClass javaClass = JavaParser.parse(stream);
+      setTarget(javaClass);
+   }
+}

Deleted: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java	2010-08-05 12:31:27 UTC (rev 13560)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -1,277 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.encore.grammar.java;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- */
-public class JavaClassTest
-{
-   private InputStream stream;
-   private JavaClass javaClass;
-
-   @Before
-   public void reset()
-   {
-      stream = JavaClassTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
-      javaClass = JavaParser.parse(stream);
-   }
-
-   @Test
-   public void testApplyChangesRequiredForModification() throws Exception
-   {
-      assertEquals("MockClassFile", javaClass.getName());
-      javaClass.setName("Telephone");
-      assertEquals("Telephone", javaClass.getName());
-      assertFalse(javaClass.toString().contains("Telephone"));
-      assertTrue(javaClass.toString().contains("MockClassFile"));
-
-      javaClass.applyChanges();
-      assertTrue(javaClass.toString().contains("Telephone"));
-      assertFalse(javaClass.toString().contains("MockClassFile"));
-   }
-
-   @Test
-   public void testParse() throws Exception
-   {
-      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
-      assertEquals(2, javaClass.getMethods().size());
-      assertEquals("MockClassFile", javaClass.getName());
-      assertTrue(javaClass.isPublic());
-      assertFalse(javaClass.isAbstract());
-   }
-
-   @Test
-   public void testSetName() throws Exception
-   {
-      assertEquals("MockClassFile", javaClass.getName());
-      javaClass.setName("Telephone");
-      assertEquals("Telephone", javaClass.getName());
-   }
-
-   @Test
-   public void testSetNameUpdatesConstructorNames() throws Exception
-   {
-      assertEquals("MockClassFile", javaClass.getName());
-      assertEquals("MockClassFile", javaClass.getMethods().get(0).getName());
-      javaClass.setName("Telephone");
-      assertEquals("Telephone", javaClass.getName());
-      assertEquals("Telephone", javaClass.getMethods().get(0).getName());
-   }
-
-   @Test
-   public void testSetPackage() throws Exception
-   {
-      javaClass.setPackage("org.lincoln");
-      assertEquals("org.lincoln", javaClass.getPackage());
-      assertFalse(javaClass.isDefaultPackage());
-   }
-
-   @Test
-   public void testSetAbstract() throws Exception
-   {
-      javaClass.setAbstract(true);
-      assertTrue(javaClass.isAbstract());
-   }
-
-   @Test
-   public void testSetVisibilityPublic() throws Exception
-   {
-      javaClass.setPublic();
-      assertFalse(javaClass.isPrivate());
-      assertFalse(javaClass.isPackagePrivate());
-      assertTrue(javaClass.isPublic());
-      assertFalse(javaClass.isProtected());
-   }
-
-   @Test
-   public void testSetVisibilityPackagePrivate() throws Exception
-   {
-      javaClass.setPackagePrivate();
-      assertTrue(javaClass.isPackagePrivate());
-      assertFalse(javaClass.isPublic());
-      assertFalse(javaClass.isPrivate());
-      assertFalse(javaClass.isProtected());
-   }
-
-   @Test
-   public void testSetVisibilityPrivate() throws Exception
-   {
-      javaClass.setPrivate();
-      assertTrue(javaClass.isPrivate());
-      assertFalse(javaClass.isPackagePrivate());
-      assertFalse(javaClass.isPublic());
-      assertFalse(javaClass.isProtected());
-   }
-
-   @Test
-   public void testSetVisibilityProtected() throws Exception
-   {
-      javaClass.setProtected();
-      assertFalse(javaClass.isPrivate());
-      assertFalse(javaClass.isPackagePrivate());
-      assertFalse(javaClass.isPublic());
-      assertTrue(javaClass.isProtected());
-   }
-
-   @Test
-   public void testSetPackageDefault() throws Exception
-   {
-      javaClass.setDefaultPackage();
-      assertNull(javaClass.getPackage());
-      assertTrue(javaClass.isDefaultPackage());
-   }
-
-   @Test
-   public void testAddImport() throws Exception
-   {
-      javaClass.addImport(List.class.getName());
-      assertEquals(2, javaClass.getImports().size());
-      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
-      assertEquals(List.class.getName(), javaClass.getImports().get(1).getName());
-   }
-
-   @Test
-   public void testAddImportsClasses() throws Exception
-   {
-      assertEquals(1, javaClass.getImports().size());
-
-      javaClass.addImports(List.class, Map.class);
-
-      assertEquals(3, javaClass.getImports().size());
-      assertEquals(Map.class.getName(), javaClass.getImports().get(2).getName());
-   }
-
-   @Test
-   public void testAddImportStatic() throws Exception
-   {
-      assertEquals(1, javaClass.getImports().size());
-      javaClass.addImport(List.class).setStatic(true).applyChanges();
-      assertEquals(2, javaClass.getImports().size());
-      assertTrue(javaClass.getImports().get(1).isStatic());
-   }
-
-   @Test
-   public void testRemoveImportByClass() throws Exception
-   {
-      List<Import> imports = javaClass.getImports();
-      assertEquals(1, imports.size());
-      assertEquals(URL.class.getName(), imports.get(0).getName());
-
-      javaClass.removeImport(URL.class);
-      imports = javaClass.getImports();
-      assertEquals(0, imports.size());
-   }
-
-   @Test
-   public void testRemoveImportByName() throws Exception
-   {
-      assertEquals(1, javaClass.getImports().size());
-      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
-
-      javaClass.removeImport(URL.class.getName());
-      assertEquals(0, javaClass.getImports().size());
-   }
-
-   @Test
-   public void testRemoveImportByReference() throws Exception
-   {
-      assertEquals(1, javaClass.getImports().size());
-      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
-
-      javaClass.removeImport(javaClass.getImports().get(0));
-      assertEquals(0, javaClass.getImports().size());
-   }
-
-   @Test
-   public void testAddMethod() throws Exception
-   {
-      javaClass.addMethod().setName("testMethod").setReturnTypeVoid().setBody("").applyChanges();
-      List<Method> methods = javaClass.getMethods();
-      assertEquals(3, methods.size());
-      assertNull(methods.get(2).getReturnType());
-   }
-
-   @Test
-   public void testAddMethodFromString() throws Exception
-   {
-      javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }").setPackagePrivate().applyChanges();
-      List<Method> methods = javaClass.getMethods();
-      assertEquals(3, methods.size());
-      assertEquals("URL", methods.get(2).getReturnType());
-      assertEquals("rewriteURL", methods.get(2).getName());
-
-      String body = methods.get(2).getBody();
-      assertEquals("return null;".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
-   }
-
-   @Test
-   public void testRemoveMethod() throws Exception
-   {
-      List<Method> methods = javaClass.getMethods();
-      javaClass.removeMethod(methods.get(0)).applyChanges();
-      methods = javaClass.getMethods();
-      assertEquals(1, methods.size());
-   }
-
-   @Test
-   public void testAddConstructor() throws Exception
-   {
-      javaClass.addMethod().setName("testMethod").setConstructor(true).setProtected().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
-      Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
-      assertEquals(3, javaClass.getMethods().size());
-      assertEquals(javaClass.getName(), method.getName());
-      assertTrue(method.isProtected());
-      assertTrue(method.isConstructor());
-      assertNull(method.getReturnType());
-      String body = method.getBody();
-      assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
-   }
-
-   @Test
-   public void testAddConstructorIngoresReturnTypeAndName() throws Exception
-   {
-      javaClass.addMethod().setName("testMethod").setConstructor(true).setPrivate().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
-      Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
-      assertEquals(3, javaClass.getMethods().size());
-      assertTrue(method.isPrivate());
-      assertTrue(method.isConstructor());
-      assertNull(method.getReturnType());
-      assertEquals(javaClass.getName(), method.getName());
-      String body = method.getBody();
-      assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
-   }
-
-}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.encore.grammar.java.Import;
+import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.grammar.java.Method;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class JavaClassTest
+{
+   private InputStream stream;
+   private JavaClass javaClass;
+
+   @Before
+   public void reset()
+   {
+      stream = JavaClassTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClass.java");
+      javaClass = JavaParser.parse(stream);
+   }
+
+   @Test
+   public void testApplyChangesRequiredForModification() throws Exception
+   {
+      assertEquals("MockClass", javaClass.getName());
+      javaClass.setName("Telephone");
+      assertEquals("Telephone", javaClass.getName());
+      assertFalse(javaClass.toString().contains("Telephone"));
+      assertTrue(javaClass.toString().contains("MockClass"));
+
+      javaClass.applyChanges();
+      assertTrue(javaClass.toString().contains("Telephone"));
+      assertFalse(javaClass.toString().contains("MockClass"));
+   }
+
+   @Test
+   public void testParse() throws Exception
+   {
+      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+      assertEquals(2, javaClass.getMethods().size());
+      assertEquals("MockClass", javaClass.getName());
+      assertTrue(javaClass.isPublic());
+      assertFalse(javaClass.isAbstract());
+   }
+
+   @Test
+   public void testSetName() throws Exception
+   {
+      assertEquals("MockClass", javaClass.getName());
+      javaClass.setName("Telephone");
+      assertEquals("Telephone", javaClass.getName());
+   }
+
+   @Test
+   public void testSetNameUpdatesConstructorNames() throws Exception
+   {
+      assertEquals("MockClass", javaClass.getName());
+      assertEquals("MockClass", javaClass.getMethods().get(0).getName());
+      javaClass.setName("Telephone");
+      assertEquals("Telephone", javaClass.getName());
+      assertEquals("Telephone", javaClass.getMethods().get(0).getName());
+   }
+
+   @Test
+   public void testSetPackage() throws Exception
+   {
+      javaClass.setPackage("org.lincoln");
+      assertEquals("org.lincoln", javaClass.getPackage());
+      assertFalse(javaClass.isDefaultPackage());
+   }
+
+   @Test
+   public void testSetAbstract() throws Exception
+   {
+      javaClass.setAbstract(true);
+      assertTrue(javaClass.isAbstract());
+   }
+
+   @Test
+   public void testSetPackageDefault() throws Exception
+   {
+      javaClass.setDefaultPackage();
+      assertNull(javaClass.getPackage());
+      assertTrue(javaClass.isDefaultPackage());
+   }
+
+   @Test
+   public void testAddImport() throws Exception
+   {
+      javaClass.addImport(List.class.getName());
+      assertEquals(2, javaClass.getImports().size());
+      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+      assertEquals(List.class.getName(), javaClass.getImports().get(1).getName());
+   }
+
+   @Test
+   public void testAddImportsClasses() throws Exception
+   {
+      assertEquals(1, javaClass.getImports().size());
+
+      javaClass.addImports(List.class, Map.class);
+
+      assertEquals(3, javaClass.getImports().size());
+      assertEquals(Map.class.getName(), javaClass.getImports().get(2).getName());
+   }
+
+   @Test
+   public void testAddImportStatic() throws Exception
+   {
+      assertEquals(1, javaClass.getImports().size());
+      javaClass.addImport(List.class).setStatic(true).applyChanges();
+      assertEquals(2, javaClass.getImports().size());
+      assertTrue(javaClass.getImports().get(1).isStatic());
+   }
+
+   @Test
+   public void testRemoveImportByClass() throws Exception
+   {
+      List<Import> imports = javaClass.getImports();
+      assertEquals(1, imports.size());
+      assertEquals(URL.class.getName(), imports.get(0).getName());
+
+      javaClass.removeImport(URL.class);
+      imports = javaClass.getImports();
+      assertEquals(0, imports.size());
+   }
+
+   @Test
+   public void testRemoveImportByName() throws Exception
+   {
+      assertEquals(1, javaClass.getImports().size());
+      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+
+      javaClass.removeImport(URL.class.getName());
+      assertEquals(0, javaClass.getImports().size());
+   }
+
+   @Test
+   public void testRemoveImportByReference() throws Exception
+   {
+      assertEquals(1, javaClass.getImports().size());
+      assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
+
+      javaClass.removeImport(javaClass.getImports().get(0));
+      assertEquals(0, javaClass.getImports().size());
+   }
+
+   @Test
+   public void testAddMethod() throws Exception
+   {
+      javaClass.addMethod().setName("testMethod").setReturnTypeVoid().setBody("").applyChanges();
+      List<Method> methods = javaClass.getMethods();
+      assertEquals(3, methods.size());
+      assertNull(methods.get(2).getReturnType());
+   }
+
+   @Test
+   public void testAddMethodFromString() throws Exception
+   {
+      javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }").setPackagePrivate().applyChanges();
+      List<Method> methods = javaClass.getMethods();
+      assertEquals(3, methods.size());
+      assertEquals("URL", methods.get(2).getReturnType());
+      assertEquals("rewriteURL", methods.get(2).getName());
+
+      String body = methods.get(2).getBody();
+      assertEquals("return null;".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
+   }
+
+   @Test
+   public void testRemoveMethod() throws Exception
+   {
+      List<Method> methods = javaClass.getMethods();
+      javaClass.removeMethod(methods.get(0)).applyChanges();
+      methods = javaClass.getMethods();
+      assertEquals(1, methods.size());
+   }
+
+   @Test
+   public void testAddConstructor() throws Exception
+   {
+      javaClass.addMethod().setName("testMethod").setConstructor(true).setProtected().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
+      Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+      assertEquals(3, javaClass.getMethods().size());
+      assertEquals(javaClass.getName(), method.getName());
+      assertTrue(method.isProtected());
+      assertTrue(method.isConstructor());
+      assertNull(method.getReturnType());
+      String body = method.getBody();
+      assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
+   }
+
+   @Test
+   public void testAddConstructorIngoresReturnTypeAndName() throws Exception
+   {
+      javaClass.addMethod().setName("testMethod").setConstructor(true).setPrivate().setReturnType(String.class).setBody("System.out.println(\"I am a constructor!\");").applyChanges();
+      Method method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+      assertEquals(3, javaClass.getMethods().size());
+      assertTrue(method.isPrivate());
+      assertTrue(method.isConstructor());
+      assertNull(method.getReturnType());
+      assertEquals(javaClass.getName(), method.getName());
+      String body = method.getBody();
+      assertEquals("System.out.println(\"I am a constructor!\");".replaceAll("\\s+", ""), body.replaceAll("\\s+", ""));
+   }
+
+}

Added: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassVisibilityTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassVisibilityTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/JavaClassVisibilityTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.test.grammar.java.common.VisibilityTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class JavaClassVisibilityTest extends VisibilityTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = JavaClassVisibilityTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClass.java");
+      JavaClass clazz = JavaParser.parse(stream);
+      setTarget(clazz);
+   }
+}

Deleted: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodAnnotationTest.java	2010-08-05 12:31:27 UTC (rev 13560)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.encore.grammar.java;
-
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- */
-public class MethodAnnotationTest extends AnnotationTest
-{
-   @Override
-   public void resetTests()
-   {
-      InputStream stream = MethodAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedMethodFile.java");
-      Method method = JavaParser.parse(stream).getMethods().get(0);
-      setTarget(method);
-   }
-}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodAnnotationTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodAnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.grammar.java.Method;
+import org.jboss.encore.test.grammar.java.common.AnnotationTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class MethodAnnotationTest extends AnnotationTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = MethodAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedMethod.java");
+      Method method = JavaParser.parse(stream).getMethods().get(0);
+      setTarget(method);
+   }
+}

Deleted: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java	2010-08-05 12:31:27 UTC (rev 13560)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -1,132 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.encore.grammar.java;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
- */
-public class MethodTest
-{
-   private InputStream stream;
-   private JavaClass javaClass;
-   private Method method;
-
-   @Before
-   public void reset()
-   {
-      stream = MethodTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
-      javaClass = JavaParser.parse(stream);
-      javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }");
-      method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
-   }
-
-   @Test
-   public void testSetName() throws Exception
-   {
-      assertEquals("rewriteURL", method.getName());
-      method.setName("doSomething");
-      assertEquals("doSomething", method.getName());
-   }
-
-   @Test
-   public void testSetReturnType() throws Exception
-   {
-      assertEquals("URL", method.getReturnType());
-      method.setReturnType(Class.class);
-      assertEquals("Class", method.getReturnType());
-      assertFalse(method.isReturnTypeVoid());
-   }
-
-   @Test
-   public void testSetReturnTypeVoid() throws Exception
-   {
-      assertEquals("URL", method.getReturnType());
-      method.setReturnTypeVoid();
-      assertEquals(null, method.getReturnType());
-      assertTrue(method.isReturnTypeVoid());
-   }
-
-   @Test
-   public void testSetConstructor() throws Exception
-   {
-      assertFalse(method.isConstructor());
-      method.setConstructor(true);
-      assertTrue(method.isConstructor());
-      assertEquals(javaClass.getName(), method.getName());
-   }
-
-   @Test
-   public void testSetAbstract() throws Exception
-   {
-      method.setAbstract(true);
-      assertTrue(method.isAbstract());
-   }
-
-   @Test
-   public void testSetPublic() throws Exception
-   {
-      method.setPublic();
-      assertTrue(method.isPublic());
-      assertFalse(method.isPackagePrivate());
-      assertFalse(method.isPrivate());
-      assertFalse(method.isProtected());
-   }
-
-   @Test
-   public void testSetPrivate() throws Exception
-   {
-      method.setPrivate();
-      assertFalse(method.isPublic());
-      assertFalse(method.isPackagePrivate());
-      assertTrue(method.isPrivate());
-      assertFalse(method.isProtected());
-   }
-
-   @Test
-   public void testSetProtected() throws Exception
-   {
-      method.setProtected();
-      assertFalse(method.isPublic());
-      assertFalse(method.isPackagePrivate());
-      assertFalse(method.isPrivate());
-      assertTrue(method.isProtected());
-   }
-
-   @Test
-   public void testSetPackagePrivate() throws Exception
-   {
-      method.setPackagePrivate();
-      assertFalse(method.isPublic());
-      assertTrue(method.isPackagePrivate());
-      assertFalse(method.isPrivate());
-      assertFalse(method.isProtected());
-   }
-}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java (from rev 13561, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/MethodTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.JavaClass;
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.grammar.java.Method;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class MethodTest
+{
+   private InputStream stream;
+   private JavaClass javaClass;
+   private Method method;
+
+   @Before
+   public void reset()
+   {
+      stream = MethodTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClass.java");
+      javaClass = JavaParser.parse(stream);
+      javaClass.addMethod("public URL rewriteURL(String pattern, String replacement) { return null; }");
+      method = javaClass.getMethods().get(javaClass.getMethods().size() - 1);
+   }
+
+   @Test
+   public void testSetName() throws Exception
+   {
+      assertEquals("rewriteURL", method.getName());
+      method.setName("doSomething");
+      assertEquals("doSomething", method.getName());
+   }
+
+   @Test
+   public void testSetReturnType() throws Exception
+   {
+      assertEquals("URL", method.getReturnType());
+      method.setReturnType(Class.class);
+      assertEquals("Class", method.getReturnType());
+      assertFalse(method.isReturnTypeVoid());
+   }
+
+   @Test
+   public void testSetReturnTypeVoid() throws Exception
+   {
+      assertEquals("URL", method.getReturnType());
+      method.setReturnTypeVoid();
+      assertEquals(null, method.getReturnType());
+      assertTrue(method.isReturnTypeVoid());
+   }
+
+   @Test
+   public void testSetConstructor() throws Exception
+   {
+      assertFalse(method.isConstructor());
+      method.setConstructor(true);
+      assertTrue(method.isConstructor());
+      assertEquals(javaClass.getName(), method.getName());
+   }
+
+   @Test
+   public void testSetAbstract() throws Exception
+   {
+      method.setAbstract(true);
+      assertTrue(method.isAbstract());
+   }
+}

Added: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodVisibilityTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodVisibilityTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/MethodVisibilityTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java;
+
+import java.io.InputStream;
+
+import org.jboss.encore.grammar.java.JavaParser;
+import org.jboss.encore.grammar.java.Method;
+import org.jboss.encore.test.grammar.java.common.VisibilityTest;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public class MethodVisibilityTest extends VisibilityTest
+{
+   @Override
+   public void resetTests()
+   {
+      InputStream stream = MethodVisibilityTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockAnnotatedMethod.java");
+      Method method = JavaParser.parse(stream).getMethods().get(0);
+      setTarget(method);
+   }
+}

Copied: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/AnnotationTest.java (from rev 13560, sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/AnnotationTest.java)
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/AnnotationTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/AnnotationTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jboss.encore.grammar.java.Annotation;
+import org.jboss.encore.grammar.java.AnnotationTarget;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public abstract class AnnotationTest
+{
+   private AnnotationTarget<?> target;
+
+   public void setTarget(AnnotationTarget<?> target)
+   {
+      this.target = target;
+   }
+
+   @Before
+   public void reset()
+   {
+      resetTests();
+   }
+
+   public abstract void resetTests();
+
+   @Test
+   public void testParseAnnotation() throws Exception
+   {
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(3, annotations.size());
+      assertEquals("deprecation", annotations.get(1).getStringValue());
+      assertEquals("deprecation", annotations.get(1).getStringValue("value"));
+      assertEquals("value", annotations.get(1).getValues().get(0).getName());
+      assertEquals("deprecation", annotations.get(1).getValues().get(0).getStringValue());
+
+      assertEquals("unchecked", annotations.get(2).getStringValue("value"));
+      assertEquals("unchecked", annotations.get(2).getStringValue());
+      assertEquals("value", annotations.get(2).getValues().get(0).getName());
+      assertEquals("unchecked", annotations.get(2).getValues().get(0).getStringValue());
+   }
+
+   @Test
+   public void testAddAnnotation() throws Exception
+   {
+      int size = target.getAnnotations().size();
+      target.addAnnotation().setName("RequestScoped");
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 1, annotations.size());
+      assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
+   }
+
+   @Test
+   public void testAddAnnotationByClass() throws Exception
+   {
+      int size = target.getAnnotations().size();
+      target.addAnnotation(Test.class);
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 1, annotations.size());
+      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
+      target.applyChanges();
+      assertTrue(target.toString().contains("@" + Test.class.getName()));
+   }
+
+   @Test
+   public void testAddAnnotationByName() throws Exception
+   {
+      int size = target.getAnnotations().size();
+      target.addAnnotation("RequestScoped");
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 1, annotations.size());
+      assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
+      target.applyChanges();
+      assertTrue(target.toString().contains("@RequestScoped"));
+   }
+
+   @Test
+   public void testCanAddAnnotationDuplicate() throws Exception
+   {
+      int size = target.getAnnotations().size();
+      target.addAnnotation(Test.class);
+      target.addAnnotation(Test.class);
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 2, annotations.size());
+      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
+      assertEquals(Test.class.getName(), annotations.get(annotations.size() - 2).getName());
+      target.applyChanges();
+      String pattern = "@" + Test.class.getName() + " " + "@" + Test.class.getName();
+      assertTrue(target.toString().contains(pattern));
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testCannotAddAnnotationWithIllegalName() throws Exception
+   {
+      target.addAnnotation("sdf*(&#$%");
+   }
+
+   @Test
+   public void testAddLiteralValue() throws Exception
+   {
+      int size = target.getAnnotations().size();
+
+      target.addAnnotation(Test.class).setLiteralValue("435");
+      target.applyChanges();
+
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 1, annotations.size());
+
+      Annotation annotation = annotations.get(annotations.size() - 1);
+      assertEquals(Test.class.getName(), annotation.getName());
+      assertEquals("435", annotation.getLiteralValue());
+   }
+
+   @Test
+   public void testAddObjectValue() throws Exception
+   {
+      int size = target.getAnnotations().size();
+
+      target.addAnnotation(Test.class).setLiteralValue("expected", "RuntimeException.class").setLiteralValue("foo", "bar");
+      target.applyChanges();
+
+      List<Annotation> annotations = target.getAnnotations();
+      assertEquals(size + 1, annotations.size());
+
+      Annotation annotation = annotations.get(annotations.size() - 1);
+      assertEquals(Test.class.getName(), annotation.getName());
+      assertEquals(null, annotation.getLiteralValue());
+      assertEquals("RuntimeException.class", annotation.getLiteralValue("expected"));
+      assertEquals("bar", annotation.getLiteralValue("foo"));
+   }
+
+   @Test
+   public void testAddValueConvertsToNormalAnnotation() throws Exception
+   {
+      target.addAnnotation(Test.class).setLiteralValue("RuntimeException.class");
+      target.applyChanges();
+      Annotation annotation = target.getAnnotations().get(target.getAnnotations().size() - 1);
+
+      assertEquals("RuntimeException.class", annotation.getLiteralValue());
+      assertTrue(annotation.isSingleValue());
+
+      annotation.setLiteralValue("foo", "bar");
+      assertFalse(annotation.isSingleValue());
+      assertTrue(annotation.isNormal());
+
+      assertEquals("RuntimeException.class", annotation.getLiteralValue());
+      assertEquals("RuntimeException.class", annotation.getLiteralValue("value"));
+      assertEquals("bar", annotation.getLiteralValue("foo"));
+   }
+
+   @Test
+   public void testAnnotationBeginsAsMarker() throws Exception
+   {
+      Annotation anno = target.addAnnotation(Test.class);
+      assertTrue(anno.isMarker());
+      assertFalse(anno.isSingleValue());
+      assertFalse(anno.isNormal());
+
+      anno.setLiteralValue("\"Foo!\"");
+      assertFalse(anno.isMarker());
+      assertTrue(anno.isSingleValue());
+      assertFalse(anno.isNormal());
+
+      anno.setStringValue("bar", "Foo!");
+      assertFalse(anno.isMarker());
+      assertFalse(anno.isSingleValue());
+      assertTrue(anno.isNormal());
+
+      assertEquals("\"Foo!\"", anno.getLiteralValue("bar"));
+      assertEquals("Foo!", anno.getStringValue("bar"));
+
+      anno.removeAllValues();
+      assertTrue(anno.isMarker());
+      assertFalse(anno.isSingleValue());
+      assertFalse(anno.isNormal());
+   }
+
+   @Test
+   public void testRemoveAllValues() throws Exception
+   {
+      target.addAnnotation(Test.class).setLiteralValue("expected", "RuntimeException.class");
+      target.applyChanges();
+
+      List<Annotation> annotations = target.getAnnotations();
+      Annotation annotation = annotations.get(annotations.size() - 1);
+      annotation.removeAllValues();
+
+      assertEquals(0, annotation.getValues().size());
+   }
+}

Added: sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/VisibilityTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/VisibilityTest.java	                        (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/test/grammar/java/common/VisibilityTest.java	2010-08-06 18:43:46 UTC (rev 13571)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.encore.test.grammar.java.common;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.jboss.encore.grammar.java.VisibilityScoped;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter at gmail.com">Lincoln Baxter, III</a>
+ */
+public abstract class VisibilityTest
+{
+   private VisibilityScoped<?> target;
+
+   public void setTarget(VisibilityScoped<?> target)
+   {
+      this.target = target;
+   }
+
+   @Before
+   public void reset()
+   {
+      resetTests();
+   }
+
+   public abstract void resetTests();
+
+   @Test
+   public void testSetPublic() throws Exception
+   {
+      target.setPublic();
+      assertTrue(target.isPublic());
+      assertFalse(target.isPackagePrivate());
+      assertFalse(target.isPrivate());
+      assertFalse(target.isProtected());
+   }
+
+   @Test
+   public void testSetPrivate() throws Exception
+   {
+      target.setPrivate();
+      assertFalse(target.isPublic());
+      assertFalse(target.isPackagePrivate());
+      assertTrue(target.isPrivate());
+      assertFalse(target.isProtected());
+   }
+
+   @Test
+   public void testSetProtected() throws Exception
+   {
+      target.setProtected();
+      assertFalse(target.isPublic());
+      assertFalse(target.isPackagePrivate());
+      assertFalse(target.isPrivate());
+      assertTrue(target.isProtected());
+   }
+
+   @Test
+   public void testSetPackagePrivate() throws Exception
+   {
+      target.setPackagePrivate();
+      assertFalse(target.isPublic());
+      assertTrue(target.isPackagePrivate());
+      assertFalse(target.isPrivate());
+      assertFalse(target.isProtected());
+   }
+}



More information about the seam-commits mailing list