Select the correct constraint validator

[JSR 303 TCK Result] 105 of 257 (40.86%) Pass with 25 Failures and 9 Errors.
Review at http://gwt-code-reviews.appspot.com/1368801

Review by: rchandia@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9776 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java b/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java
index 59ec77a..1ac7e25 100644
--- a/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java
+++ b/user/src/com/google/gwt/validation/client/constraints/PatternValidator.java
@@ -41,7 +41,7 @@
   }
 
   public boolean isValid(String value, ConstraintValidatorContext context) {
-    return value == null || pattern.exec(value) != null;
+    return value == null || pattern.test(value);
   }
 
   private String toString(Flag flag) {
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java
index 14150b2..1feed92 100644
--- a/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java
+++ b/user/src/com/google/gwt/validation/client/impl/ConstraintDescriptorImpl.java
@@ -45,9 +45,16 @@
     private Set<Class<? extends Payload>> payload;
     private List<Class<? extends ConstraintValidator<T, ?>>> constraintValidatorClasses;
     private Map<String, Object> attributes;
-    private Set<ConstraintDescriptor<?>> composingConstraints;
+    private Set<ConstraintDescriptor<?>> composingConstraints =
+        new HashSet<ConstraintDescriptor<?>>();
     private boolean reportAsSingleViolation;
 
+    public Builder<T> addComposingConstraint(
+        ConstraintDescriptor<?> composingConstraint) {
+      this.composingConstraints.add(composingConstraint);
+      return this;
+    }
+
     public ConstraintDescriptorImpl<T> build() {
       return new ConstraintDescriptorImpl<T>(//
           annotation, //
@@ -69,9 +76,10 @@
       return this;
     }
 
-    public Builder<T> setComposingConstraints(
-        Set<ConstraintDescriptor<?>> composingConstraints) {
-      this.composingConstraints = composingConstraints;
+    public Builder<T> setConstraintValidatorClasses(
+        Class<? extends ConstraintValidator<T, ?>>[] constraintValidatorClasses) {
+      List<Class<? extends ConstraintValidator<T, ?>>> list = Arrays.asList(constraintValidatorClasses);
+      setConstraintValidatorClasses(list);
       return this;
     }
 
@@ -81,14 +89,8 @@
       return this;
     }
 
-    /**
-     * @param classes
-     * @return
-     */
-    public Builder<T> setConstraintValidatorClasses(
-        Class<? extends ConstraintValidator<T, ?>>[] constraintValidatorClasses) {
-      List<Class<? extends ConstraintValidator<T, ?>>> list = Arrays.asList(constraintValidatorClasses);
-      setConstraintValidatorClasses(list);
+    public Builder<T> setGroups(Class<?>[] classes) {
+      setGroups(new HashSet<Class<?>>(Arrays.asList(classes)));
       return this;
     }
 
@@ -97,8 +99,8 @@
       return this;
     }
 
-    public Builder<T> setGroups(Class<?>[] classes) {
-      setGroups(new HashSet<Class<?>>(Arrays.asList(classes)));
+    public Builder<T> setPayload(Class<? extends Payload>[] classes) {
+      setPayload(new HashSet<Class<? extends Payload>>(Arrays.asList(classes)));
       return this;
     }
 
@@ -107,11 +109,6 @@
       return this;
     }
 
-    public Builder<T> setPayload(Class<? extends Payload>[] classes) {
-      setPayload(new HashSet<Class<? extends Payload>>(Arrays.asList(classes)));
-      return this;
-    }
-
     public Builder<T> setReportAsSingleViolation(boolean reportAsSingleViolation) {
       this.reportAsSingleViolation = reportAsSingleViolation;
       return this;
@@ -181,6 +178,6 @@
    */
   @Override
   public String toString() {
-    return annotation + " " + attributes;
+    return String.valueOf(annotation);
   }
 }
diff --git a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java b/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java
index 2aa2cd9..0acd234 100644
--- a/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java
+++ b/user/src/com/google/gwt/validation/client/impl/ConstraintViolationImpl.java
@@ -171,6 +171,6 @@
     return "message= " + message //
         + ", path= " + propertyPath //
         + ", invalidValue=" + invalidValue //
-        + " , desc=" + constraintDescriptor;
+        + ", desc=" + constraintDescriptor;
   }
 }
diff --git a/user/src/com/google/gwt/validation/rebind/BeanHelper.java b/user/src/com/google/gwt/validation/rebind/BeanHelper.java
index 48b0494..af494e6 100644
--- a/user/src/com/google/gwt/validation/rebind/BeanHelper.java
+++ b/user/src/com/google/gwt/validation/rebind/BeanHelper.java
@@ -69,6 +69,13 @@
     }
   };
 
+  /**
+   * Visible for testing
+   */
+  public static void clearBeanHelpersForTests() {
+    threadLocalHelperMap.get().clear();
+  }
+
   public static BeanHelper createBeanHelper(Class<?> clazz, TreeLogger logger,
       GeneratorContext context) throws UnableToCompleteException {
     JClassType beanType = context.getTypeOracle().findType(
@@ -253,7 +260,7 @@
   }
 
   public String getValidatorInstanceName() {
-    return makeJavaSafe(jClass.getName().toLowerCase() + "Validator");
+    return getFullyQualifiedValidatorName() + ".INSTANCE";
   }
 
   public String getValidatorName() {
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
index d16aa69..109fd45 100644
--- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
+++ b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
@@ -34,9 +34,12 @@
 import com.google.gwt.thirdparty.guava.common.base.Joiner;
 import com.google.gwt.thirdparty.guava.common.base.Predicate;
 import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
+import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
 import com.google.gwt.thirdparty.guava.common.collect.Iterables;
 import com.google.gwt.thirdparty.guava.common.collect.Maps;
+import com.google.gwt.thirdparty.guava.common.collect.Ordering;
 import com.google.gwt.thirdparty.guava.common.collect.Sets;
+import com.google.gwt.thirdparty.guava.common.primitives.Primitives;
 import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
 import com.google.gwt.user.rebind.SourceWriter;
 import com.google.gwt.validation.client.impl.AbstractGwtSpecificValidator;
@@ -64,6 +67,7 @@
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintViolation;
 import javax.validation.Payload;
+import javax.validation.UnexpectedTypeException;
 import javax.validation.Valid;
 import javax.validation.ValidationException;
 import javax.validation.metadata.BeanDescriptor;
@@ -191,40 +195,71 @@
         "ConstraintValidators must have a isValid method");
   }
   // Visible for testing
-  static <A extends Annotation> Class<? extends ConstraintValidator<A, ?>> getValidatorForType(
+  static <A extends Annotation> ImmutableSet<Class<? extends ConstraintValidator<A, ?>>> getValidatorForType(
       Class<?> type,
       List<Class<? extends ConstraintValidator<A, ?>>> constraintValidatorClasses) {
+    type = Primitives.wrap(type);
     Map<Class<?>, Class<? extends ConstraintValidator<A, ?>>> map = Maps.newHashMap();
     for (Class<? extends ConstraintValidator<A, ?>> constraintClass : constraintValidatorClasses) {
-      Class<?> aType = getTypeOfConstraintValidator(constraintClass);
+      Class<?> aType = Primitives.wrap(getTypeOfConstraintValidator(constraintClass));
       if (aType.isAssignableFrom(type)) {
         map.put(aType, constraintClass);
       }
     }
-    Class<?> best = null;
-    for (Class<?> c : map.keySet()) {
-      if (best == null) {
-        best = c;
-      } else {
-        if (c.equals(type)) {
-          best = c;
-          break; // Exact match we can stop
-        }
-        // TODO(nchalko) implement per spec
-        // is the new one better than the last.
+    // TODO(nchalko) implement per spec
+    // Handle Arrays and Generics
+
+    final Set<Class<?>> best = Util.findBestMatches(type, map.keySet());
+
+    Predicate<Class<?>> inBest = new Predicate<Class<?>>() {
+
+      @Override
+      public boolean apply(Class<?> key) {
+        return best.contains(key);
       }
-    }
-    return map.get(best);
+    };
+    return ImmutableSet.copyOf(Maps.filterKeys(map, inBest).values());
   }
 
+  /**
+   * Gets the best {@link ConstraintValidator}.
+   * 
+   * <p>
+   * The ConstraintValidator chosen to validate a declared type
+   * {@code targetType} is the one where the type supported by the
+   * ConstraintValidator is a supertype of {@code targetType} and where there is
+   * no other ConstraintValidator whose supported type is a supertype of
+   * {@code type} and not a supertype of the chosen ConstraintValidator
+   * supported type.
+   * 
+   * @param constraint the constraint to find ConstraintValidators for.
+   * @param targetType The type to find a ConstraintValidator for.
+   * @return ConstraintValidator
+   * 
+   * @throws UnexpectedTypeException if there is not exactly one maximally
+   *           specific constraint validator for targetType.
+   */
   private static <A extends Annotation> Class<? extends ConstraintValidator<A, ?>> getValidatorForType(
-      ConstraintDescriptor<A> constraint, Class<?> clazz) {
+      ConstraintDescriptor<A> constraint, Class<?> targetType)
+      throws UnexpectedTypeException {
     List<Class<? extends ConstraintValidator<A, ?>>> constraintValidatorClasses
         = constraint.getConstraintValidatorClasses();
     if (constraintValidatorClasses.isEmpty()) {
-      return null;
+      throw new UnexpectedTypeException("No ConstraintValidator found for  "
+          + constraint.getAnnotation());
     }
-    return getValidatorForType(clazz, constraintValidatorClasses);
+    ImmutableSet<Class<? extends ConstraintValidator<A, ?>>> best = getValidatorForType(
+        targetType, constraintValidatorClasses);
+    if (best.isEmpty()) {
+      throw new UnexpectedTypeException("No " + constraint.getAnnotation()
+          + " ConstraintValidator for type " + targetType);
+    }
+    if (best.size() > 1) {
+      throw new UnexpectedTypeException("More than one maximally specific "
+          + constraint.getAnnotation() + " ConstraintValidator for type "
+          + targetType + ", found " + Ordering.usingToString().sortedCopy(best));
+    }
+    return Iterables.get(best, 0);
   }
 
   private final BeanHelper beanHelper;
@@ -278,10 +313,6 @@
     // Write the wrappers after we know which are needed
     writeWrappers(sw);
     sw.println();
-
-    // Write the Validator instance variables after we have collected the
-    // ones we need in beansToValidate
-    writeValidatorInstances(sw);
   }
 
   protected void writeUnsafeNativeLongIfNeeded(SourceWriter sw, JType jType) {
@@ -448,7 +479,8 @@
   private void writeBeanDescriptor(SourceWriter sw) {
     BeanDescriptor beanDescriptor = beanHelper.getBeanDescriptor();
 
-    // GwtBeanDescriptor <MyBean> beanDescriptor =
+    // private final GwtBeanDescriptor <MyBean> beanDescriptor =
+    sw.print("private final ");
     sw.print(GwtBeanDescriptor.class.getCanonicalName());
     sw.print("<" + beanHelper.getTypeCanonicalName() + ">");
     sw.println(" beanDescriptor = ");
@@ -465,7 +497,7 @@
     sw.println(".setConstrained(" + beanDescriptor.isBeanConstrained() + ")");
 
     int count = 0;
-    for (ConstraintDescriptor<? extends Annotation>constraint : beanDescriptor.getConstraintDescriptors()) {
+    for (ConstraintDescriptor<? extends Annotation> constraint : beanDescriptor.getConstraintDescriptors()) {
       // .add(c0)
       sw.println(".add(" + constraintDescriptorVar("this", count++) + ")");
     }
@@ -531,7 +563,8 @@
           constraintDescripotorVar + "_" + count++);
     }
 
-    // ConstraintDescriptorImpl<MyAnnotation> constraintDescriptor = ;
+    // private final ConstraintDescriptorImpl<MyAnnotation> constraintDescriptor = ;
+    sw.print("private final ");
     sw.print(ConstraintDescriptorImpl.class.getCanonicalName());
     sw.print("<");
 
@@ -584,6 +617,14 @@
         new Class[0])));
     sw.println(")");
 
+    int ccCount = constraint.getComposingConstraints().size();
+    for (int i = 0; i < ccCount; i++) {
+      // .addComposingConstraint(cX_X)
+      sw.print(".addComposingConstraint(");
+      sw.print(constraintDescripotorVar + "_" + i);
+      sw.println(")");
+    }
+
     // .getGroups(groups)
     sw.print(".setGroups(");
     Set<Class<?>> groups = constraint.getGroups();
@@ -596,7 +637,7 @@
     sw.print(asLiteral(asArray(payload, new Class[0])));
     sw.println(")");
 
-    // .setsetReportAsSingleViolation(boolean )
+    // .setReportAsSingleViolation(boolean )
     sw.print(".setReportAsSingleViolation(");
     sw.print(Boolean.valueOf(constraint.isReportAsSingleViolation())
         .toString());
@@ -615,7 +656,6 @@
   private void writeFields(SourceWriter sw) throws UnableToCompleteException {
 
     // Create a static array of all valid property names.
-
     BeanInfo beanInfo;
     try {
       beanInfo = Introspector.getBeanInfo(beanHelper.getClazz());
@@ -623,15 +663,29 @@
       throw error(logger, e);
     }
 
-    // java.util.List<String> allPropertyNames = java.util.Arrays.asList(
-    sw.print("java.util.List<String> allPropertyNames = java.util.Arrays.asList(");
+    // private static final java.util.List<String> ALL_PROPERTY_NAMES =
+    sw.println("private static final java.util.List<String> ALL_PROPERTY_NAMES = ");
+    sw.indent();
+    sw.indent();
+
+    // Collections.<String>unmodifiableList(
+    sw.println("java.util.Collections.<String>unmodifiableList(");
+    sw.indent();
+    sw.indent();
+
+    // java.util.Arrays.<String>asList(
+    sw.print("java.util.Arrays.<String>asList(");
 
     // "foo","bar" );
     sw.print(Joiner.on(",").join(
         Iterables.transform(
             ImmutableList.copyOf(beanInfo.getPropertyDescriptors()),
             Functions.compose(TO_LITERAL, PROPERTY_DESCRIPTOR_TO_NAME))));
-    sw.println(");");
+    sw.println("));");
+    sw.outdent();
+    sw.outdent();
+    sw.outdent();
+    sw.outdent();
 
     // Create a variable for each constraint of each property
     for (PropertyDescriptor p :
@@ -726,8 +780,8 @@
   }
 
   private void writeIfPropertyNameNotFound(SourceWriter sw) {
-    // if (!allPropertyNames.contains(propertyName)) {
-    sw.println(" if (!allPropertyNames.contains(propertyName)) {");
+    // if (!ALL_PROPERTY_NAMES.contains(propertyName)) {
+    sw.println(" if (!ALL_PROPERTY_NAMES.contains(propertyName)) {");
     sw.indent();
 
     // throw new IllegalArgumentException(propertyName
@@ -809,7 +863,8 @@
    * @param p
    */
   private void writePropertyDescriptor(SourceWriter sw, PropertyDescriptor p) {
-    // PropertyDescriptor myProperty_pd =
+    // private final PropertyDescriptor myProperty_pd =
+    sw.print("private final ");
     sw.print(PropertyDescriptor.class.getCanonicalName());
     sw.print(" ");
     sw.print(p.getPropertyName());
@@ -895,17 +950,14 @@
     }
 
     // all class level constraints
-
-
     int count = 0;
     Class<?> clazz = beanHelper.getClazz();
     for (ConstraintDescriptor<?> constraint : beanHelper.getBeanDescriptor().getConstraintDescriptors()) {
       if (hasMatchingAnnotation(constraint)) {
-        Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass = getValidatorForType(
-            constraint, clazz);
-        if (validatorClass != null) {
-          // TODO(nchalko) handle constraint.isReportAsSingleViolation() and
-          // hasComposingConstraints
+
+        if (!constraint.getConstraintValidatorClasses().isEmpty()) {
+          Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass = getValidatorForType(
+              constraint, clazz);
 
           // validate(context, violations, null, object,
           sw.print("validate(context, violations, null, object, ");
@@ -913,18 +965,18 @@
           // new MyValidtor();
           sw.print("new ");
           sw.print(validatorClass.getCanonicalName());
-          sw.print("(), "); // new one each time because validators are not
-                            // thread
-                            // safe
+          sw.print("(), "); // TODO(nchalko) use ConstraintValidatorFactory
 
           // this.aConstraintDescriptor, groups);;
           sw.print(constraintDescriptorVar("this", count));
           sw.println(", groups);");
-        } else {
+        } else if (constraint.getComposingConstraints().isEmpty()) {
           // TODO(nchalko) What does the spec say to do here.
           logger.log(Type.WARN, "No ConstraintValidator of " + constraint
               + " for type " + clazz);
         }
+        // TODO(nchalko) handle constraint.isReportAsSingleViolation() and
+        // hasComposingConstraints
       }
       count++;
     }
@@ -944,27 +996,30 @@
 
   private void writeValidateConstraint(SourceWriter sw, PropertyDescriptor p,
       Class<?> elementClass, ConstraintDescriptor<?> constraint,
-      String constraintDescriptorVar) {
-    Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass =
-        getValidatorForType(constraint, elementClass);
-    if (validatorClass == null) {
-      // TODO(nchalko) What does the spec say to do here.
-      logger.log(Type.WARN, "No ConstraintValidator of " + constraint + " for "
-          + p.getPropertyName() + " of type " + elementClass);
+      String constraintDescriptorVar) throws UnableToCompleteException {
+    if (!constraint.getConstraintValidatorClasses().isEmpty()) {
 
-    } else {
-      // TODO(nchalko) handle constraint.isReportAsSingleViolation()
+      Class<? extends ConstraintValidator<? extends Annotation, ?>> validatorClass;
+      try {
+        validatorClass = getValidatorForType(constraint, elementClass);
+      } catch (UnexpectedTypeException e) {
+        throw error(logger, e);
+      }
+
       // validate(myContext, violations, object, value, new MyValidator(),
       // constraintDescriptor, groups);
       sw.print("validate(myContext, violations, object, value, ");
-      sw.print("new "); // new one each time because validators are not
-                        // thread safe
-                        // TODO(nchalko) use ConstraintValidatorFactory
+      sw.print("new "); // TODO(nchalko) use ConstraintValidatorFactory
       sw.print(validatorClass.getCanonicalName());
       sw.print("(), ");
       sw.print(constraintDescriptorVar);
       sw.println(", groups);");
+    } else if (constraint.getComposingConstraints().isEmpty()) {
+        // TODO(nchalko) What does the spec say to do here.
+        logger.log(Type.WARN, "No ConstraintValidator of " + constraint
+            + " for " + p.getPropertyName() + " of type " + elementClass);
     }
+    // TODO(nchalko) handle constraint.isReportAsSingleViolation()
     int count = 0;
     for (ConstraintDescriptor<?> compositeConstraint : constraint.getComposingConstraints()) {
       String compositeVar = constraintDescriptorVar + "_" + count++;
@@ -1433,13 +1488,6 @@
     }
   }
 
-  private void writeValidatorInstances(SourceWriter sw) {
-    sw.println("// The validator instance variables are written last ");
-    sw.println("// after we have identified all the ones we need.");
-    for (BeanHelper helper : beansToValidate) {
-      writeValidatorInstance(sw, helper);
-    }
-  }
 
   private void writeWrappers(SourceWriter sw) {
     sw.println("// Write the wrappers after we know which are needed");
diff --git a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java b/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java
index c1dc0f1..83ffd12 100644
--- a/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java
+++ b/user/src/com/google/gwt/validation/rebind/ValidatorGenerator.java
@@ -34,12 +34,11 @@
   @Override
   public String generate(TreeLogger logger, GeneratorContext context,
       String typeName) throws UnableToCompleteException {
-    JClassType validatorType = context.getTypeOracle().findType(typeName);
     TypeOracle typeOracle = context.getTypeOracle();
     assert (typeOracle != null);
 
-    JClassType validator = typeOracle.findType(typeName);
-    if (validator == null) {
+    JClassType validatorType = typeOracle.findType(typeName);
+    if (validatorType == null) {
       logger.log(TreeLogger.ERROR, "Unable to find metadata for type '"
           + typeName + "'", null);
       throw new UnableToCompleteException();
@@ -61,7 +60,7 @@
     }
 
     TreeLogger validatorLogger = logger.branch(TreeLogger.DEBUG,
-        "Generating Validator for  '" + validator.getQualifiedSourceName()
+        "Generating Validator for  '" + validatorType.getQualifiedSourceName()
             + "'", null);
     AbstractCreator creator = new ValidatorCreator(validatorType,
         gwtValidation,
diff --git a/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java b/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java
index 06f5b14..7f735d4 100644
--- a/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java
+++ b/user/test/com/google/gwt/validation/rebind/GwtSpecificValidatorCreatorTest.java
@@ -18,6 +18,7 @@
 import static com.google.gwt.validation.rebind.GwtSpecificValidatorCreator.getValidatorForType;
 
 import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
+import com.google.gwt.thirdparty.guava.common.collect.ImmutableSet;
 import com.google.gwt.validation.client.constraints.SizeValidatorForCollection;
 import com.google.gwt.validation.client.constraints.SizeValidatorForString;
 
@@ -25,6 +26,7 @@
 
 import java.lang.annotation.Annotation;
 import java.util.List;
+import java.util.Set;
 
 import javax.validation.ConstraintValidator;
 import javax.validation.constraints.Size;
@@ -34,20 +36,26 @@
  */
 public class GwtSpecificValidatorCreatorTest extends TestCase {
 
+  private static Set<Class<? extends ConstraintValidator<? extends Annotation, ?>>> copyOf(
+      Class<? extends ConstraintValidator<? extends Annotation, ?>>... classes) {
+    return ImmutableSet.copyOf(classes);
+  }
+
   ImmutableList<Class<? extends ConstraintValidator<Size, ?>>> sizeValidators = ImmutableList.<Class<? extends ConstraintValidator<Size, ?>>> of(
       SizeValidatorForCollection.class, SizeValidatorForString.class);
 
+  @SuppressWarnings("unchecked")
   public void testGetValidatorForType_collection() throws Exception {
-    Class<? extends ConstraintValidator<? extends Annotation, ?>> expected = SizeValidatorForCollection.class;
-    Class<? extends ConstraintValidator<Size, ?>> actual = getValidatorForType(
+    ImmutableSet<Class<? extends ConstraintValidator<Size, ?>>> actual = getValidatorForType(
         List.class, sizeValidators);
-    assertEquals(expected, actual);
+    assertEquals(copyOf(SizeValidatorForCollection.class), actual);
   }
 
+  @SuppressWarnings("unchecked")
   public void testGetValidatorForType_string() throws Exception {
     Class<String> target = String.class;
-    Class<? extends ConstraintValidator<Size, ?>> actual = getValidatorForType(
+    ImmutableSet<Class<? extends ConstraintValidator<Size, ?>>> actual = getValidatorForType(
         target, sizeValidators);
-    assertEquals(SizeValidatorForString.class, actual);
+    assertEquals(copyOf(SizeValidatorForString.class), actual);
   }
 }
diff --git a/user/test/com/google/gwt/validation/tck/ConstraintCompositionGwtSuite.java b/user/test/com/google/gwt/validation/tck/ConstraintCompositionGwtSuite.java
index c5d791b..0a798ab 100644
--- a/user/test/com/google/gwt/validation/tck/ConstraintCompositionGwtSuite.java
+++ b/user/test/com/google/gwt/validation/tck/ConstraintCompositionGwtSuite.java
@@ -18,6 +18,7 @@
 
 import junit.framework.Test;
 
+import org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.ConstraintCompositionCompileTest;
 import org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.ConstraintCompositionGwtTest;
 import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper;
 
@@ -28,6 +29,7 @@
   public static Test suite() {
     TckTestSuiteWrapper suite = new TckTestSuiteWrapper(
         "TCK for GWT Validation, constraints composition package");
+    suite.addTestSuite(ConstraintCompositionCompileTest.class);
     suite.addTestSuite(ConstraintCompositionGwtTest.class);
     return suite;
   }
diff --git a/user/test/com/google/gwt/validation/tck/ValidatorResolutionGwtSuite.java b/user/test/com/google/gwt/validation/tck/ValidatorResolutionGwtSuite.java
index 7a09f10..fb204fb 100644
--- a/user/test/com/google/gwt/validation/tck/ValidatorResolutionGwtSuite.java
+++ b/user/test/com/google/gwt/validation/tck/ValidatorResolutionGwtSuite.java
@@ -18,6 +18,7 @@
 
 import junit.framework.Test;
 
+import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionCompileTest;
 import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.ValidatorResolutionGwtTest;
 import org.hibernate.jsr303.tck.util.TckTestSuiteWrapper;
 
@@ -28,6 +29,7 @@
   public static Test suite() {
     TckTestSuiteWrapper suite = new TckTestSuiteWrapper(
         "TCK for GWT Validation, validator resolution package");
+    suite.addTestSuite(ValidatorResolutionCompileTest.class);
     suite.addTestSuite(ValidatorResolutionGwtTest.class);
     return suite;
   }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java
index c692f28..50ac06c 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementGwtTest.java
@@ -51,7 +51,6 @@
     delegate.testFieldAccess();
   }
 
-  @Failing(issue = 5798)
   public void testFieldAndPropertyVisibilityIsNotConstrained() {
     delegate.testFieldAndPropertyVisibilityIsNotConstrained();
   }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java
new file mode 100644
index 0000000..f4637a8
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.hibernate.jsr303.tck.tests.constraints.constraintcomposition;
+
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.util.UnitTestTreeLogger;
+
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.assertModuleFails;
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.getFullyQaulifiedModuleName;
+
+import org.hibernate.jsr303.tck.util.TckCompileTestCase;
+
+import javax.validation.UnexpectedTypeException;
+
+/**
+ * Test wrapper for {@link ConstraintCompositionTest} tests that are meant to
+ * fail to compile.
+ */
+public class ConstraintCompositionCompileTest extends TckCompileTestCase {
+
+  /**
+   * Replacement for
+   * {@link ConstraintCompositionTest#testAllComposingConstraintsMustBeApplicableToAnnotatedType()}
+   * 
+   * @throws UnableToCompleteException
+   */
+  public void testAllComposingConstraintsMustBeApplicableToAnnotatedType()
+      throws UnableToCompleteException {
+    UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
+    builder.expect(
+        Type.ERROR,
+        "No @org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.NotEmpty("
+            + "message={constraint.notEmpty}, payload=[], groups=[]) "
+            + "ConstraintValidator for type int", UnexpectedTypeException.class);
+    builder.setLowestLogLevel(Type.INFO);
+    UnitTestTreeLogger testLogger = builder.createLogger();
+    assertModuleFails(testLogger,
+        getFullyQaulifiedModuleName(getClass(), "MustBeApplicableTest"),
+        MustBeApplicableValidatorFactory.MustBeApplicableValidator.class,
+        Shoe.class);
+  }
+}
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
index 441a82d..dc1ed19 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -31,12 +31,6 @@
     return "org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.TckTest";
   }
 
-  @Failing(issue = 5799)
-  public void testAllComposingConstraintsMustBeApplicableToAnnotatedType() {
-    delegate.testAllComposingConstraintsMustBeApplicableToAnnotatedType();
-  }
-
-  @Failing(issue = 5799)
   public void testAttributesDefinedOnComposingConstraints() {
     delegate.testAttributesDefinedOnComposingConstraints();
   }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableTest.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableTest.gwt.xml
new file mode 100644
index 0000000..4d13849
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableTest.gwt.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd">
+<!--
+  Copyright 2010 Google Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License. You may obtain a copy of
+  the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+  License for the specific language governing permissions and limitations under
+  the License.
+-->
+<module>
+  <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
+  <source path="">
+    <include name="*.java" />
+    <exclude name="*CompileTest.java" />
+  </source>
+  <replace-with class="org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.MustBeApplicableValidatorFactory">
+    <when-type-is class="javax.validation.ValidatorFactory"/>
+  </replace-with>
+</module>
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableValidatorFactory.java
new file mode 100644
index 0000000..d3997fc
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableValidatorFactory.java
@@ -0,0 +1,29 @@
+package org.hibernate.jsr303.tck.tests.constraints.constraintcomposition;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
+import com.google.gwt.validation.client.GwtValidation;
+import com.google.gwt.validation.client.impl.AbstractGwtValidator;
+
+import javax.validation.Validator;
+
+/**
+ * {@link AbstractGwtValidatorFactory} implementation that uses
+ * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}.
+ */
+public final class MustBeApplicableValidatorFactory extends
+    AbstractGwtValidatorFactory {
+
+  /**
+   * Validator for
+   * {@link ConstraintCompositionTest#testAllComposingConstraintsMustBeApplicableToAnnotatedType()}
+   */
+  @GwtValidation(value = {Shoe.class})
+  public static interface MustBeApplicableValidator extends Validator {
+  }
+
+  @Override
+  public AbstractGwtValidator createValidator() {
+    return GWT.create(MustBeApplicableValidator.class);
+  }
+}
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml
index c2d6b12..f3c9ac1 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTest.gwt.xml
@@ -19,6 +19,7 @@
   <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
   <source path="">
     <include name="*.java" />
+    <exclude name="*CompileTest.java" />
   </source>
   <replace-with class="org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.TckTestValidatorFactory">
     <when-type-is class="javax.validation.ValidatorFactory"/>
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java
index 38aaa79..bca5b15 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/TckTestValidatorFactory.java
@@ -31,8 +31,7 @@
    * Marker Interface for {@link GWT#create(Class)}.
    */
   @GwtValidation(value = {
-      Address.class, FrenchAddress.class, Friend.class, GermanAddress.class,
-      Shoe.class
+      Address.class, FrenchAddress.class, Friend.class, GermanAddress.class
       // TODO(nchalko) handle ConstraintDefinitionException
       // ConstraintCompositionGwtTest.DummyEntityWithZipCode.class
   })
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java
new file mode 100644
index 0000000..68e65d8
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
+
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.util.UnitTestTreeLogger;
+
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.assertModuleFails;
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.getFullyQaulifiedModuleName;
+
+import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.OddShoe;
+import org.hibernate.jsr303.tck.util.TckCompileTestCase;
+
+import javax.validation.UnexpectedTypeException;
+
+/**
+ * Test wrapper for {@link CustomConstraintValidatorTest} that are meant to fail
+ * to compile.
+ */
+public class CustomConstraintValidatorCompileTest extends TckCompileTestCase {
+
+  /**
+   * Replacement for
+   * {@link CustomConstraintValidatorTest#testUnexpectedTypeExceptionIsRaisedForInvalidType()}
+   * 
+   * @throws UnableToCompleteException
+   */
+  public void testUnexpectedTypeExceptionIsRaisedForInvalidType()
+      throws UnableToCompleteException {
+    UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
+    builder.expect(
+        Type.ERROR,
+        "No @org.hibernate.jsr303.tck.tests.constraints.customconstraint.Positive("
+            + "message={validation.positive}, payload=[], groups=[]) "
+            + "ConstraintValidator for type class java.lang.String",
+        UnexpectedTypeException.class);
+    builder.setLowestLogLevel(Type.INFO);
+    UnitTestTreeLogger testLogger = builder.createLogger();
+    assertModuleFails(testLogger,
+        getFullyQaulifiedModuleName(getClass(), "TckCompileTest"),
+        TckCompileTestValidatorFactory.GwtValidator.class, OddShoe.class);
+  }
+}
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java
index 11aa059..ec4bc98 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorGwtTest.java
@@ -17,7 +17,7 @@
 
 import com.google.gwt.junit.client.GWTTestCase;
 
-import org.hibernate.jsr303.tck.util.client.Failing;
+import javax.validation.ValidationException;
 
 /**
  * Test wrapper for {@link CustomConstraintValidatorTest}.
@@ -34,7 +34,6 @@
     delegate.testDefaultPropertyPath();
   }
 
-  @Failing(issue = 5800)
   public void testIsValidIsCalledForEachValidation() {
     delegate.testIsValidIsCalledForEachValidation();
   }
@@ -47,20 +46,25 @@
     delegate.testOneConstraintViolationPerFailingConstraint();
   }
 
-  @Failing(issue = 5800)
   public void testRightValidatorIsSelectedAndInitializedCalled() {
     delegate.testRightValidatorIsSelectedAndInitializedCalled();
   }
 
   public void testRuntimeExceptionFromInitializeIsWrapped() {
-    delegate.testRuntimeExceptionFromInitializeIsWrapped();
+    try {
+      delegate.testRuntimeExceptionFromInitializeIsWrapped();
+      fail("Expected a " + ValidationException.class);
+    } catch (ValidationException expected) {
+      // expected
+    }
   }
 
   public void testRuntimeExceptionFromIsValidIsWrapped() {
-    delegate.testRuntimeExceptionFromIsValidIsWrapped();
-  }
-
-  public void testUnexpectedTypeExceptionIsRaisedForInvalidType() {
-    delegate.testUnexpectedTypeExceptionIsRaisedForInvalidType();
+    try {
+      delegate.testRuntimeExceptionFromIsValidIsWrapped();
+      fail("Expected a " + ValidationException.class);
+    } catch (ValidationException expected) {
+      // expected
+    }
   }
 }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTest.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTest.gwt.xml
new file mode 100644
index 0000000..82adec3
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTest.gwt.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd">
+<!--
+  Copyright 2010 Google Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License. You may obtain a copy of
+  the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+  License for the specific language governing permissions and limitations under
+  the License.
+-->
+<module>
+  <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
+  <source path="">
+    <include name="*.java" />
+    <exclude name="*CompileTest.java" />
+  </source>
+  <replace-with class="org.hibernate.jsr303.tck.tests.constraints.customconstraint.TckCompileTestValidatorFactory">
+    <when-type-is class="javax.validation.ValidatorFactory"/>
+  </replace-with>
+</module>
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTestValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTestValidatorFactory.java
new file mode 100644
index 0000000..ecfe8fc
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTestValidatorFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
+import com.google.gwt.validation.client.GwtValidation;
+import com.google.gwt.validation.client.impl.AbstractGwtValidator;
+
+import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.OddShoe;
+
+import javax.validation.Validator;
+
+/**
+ * {@link AbstractGwtValidatorFactory} implementation that uses
+ * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}.
+ */
+public final class TckCompileTestValidatorFactory extends AbstractGwtValidatorFactory {
+  /**
+   * Marker Interface to {@link GWT#create(Class)}.
+   */
+  @GwtValidation(value = {OddShoe.class})
+  public static interface GwtValidator extends Validator {
+  }
+
+  @Override
+  public AbstractGwtValidator createValidator() {
+    return GWT.create(GwtValidator.class);
+  }
+}
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml
index a1abcb7..37c38b9 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTest.gwt.xml
@@ -19,6 +19,7 @@
   <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
   <source path="">
     <include name="*.java" />
+    <exclude name="*CompileTest.java" />
   </source>
   <replace-with class="org.hibernate.jsr303.tck.tests.constraints.customconstraint.TckTestValidatorFactory">
     <when-type-is class="javax.validation.ValidatorFactory"/>
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java
index c224a78..49fb83c 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckTestValidatorFactory.java
@@ -21,7 +21,6 @@
 import com.google.gwt.validation.client.impl.AbstractGwtValidator;
 
 import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.Freezer;
-import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.OddShoe;
 import org.hibernate.jsr303.tck.tests.constraints.customconstraint.CustomConstraintValidatorTest.Shoe;
 
 import javax.validation.Validator;
@@ -34,8 +33,7 @@
   /**
    * Marker Interface to {@link GWT#create(Class)}.
    */
-  @GwtValidation(value = {
-      Author.class, Freezer.class, OddShoe.class, Shoe.class})
+  @GwtValidation(value = {Author.class, Freezer.class, Shoe.class})
   public static interface GwtValidator extends Validator {
   }
 
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.gwt.xml
new file mode 100644
index 0000000..c827904
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.gwt.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd">
+<!--
+  Copyright 2010 Google Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License. You may obtain a copy of
+  the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+  License for the specific language governing permissions and limitations under
+  the License.
+-->
+<module>
+  <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
+  <source path="">
+    <include name="*.java" />
+    <exclude name="*CompileTest.java" />
+  </source>
+  <replace-with class="org.hibernate.jsr303.tck.tests.constraints.validatorresolution.AmbiguousValidatorFactory">
+    <when-type-is class="javax.validation.ValidatorFactory"/>
+  </replace-with>
+</module>
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.java
new file mode 100644
index 0000000..a9db99e
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/AmbiguousValidatorFactory.java
@@ -0,0 +1,29 @@
+package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
+import com.google.gwt.validation.client.GwtValidation;
+import com.google.gwt.validation.client.impl.AbstractGwtValidator;
+
+import javax.validation.Validator;
+
+/**
+ * {@link AbstractGwtValidatorFactory} implementation that uses
+ * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}.
+ */
+public final class AmbiguousValidatorFactory extends
+    AbstractGwtValidatorFactory {
+
+  /**
+   * Validator for
+   * {@link ValidatorResolutionTest#testAmbiguousValidatorResolution()}
+   */
+  @GwtValidation(value = {Foo.class})
+  public static interface AmbiguousValidator extends Validator {
+  }
+
+  @Override
+  public AbstractGwtValidator createValidator() {
+    return GWT.create(AmbiguousValidator.class);
+  }
+}
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml
index 96c8942..52be2f1 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTest.gwt.xml
@@ -19,6 +19,7 @@
   <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
   <source path="">
     <include name="*.java" />
+    <exclude name="*CompileTest.java" />
   </source>
   <replace-with class="org.hibernate.jsr303.tck.tests.constraints.validatorresolution.TckTestValidatorFactory">
     <when-type-is class="javax.validation.ValidatorFactory"/>
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java
index 85e7c8b..0fba419 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/TckTestValidatorFactory.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -36,8 +36,8 @@
    * Marker Interface for {@link GWT#create(Class)}.
    */
   @GwtValidation(value = {
-      Bar.class, CustomClass.class, CustomInterfaceImpl.class, Foo.class,
-      MinMax.class, SubClassAHolder.class, SubClassBHolder.class, Suburb.class})
+      CustomClass.class, CustomInterfaceImpl.class, MinMax.class,
+      SubClassAHolder.class, SubClassBHolder.class, Suburb.class})
   public static interface GwtValidator extends Validator {
   }
 
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.gwt.xml b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.gwt.xml
new file mode 100644
index 0000000..8b73617
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.gwt.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.1/distro-source/core/src/gwt-module.dtd">
+<!--
+  Copyright 2010 Google Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License"); you may not
+  use this file except in compliance with the License. You may obtain a copy of
+  the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+  License for the specific language governing permissions and limitations under
+  the License.
+-->
+<module>
+  <inherits name="org.hibernate.jsr303.tck.tests.ValidationTck" />
+  <source path="">
+    <include name="*.java" />
+    <exclude name="*CompileTest.java" />
+  </source>
+  <replace-with class="org.hibernate.jsr303.tck.tests.constraints.validatorresolution.UnexectedTypeValidatorFactory">
+    <when-type-is class="javax.validation.ValidatorFactory"/>
+  </replace-with>
+</module>
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.java
new file mode 100644
index 0000000..e19d1e8
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.java
@@ -0,0 +1,29 @@
+package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
+import com.google.gwt.validation.client.GwtValidation;
+import com.google.gwt.validation.client.impl.AbstractGwtValidator;
+
+import javax.validation.Validator;
+
+/**
+ * {@link AbstractGwtValidatorFactory} implementation that uses
+ * {@link com.google.gwt.validation.client.GwtValidation GwtValidation}.
+ */
+public final class UnexpectedTypeValidatorFactory extends
+    AbstractGwtValidatorFactory {
+
+  /**
+   * Validator for
+   * {@link ValidatorResolutionTest#testUnexpectedTypeInValidatorResolution()}
+   */
+  @GwtValidation(value = {Bar.class})
+  public static interface UnexpectedTypeValidator extends Validator {
+  }
+
+  @Override
+  public AbstractGwtValidator createValidator() {
+    return GWT.create(UnexpectedTypeValidator.class);
+  }
+}
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java
new file mode 100644
index 0000000..bee414f
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
+
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.util.UnitTestTreeLogger;
+
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.assertModuleFails;
+import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.getFullyQaulifiedModuleName;
+
+import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.AmbiguousValidatorFactory.AmbiguousValidator;
+import org.hibernate.jsr303.tck.tests.constraints.validatorresolution.UnexpectedTypeValidatorFactory.UnexpectedTypeValidator;
+import org.hibernate.jsr303.tck.util.TckCompileTestCase;
+
+import javax.validation.ValidationException;
+
+/**
+ * Wraps {@link ValidatorResolutionTest} .
+ */
+public class ValidatorResolutionCompileTest extends TckCompileTestCase {
+
+  /**
+   * Replaces {@link ValidatorResolutionTest#testAmbiguousValidatorResolution()}
+   */
+  public void testAmbiguousValidatorResolution()
+      throws UnableToCompleteException {
+    UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
+    builder.expect(
+        Type.ERROR,
+        "More than one maximally specific "
+            + "@org.hibernate.jsr303.tck.tests.constraints.validatorresolution.Ambiguous"
+            + "(message=foobar, payload=[], groups=[]) "
+            + "ConstraintValidator for type "
+            + "class org.hibernate.jsr303.tck.tests.constraints.validatorresolution.Bar, "
+            + "found [class org.hibernate.jsr303.tck.tests.constraints.validatorresolution.Ambiguous$AmbiguousValidatorForDummy,"
+            + " class org.hibernate.jsr303.tck.tests.constraints.validatorresolution.Ambiguous$AmbiguousValidatorForSerializable]",
+        ValidationException.class);
+    builder.setLowestLogLevel(Type.INFO);
+    UnitTestTreeLogger testLogger = builder.createLogger();
+    assertModuleFails(
+        testLogger,
+        getFullyQaulifiedModuleName(getClass(),
+            AmbiguousValidatorFactory.class.getSimpleName()),
+        AmbiguousValidator.class, Foo.class);
+  }
+
+  public void testUnexpectedTypeInValidatorResolution()
+      throws UnableToCompleteException {
+    UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
+    builder.expect(
+        Type.ERROR,
+        "No @javax.validation.constraints.Size(message={javax.validation.constraints.Size.message},"
+            + " min=0, max=2147483647, payload=[], groups=[]) "
+            + "ConstraintValidator for type class java.lang.Integer",
+        ValidationException.class);
+    builder.setLowestLogLevel(Type.INFO);
+    UnitTestTreeLogger testLogger = builder.createLogger();
+    assertModuleFails(
+        testLogger,
+        getFullyQaulifiedModuleName(getClass(),
+            UnexpectedTypeValidatorFactory.class.getSimpleName()),
+        UnexpectedTypeValidator.class, Bar.class);
+  }
+}
diff --git a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java
index cfa7773..c7b7070 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionGwtTest.java
@@ -29,11 +29,6 @@
     return "org.hibernate.jsr303.tck.tests.constraints.validatorresolution.TckTest";
   }
 
-  @Failing(issue = 5806)
-  public void testAmbiguousValidatorResolution() {
-    delegate.testAmbiguousValidatorResolution();
-  }
-
   public void testResolutionOfMinMaxForDifferentTypes() {
     delegate.testResolutionOfMinMaxForDifferentTypes();
   }
@@ -59,8 +54,4 @@
     delegate.testTargetTypeIsInterface();
   }
 
-  @Failing(issue = 5806)
-  public void testUnexpectedTypeInValidatorResolution() {
-    delegate.testUnexpectedTypeInValidatorResolution();
-  }
 }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorGwtTest.java
index 89a0f39..28a7566 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorGwtTest.java
@@ -17,8 +17,6 @@
 
 import com.google.gwt.junit.client.GWTTestCase;
 
-import org.hibernate.jsr303.tck.util.client.Failing;
-
 /**
  * Test wrapper for {@link ConstraintDescriptorTest}.
  */
@@ -30,17 +28,14 @@
     return "org.hibernate.jsr303.tck.tests.metadata.TckTest";
   }
 
-  @Failing(issue = 5931)
   public void testAnnotationAndMapParametersReflectParameterOverriding() {
     delegate.testAnnotationAndMapParametersReflectParameterOverriding();
   }
 
-  @Failing(issue = 5931)
   public void testComposingConstraints() {
     delegate.testComposingConstraints();
   }
 
-  @Failing(issue = 5931)
   public void testComposingConstraintsPayload() {
     delegate.testComposingConstraintsPayload();
   }
@@ -49,7 +44,6 @@
     delegate.testDefaultGroupIsReturnedIfNoGroupSpecifiedInDeclaration();
   }
 
-  @Failing(issue = 5931)
   public void testEmptyComposingConstraints() {
     delegate.testEmptyComposingConstraints();
   }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java b/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
index 729031f..577229d 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
@@ -18,28 +18,22 @@
 import com.google.gwt.core.ext.TreeLogger.Type;
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.dev.util.UnitTestTreeLogger;
-import com.google.gwt.junit.client.GWTTestCase;
 
 import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.assertModuleFails;
 import static org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.getFullyQaulifiedModuleName;
 
+import org.hibernate.jsr303.tck.util.TckCompileTestCase;
+
 import javax.validation.ValidationException;
 
 /**
  * Test wrapper for {@link ValidateTest} methods that are suppose to fail to
  * compile.
  */
-public class ValidateCompileTest extends GWTTestCase {
-
-  @Override
-  public String getModuleName() {
-    return null; // null runs as normal JRE JunitTest
-  }
+public class ValidateCompileTest extends TckCompileTestCase {
 
   public void testValidatedPropertyDoesNotFollowJavaBeansConvention()
       throws UnableToCompleteException {
-    String moduleName = "TckCompileTest";
-
     UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
     builder.expect(
         Type.ERROR,
@@ -48,9 +42,8 @@
         ValidationException.class);
     builder.setLowestLogLevel(Type.INFO);
     UnitTestTreeLogger testLogger = builder.createLogger();
-    // TODO (nchalko) create this module in memory just for this test.
     assertModuleFails(testLogger,
-        getFullyQaulifiedModuleName(getClass(), moduleName),
+        getFullyQaulifiedModuleName(getClass(), "TckCompileTest"),
         TckCompileTestValidatorFactory.GwtValidator.class);
   }
 }
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationGwtTest.java
index 032d939..d275af9 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationGwtTest.java
@@ -35,7 +35,6 @@
     delegate.testContainedIterable();
   }
 
-  @Failing(issue = 5946)
   public void testContainedMap() {
     delegate.testContainedMap();
   }
@@ -56,6 +55,7 @@
 
   @Failing(issue = 5946)
   public void testNoEndlessLoop() {
+    fail("Fail early so othe tests pass");
     delegate.testNoEndlessLoop();
   }
 
@@ -68,7 +68,6 @@
     delegate.testTypeOfContainedValueIsDeterminedAtRuntime();
   }
 
-  @Failing(issue = 5946)
   public void testTypeOfContainedValuesIsDeterminedAtRuntime() {
     delegate.testTypeOfContainedValuesIsDeterminedAtRuntime();
   }
diff --git a/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/TckTestValidatorFactory.java b/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/TckTestValidatorFactory.java
index 4ce7357..5baadb2 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/TckTestValidatorFactory.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/validation/graphnavigation/TckTestValidatorFactory.java
@@ -33,7 +33,7 @@
   @GwtValidation(value = {
       AnimalCaretaker.class, Condor.class, Elephant.class, GameReserve.class,
       MultiCage.class, MultiCage.class, Parent.class, SingleCage.class,
-      Zebra.class, Zoo.class})
+      User.class, Zebra.class, Zoo.class})
   public static interface GwtValidator extends Validator {
   }
 
diff --git a/user/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java
index 6b4569e..480da20 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorGwtTest.java
@@ -32,15 +32,17 @@
     return "org.hibernate.jsr303.tck.tests.validatorfactory.TckTest";
   }
 
-  @Failing(issue = 5805)
+
   public void testDefaultConstructorInValidatorCalled() {
     delegate.testDefaultConstructorInValidatorCalled();
   }
 
+  @Failing(issue = 5805)
   public void testRuntimeExceptionInValidatorCreationIsWrapped() {
     delegate.testRuntimeExceptionInValidatorCreationIsWrapped();
   }
 
+  @Failing(issue = 5805)
   public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() {
     delegate.testValidationExceptionIsThrownInCaseFactoryReturnsNull();
   }
diff --git a/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java b/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java
new file mode 100644
index 0000000..71740ac
--- /dev/null
+++ b/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */package org.hibernate.jsr303.tck.util;
+
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.validation.rebind.BeanHelper;
+
+/**
+ * Abstract TestCase for TCK tests that are expected to fail to compile.
+ */
+public abstract class TckCompileTestCase extends GWTTestCase {
+
+  public TckCompileTestCase() {
+    super();
+  }
+
+  @Override
+  public final String getModuleName() {
+    return null; // Run as JRE tests
+  }
+
+  @Override
+  protected void gwtSetUp() throws Exception {
+    super.gwtSetUp();
+    BeanHelper.clearBeanHelpersForTests();
+  }
+
+  @Override
+  protected void gwtTearDown() throws Exception {
+   BeanHelper.clearBeanHelpersForTests();
+    super.gwtTearDown();
+  }
+
+}
\ No newline at end of file
diff --git a/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java b/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
index 46cee98..66908c6 100644
--- a/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
+++ b/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
@@ -23,6 +23,10 @@
 import com.google.gwt.dev.javac.StandardGeneratorContext;
 import com.google.gwt.dev.shell.FailErrorLogger;
 import com.google.gwt.dev.util.UnitTestTreeLogger;
+import com.google.gwt.dev.util.log.CompositeTreeLogger;
+import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
+import com.google.gwt.validation.rebind.BeanHelper;
+import com.google.gwt.validation.rebind.GwtSpecificValidatorGenerator;
 import com.google.gwt.validation.rebind.ValidatorGenerator;
 
 import junit.framework.Assert;
@@ -36,6 +40,8 @@
  */
 public class TckGeneratorTestUtils {
 
+  private final static boolean LOG_TO_CONSOLE = false;
+
   /**
    * Asserts that calling
    * {@link ValidatorGenerator#generate(TreeLogger, com.google.gwt.core.ext.GeneratorContext, String)}
@@ -52,20 +58,50 @@
       String fullyQaulifiedModuleName,
       Class<? extends Validator> validatorClass)
       throws UnableToCompleteException {
-    TreeLogger logger = new FailErrorLogger();
-    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
-        fullyQaulifiedModuleName);
-    File genDir = new File(System.getProperty("java.io.tmpdir"));
-    ArtifactSet allGenreatedArtifacts = new ArtifactSet();
-    boolean isProd = false;
-    StandardGeneratorContext context = new StandardGeneratorContext(
-        module.getCompilationState(logger), module, genDir,
-        allGenreatedArtifacts, isProd);
-
+    TreeLogger logger = createFailLogger();
+    StandardGeneratorContext context = createGeneratorContext(
+        fullyQaulifiedModuleName, logger);
     ValidatorGenerator generator = new ValidatorGenerator();
     try {
-      generator.generate(testLogger, context,
-          validatorClass.getCanonicalName());
+      generator.generate(testLogger, context, validatorClass.getCanonicalName());
+      context.finish(logger);
+      Assert.fail("Expected a " + UnableToCompleteException.class);
+    } catch (UnableToCompleteException expected) {
+      // expected
+    }
+    testLogger.assertCorrectLogEntries();
+  }
+
+  /**
+   * Asserts that calling
+   * {@link ValidatorGenerator#generate(TreeLogger, com.google.gwt.core.ext.GeneratorContext, String)}
+   * causes a {@link UnableToCompleteException} with exactly the log messages
+   * specified in {@code testLogger}.
+   * 
+   * @param testLogger test logger with expected log messages set.
+   * @param fullyQaulifiedModuleName the gwt Module to load.
+   * @param validatorClass the Validator to generate.
+   * @param beanType the type of bean to create a validator for.
+   * @throws UnableToCompleteException if The module or derived CompilationState
+   *           can not be loaded.
+   */
+  public static void assertModuleFails(UnitTestTreeLogger testLogger,
+      String fullyQaulifiedModuleName,
+      Class<? extends Validator> validatorClass, Class<?> beanType)
+      throws UnableToCompleteException {
+    TreeLogger logger = createFailLogger();
+    StandardGeneratorContext context = createGeneratorContext(
+        fullyQaulifiedModuleName, logger);
+
+    ValidatorGenerator generator = new ValidatorGenerator();
+    GwtSpecificValidatorGenerator specificGenerator = new GwtSpecificValidatorGenerator();
+    generator.generate(testLogger, context, validatorClass.getCanonicalName());
+    context.finish(logger);
+    try {
+      specificGenerator.generate(
+          testLogger,
+          context,
+          BeanHelper.createBeanHelper(beanType, testLogger, context).getFullyQualifiedValidatorName());
       Assert.fail("Expected a " + UnableToCompleteException.class);
     } catch (UnableToCompleteException expected) {
       // expected
@@ -85,4 +121,27 @@
       String moduleName) {
     return clazz.getPackage().getName() + "." + moduleName;
   }
+
+  private static TreeLogger createFailLogger() {
+    TreeLogger logger = LOG_TO_CONSOLE ? new CompositeTreeLogger(
+        new PrintWriterTreeLogger(), new FailErrorLogger())
+        : new FailErrorLogger();
+    return logger;
+  }
+
+  private static StandardGeneratorContext createGeneratorContext(
+      String fullyQaulifiedModuleName, TreeLogger logger)
+      throws UnableToCompleteException {
+    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
+        fullyQaulifiedModuleName);
+    File genDir = new File(System.getProperty("java.io.tmpdir"));
+
+    ArtifactSet allGenreatedArtifacts = new ArtifactSet();
+    boolean isProd = false;
+    StandardGeneratorContext context = new StandardGeneratorContext(
+        module.getCompilationState(logger), module, genDir,
+        allGenreatedArtifacts, isProd);
+    return context;
+  }
+
 }