Author: hardy.ferentschik
Date: 2009-04-02 08:10:40 -0400 (Thu, 02 Apr 2009)
New Revision: 16249
Added:
validator/trunk/hibernate-validator/src/test/suite/
validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/IdentitySetTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/PropertyIteratorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java
Log:
Switched to TestNG in order to be able to reuse some of the webbeans tck stuff
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-04-01 13:04:03 UTC (rev 16248)
+++ validator/trunk/hibernate-validator/pom.xml 2009-04-02 12:10:40 UTC (rev 16249)
@@ -49,19 +49,29 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.8</version>
<scope>test</scope>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
+
<dependency>
- <groupId>junitperf</groupId>
- <artifactId>junitperf</artifactId>
- <version>1.8</version>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+
</dependencies>
<build>
+ <defaultGoal>test</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -90,6 +100,33 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <suiteXmlFiles>
+
<suiteXmlFile>${basedir}/src/test/suite/unit-tests.xml</suiteXmlFile>
+ </suiteXmlFiles>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-test-report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report-only</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+
<outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
+ <outputName>test-report</outputName>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -37,19 +37,19 @@
import javax.validation.bootstrap.ProviderSpecificBootstrap;
import javax.validation.spi.ValidationProvider;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.constraints.NotNullValidator;
-import org.hibernate.validation.engine.metadata.Customer;
import org.hibernate.validation.engine.ConfigurationImpl;
import org.hibernate.validation.engine.ConstraintValidatorFactoryImpl;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
import org.hibernate.validation.engine.ValidatorFactoryImpl;
+import org.hibernate.validation.engine.metadata.Customer;
/**
* Tests the Bean Validation bootstrapping.
@@ -84,12 +84,12 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
customer.setLastName( "Doe" );
constraintViolations = validator.validate( customer );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -106,9 +106,9 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation<Customer> constraintViolation =
constraintViolations.iterator().next();
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
// now we modify the configuration, get a new factory and valiator and try again
configuration = Validation.byDefaultProvider().configure();
@@ -126,9 +126,9 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong message", "my custom message",
constraintViolation.getMessage() );
+ assertEquals( "my custom message", constraintViolation.getMessage(),
"Wrong message" );
}
@Test
@@ -144,9 +144,9 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation<Customer> constraintViolation =
constraintViolations.iterator().next();
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
// get a new factory using a custom configuration
configuration = Validation.byDefaultProvider().configure();
@@ -164,7 +164,7 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -225,9 +225,9 @@
}
catch ( ValidationException e ) {
assertEquals(
- "Wrong error message",
"Unable to find provider: interface
org.hibernate.validation.engine.HibernateValidatorConfiguration",
- e.getMessage()
+ e.getMessage(),
+ "Wrong error message"
);
}
}
@@ -265,9 +265,9 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation<Customer> constraintViolation =
constraintViolations.iterator().next();
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
// get a new factory using a custom configuration
configuration = Validation.byDefaultProvider().configure();
@@ -281,6 +281,6 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -17,10 +17,10 @@
*/
package org.hibernate.validation.constraints;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -17,10 +17,10 @@
*/
package org.hibernate.validation.constraints;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
@@ -43,3 +43,4 @@
assertFalse( constraint.isValid( Boolean.FALSE, null ) );
}
}
+
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -21,9 +21,9 @@
import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -80,7 +80,7 @@
assertFalse( constraint.isValid( Double.valueOf( "500.2" ), null ) );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeIntegerLength() {
AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>(
Digits.class );
@@ -93,7 +93,7 @@
constraint.initialize( p );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeFractionLength() {
AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>(
Digits.class );
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -20,10 +20,10 @@
import javax.validation.ValidationException;
import javax.validation.constraints.Digits;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -62,7 +62,7 @@
assertFalse( constraint.isValid( "12.0001", null ) );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeIntegerLength() {
AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>(
Digits.class );
@@ -75,7 +75,7 @@
constraint.initialize( p );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeFractionLength() {
AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>(
Digits.class );
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,10 +19,10 @@
import java.util.Calendar;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -19,10 +19,10 @@
import java.util.Date;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
public class FutureValidatorForDateTest {
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,9 +19,9 @@
import javax.validation.ValidationException;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -50,7 +50,7 @@
assertFalse( constraint.isValid( "foobar", null ) );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeMinValue() {
AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>(
Length.class );
descriptor.setValue( "min", -1 );
@@ -62,7 +62,7 @@
constraint.initialize( p );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeMaxValue() {
AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>(
Length.class );
descriptor.setValue( "min", 1 );
@@ -74,7 +74,7 @@
constraint.initialize( p );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testNegativeLength() {
AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>(
Length.class );
descriptor.setValue( "min", 5 );
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -21,10 +21,10 @@
import java.math.BigInteger;
import javax.validation.constraints.Max;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,10 +19,10 @@
import javax.validation.constraints.Max;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -21,10 +21,10 @@
import java.math.BigInteger;
import javax.validation.constraints.Min;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,10 +19,10 @@
import javax.validation.constraints.Min;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,10 +17,10 @@
*/
package org.hibernate.validation.constraints;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
/**
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,9 +17,9 @@
*/
package org.hibernate.validation.constraints;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
/**
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -17,10 +17,10 @@
*/
package org.hibernate.validation.constraints;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,10 +19,10 @@
import java.util.Calendar;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -19,10 +19,10 @@
import java.util.Date;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
public class PastValidatorForDateTest {
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -20,9 +20,9 @@
import javax.validation.ValidationException;
import javax.validation.constraints.Pattern;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -49,7 +49,7 @@
assertFalse( constraint.isValid( "This test is not foobar", null ) );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testInvalidRegularExpression() {
AnnotationDescriptor<Pattern> descriptor = new
AnnotationDescriptor<Pattern>( Pattern.class );
descriptor.setValue( "regexp", "(unbalanced parentheses" );
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -23,10 +23,10 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.TestUtil;
@@ -45,9 +45,9 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong message", "dummy message",
constraintViolation.getMessage() );
+ assertEquals( "dummy message", constraintViolation.getMessage(), "Wrong
message" );
}
/**
@@ -64,7 +64,7 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -79,10 +79,10 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong message", "message1",
constraintViolation.getMessage() );
- assertEquals( "Wrong property", "property1",
constraintViolation.getPropertyPath() );
+ assertEquals( "message1", constraintViolation.getMessage(), "Wrong
message" );
+ assertEquals( "property1", constraintViolation.getPropertyPath(), "Wrong
property" );
}
@Test
@@ -96,15 +96,15 @@
bean.setNestedDummy( new DummyBean( "bar" ) );
Set<ConstraintViolation<DummyBean>> constraintViolations =
validator.validate( bean );
- assertEquals( "Wrong number of constraints", 2, constraintViolations.size()
);
+ assertEquals( 2, constraintViolations.size(), "Wrong number of constraints"
);
boolean validatedNestedBean = false;
for ( ConstraintViolation<DummyBean> violation : constraintViolations ) {
if ( violation.getPropertyPath().equals( "value" ) ) {
- assertEquals( "Wrong message", "dummy message",
violation.getMessage() );
+ assertEquals( "dummy message", violation.getMessage(), "Wrong
message" );
}
else if ( violation.getPropertyPath().equals( "nestedDummy.value" ) ) {
- assertEquals( "Wrong message", "dummy message",
violation.getMessage() );
+ assertEquals( "dummy message", violation.getMessage(), "Wrong
message" );
validatedNestedBean = true;
}
else {
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ConstraintHelperTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -23,17 +23,15 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import org.hibernate.validation.constraints.invalidvalidators.NoGroups;
import org.hibernate.validation.constraints.invalidvalidators.NoMessage;
import org.hibernate.validation.constraints.invalidvalidators.ValidProperty;
-import org.hibernate.validation.engine.Engine;
-import org.hibernate.validation.engine.Order;
import org.hibernate.validation.util.ReflectionHelper;
/**
@@ -60,7 +58,7 @@
}
};
assertFalse(
- "The constraint annotation should not be valid",
constraintHelper.isConstraintAnnotation( annotation )
+ constraintHelper.isConstraintAnnotation( annotation ), "The constraint
annotation should not be valid"
);
}
@@ -76,7 +74,7 @@
}
};
assertFalse(
- "The constraint annotation should not be valid",
constraintHelper.isConstraintAnnotation( annotation )
+ constraintHelper.isConstraintAnnotation( annotation ), "The constraint
annotation should not be valid"
);
}
@@ -100,7 +98,7 @@
}
};
assertFalse(
- "The constraint annotation should not be valid",
constraintHelper.isConstraintAnnotation( annotation )
+ constraintHelper.isConstraintAnnotation( annotation ), "The constraint
annotation should not be valid"
);
}
@@ -115,9 +113,9 @@
Annotation annotation = fields[0].getAnnotation( Pattern.List.class );
assertNotNull( annotation );
List<Annotation> multiValueConstraintAnnotations =
constraintHelper.getMultiValueConstraints( annotation );
- assertTrue( "There should be two constraint annotations",
multiValueConstraintAnnotations.size() == 2 );
- assertTrue( "Wrong constraint annotation",
multiValueConstraintAnnotations.get( 0 ) instanceof Pattern );
- assertTrue( "Wrong constraint annotation",
multiValueConstraintAnnotations.get( 1 ) instanceof Pattern );
+ assertTrue( multiValueConstraintAnnotations.size() == 2, "There should be two
constraint annotations" );
+ assertTrue( multiValueConstraintAnnotations.get( 0 ) instanceof Pattern, "Wrong
constraint annotation" );
+ assertTrue( multiValueConstraintAnnotations.get( 1 ) instanceof Pattern, "Wrong
constraint annotation" );
Order order = new Order();
@@ -129,6 +127,6 @@
annotation = fields[0].getAnnotation( NotNull.class );
assertNotNull( annotation );
multiValueConstraintAnnotations = constraintHelper.getMultiValueConstraints( annotation
);
- assertTrue( "There should be no constraint annotations",
multiValueConstraintAnnotations.size() == 0 );
+ assertTrue( multiValueConstraintAnnotations.size() == 0, "There should be no
constraint annotations" );
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -24,14 +24,14 @@
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
+import javax.validation.MessageInterpolator;
+import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
-import javax.validation.constraints.Max;
-import javax.validation.MessageInterpolator;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
@@ -47,7 +47,7 @@
private NotNull notNull;
private Size size;
- @Before
+ @BeforeTest
public void setUp() {
// Create some annotations for testing using AnnotationProxies
AnnotationDescriptor<NotNull> descriptor = new
AnnotationDescriptor<NotNull>( NotNull.class );
@@ -67,19 +67,19 @@
MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null
);
String expected = "replacement worked";
String actual = interpolator.interpolate( "{foo}", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
expected = "replacement worked replacement worked";
actual = interpolator.interpolate( "{foo} {foo}", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
expected = "This replacement worked just fine";
actual = interpolator.interpolate( "This {foo} just fine", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
expected = "{} { replacement worked }";
actual = interpolator.interpolate( "{} { {foo} }", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -93,11 +93,11 @@
String expected = "foo"; // missing {}
String actual = interpolator.interpolate( "foo", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
expected = "#{foo {}";
actual = interpolator.interpolate( "#{foo {}", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -111,7 +111,7 @@
String expected = "{bar}"; // unkown token {}
String actual = interpolator.interpolate( "{bar}", context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -125,7 +125,7 @@
String expected = "may not be null";
String actual = interpolator.interpolate( notNull.message(), context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
ConstraintDescriptorImpl<Size> sizeDescriptor = new
ConstraintDescriptorImpl<Size>(
size, new Class<?>[] { }, new ConstraintHelper()
@@ -133,7 +133,7 @@
expected = "size must be between 0 and 2147483647"; // unkown token {}
context = new MessageInterpolatorContext( sizeDescriptor, null );
actual = interpolator.interpolate( size.message(), context );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -147,7 +147,7 @@
String expected = "kann nicht null sein";
MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null
);
String actual = interpolator.interpolate( notNull.message(), context, Locale.GERMAN );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -161,7 +161,7 @@
String expected = "may not be null";
String actual = interpolator.interpolate( notNull.message(), context, Locale.JAPAN );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
@Test
@@ -175,7 +175,7 @@
String expected = "no puede ser null";
String actual = interpolator.interpolate( notNull.message(), context, new Locale(
"es", "ES" ) );
- assertEquals( "Wrong substitution", expected, actual );
+ assertEquals( expected, actual, "Wrong substitution" );
}
/**
@@ -185,7 +185,7 @@
public void testRecursiveMessageInterpoliation() {
AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>(
Max.class );
descriptor.setValue( "message", "{replace.in.user.bundle1}" );
- descriptor.setValue( "value", 10l);
+ descriptor.setValue( "value", 10l );
Max max = AnnotationFactory.create( descriptor );
@@ -198,7 +198,9 @@
String expected = "{replace.in.default.bundle2}";
String actual = interpolator.interpolate( max.message(), context );
- assertEquals( "Within default bundle replacement parameter evauation should not be
recursive!", expected, actual );
+ assertEquals(
+ expected, actual, "Within default bundle replacement parameter evauation should
not be recursive!"
+ );
}
/**
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -26,22 +26,13 @@
import javax.validation.Validator;
import javax.validation.groups.Default;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Test;
import org.slf4j.Logger;
+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.hibernate.validation.engine.Actor;
-import org.hibernate.validation.engine.Address;
-import org.hibernate.validation.engine.Boy;
import org.hibernate.validation.engine.metadata.Customer;
-import org.hibernate.validation.engine.Engine;
-import org.hibernate.validation.engine.Order;
-import org.hibernate.validation.engine.Person;
-import org.hibernate.validation.engine.First;
-import org.hibernate.validation.engine.Last;
-import org.hibernate.validation.engine.Second;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
@@ -64,19 +55,19 @@
}
catch ( ValidationException e ) {
assertEquals(
- "Wrong error message",
"Annotated methods must follow the JavaBeans naming convention. age() does
not.",
- e.getMessage()
+ e.getMessage(),
+ "Wrong error message"
);
}
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testNullParamterToValidatorImplConstructor() {
TestUtil.getValidator().getConstraintsForClass( null );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testValidateWithNull() {
Validator validator = TestUtil.getValidator();
validator.validate( null );
@@ -148,12 +139,12 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
customer.setLastName( "Doe" );
constraintViolations = validator.validate( customer );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -167,30 +158,30 @@
Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( address );
assertEquals(
- "we should have been 2 not null violation for addresslines and one lenth
violation for city",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "we should have been 2 not null violation for addresslines and one lenth
violation for city"
);
constraintViolations = validator.validateProperty( address, "city" );
assertEquals(
- "only city should be validated",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "only city should be validated"
);
constraintViolations = validator.validateProperty( address, "city" );
assertEquals(
- "only city should be validated",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "only city should be validated"
);
constraintViolations = validator.validateValue( Address.class, "city",
"Paris" );
assertEquals(
- "Paris should be a valid city name.",
0,
- constraintViolations.size()
+ constraintViolations.size(),
+ "Paris should be a valid city name."
);
}
@@ -203,19 +194,18 @@
customer.setLastName( "Doe" );
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
Order order = new Order();
customer.addOrder( order );
constraintViolations = validator.validate( customer );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", customer,
constraintViolation.getRootBean() );
- assertEquals( "Wrong value", order.getOrderNumber(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "orderList[0].orderNumber",
constraintViolation.getPropertyPath() );
-
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( customer, constraintViolation.getRootBean(), "Wrong root
entity" );
+ assertEquals( order.getOrderNumber(), constraintViolation.getInvalidValue(),
"Wrong value" );
+ assertEquals( "orderList[0].orderNumber",
constraintViolation.getPropertyPath(), "Wrong propertyName" );
}
@Test
@@ -225,15 +215,15 @@
Engine engine = new Engine();
engine.setSerialNumber( "mail(a)foobar.com" );
Set<ConstraintViolation<Engine>> constraintViolations = validator.validate(
engine );
- assertEquals( "Wrong number of constraints", 2, constraintViolations.size()
);
+ assertEquals( 2, constraintViolations.size(), "Wrong number of constraints"
);
engine.setSerialNumber( "ABCDEFGH1234" );
constraintViolations = validator.validate( engine );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
engine.setSerialNumber( "ABCD-EFGH-1234" );
constraintViolations = validator.validate( engine );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -254,12 +244,12 @@
Set<ConstraintViolation<Actor>> constraintViolations = validator.validate(
clint );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be empty",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", clint, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", morgan.getLastName(),
constraintViolation.getInvalidValue() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be empty", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( clint, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( morgan.getLastName(), constraintViolation.getInvalidValue(), "Wrong
value" );
assertEquals(
- "Wrong propertyName", "playedWith[0].playedWith[1].lastName",
constraintViolation.getPropertyPath()
+ "playedWith[0].playedWith[1].lastName",
constraintViolation.getPropertyPath(), "Wrong propertyName"
);
}
@@ -270,17 +260,17 @@
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validateValue(
Customer.class, "orderList[0].orderNumber", null
);
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", null, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", null, constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "orderList[0].orderNumber",
constraintViolation.getPropertyPath() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( null, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( null, constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( "orderList[0].orderNumber",
constraintViolation.getPropertyPath(), "Wrong propertyName" );
constraintViolations = validator.validateValue( Customer.class,
"orderList[0].orderNumber", "1234" );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -323,18 +313,18 @@
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validateProperty(
customer, "orderList[0].orderNumber"
);
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", customer,
constraintViolation.getRootBean() );
- assertEquals( "Wrong value", order.getOrderNumber(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "orderList[0].orderNumber",
constraintViolation.getPropertyPath() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( customer, constraintViolation.getRootBean(), "Wrong root
entity" );
+ assertEquals( order.getOrderNumber(), constraintViolation.getInvalidValue(),
"Wrong value" );
+ assertEquals( "orderList[0].orderNumber",
constraintViolation.getPropertyPath(), "Wrong propertyName" );
order.setOrderNumber( 1234 );
constraintViolations = validator.validateProperty( customer,
"orderList[0].orderNumber" );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -395,7 +385,7 @@
Person person = customer;
Set<ConstraintViolation<Person>> constraintViolations = validator.validate(
person );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
assertConstraintViolation(
constraintViolations.iterator().next(),
@@ -408,7 +398,7 @@
order.setOrderNumber( 123 );
constraintViolations = validator.validate( person );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -427,7 +417,7 @@
Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate(
customer, Default.class, First.class, Second.class, Last.class
);
- assertEquals( "Wrong number of constraints", 100, constraintViolations.size()
);
+ assertEquals( 100, constraintViolations.size(), "Wrong number of constraints"
);
}
/**
@@ -441,14 +431,14 @@
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderNumber" );
Set<ConstraintDescriptor<?>> descriptors =
propertyDescriptor.getConstraintDescriptors();
- assertEquals( "There should be only one constraint descriptor", 1,
descriptors.size() );
+ assertEquals( 1, descriptors.size(), "There should be only one constraint
descriptor" );
ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
Set<Class<?>> groups = descriptor.getGroups();
- assertTrue( "There should be only one group", groups.size() == 1 );
+ assertTrue( groups.size() == 1, "There should be only one group" );
assertEquals(
- "The declared constraint does not explicitly define a group, hence Default is
expected",
Default.class,
- groups.iterator().next()
+ groups.iterator().next(),
+ "The declared constraint does not explicitly define a group, hence Default is
expected"
);
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/constraintcomposition/ConstraintCompositionTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -21,11 +21,9 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
-import static org.junit.Assert.fail;
-import org.junit.Test;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
-import org.hibernate.validation.engine.constraintcomposition.FrenchAddress;
-import org.hibernate.validation.engine.constraintcomposition.GermanAddress;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
import static org.hibernate.validation.util.TestUtil.getValidator;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -23,9 +23,9 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.validation.util.TestUtil;
@@ -61,7 +61,7 @@
Validator validator = TestUtil.getValidator();
Set<ConstraintViolation<Order>> constraintViolations = validator.validate(
order );
- assertEquals( "Wrong number of constraints", 3, constraintViolations.size()
);
+ assertEquals( 3, constraintViolations.size(), "Wrong number of constraints"
);
List<String> expectedErrorMessages = new ArrayList<String>();
expectedErrorMessages.add( "shippingAddress.addressline1" );
@@ -74,7 +74,7 @@
}
}
- assertTrue( "All error messages should have occured once",
expectedErrorMessages.size() == 0 );
+ assertTrue( expectedErrorMessages.size() == 0, "All error messages should have
occured once" );
}
@Test
@@ -85,7 +85,7 @@
Validator validator = TestUtil.getValidator();
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
john );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class,
null, "lastName"
);
@@ -96,21 +96,19 @@
john.knows( jane );
constraintViolations = validator.validate( john );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class,
null, "lastName"
);
constraintViolations = validator.validate( jane );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class,
null, "knowsUser[0].lastName"
);
john.setLastName( "Doe" );
constraintViolations = validator.validate( john );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
-
-
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,14 +19,14 @@
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
-import java.util.List;
import javax.validation.ValidationException;
import javax.validation.groups.Default;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import org.hibernate.validation.engine.First;
import org.hibernate.validation.engine.Last;
@@ -39,36 +39,36 @@
GroupChainGenerator generator;
- @Before
+ @BeforeTest
public void init() {
generator = new GroupChainGenerator();
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testGroupChainForNonInterface() {
Set<Class<?>> groups = new HashSet<Class<?>>();
groups.add( String.class );
generator.getGroupChainFor( groups );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGroupChainForNull() {
generator.getGroupChainFor( null );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void testGroupChainForEmptySet() {
generator.getGroupChainFor( new HashSet<Class<?>>() );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testCyclicGroupSequences() {
Set<Class<?>> groups = new HashSet<Class<?>>();
groups.add( CyclicGroupSequence1.class );
generator.getGroupChainFor( groups );
}
- @Test(expected = ValidationException.class)
+ @Test(expectedExceptions = ValidationException.class)
public void testCyclicGroupSequence() {
Set<Class<?>> groups = new HashSet<Class<?>>();
groups.add( CyclicGroupSequence.class );
@@ -83,14 +83,14 @@
groups.add( Last.class );
GroupChain chain = generator.getGroupChainFor( groups );
int count = countGroups( chain );
- assertEquals( "Wrong number of groups", 3, count );
+ assertEquals( 3, count, "Wrong number of groups" );
groups.clear();
groups.add( First.class );
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
count = countGroups( chain );
- assertEquals( "Wrong number of groups", 1, count );
+ assertEquals( 1, count, "Wrong number of groups" );
groups.clear();
groups.add( First.class );
@@ -98,13 +98,13 @@
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
count = countGroups( chain );
- assertEquals( "Wrong number of groups", 2, count );
+ assertEquals( 2, count, "Wrong number of groups" );
}
private int countGroups(GroupChain chain) {
Iterator<Group> groupIterator = chain.getGroupIterator();
int count = 0;
- while (groupIterator.hasNext()) {
+ while ( groupIterator.hasNext() ) {
groupIterator.next();
count++;
}
@@ -119,7 +119,7 @@
Iterator<List<Group>> sequences = chain.getSequenceIterator();
List<Group> sequence = sequences.next();
- assertEquals( "Wrong group", Default.class, sequence.get(0).getGroup() );
- assertEquals( "Wrong group", Address.HighLevelCoherence.class,
sequence.get(1).getGroup() );
+ assertEquals( Default.class, sequence.get( 0 ).getGroup(), "Wrong group" );
+ assertEquals( Address.HighLevelCoherence.class, sequence.get( 1 ).getGroup(),
"Wrong group" );
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -20,22 +20,18 @@
import java.util.Set;
import javax.validation.BeanDescriptor;
import javax.validation.ConstraintViolation;
+import javax.validation.PropertyDescriptor;
import javax.validation.ValidationException;
import javax.validation.Validator;
-import javax.validation.PropertyDescriptor;
import javax.validation.groups.Default;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+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.hibernate.validation.engine.groups.Animal;
-import org.hibernate.validation.engine.groups.Author;
-import org.hibernate.validation.engine.groups.Book;
import org.hibernate.validation.engine.DefaultAlias;
import org.hibernate.validation.engine.First;
-import org.hibernate.validation.engine.groups.Dictonary;
import org.hibernate.validation.engine.Last;
import org.hibernate.validation.engine.Second;
import org.hibernate.validation.util.TestUtil;
@@ -62,45 +58,45 @@
Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
book, First.class, Second.class, Last.class
);
- assertEquals( "Wrong number of constraints", 3, constraintViolations.size()
);
+ assertEquals( 3, constraintViolations.size(), "Wrong number of constraints"
);
author.setFirstName( "Gavin" );
author.setLastName( "King" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be empty",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", book, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", book.getTitle(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "title",
constraintViolation.getPropertyPath() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be empty", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( book.getTitle(), constraintViolation.getInvalidValue(), "Wrong
value" );
+ assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong message", "length must be between 0 and 30",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", book, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", book.getSubtitle(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "subtitle",
constraintViolation.getPropertyPath() );
+ assertEquals( "length must be between 0 and 30",
constraintViolation.getMessage(), "Wrong message" );
+ assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( book.getSubtitle(), constraintViolation.getInvalidValue(), "Wrong
value" );
+ assertEquals( "subtitle", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
book.setSubtitle( "Revised Edition" );
author.setCompany( "JBoss a divison of RedHat" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "length must be between 0 and 20",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", book, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", author.getCompany(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "author.company",
constraintViolation.getPropertyPath() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "length must be between 0 and 20",
constraintViolation.getMessage() );
+ assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( author.getCompany(), constraintViolation.getInvalidValue(), "Wrong
value" );
+ assertEquals( "author.company", constraintViolation.getPropertyPath(),
"Wrong propertyName" );
author.setCompany( "JBoss" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -114,35 +110,35 @@
book.setAuthor( author );
Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
book, Book.All.class );
- assertEquals( "Wrong number of constraints", 2, constraintViolations.size()
);
+ assertEquals( 2, constraintViolations.size(), "Wrong number of constraints"
);
author.setFirstName( "Gavin" );
author.setLastName( "King" );
constraintViolations = validator.validate( book, Book.All.class );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
- assertEquals( "Wrong message", "may not be null",
constraintViolation.getMessage() );
- assertEquals( "Wrong root entity", book, constraintViolation.getRootBean()
);
- assertEquals( "Wrong value", book.getTitle(),
constraintViolation.getInvalidValue() );
- assertEquals( "Wrong propertyName", "title",
constraintViolation.getPropertyPath() );
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity"
);
+ assertEquals( book.getTitle(), constraintViolation.getInvalidValue(), "Wrong
value" );
+ assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
book.setSubtitle( "Revised Edition" );
author.setCompany( "JBoss a divison of RedHat" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( "Wrong number of constraints", 1, constraintViolations.size()
);
+ assertEquals( 1, constraintViolations.size(), "Wrong number of constraints"
);
author.setCompany( "JBoss" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -158,7 +154,7 @@
dictonary.setAuthor( author );
Set<ConstraintViolation<Dictonary>> constraintViolations =
validator.validate( dictonary, DefaultAlias.class );
- assertEquals( "Wrong number of constraints", 0, constraintViolations.size()
);
+ assertEquals( 0, constraintViolations.size(), "Wrong number of constraints"
);
}
@Test
@@ -172,9 +168,9 @@
elepfant, First.class, Second.class
);
assertEquals(
- "The should be two invalid constraints since the same propertyName gets
validated in both groups",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "The should be two invalid constraints since the same propertyName gets
validated in both groups"
);
}
@@ -188,65 +184,65 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
assertEquals(
- "There should be two violations against the implicit default group",
2,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be two violations against the implicit default group"
);
constraintViolations = validator.validate( user, Default.class );
assertEquals(
- "There should be two violations against the explicit defualt group",
2,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be two violations against the explicit defualt group"
);
constraintViolations = validator.validate( user, Billable.class );
assertEquals(
- "There should be one violation against Billable",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be one violation against Billable"
);
constraintViolations = validator.validate( user, Default.class, Billable.class );
assertEquals(
- "There should be 3 violation against Default and Billable",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be 3 violation against Default and Billable"
);
constraintViolations = validator.validate( user, BuyInOneClick.class );
assertEquals(
- "Three violations expected since BuyInOneClick extends Default and
Billable",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "Three violations expected since BuyInOneClick extends Default and
Billable"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Billable.class
);
assertEquals(
- "BuyInOneClick already contains all other groups. Adding Billable does not
change the number of violations",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "BuyInOneClick already contains all other groups. Adding Billable does not
change the number of violations"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class );
assertEquals(
- "BuyInOneClick already contains all other groups. Adding Default does not change
the number of violations",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "BuyInOneClick already contains all other groups. Adding Default does not change
the number of violations"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class,
Billable.class );
assertEquals(
- "BuyInOneClick already contains all other groups. Adding Billable and Default
does not change the number of violations",
3,
- constraintViolations.size()
+ constraintViolations.size(),
+ "BuyInOneClick already contains all other groups. Adding Billable and Default
does not change the number of violations"
);
constraintViolations = validator.validate( user, Billable.class, Billable.class );
assertEquals(
- "Adding the same group twice is still only leads to a single violation",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "Adding the same group twice is still only leads to a single violation"
);
}
@@ -266,9 +262,9 @@
user, BuyInOneClick.class, Optional.class
);
assertEquals(
- "There should be two violations against the implicit default group",
2,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be two violations against the implicit default group"
);
for ( ConstraintViolation<User> constraintViolation : constraintViolations ) {
@@ -309,9 +305,9 @@
Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( address );
assertEquals(
- "There should only be one violation for zipcode",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should only be one violation for zipcode"
);
ConstraintViolation<Address> violation = constraintViolations.iterator().next();
@@ -322,9 +318,9 @@
// now the second group in the re-defined default group causes an error
constraintViolations = validator.validate( address );
assertEquals(
- "There should only be one violation for zipcode",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should only be one violation for zipcode"
);
violation = constraintViolations.iterator().next();
@@ -343,38 +339,38 @@
Set<ConstraintViolation<Car>> constraintViolations = validator.validate(
car );
assertEquals(
- "There should be one violations due to the re-defintion of the default
group",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be one violations due to the re-defintion of the default
group"
);
assertEquals(
- "Wrong constraint",
"length must be between 2 and 20",
- constraintViolations.iterator().next().getMessage()
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
);
constraintViolations = validator.validateProperty( car, "type" );
assertEquals(
- "There should be one violations due to the re-defintion of the default
group",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be one violations due to the re-defintion of the default
group"
);
assertEquals(
- "Wrong constraint",
"length must be between 2 and 20",
- constraintViolations.iterator().next().getMessage()
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
);
constraintViolations = validator.validateValue( Car.class, "type",
"A" );
assertEquals(
- "There should be one violations due to the re-defintion of the default
group",
1,
- constraintViolations.size()
+ constraintViolations.size(),
+ "There should be one violations due to the re-defintion of the default
group"
);
assertEquals(
- "Wrong constraint",
"length must be between 2 and 20",
- constraintViolations.iterator().next().getMessage()
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
);
}
@@ -391,7 +387,7 @@
}
catch ( ValidationException e ) {
assertEquals(
- "Wrong message", "'Default.class' cannot appear in default
group sequence list.", e.getMessage()
+ "'Default.class' cannot appear in default group sequence list.",
e.getMessage(), "Wrong message"
);
}
}
@@ -406,14 +402,14 @@
assertTrue( beanDescriptor.isBeanConstrained() );
Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
- assertTrue( "Each of the properties should have at least one constraint.",
constraintProperties.size() == 5 );
+ assertTrue( constraintProperties.size() == 5, "Each of the properties should have
at least one constraint." );
Order order = new Order();
Set<ConstraintViolation<Order>> violations = validator.validate( order );
- assertTrue( "All 5 NotNull constraints should fail.", violations.size() == 5
);
+ assertTrue( violations.size() == 5, "All 5 NotNull constraints should fail."
);
// use implicit group Auditable
violations = validator.validate( order, Auditable.class );
- assertTrue( "All 4 NotNull constraints on Auditable should fail.",
violations.size() == 4 );
+ assertTrue( violations.size() == 4, "All 4 NotNull constraints on Auditable should
fail." );
}
}
\ No newline at end of file
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -22,14 +22,16 @@
import javax.validation.PropertyDescriptor;
import javax.validation.Validator;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import org.slf4j.Logger;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
import org.hibernate.validation.engine.Order;
+import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
@@ -38,32 +40,34 @@
*/
public class BeanDescriptorTest {
+ private static final Logger log = LoggerFactory.make();
+
@Test
public void testIsBeanConstrained() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
// constraint via @Valid
- assertFalse( "There should be no direct constraints on the specified bean.",
beanDescriptor.hasConstraints() );
- assertTrue( "Bean should be constrainted due to @valid ",
beanDescriptor.isBeanConstrained() );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @valid " );
// constraint hosted on bean itself
beanDescriptor = validator.getConstraintsForClass( Account.class );
- assertTrue( "There should be direct constraints on the specified bean.",
beanDescriptor.hasConstraints() );
- assertTrue( "Bean should be constrainted due to @valid",
beanDescriptor.isBeanConstrained() );
+ assertTrue( beanDescriptor.hasConstraints(), "There should be direct constraints
on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @valid" );
// constraint on bean property
beanDescriptor = validator.getConstraintsForClass( Order.class );
- assertFalse( "There should be no direct constraints on the specified bean.",
beanDescriptor.hasConstraints() );
- assertTrue( "Bean should be constrainted due to @NotNull",
beanDescriptor.isBeanConstrained() );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @NotNull" );
}
@Test
public void testUnconstraintClass() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(
UnconstraintEntity.class );
- assertFalse( "There should be no direct constraints on the specified bean.",
beanDescriptor.hasConstraints() );
- assertFalse( "Bean should be unconstrainted.",
beanDescriptor.isBeanConstrained() );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
+ assertFalse( beanDescriptor.isBeanConstrained(), "Bean should be
unconstrainted." );
}
@Test
@@ -72,15 +76,15 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderNumber" );
assertEquals(
- "There should be one constraint descriptor", 1,
propertyDescriptor.getConstraintDescriptors().size()
+ 1, propertyDescriptor.getConstraintDescriptors().size(), "There should be one
constraint descriptor"
);
beanDescriptor = validator.getConstraintsForClass( Customer.class );
propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList"
);
assertEquals(
- "There should be no constraint descriptors", 0,
propertyDescriptor.getConstraintDescriptors().size()
+ 0, propertyDescriptor.getConstraintDescriptors().size(), "There should be no
constraint descriptors"
);
- assertTrue( "The property should be cascaded",
propertyDescriptor.isCascaded() );
+ assertTrue( propertyDescriptor.isCascaded(), "The property should be
cascaded" );
}
@Test
@@ -89,16 +93,16 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderList" );
assertEquals(
- "There should be no constraint descriptors", 0,
propertyDescriptor.getConstraintDescriptors().size()
+ 0, propertyDescriptor.getConstraintDescriptors().size(), "There should be no
constraint descriptors"
);
- assertTrue( "The property should be cascaded",
propertyDescriptor.isCascaded() );
+ assertTrue( propertyDescriptor.isCascaded(), "The property should be
cascaded" );
}
@Test
public void testGetConstraintsForNonExistingProperty() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- assertNull( "There should be no descriptor",
beanDescriptor.getConstraintsForProperty( "foobar" ) );
+ assertNull( beanDescriptor.getConstraintsForProperty( "foobar" ), "There
should be no descriptor" );
}
/**
@@ -108,7 +112,7 @@
public void testGetConstraintsForNullProperty() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- assertNull( "There should be no descriptor",
beanDescriptor.getConstraintsForProperty( null ) );
+ assertNull( beanDescriptor.getConstraintsForProperty( null ), "There should be no
descriptor" );
}
/**
@@ -119,12 +123,12 @@
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
- assertEquals( "There should be only one property", 1,
constraintProperties.size() );
+ assertEquals( 1, constraintProperties.size(), "There should be only one
property" );
boolean hasOrderNumber = false;
for ( PropertyDescriptor pd : constraintProperties ) {
hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
}
- assertTrue( "Wrong property", hasOrderNumber );
+ assertTrue( hasOrderNumber, "Wrong property" );
}
/**
@@ -140,7 +144,7 @@
fail( "Set should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
try {
@@ -148,7 +152,7 @@
fail( "Set should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
}
@@ -160,6 +164,6 @@
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(
UnconstraintEntity.class );
Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
- assertEquals( "We should get the empty set.", 0, constraintProperties.size()
);
+ assertEquals( 0, constraintProperties.size(), "We should get the empty set."
);
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -24,16 +24,18 @@
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import org.slf4j.Logger;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
import org.hibernate.validation.constraints.NotNullValidator;
import org.hibernate.validation.engine.Order;
import org.hibernate.validation.engine.constraintcomposition.GermanAddress;
+import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
@@ -41,6 +43,8 @@
* @author Hardy Ferentschik
*/
public class ConstraintDescriptorTest {
+ private static final Logger log = LoggerFactory.make();
+
@Test
public void testConstraintDescriptorImmutable() {
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor(
Order.class, "orderNumber" );
@@ -50,7 +54,7 @@
fail( "Should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
try {
@@ -58,7 +62,7 @@
fail( "Should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
try {
@@ -66,7 +70,7 @@
fail( "Should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
try {
@@ -74,7 +78,7 @@
fail( "Should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
}
@@ -101,7 +105,7 @@
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor(
GermanAddress.class, "zipCode"
);
- assertEquals( "Wrong number of composing constraints", 1,
descriptor.getComposingConstraints().size() );
+ assertEquals( 1, descriptor.getComposingConstraints().size(), "Wrong number of
composing constraints" );
}
@Test
@@ -117,13 +121,13 @@
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor(
Order.class, "orderNumber" );
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 1 );
- assertEquals( "Wrong group", Default.class, groups.iterator().next() );
+ assertEquals( Default.class, groups.iterator().next(), "Wrong group" );
}
@Test
public void testGetConstraintValidatorClasses() {
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor(
Order.class, "orderNumber" );
- assertEquals( "Wrong classes", NotNullValidator.class,
descriptor.getConstraintValidatorClasses().get( 0 ) );
+ assertEquals( NotNullValidator.class, descriptor.getConstraintValidatorClasses().get( 0
), "Wrong classes" );
}
@Test
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -23,12 +23,14 @@
import javax.validation.ElementDescriptor;
import javax.validation.Validator;
-import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import org.slf4j.Logger;
+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.hibernate.validation.engine.Order;
+import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
@@ -37,17 +39,19 @@
*/
public class ElementDescriptorTest {
+ private static final Logger log = LoggerFactory.make();
+
@Test
public void testGetTypeForConstrainedBean() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
- assertEquals( "Wrong type.", Customer.class, beanDescriptor.getType() );
+ assertEquals( Customer.class, beanDescriptor.getType(), "Wrong type." );
}
@Test
public void testGetTypeForConstrainedProperty() {
ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class,
"orderNumber" );
- assertEquals( "Wrong type.", Integer.class, elementDescriptor.getType() );
+ assertEquals( Integer.class, elementDescriptor.getType(), "Wrong type." );
}
/**
@@ -57,7 +61,7 @@
public void testElementDescriptorForProperty() {
ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class,
"orderNumber" );
Set<ConstraintDescriptor<?>> constraintDescriptors =
elementDescriptor.getConstraintDescriptors();
- assertTrue( "There should be a descriptor", constraintDescriptors.size() == 1
);
+ assertTrue( constraintDescriptors.size() == 1, "There should be a descriptor"
);
}
/**
@@ -73,7 +77,7 @@
fail( "Set should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
try {
@@ -81,7 +85,7 @@
fail( "Set should be immutable" );
}
catch ( UnsupportedOperationException e ) {
-
+ log.trace( "success" );
}
}
}
\ No newline at end of file
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -19,10 +19,10 @@
import javax.validation.PropertyDescriptor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.validation.engine.Order;
import org.hibernate.validation.util.TestUtil;
@@ -35,19 +35,19 @@
@Test
public void testIsNotCascaded() {
PropertyDescriptor descriptor = TestUtil.getPropertyDescriptor( Order.class,
"orderNumber" );
- assertFalse( "Should not be cascaded", descriptor.isCascaded() );
+ assertFalse( descriptor.isCascaded(), "Should not be cascaded" );
}
@Test
public void testIsCascaded() {
PropertyDescriptor descriptor = TestUtil.getPropertyDescriptor( Customer.class,
"orderList" );
- assertTrue( "Should be cascaded", descriptor.isCascaded() );
+ assertTrue( descriptor.isCascaded(), "Should be cascaded" );
}
@Test
public void testPropertyName() {
String propertyName = "orderList";
PropertyDescriptor descriptor = TestUtil.getPropertyDescriptor( Customer.class,
propertyName );
- assertEquals( "Wrong property name", propertyName,
descriptor.getPropertyName() );
+ assertEquals( propertyName, descriptor.getPropertyName(), "Wrong property
name" );
}
}
\ No newline at end of file
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,19 +17,18 @@
*/
package org.hibernate.validation.engine.validatorresolution;
-import java.util.Set;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.UnexpectedTypeException;
import javax.validation.Validator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Test;
+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.hibernate.validation.engine.validatorresolution.MultipleMinMax;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
import static org.hibernate.validation.util.TestUtil.getValidator;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/IdentitySetTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/IdentitySetTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/IdentitySetTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -20,8 +20,8 @@
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
/**
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/PropertyIteratorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/PropertyIteratorTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/PropertyIteratorTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,10 +17,10 @@
*/
package org.hibernate.validation.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
/**
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -31,12 +31,12 @@
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
/**
* Tests for the <code>ReflectionHelper</code>.
@@ -93,17 +93,17 @@
map.put( key, testObject );
Object value = ReflectionHelper.getIndexedValue( map, key );
- assertEquals( "We should be able to retrieve the indexed object", testObject,
value );
+ assertEquals( testObject, value, "We should be able to retrieve the indexed
object" );
// try to get to the value by integer index
value = ReflectionHelper.getIndexedValue( map, "0" );
- assertEquals( "We should be able to retrieve the indexed object", testObject,
value );
+ assertEquals( testObject, value, "We should be able to retrieve the indexed
object" );
value = ReflectionHelper.getIndexedValue( map, "foo" );
- assertNull( "A non existent index should return the null value", value );
+ assertNull( value, "A non existent index should return the null value" );
value = ReflectionHelper.getIndexedValue( map, "2" );
- assertNull( "A non existent index should return the null value", value );
+ assertNull( value, "A non existent index should return the null value" );
}
@Test
@@ -113,10 +113,10 @@
list.add( testObject );
Object value = ReflectionHelper.getIndexedValue( list, "0" );
- assertEquals( "We should be able to retrieve the indexed object", testObject,
value );
+ assertEquals( testObject, value, "We should be able to retrieve the indexed
object" );
value = ReflectionHelper.getIndexedValue( list, "2" );
- assertNull( "A non existent index should return the null value", value );
+ assertNull( value, "A non existent index should return the null value" );
}
@Test
@@ -141,17 +141,17 @@
}
};
String message = ReflectionHelper.getAnnotationParameter( testAnnotation,
"message", String.class );
- assertEquals( "Wrong message", "test", message );
+ assertEquals( "test", message, "Wrong message" );
Class<?>[] group = ReflectionHelper.getAnnotationParameter( testAnnotation,
"groups", Class[].class );
- assertEquals( "Wrong message", Default.class, group[0] );
+ assertEquals( Default.class, group[0], "Wrong message" );
try {
ReflectionHelper.getAnnotationParameter( testAnnotation, "message",
Integer.class );
fail();
}
catch ( ValidationException e ) {
- assertTrue( "Wrong exception message", e.getMessage().startsWith(
"Wrong parameter type." ) );
+ assertTrue( e.getMessage().startsWith( "Wrong parameter type." ),
"Wrong exception message" );
}
try {
@@ -160,8 +160,8 @@
}
catch ( ValidationException e ) {
assertTrue(
- "Wrong exception message",
- e.getMessage().startsWith( "The specified annotation defines no parameter"
)
+ e.getMessage().startsWith( "The specified annotation defines no parameter"
),
+ "Wrong exception message"
);
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -21,12 +21,12 @@
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintViolation;
import javax.validation.ElementDescriptor;
+import javax.validation.PropertyDescriptor;
import javax.validation.Validation;
import javax.validation.Validator;
-import javax.validation.PropertyDescriptor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
@@ -55,7 +55,7 @@
public static ConstraintDescriptor<?>
getSingleConstraintDescriptorFor(Class<?> clazz, String property) {
Set<ConstraintDescriptor<?>> constraintDescriptors =
getConstraintDescriptorsFor( clazz, property );
assertTrue(
- "This method should only be used when there is a single constraint",
constraintDescriptors.size() == 1
+ constraintDescriptors.size() == 1, "This method should only be used when there
is a single constraint"
);
return constraintDescriptors.iterator().next();
}
@@ -72,45 +72,46 @@
public static void assertConstraintViolation(ConstraintViolation violation, String
errorMessage, Class rootBean, Object invalidValue, String propertyPath, Class leafBean) {
assertEquals(
- "Wrong leaf bean type",
+
leafBean,
- violation.getLeafBean().getClass()
+ violation.getLeafBean().getClass(),
+ "Wrong leaf bean type"
);
assertConstraintViolation( violation, errorMessage, rootBean, invalidValue,
propertyPath );
}
public static void assertConstraintViolation(ConstraintViolation violation, String
errorMessage, Class rootBean, Object invalidValue, String propertyPath) {
assertEquals(
- "Wrong propertyPath",
propertyPath,
- violation.getPropertyPath()
+ violation.getPropertyPath(),
+ "Wrong propertyPath"
);
assertConstraintViolation( violation, errorMessage, rootBean, invalidValue );
}
public static void assertConstraintViolation(ConstraintViolation violation, String
errorMessage, Class rootBean, Object invalidValue) {
assertEquals(
- "Wrong invalid value",
invalidValue,
- violation.getInvalidValue()
+ violation.getInvalidValue(),
+ "Wrong invalid value"
);
assertConstraintViolation( violation, errorMessage, rootBean );
}
public static void assertConstraintViolation(ConstraintViolation violation, String
errorMessage, Class rootBean) {
assertEquals(
- "Wrong root bean type",
rootBean,
- violation.getRootBean().getClass()
+ violation.getRootBean().getClass(),
+ "Wrong root bean type"
);
assertConstraintViolation( violation, errorMessage );
}
public static void assertConstraintViolation(ConstraintViolation violation, String
message) {
- assertEquals( "Wrong message", message, violation.getMessage() );
+ assertEquals( message, violation.getMessage(), "Wrong message" );
}
public static void assertNumberOfViolations(Set violations, int expectedViolations) {
- assertEquals( "Wrong number of constraint violations", expectedViolations,
violations.size() );
+ assertEquals( expectedViolations, violations.size(), "Wrong number of constraint
violations" );
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,18 +17,17 @@
*/
package org.hibernate.validation.util;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.validation.ConstraintValidator;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
-import
org.hibernate.validation.constraints.composition.FrenchZipcodeConstraintValidator;
import org.hibernate.validation.constraints.composition.FrenchZipcode;
+import
org.hibernate.validation.constraints.composition.FrenchZipcodeConstraintValidator;
/**
* Tests for message resolution.
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -17,11 +17,11 @@
*/
package org.hibernate.validation.util.annotationfactory;
+import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
-import javax.validation.constraints.Pattern;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
/**
@@ -37,11 +37,11 @@
Size size = AnnotationFactory.create( descriptor );
- assertEquals( "Wrong parameter value", 5, size.min() );
- assertEquals( "Wrong parameter value", 10, size.max() );
+ assertEquals( 5, size.min(), "Wrong parameter value" );
+ assertEquals( 10, size.max(), "Wrong parameter value" );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expectedExceptions = IllegalArgumentException.class)
public void createAnnotationProxyMissingRequiredParamter() {
AnnotationDescriptor<Pattern> descriptor = new
AnnotationDescriptor<Pattern>( Pattern.class );
AnnotationFactory.create( descriptor );
@@ -54,6 +54,6 @@
Pattern pattern = AnnotationFactory.create( descriptor );
- assertEquals( "Wrong parameter value", ".*", pattern.regexp() );
+ assertEquals( ".*", pattern.regexp(), "Wrong parameter value" );
}
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -17,36 +17,36 @@
*/
package org.hibernate.validation.util.performance;
-import java.util.List;
+//import java.util.List;
+//
+//import com.clarkware.junitperf.TestFactory;
+//import junit.framework.JUnit4TestAdapter;
+//import junit.framework.TestCase;
+//import junit.framework.TestSuite;
-import com.clarkware.junitperf.TestFactory;
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+class JUnit4TestFactory { //extends TestFactory {
-class JUnit4TestFactory extends TestFactory {
-
- static class DummyTestCase extends TestCase {
- public void test() {
- }
- }
-
- private List<Class<?>> junit4TestClass;
-
- public JUnit4TestFactory(List<Class<?>> testClasses) {
- super( DummyTestCase.class );
- this.junit4TestClass = testClasses;
- }
-
- @Override
- protected TestSuite makeTestSuite() {
- TestSuite testSuite = new TestSuite( "JUnit4TestFactory" );
- JUnit4TestAdapter unit4TestAdapter;
- for ( Class<?> testClass : junit4TestClass ) {
- unit4TestAdapter = new JUnit4TestAdapter( testClass );
- testSuite.addTest( unit4TestAdapter );
- }
- return testSuite;
- }
+// static class DummyTestCase extends TestCase {
+// public void test() {
+// }
+// }
+//
+// private List<Class<?>> junit4TestClass;
+//
+// public JUnit4TestFactory(List<Class<?>> testClasses) {
+// super( DummyTestCase.class );
+// this.junit4TestClass = testClasses;
+// }
+//
+// @Override
+// protected TestSuite makeTestSuite() {
+// TestSuite testSuite = new TestSuite( "JUnit4TestFactory" );
+// JUnit4TestAdapter unit4TestAdapter;
+// for ( Class<?> testClass : junit4TestClass ) {
+// unit4TestAdapter = new JUnit4TestAdapter( testClass );
+// testSuite.addTest( unit4TestAdapter );
+// }
+// return testSuite;
+// }
}
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java 2009-04-01
13:04:03 UTC (rev 16248)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java 2009-04-02
12:10:40 UTC (rev 16249)
@@ -20,8 +20,8 @@
import java.util.ArrayList;
import java.util.List;
-import com.clarkware.junitperf.TimedTest;
-import junit.framework.Test;
+//import com.clarkware.junitperf.TimedTest;
+//import junit.framework.Test;
import org.hibernate.validation.engine.ValidatorImplTest;
import org.hibernate.validation.engine.ResourceBundleMessageInterpolatorTest;
@@ -34,18 +34,18 @@
*/
public class ValidationPerformace {
- public static Test suite() {
-
- long maxTimeInMillis = 1000;
- List<Class<?>> testClasses = new ArrayList<Class<?>>();
- //testClasses.add( ValidatorImplTest.class );
- testClasses.add( ResourceBundleMessageInterpolatorTest.class );
- //testClasses.add( ConstraintCompositionTest.class );
- Test test = new JUnit4TestFactory( testClasses ).makeTestSuite();
- return new TimedTest( test, maxTimeInMillis );
- }
-
- public static void main(String args[]) {
- junit.textui.TestRunner.run( suite() );
- }
+// public static Test suite() {
+//
+// long maxTimeInMillis = 1000;
+// List<Class<?>> testClasses = new ArrayList<Class<?>>();
+// //testClasses.add( ValidatorImplTest.class );
+// testClasses.add( ResourceBundleMessageInterpolatorTest.class );
+// //testClasses.add( ConstraintCompositionTest.class );
+// Test test = new JUnit4TestFactory( testClasses ).makeTestSuite();
+// return new TimedTest( test, maxTimeInMillis );
+// }
+//
+// public static void main(String args[]) {
+// junit.textui.TestRunner.run( suite() );
+// }
}
Added: validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
(rev 0)
+++ validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-04-02 12:10:40
UTC (rev 16249)
@@ -0,0 +1,19 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="Hibernate Validator Unit Tests" verbose="1">
+ <test name="Unit tests">
+ <packages>
+ <package name="org.hibernate.validation.bootstrap"/>
+ <package name="org.hibernate.validation.constraints"/>
+ <package
name="org.hibernate.validation.constraints.validatorcontext"/>
+ <package name="org.hibernate.validation.engine"/>
+ <package
name="org.hibernate.validation.engine.constraintcomposition"/>
+ <package
name="org.hibernate.validation.engine.graphnavigation"/>
+ <package name="org.hibernate.validation.engine.groups"/>
+ <package name="org.hibernate.validation.engine.metadata"/>
+ <package
name="org.hibernate.validation.engine.validatorresolution"/>
+ <package name="org.hibernate.validation.util"/>
+ <package
name="org.hibernate.validation.util.annotationfactory"/>
+ </packages>
+ </test>
+</suite>
\ No newline at end of file