Revision: 10486
Author: gwt.mirror...@gmail.com
Date: Tue Aug 2 05:56:59 2011
Log: Simplify the use of TckCompileTestCase by always using the module
named
TckTest.gwt.xml.
Add asserts for generator compile time errors.
Review at http://gwt-code-reviews.appspot.com/1467811
Review by: rchan...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10486
Deleted:
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/OverriddenAttributesMustMatchInTypeTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupSequenceContainingDefaultTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupSequenceWithNoImplicitDefaultGroupTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/TckCompileTest.gwt.xml
Modified:
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsGwtTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionCompileTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
/trunk/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java
/trunk/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/MustBeApplicableTest.gwt.xml
Mon Feb 28 07:12:19 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/OverriddenAttributesMustMatchInTypeTest.gwt.xml
Tue Mar 15 04:56:41 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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.OverriddenAttributesMustMatchInTypeValidatorFactory">
- <when-type-is class="javax.validation.ValidatorFactory"/>
- </replace-with>
-</module>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/TckCompileTest.gwt.xml
Mon Feb 28 07:12:19 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupSequenceContainingDefaultTest.gwt.xml
Wed Jun 22 06:42:43 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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.groups.GroupSequenceContainingDefaultValidatorFactory">
- <when-type-is class="javax.validation.ValidatorFactory"/>
- </replace-with>
-</module>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/GroupSequenceWithNoImplicitDefaultGroupTest.gwt.xml
Wed Jun 22 06:42:43 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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.groups.GroupSequenceContainingDefaultValidatorFactory">
- <when-type-is class="javax.validation.ValidatorFactory"/>
- </replace-with>
-</module>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/UnexpectedTypeValidatorFactory.gwt.xml
Mon Feb 28 07:12:19 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/TckCompileTest.gwt.xml
Tue Feb 22 10:50:07 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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.validation.TckCompileTestValidatorFactory">
- <when-type-is class="javax.validation.ValidatorFactory"/>
- </replace-with>
-</module>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java
Tue Apr 26 08:02:24 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionCompileTest.java
Tue Aug 2 05:56:59 2011
@@ -15,13 +15,9 @@
*/
package org.hibernate.jsr303.tck.tests.constraints.constraintcomposition;
-import com.google.gwt.core.ext.TreeLogger;
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.constraintcomposition.OverriddenAttributesMustMatchInTypeValidatorFactory.OverriddenAttributesMustMatchInTypeValidator;
import org.hibernate.jsr303.tck.util.TckCompileTestCase;
import javax.validation.ConstraintDefinitionException;
@@ -41,18 +37,13 @@
*/
public void testAllComposingConstraintsMustBeApplicableToAnnotatedType()
throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(
- TreeLogger.ERROR,
- "No
@org.hibernate.jsr303.tck.tests.constraints.constraintcomposition.NotEmpty("
- + "message={constraint.notEmpty}, payload=[], groups=[]) "
- + "ConstraintValidator for type int",
UnexpectedTypeException.class);
- builder.setLowestLogLevel(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(testLogger,
- getFullyQaulifiedModuleName(getClass(), "MustBeApplicableTest"),
+ assertBeanValidatorFailsToCompile(
MustBeApplicableValidatorFactory.MustBeApplicableValidator.class,
- Shoe.class);
+ Shoe.class,
+ UnexpectedTypeException.class,
+ "No
@org.hibernate.jsr303.tck.tests.constraints.constraintcomposition"
+ + ".NotEmpty(message={constraint.notEmpty}, payload=[],
groups=[]) "
+ + "ConstraintValidator for type int");
}
/**
@@ -63,20 +54,14 @@
*/
public void testOverriddenAttributesMustMatchInType()
throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(TreeLogger.ERROR, "Unable to create a validator for "
-
+ "org.hibernate.jsr303.tck.tests.constraints.constraintcomposition."
- + "ConstraintCompositionTest.DummyEntityWithZipCode "
- + "because The overriding type of a composite constraint must be "
- + "identical to the overridden one. "
- + "Expected int found class java.lang.String",
- ConstraintDefinitionException.class);
- builder.setLowestLogLevel(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(
- testLogger,
- getFullyQaulifiedModuleName(getClass(),
- "OverriddenAttributesMustMatchInTypeTest"),
-
OverriddenAttributesMustMatchInTypeValidatorFactory.OverriddenAttributesMustMatchInTypeValidator.class);
+ assertValidatorFailsToCompile(
+ OverriddenAttributesMustMatchInTypeValidator.class,
+ ConstraintDefinitionException.class,
+ "Unable to create a validator for "
+
+ "org.hibernate.jsr303.tck.tests.constraints.constraintcomposition."
+ + "ConstraintCompositionTest.DummyEntityWithZipCode "
+ + "because The overriding type of a composite constraint must
be "
+ + "identical to the overridden one. "
+ + "Expected int found class java.lang.String");
}
}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsGwtTest.java
Mon Jun 13 07:06:54 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsGwtTest.java
Tue Aug 2 05:56:59 2011
@@ -27,7 +27,7 @@
// TODO(nchalko) Generating Person validator fails.
// see http://code.google.com/p/google-web-toolkit/issues/detail?id=6284
- // private ConstraintDefinitionsTest deleagete = new
+ // private ConstraintDefinitionsTest delegate = new
// ConstraintDefinitionsTest();
@Override
@@ -38,13 +38,13 @@
@Failing(issue = 6284)
public void testConstraintWithCustomAttributes() {
fail();
- // deleagete.testConstraintWithCustomAttributes();
+ // delegate.testConstraintWithCustomAttributes();
}
@Failing(issue = 6284)
public void testDefaultGroupAssumedWhenNoGroupsSpecified() {
fail();
- // deleagete.testDefaultGroupAssumedWhenNoGroupsSpecified();
+ // delegate.testDefaultGroupAssumedWhenNoGroupsSpecified();
}
@NonTckTest
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java
Tue Apr 26 08:02:24 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorCompileTest.java
Tue Aug 2 05:56:59 2011
@@ -15,12 +15,7 @@
*/
package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
-import com.google.gwt.core.ext.TreeLogger;
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;
@@ -41,17 +36,12 @@
*/
public void testUnexpectedTypeExceptionIsRaisedForInvalidType()
throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(
- TreeLogger.ERROR,
+ assertBeanValidatorFailsToCompile(
+ TckCompileTestValidatorFactory.GwtValidator.class, OddShoe.class,
+ UnexpectedTypeException.class,
"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(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(testLogger,
- getFullyQaulifiedModuleName(getClass(), "TckCompileTest"),
- TckCompileTestValidatorFactory.GwtValidator.class, OddShoe.class);
- }
-}
+ + "ConstraintValidator for type class java.lang.String");
+ }
+
+}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionCompileTest.java
Wed Jun 22 06:42:43 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionCompileTest.java
Tue Aug 2 05:56:59 2011
@@ -15,13 +15,8 @@
*/
package org.hibernate.jsr303.tck.tests.constraints.groups;
-import com.google.gwt.core.ext.TreeLogger;
-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.groups.GroupSequenceContainingDefaultValidatorFactory.GroupSequenceContainingDefaultValidator;
+import
org.hibernate.jsr303.tck.tests.constraints.groups.GroupSequenceWithNoImplicitDefaultGroupValidatorFactory.TestValidator;
import org.hibernate.jsr303.tck.util.TckCompileTestCase;
import javax.validation.GroupDefinitionException;
@@ -32,44 +27,22 @@
*/
public class DefaultGroupRedefinitionCompileTest extends
TckCompileTestCase {
- public void testGroupSequenceContainingDefault()
- throws UnableToCompleteException {
-
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(TreeLogger.ERROR, //
- "Unable to create a validator for "
+ public void testGroupSequenceContainingDefault() {
+ assertValidatorFailsToCompile(
+ GroupSequenceContainingDefaultValidator.class,
+ GroupDefinitionException.class, "Unable to create a validator for "
+ "org.hibernate.jsr303.tck.tests.constraints.groups."
+ "DefaultGroupRedefinitionTest.AddressWithDefaultInGroupSequence "
+ "because 'Default.class' cannot appear in default group "
- + "sequence list.", //
- GroupDefinitionException.class);
- builder.setLowestLogLevel(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(
- testLogger,
- getFullyQaulifiedModuleName(getClass(),
- "GroupSequenceContainingDefaultTest"),
-
GroupSequenceContainingDefaultValidatorFactory.GroupSequenceContainingDefaultValidator.class);
+ + "sequence list.");
}
- public void testGroupSequenceWithNoImplicitDefaultGroup()
- throws UnableToCompleteException {
-
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(TreeLogger.ERROR, //
- "Unable to create a validator for "
+ public void testGroupSequenceWithNoImplicitDefaultGroup() {
+ assertValidatorFailsToCompile(TestValidator.class,
+ GroupDefinitionException.class, "Unable to create a validator for "
+ "org.hibernate.jsr303.tck.tests.constraints.groups."
+ "DefaultGroupRedefinitionTest.AddressWithDefaultInGroupSequence "
+ "because 'Default.class' cannot appear in default group "
- + "sequence list.", //
- GroupDefinitionException.class);
- builder.setLowestLogLevel(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(
- testLogger,
- getFullyQaulifiedModuleName(getClass(),
- "GroupSequenceContainingDefaultTest"),
-
GroupSequenceWithNoImplicitDefaultGroupValidatorFactory.TestValidator.class);
- }
-
-}
+ + "sequence list.");
+ }
+}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml
Tue Jan 11 14:19:47 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/groups/TckTest.gwt.xml
Tue Aug 2 05:56:59 2011
@@ -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.groups.TckTestValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java
Tue Apr 26 08:02:24 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionCompileTest.java
Tue Aug 2 05:56:59 2011
@@ -15,12 +15,7 @@
*/
package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
-import com.google.gwt.core.ext.TreeLogger;
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;
@@ -38,41 +33,31 @@
*/
public void testAmbiguousValidatorResolution()
throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(
- TreeLogger.ERROR,
+ assertBeanValidatorFailsToCompile(
+ AmbiguousValidator.class,
+ Foo.class,
+ ValidationException.class,
"More than one maximally specific "
-
+ "@org.hibernate.jsr303.tck.tests.constraints.validatorresolution.Ambiguous"
- + "(message=foobar, payload=[], groups=[]) "
+
+ "@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(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(
- testLogger,
- getFullyQaulifiedModuleName(getClass(),
- AmbiguousValidatorFactory.class.getSimpleName()),
- AmbiguousValidator.class, Foo.class);
+ + "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]");
+
}
public void testUnexpectedTypeInValidatorResolution()
throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(
- TreeLogger.ERROR,
- "No
@javax.validation.constraints.Size(message={javax.validation.constraints.Size.message},"
+ assertBeanValidatorFailsToCompile(UnexpectedTypeValidator.class,
Bar.class,
+ ValidationException.class,
+ "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(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(
- testLogger,
- getFullyQaulifiedModuleName(getClass(),
- UnexpectedTypeValidatorFactory.class.getSimpleName()),
- UnexpectedTypeValidator.class, Bar.class);
+ + "ConstraintValidator for type class java.lang.Integer");
}
}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
Tue Apr 26 08:02:24 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateCompileTest.java
Tue Aug 2 05:56:59 2011
@@ -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
@@ -15,13 +15,6 @@
*/
package org.hibernate.jsr303.tck.tests.validation;
-import com.google.gwt.core.ext.TreeLogger;
-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.ValidationException;
@@ -32,18 +25,12 @@
*/
public class ValidateCompileTest extends TckCompileTestCase {
- public void testValidatedPropertyDoesNotFollowJavaBeansConvention()
- throws UnableToCompleteException {
- UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
- builder.expect(
- TreeLogger.ERROR,
- "Unable to create a validator for
org.hibernate.jsr303.tck.tests.validation.Boy because "
- + "Annotated methods must follow the JavaBeans naming
convention. age() does not.",
- ValidationException.class);
- builder.setLowestLogLevel(TreeLogger.INFO);
- UnitTestTreeLogger testLogger = builder.createLogger();
- assertModuleFails(testLogger,
- getFullyQaulifiedModuleName(getClass(), "TckCompileTest"),
- TckCompileTestValidatorFactory.GwtValidator.class);
+ public void testValidatedPropertyDoesNotFollowJavaBeansConvention() {
+ assertValidatorFailsToCompile(
+ TckCompileTestValidatorFactory.GwtValidator.class,
+ ValidationException.class, "Unable to create a validator for "
+ + "org.hibernate.jsr303.tck.tests.validation.Boy "
+ + "because Annotated methods must follow the "
+ + "JavaBeans naming convention. age() does not.");
}
}
=======================================
--- /trunk/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java
Tue Mar 15 04:56:41 2011
+++ /trunk/user/test/org/hibernate/jsr303/tck/util/TckCompileTestCase.java
Tue Aug 2 05:56:59 2011
@@ -14,15 +14,35 @@
* the License.
*/package org.hibernate.jsr303.tck.util;
+import com.google.gwt.core.ext.Generator;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.javac.StandardGeneratorContext;
+import com.google.gwt.dev.util.UnitTestTreeLogger;
import com.google.gwt.junit.client.GWTTestCase;
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;
+
+import static
org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.createFailOnErrorLogger;
+import static
org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.createGeneratorContext;
+import static
org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.createTestLogger;
+import static
org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.getFullyQualifiedModuleName;
+
+import javax.validation.ValidationException;
+import javax.validation.Validator;
/**
* Abstract TestCase for TCK tests that are expected to fail to compile.
*/
public abstract class TckCompileTestCase extends GWTTestCase {
- public TckCompileTestCase() {
+ private StandardGeneratorContext context;
+ private TreeLogger failOnErrorLogger;
+
+ protected TckCompileTestCase() {
super();
}
@@ -30,11 +50,38 @@
public final String getModuleName() {
return null; // Run as JRE tests
}
+
+ protected void assertBeanValidatorFailsToCompile(
+ Class<? extends Validator> validatorClass, Class<?> beanType,
+ Class<? extends ValidationException> expectedException,
+ String expectedMessage) throws UnableToCompleteException {
+ ValidatorGenerator generator = new ValidatorGenerator();
+ generator.generate(failOnErrorLogger, context,
+ validatorClass.getCanonicalName());
+ context.finish(failOnErrorLogger);
+
+ // Now create the validator that is going to fail
+ GwtSpecificValidatorGenerator specificGenerator = new
GwtSpecificValidatorGenerator();
+ String beanHelperName = createBeanHelper(beanType);
+ assertUnableToComplete(expectedException, expectedMessage,
+ specificGenerator, beanHelperName);
+ }
+
+ protected void assertValidatorFailsToCompile(
+ Class<? extends Validator> validatorClass,
+ Class<? extends ValidationException> expectedException,
+ String expectedMessage) {
+ ValidatorGenerator generator = new ValidatorGenerator();
+ assertUnableToComplete(expectedException, expectedMessage, generator,
+ validatorClass.getCanonicalName());
+ }
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
BeanHelper.clearBeanHelpersForTests();
+ failOnErrorLogger = createFailOnErrorLogger();
+ context = createGeneratorContext(getTckTestModuleName(),
failOnErrorLogger);
}
@Override
@@ -43,4 +90,28 @@
super.gwtTearDown();
}
-}
+ private void assertUnableToComplete(
+ Class<? extends ValidationException> expectedException,
+ String expectedMessage, Generator generator, final String typeName) {
+ UnitTestTreeLogger testLogger = createTestLogger(expectedException,
+ expectedMessage);
+
+ try {
+ generator.generate(testLogger, context, typeName);
+ Assert.fail("Expected a " + UnableToCompleteException.class);
+ } catch (UnableToCompleteException expected) {
+ // expected
+ }
+ testLogger.assertCorrectLogEntries();
+ }
+
+ private String createBeanHelper(Class<?> beanType)
+ throws UnableToCompleteException {
+ return BeanHelper.createBeanHelper(beanType, failOnErrorLogger,
context)
+ .getFullyQualifiedValidatorName();
+ }
+
+ private String getTckTestModuleName() {
+ return getFullyQualifiedModuleName(getClass(), "TckTest");
+ }
+}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
Mon Feb 28 07:12:19 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/util/TckGeneratorTestUtils.java
Tue Aug 2 05:56:59 2011
@@ -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
@@ -15,6 +15,8 @@
*/
package org.hibernate.jsr303.tck.util;
+import com.google.gwt.core.ext.Generator;
+import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.ArtifactSet;
@@ -25,15 +27,12 @@
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;
import java.io.File;
-import javax.validation.Validator;
+import javax.validation.ValidationException;
/**
* Static utilities useful for testing TCK Generators.
@@ -42,98 +41,16 @@
private final static boolean LOG_TO_CONSOLE = false;
- /**
- * 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.
- * @throws UnableToCompleteException if The module or derived
CompilationState
- * can not be loaded.
- */
- public static void assertModuleFails(UnitTestTreeLogger testLogger,
- String fullyQaulifiedModuleName,
- Class<? extends Validator> validatorClass)
- throws UnableToCompleteException {
- TreeLogger logger = createFailLogger();
- StandardGeneratorContext context = createGeneratorContext(
- fullyQaulifiedModuleName, logger);
- ValidatorGenerator generator = new ValidatorGenerator();
- try {
- 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
- }
- testLogger.assertCorrectLogEntries();
- }
-
- /**
- * Creates the fully qualified GWT module name using the package of
- * {@code clazz} and the {@code moduleNam}
- *
- * @param clazz the class whose package the module is in.
- * @param moduleName the module name.
- * @return the fully qualified module name.
- */
- public static String getFullyQaulifiedModuleName(Class<?> clazz,
- String moduleName) {
- return clazz.getPackage().getName() + "." + moduleName;
- }
-
- private static TreeLogger createFailLogger() {
+ static TreeLogger createFailOnErrorLogger() {
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);
+ static StandardGeneratorContext createGeneratorContext(String moduleName,
+ TreeLogger logger) throws UnableToCompleteException {
+ ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
moduleName);
File genDir = new File(System.getProperty("java.io.tmpdir"));
ArtifactSet allGenreatedArtifacts = new ArtifactSet();
@@ -144,4 +61,25 @@
return context;
}
-}
+ static UnitTestTreeLogger createTestLogger(
+ final Class<? extends ValidationException> expectedException,
+ final String expectedMessage) {
+ UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
+ builder.expect(TreeLogger.ERROR, expectedMessage, expectedException);
+ builder.setLowestLogLevel(TreeLogger.INFO);
+ UnitTestTreeLogger testLogger = builder.createLogger();
+ return testLogger;
+ }
+
+ /**
+ * Creates the fully qualified GWT module name using the package of
+ * {@code clazz} and the {@code simpleName}
+ *
+ * @param clazz the class whose package the module is in.
+ * @param simpleName the module name.
+ * @return the fully qualified module name.
+ */
+ static String getFullyQualifiedModuleName(Class<?> clazz, String
simpleName) {
+ return clazz.getPackage().getName() + "." + simpleName;
+ }
+}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors