Author: hardy.ferentschik
Date: 2009-06-23 08:56:46 -0400 (Tue, 23 Jun 2009)
New Revision: 16900
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Order.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/OrderLine.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
Log:
Updated the tests to make the TCK run again
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -221,12 +221,9 @@
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
assertEquals( "Everyone has a last name.", constraintViolation.getMessage(),
"Wrong message" );
- org.testng.Assert.assertEquals( constraintViolation.getRootBean(), clint, "Wrong
root entity" );
- org.testng.Assert.assertEquals( constraintViolation.getInvalidValue(),
morgan.getLastName(), "Wrong value" );
-
- assertEquals(
- constraintViolation.getPropertyPath(),
"playedWith[0].playedWith[1].lastName", "Wrong propertyName"
- );
+ assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity"
);
+ assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong
value" );
+ assertCorrectPropertyPaths( constraintViolations,
"playedWith[0].playedWith[1].lastName");
}
@Test(expectedExceptions = IllegalArgumentException.class)
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Order.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Order.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Order.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -77,4 +77,15 @@
public void setBillingAddress(Address billingAddress) {
this.billingAddress = billingAddress;
}
+
+ @Override
+ public String toString() {
+ return "Order{" +
+ "orderId=" + orderId +
+ ", orderLines=" + orderLines +
+ ", customer=" + customer +
+ ", shippingAddress=" + shippingAddress +
+ ", billingAddress=" + billingAddress +
+ '}';
+ }
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/OrderLine.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/OrderLine.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/OrderLine.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -42,4 +42,11 @@
public void setArticleNumber(Integer articleNumber) {
this.articleNumber = articleNumber;
}
+
+ @Override
+ public String toString() {
+ return "OrderLine{" +
+ "articleNumber=" + articleNumber +
+ '}';
+ }
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -20,8 +20,8 @@
import java.lang.annotation.ElementType;
import java.util.HashSet;
import java.util.Set;
-import javax.validation.TraversableResolver;
import javax.validation.Path;
+import javax.validation.TraversableResolver;
/**
* @author Emmanuel Bernard
@@ -60,48 +60,35 @@
traversableObject, traversableProperty, rootBeanType, pathToTraversableObject,
elementType
);
if ( !calls.contains( call ) ) {
-
throw new IllegalStateException( "Unexpected " + call.toString() );
}
return true;
}
-
-
-
-
- public boolean isReachable(Object traversableObject, String traversableProperty,
Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return isTraversable(
reachCalls,
reachPaths,
traversableObject,
- traversableProperty,
+ traversableProperty.toString(),
rootBeanType,
- pathToTraversableObject,
+ pathToTraversableObject.toString(),
elementType
);
}
- public boolean isCascadable(Object traversableObject, String traversableProperty,
Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return isTraversable(
cascadeCalls,
cascadePaths,
traversableObject,
- traversableProperty,
+ traversableProperty.toString(),
rootBeanType,
- pathToTraversableObject,
+ pathToTraversableObject.toString(),
elementType
);
}
- public boolean isReachable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
- return false; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
- public boolean isCascadable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
- return false; //To change body of implemented methods use File | Settings | File
Templates.
- }
-
private static final class Call {
private Object traversableObject;
private String traversableProperty;
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/TraversableResolverTest.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -23,12 +23,12 @@
import javax.validation.ValidatorFactory;
import javax.validation.groups.Default;
-import static org.testng.Assert.assertEquals;
-import org.testng.annotations.Test;
+import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.AbstractTest;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
@@ -50,7 +50,9 @@
SnifferTraversableResolver resolver = new SnifferTraversableResolver( suit );
// TODO - Investigate why this cast is needed with Java 5. In Java 6 there is no
problem.
- Configuration<?> config = (Configuration<?>)
Validation.byDefaultProvider().configure().traversableResolver( resolver );
+ Configuration<?> config = ( Configuration<?> )
Validation.byDefaultProvider()
+ .configure()
+ .traversableResolver( resolver );
ValidatorFactory factory = config.buildValidatorFactory();
Validator v = factory.getValidator();
@@ -58,7 +60,7 @@
//Raises an IllegalStateException if something goes wrong
v.validate( suit, Default.class, Cloth.class );
- assertEquals( 5, resolver.getReachPaths().size() );
- assertEquals( 2, resolver.getCascadePaths().size() );
+ assertEquals( resolver.getReachPaths().size(), 5 );
+ assertEquals( resolver.getCascadePaths().size(), 2 );
}
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -23,16 +23,17 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
* @author Hardy Ferentschik
@@ -87,8 +88,8 @@
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "message1", constraintViolation.getMessage(), "Wrong
message" );
- assertEquals( "property1", constraintViolation.getPropertyPath(), "Wrong
property" );
+ assertEquals( constraintViolation.getMessage(), "message1", "Wrong
message" );
+ assertCorrectPropertyPaths( constraintViolations, "property1" );
}
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-06-23
10:36:55 UTC (rev 16899)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-06-23
12:56:46 UTC (rev 16900)
@@ -42,7 +42,7 @@
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
constraintValidatorContext.buildErrorWithMessageTemplate( entry.getKey() )
- .inSubNode( entry.getValue() );
+ .inSubNode( entry.getValue() ).addError();
}
}