You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2016/10/19 20:36:27 UTC

svn commit: r1765712 [2/3] - in /bval/trunk: bval-core/src/test/java/org/apache/bval/ bval-core/src/test/java/org/apache/bval/model/ bval-json/src/test/java/org/apache/bval/json/ bval-jsr/src/test/java/org/apache/bval/constraints/ bval-jsr/src/test/jav...

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/CustomValidatorFactoryTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/CustomValidatorFactoryTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/CustomValidatorFactoryTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/CustomValidatorFactoryTest.java Wed Oct 19 20:36:26 2016
@@ -18,7 +18,7 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.TestCase;
+import static org.hamcrest.CoreMatchers.isA;
 
 import javax.validation.ConstraintValidatorFactory;
 import javax.validation.MessageInterpolator;
@@ -31,13 +31,15 @@ import javax.validation.ValidatorContext
 import javax.validation.ValidatorFactory;
 import javax.validation.spi.ConfigurationState;
 
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
 /**
  * Test the ability to force a particular {@link ValidatorFactory}
  * implementation class.
- * 
- * @version $Rev$ $Date$
  */
-public class CustomValidatorFactoryTest extends TestCase {
+public class CustomValidatorFactoryTest {
 
     public static class CustomValidatorFactory extends ApacheValidatorFactory {
 
@@ -100,43 +102,49 @@ public class CustomValidatorFactoryTest
         }
     }
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Test
     public void testDefaultValidatorFactory() {
         Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory().unwrap(
             ApacheValidatorFactory.class);
     }
 
+    @Test
     public void testNoSuchType() {
-        try {
-            Validation.byProvider(ApacheValidationProvider.class).configure().addProperty(
-                ApacheValidatorConfiguration.Properties.VALIDATOR_FACTORY_CLASSNAME, "no.such.type")
-                .buildValidatorFactory();
-            fail();
-        } catch (ValidationException ex) {
-            assertTrue(ex.getCause() instanceof ClassNotFoundException);
-        }
+        thrown.expect(ValidationException.class);
+        thrown.expectCause(isA(ClassNotFoundException.class));
+
+        Validation.byProvider(ApacheValidationProvider.class).configure()
+            .addProperty(ApacheValidatorConfiguration.Properties.VALIDATOR_FACTORY_CLASSNAME, "no.such.type")
+            .buildValidatorFactory();
     }
 
+    @Test
     public void testCustomValidatorFactory() {
         doTest(CustomValidatorFactory.class, null);
     }
 
+    @Test
     public void testInvalidType() {
         doTest(NotAValidatorFactory.class, ClassCastException.class);
+        doTest(NotAValidatorFactory.class, ClassCastException.class);
     }
 
+    @Test
     public void testUnsupportedValidatorFactoryType() {
         doTest(IncompatibleValidatorFactory.class, NoSuchMethodException.class);
     }
 
     private void doTest(Class<?> validatorFactoryType, Class<? extends Exception> expectedFailureCause) {
-        try {
-            Validation.byProvider(ApacheValidationProvider.class).configure().addProperty(
-                ApacheValidatorConfiguration.Properties.VALIDATOR_FACTORY_CLASSNAME, validatorFactoryType.getName())
-                .buildValidatorFactory().unwrap(validatorFactoryType);
-            assertNull(expectedFailureCause);
-        } catch (ValidationException ex) {
-            assertNotNull(expectedFailureCause);
-            assertTrue(expectedFailureCause.isInstance(ex.getCause()));
-        }
+        if (expectedFailureCause != null) {
+            thrown.expect(ValidationException.class);
+            thrown.expectCause(isA(expectedFailureCause));
+        }
+        Validation.byProvider(ApacheValidationProvider.class).configure()
+            .addProperty(ApacheValidatorConfiguration.Properties.VALIDATOR_FACTORY_CLASSNAME,
+                validatorFactoryType.getName())
+            .buildValidatorFactory().unwrap(validatorFactoryType);
     }
 }

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/DefaultMessageInterpolatorTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/DefaultMessageInterpolatorTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/DefaultMessageInterpolatorTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/DefaultMessageInterpolatorTest.java Wed Oct 19 20:36:26 2016
@@ -16,46 +16,40 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.bval.jsr.example.Author;
-import org.apache.bval.jsr.example.PreferredGuest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Locale;
 
 import javax.validation.MessageInterpolator;
 import javax.validation.Validator;
 import javax.validation.constraints.Pattern;
 import javax.validation.metadata.ConstraintDescriptor;
-import java.util.Locale;
+
+import org.apache.bval.jsr.example.Author;
+import org.apache.bval.jsr.example.PreferredGuest;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * MessageResolverImpl Tester.
  */
-public class DefaultMessageInterpolatorTest extends TestCase {
+public class DefaultMessageInterpolatorTest {
 
     private DefaultMessageInterpolator interpolator;
 
-    public DefaultMessageInterpolatorTest(String name) {
-        super(name);
-    }
-
-    public static Test suite() {
-        return new TestSuite(DefaultMessageInterpolatorTest.class);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp(); // call super!
+    @Before
+    public void setUp() throws Exception {
         interpolator = new DefaultMessageInterpolator();
         interpolator.setLocale(Locale.ENGLISH);
     }
 
+    @Test
     public void testCreateResolver() {
 
         final Validator gvalidator = getValidator();
 
-        assertTrue(!gvalidator.getConstraintsForClass(PreferredGuest.class).getConstraintsForProperty(
+        assertFalse(gvalidator.getConstraintsForClass(PreferredGuest.class).getConstraintsForProperty(
             "guestCreditCardNumber").getConstraintDescriptors().isEmpty());
 
         MessageInterpolator.Context ctx = new MessageInterpolator.Context() {
@@ -77,7 +71,7 @@ public class DefaultMessageInterpolatorT
             }
         };
         String msg = interpolator.interpolate("{validator.creditcard}", ctx);
-        Assert.assertEquals("credit card is not valid", msg);
+        assertEquals("credit card is not valid", msg);
 
         ctx = new MessageInterpolator.Context() {
             @Override
@@ -98,13 +92,14 @@ public class DefaultMessageInterpolatorT
         };
 
         msg = interpolator.interpolate("{org.apache.bval.constraints.NotEmpty.message}", ctx);
-        Assert.assertEquals("may not be empty", msg);
+        assertEquals("may not be empty", msg);
     }
 
     /**
      * Checks that strings containing special characters are correctly
      * substituted when interpolating.
      */
+    @Test
     public void testReplacementWithSpecialChars() {
 
         final Validator validator = getValidator();
@@ -131,8 +126,8 @@ public class DefaultMessageInterpolatorT
         };
 
         String result = this.interpolator.interpolate("Id number should match {regexp}", ctx);
-        Assert.assertEquals("Incorrect message interpolation when $ is in an attribute",
-            "Id number should match ....$", result);
+        assertEquals("Incorrect message interpolation when $ is in an attribute", "Id number should match ....$",
+            result);
 
         // Try to interpolate an annotation attribute containing \
         ctx = new MessageInterpolator.Context() {
@@ -155,9 +150,8 @@ public class DefaultMessageInterpolatorT
         };
 
         result = this.interpolator.interpolate("Other id should match {regexp}", ctx);
-        Assert.assertEquals("Incorrect message interpolation when \\ is in an attribute value",
-            "Other id should match .\\n", result);
-
+        assertEquals("Incorrect message interpolation when \\ is in an attribute value", "Other id should match .\\n",
+            result);
     }
 
     public static class Person {

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ExceptionsContractTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ExceptionsContractTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ExceptionsContractTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ExceptionsContractTest.java Wed Oct 19 20:36:26 2016
@@ -18,17 +18,13 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import javax.validation.Validation;
 import javax.validation.ValidationException;
 import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import javax.validation.metadata.BeanDescriptor;
-import java.util.Locale;
+
+import org.junit.Test;
 
 /**
  * Several checks to validate that the implementations of {@link Validator} and
@@ -36,103 +32,60 @@ import java.util.Locale;
  * 
  * @author Carlos Vara
  */
-public class ExceptionsContractTest extends TestCase {
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
+public class ExceptionsContractTest extends ValidationTestBase {
 
     /**
-     * {@inheritDoc}
+     * Checks that the correct exception is thrown when validating a bean whose
+     * getter throws an exception.
      */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
+    @Test(expected = ValidationException.class)
+    public void testExceptionThrowingBean() {
+        validator.validate(new ExceptionThrowingBean());
     }
 
     /**
-     * Create the validator instance.
-     * 
-     * @return Validator
+     * Checks that an {@link IllegalArgumentException} is thrown when passing
+     * <code>null</code> as group array.
      */
-    protected Validator createValidator() {
-        return factory.getValidator();
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateNullGroup() {
+        validator.validate(new String(), (Class<?>[]) null);
     }
 
     /**
-     * Checks that the correct exception is thrown when validating a bean whose
-     * getter throws an exception.
+     * Checks that an {@link IllegalArgumentException} is thrown when passing a
+     * {@code null} property name.
      */
-    public void testExceptionThrowingBean() {
-        try {
-            validator.validate(new ExceptionThrowingBean());
-            Assert.fail("No exception thrown when validating a bean whose getter throws a RTE");
-        } catch (ValidationException e) {
-            // Correct
-        }
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateNullPropertyName() {
+        validator.validateProperty(new Person(), null);
     }
 
     /**
-     * Checks that an {@link IllegalArgumentException} is thrown when passing
-     * <code>null</code> as group array.
+     * Checks that an {@link IllegalArgumentException} is thrown when passing an
+     * empty property name.
      */
-    public void testValidateNullGroup() {
-        try {
-            Class<?>[] groups = null;
-            validator.validate(new String(), groups);
-            Assert.fail("No exception thrown when passing null as group array");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateEmptyPropertyName() {
+        validator.validateProperty(new Person(), "");
     }
 
     /**
      * Checks that an {@link IllegalArgumentException} is thrown when passing an
      * invalid property name.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateInvalidPropertyName() {
-
-        // Null propertyName
-        try {
-            validator.validateProperty(new Person(), null);
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
-        // Empty propertyName
-        try {
-            validator.validateProperty(new Person(), "");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
-        // Invalid propertyName
-        try {
-            validator.validateProperty(new Person(), "surname");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
+        validator.validateProperty(new Person(), "surname");
     }
 
     /**
      * Checks that an {@link IllegalArgumentException} is thrown when trying to
      * validate a property on a null object.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidatePropertyOnNullBean() {
-        try {
-            validator.validateProperty(null, "class");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateProperty(null, "class");
     }
 
     /**
@@ -140,14 +93,9 @@ public class ExceptionsContractTest exte
      * <code>null</code> as group array in a
      * {@link Validator#validateProperty(Object, String, Class...)} call.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidatePropertyNullGroup() {
-        try {
-            Class<?>[] groups = null;
-            validator.validateProperty(new Person(), "name", groups);
-            Assert.fail("No exception thrown when passing null as group array");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateProperty(new Person(), "name", (Class<?>[]) null);
     }
 
     /**
@@ -155,13 +103,29 @@ public class ExceptionsContractTest exte
      * {@link Validator#validateValue(Class, String, Object, Class...)} with a
      * <code>null</code> class.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateValueOnNullClass() {
-        try {
-            validator.validateValue(null, "class", Object.class);
-            Assert.fail("No exception thrown when passing null as group array");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateValue(null, "class", Object.class);
+    }
+
+    /**
+     * Checks that an {@link IllegalArgumentException} is thrown when passing a
+     * {@code null} property name to
+     * {@link Validator#validateValue(Class, String, Object, Class...)}.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateValueNullPropertyName() {
+        validator.validateValue(Person.class, null, "John");
+    }
+
+    /**
+     * Checks that an {@link IllegalArgumentException} is thrown when passing an
+     * empty property name to
+     * {@link Validator#validateValue(Class, String, Object, Class...)}.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateValueEmptyPropertyName() {
+        validator.validateValue(Person.class, "", "John");
     }
 
     /**
@@ -169,27 +133,9 @@ public class ExceptionsContractTest exte
      * invalid property name to
      * {@link Validator#validateValue(Class, String, Object, Class...)}.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateValueInvalidPropertyName() {
-        // Null propertyName
-        try {
-            validator.validateValue(Person.class, null, "John");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
-        // Empty propertyName
-        try {
-            validator.validateValue(Person.class, "", "John");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
-        // Invalid propertyName
-        try {
-            validator.validateValue(Person.class, "unexistant", "John");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateValue(Person.class, "unexistant", "John");
     }
 
     /**
@@ -197,33 +143,27 @@ public class ExceptionsContractTest exte
      * {@link Validator#validateValue(Class, String, Object, Class...)} with a
      * <code>null</code> group array.
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateValueNullGroup() {
-        try {
-            Class<?>[] groups = null;
-            validator.validateValue(Person.class, "name", "John", groups);
-            Assert.fail("No exception thrown when passing null as group array");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateValue(Person.class, "name", "John", (Class<?>[]) null);
     }
 
     /**
      * Enforces the "not a valid object property" part of the {@link IllegalArgumentException}
      * declaration on {@link Validator#validateValue(Class, String, Object, Class...)}
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateIncompatibleValue() {
-        try {
-            validator.validateValue(Person.class, "name", 666);
-            Assert.fail("No exception thrown when passing Integer for string value");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-        try {
-            validator.validateValue(Person.class, "age", null);
-            Assert.fail("No exception thrown when passing null for primitive value");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+        validator.validateValue(Person.class, "name", 666);
+    }
+
+    /**
+     * Enforces the "not a valid object property" part of the {@link IllegalArgumentException}
+     * declaration on {@link Validator#validateValue(Class, String, Object, Class...)}
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testValidateIncompatiblePrimitiveValue() {
+        validator.validateValue(Person.class, "age", null);
     }
 
     /**
@@ -231,22 +171,21 @@ public class ExceptionsContractTest exte
      * {@link BeanDescriptor#getConstraintsForProperty(String)} with an invalid
      * property name.
      */
-    public void testGetConstraintsForInvalidProperty() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetConstraintsForNullProperty() {
         BeanDescriptor personDescriptor = validator.getConstraintsForClass(Person.class);
+        personDescriptor.getConstraintsForProperty(null);
+    }
 
-        try {
-            personDescriptor.getConstraintsForProperty(null);
-            fail("No exception thrown when calling getConstraintsForProperty with null property");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
-
-        try {
-            personDescriptor.getConstraintsForProperty("");
-            fail("No exception thrown when calling getConstraintsForProperty with empty property");
-        } catch (IllegalArgumentException e) {
-            // Correct
-        }
+    /**
+     * Checks that an {@link IllegalArgumentException} is thrown when calling
+     * {@link BeanDescriptor#getConstraintsForProperty(String)} with an invalid
+     * property name.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testGetConstraintsForEmptyProperty() {
+        BeanDescriptor personDescriptor = validator.getConstraintsForClass(Person.class);
+        personDescriptor.getConstraintsForProperty("");
     }
 
     public static class ExceptionThrowingBean {

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/FooTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/FooTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/FooTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/FooTest.java Wed Oct 19 20:36:26 2016
@@ -18,46 +18,46 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.Valid;
-import javax.validation.Validator;
 import javax.validation.constraints.NotNull;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Description: <br/>
  */
-public class FooTest extends TestCase {
+public class FooTest extends ValidationTestBase {
 
     @Valid
     private Collection<Foo> foos = new ArrayList<Foo>();
 
-    public FooTest() {
+    @Before
+    public void setup() {
         foos.add(new Foo("foo1"));
         foos.add(null);
         foos.add(new Foo("foo3"));
     }
 
-
-    public class Foo {
+    public static class Foo {
         @NotNull
         public String bar;
 
         public Foo(String bar) {
             this.bar = bar;
         }
-
     }
 
+    @Test
     public void testValidation() {
         FooTest t = new FooTest();
 
-        Validator v = ApacheValidatorFactory.getDefault().getValidator();
-        Set<ConstraintViolation<FooTest>> errors = v.validate(t);
+        Set<ConstraintViolation<FooTest>> errors = validator.validate(t);
         System.out.println("got errors:");
         for (ConstraintViolation<?> error : errors) {
             System.out.println(error.getPropertyPath());

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/Jsr303Test.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/Jsr303Test.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/Jsr303Test.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/Jsr303Test.java Wed Oct 19 20:36:26 2016
@@ -18,8 +18,26 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.UnexpectedTypeException;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
 import org.apache.bval.constraints.SizeValidatorForCharSequence;
 import org.apache.bval.jsr.example.Address;
 import org.apache.bval.jsr.example.Book;
@@ -30,141 +48,72 @@ import org.apache.bval.jsr.example.NoVal
 import org.apache.bval.jsr.example.Second;
 import org.apache.bval.jsr.example.SizeTestEntity;
 import org.apache.bval.jsr.util.TestUtils;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.UnexpectedTypeException;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.metadata.ElementDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 /**
  * Description: <br/>
  */
-public class Jsr303Test extends TestCase {
-    /*
-     * static { ApacheValidatorFactory.getDefault().getMetaBeanManager()
-     * .addResourceLoader("org/apache/bval/example/test-beanInfos.xml"); }
-     */
-
-    /*
-     * public void testUseCoreXmlMetaData() { Validator validator =
-     * getValidator();
-     * 
-     * BusinessObject object = new BusinessObject();
-     * object.setTitle("1234567834567 too long title ");
-     * Set<ConstraintViolation<BusinessObject>> violations =
-     * validator.validate(object); Assert.assertNotNull(violations);
-     * Assert.assertTrue(!violations.isEmpty());
-     * 
-     * Assert.assertTrue(!validator.validateProperty(object,
-     * "title").isEmpty()); }
-     */
-
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
-    }
-
-    /**
-     * Create the validator instance.
-     * 
-     * @return Validator
-     */
-    protected Validator createValidator() {
-        return factory.getValidator();
-    }
+public class Jsr303Test extends ValidationTestBase {
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
 
+    @Test
     public void testPropertyDescriptorHasConstraints() {
         BeanDescriptor cons = validator.getConstraintsForClass(Book.class);
         assertTrue(cons.getConstraintsForProperty("author").hasConstraints());
         assertTrue(cons.getConstraintsForProperty("title").hasConstraints());
         assertTrue(cons.getConstraintsForProperty("uselessField").hasConstraints());
-        // cons.getConstraintsForProperty("unconstraintField") == null without
-        // Introspector
-        // cons.getConstraintsForProperty("unconstraintField") != null with
-        // Introspector
+        // cons.getConstraintsForProperty("unconstraintField") == null without Introspector
+        // cons.getConstraintsForProperty("unconstraintField") != null with Introspector
         assertTrue(cons.getConstraintsForProperty("unconstraintField") == null
             || !cons.getConstraintsForProperty("unconstraintField").hasConstraints());
         assertNull(cons.getConstraintsForProperty("unknownField"));
     }
 
+    @Test
     public void testValidateValue() {
         assertTrue(validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
         assertFalse(validator.validateValue(Book.class, "subtitle",
             "123456789098765432123412345678909876543212341234564567890987654321234", Second.class).isEmpty());
         // tests for issue 22: validation of a field without any constraints
-        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
-        // tests for issue 22: validation of unknown field cause
-        // ValidationException
-        try {
-            validator.validateValue(Book.class, "unknownProperty", 4);
-            fail("unknownProperty not detected");
-        } catch (IllegalArgumentException ex) {
-            // OK
-            assertEquals("unknown property 'unknownProperty' in org.apache.bval.jsr.example.Book", ex.getMessage());
-        }
+        assertTrue(validator.validateValue(Book.class, "unconstraintField", 4).isEmpty());
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testUnknownProperty() {
+        // tests for issue 22: validation of unknown field cause ValidationException
+        validator.validateValue(Book.class, "unknownProperty", 4);
     }
 
+    @Test(expected = IllegalArgumentException.class)
     public void testValidateNonCascadedRealNestedProperty() {
-        try {
-            validator.validateValue(IllustratedBook.class, "illustrator.firstName", "Edgar");
-            fail("unknownProperty not detected");
-        } catch (IllegalArgumentException ex) {
-            // OK
-            assertEquals("Property org.apache.bval.jsr.example.IllustratedBook.illustrator is not cascaded", ex.getMessage());
-        }
+        validator.validateValue(IllustratedBook.class, "illustrator.firstName", "Edgar");
     }
 
+    @Test
     public void testMetadataAPI_Book() {
-        Assert.assertNotNull(validator.getConstraintsForClass(Book.class));
-        // not necessary for implementation correctness, but we'll test
-        // nevertheless:
-        Assert.assertSame(validator.getConstraintsForClass(Book.class), validator.getConstraintsForClass(Book.class));
+        assertNotNull(validator.getConstraintsForClass(Book.class));
+        // not necessary for implementation correctness, but we'll test nevertheless:
+        assertSame(validator.getConstraintsForClass(Book.class), validator.getConstraintsForClass(Book.class));
         BeanDescriptor bc = validator.getConstraintsForClass(Book.class);
-        // assertEquals(ElementType.TYPE, bc.getElementType());
-        Assert.assertEquals(Book.class, bc.getElementClass());
-        // assertEquals(false, bc.isCascaded());
-        // assertEquals("", bc.getPropertyPath());
-        Assert.assertTrue(bc.getConstraintDescriptors() != null);
+        assertEquals(Book.class, bc.getElementClass());
+        assertNotNull(bc.getConstraintDescriptors());
         TestUtils.failOnModifiable(bc.getConstraintDescriptors(), "beanDescriptor constraintDescriptors");
     }
 
+    @Test
     public void testMetadataAPI_Engine() {
         ElementDescriptor desc =
             validator.getConstraintsForClass(Engine.class).getConstraintsForProperty("serialNumber");
         assertNotNull(desc);
-        // assertEquals(ElementType.FIELD, desc.getElementType());
-        Assert.assertEquals(String.class, desc.getElementClass());
+        assertEquals(String.class, desc.getElementClass());
     }
 
+    @Test
     public void testMetadataAPI_Address() {
-        Assert.assertFalse(validator.getConstraintsForClass(Address.class).getConstraintDescriptors().isEmpty());
+        assertFalse(validator.getConstraintsForClass(Address.class).getConstraintDescriptors().isEmpty());
 
         Set<PropertyDescriptor> props = validator.getConstraintsForClass(Address.class).getConstrainedProperties();
         TestUtils.failOnModifiable(props, "beanDescriptor constrainedProperties");
@@ -173,30 +122,30 @@ public class Jsr303Test extends TestCase
             TestUtils.failOnModifiable(each.getConstraintDescriptors(), "propertyDescriptor constraintDescriptors");
             propNames.add(each.getPropertyName());
         }
-        Assert.assertTrue(propNames.contains("addressline1")); // annotated at
+        assertTrue(propNames.contains("addressline1")); // annotated at
         // field level
-        Assert.assertTrue(propNames.contains("addressline2"));
-        Assert.assertTrue(propNames.contains("zipCode"));
-        Assert.assertTrue(propNames.contains("country"));
-        Assert.assertTrue(propNames.contains("city")); // annotated at method
+        assertTrue(propNames.contains("addressline2"));
+        assertTrue(propNames.contains("zipCode"));
+        assertTrue(propNames.contains("country"));
+        assertTrue(propNames.contains("city")); // annotated at method
         // level
-        Assert.assertEquals(5, props.size());
+        assertEquals(5, props.size());
 
         ElementDescriptor desc =
             validator.getConstraintsForClass(Address.class).getConstraintsForProperty("addressline1");
-        Assert.assertNotNull(desc);
+        assertNotNull(desc);
         boolean found = false;
         for (ConstraintDescriptor<?> each : desc.getConstraintDescriptors()) {
-            if (each.getConstraintValidatorClasses().get(0).equals(SizeValidatorForCharSequence.class)) {
-                Assert.assertTrue(each.getAttributes().containsKey("max"));
+            if (SizeValidatorForCharSequence.class.equals(each.getConstraintValidatorClasses().get(0))) {
+                assertTrue(each.getAttributes().containsKey("max"));
                 assertEquals(30, each.getAttributes().get("max"));
                 found = true;
             }
         }
-        Assert.assertTrue(found);
-
+        assertTrue(found);
     }
 
+    @Test
     public void testValidateMultiValuedConstraints() {
         Engine engine = new Engine();
         engine.serialNumber = "abcd-defg-0123";
@@ -207,11 +156,12 @@ public class Jsr303Test extends TestCase
         engine.serialNumber = "!)/(/()";
         violations = validator.validate(engine);
         assertEquals(2, violations.size());
-        for (String msg : new String[] { "must contain alphabetical characters only", "must match ....-....-...." }) {
+        for (String msg : Arrays.asList("must contain alphabetical characters only", "must match ....-....-....")) {
             assertNotNull(TestUtils.getViolationWithMessage(violations, msg));
         }
     }
 
+    @Test
     public void testConstraintValidatorResolutionAlgorithm() {
         MaxTestEntity entity = new MaxTestEntity();
         entity.setText("101");
@@ -220,19 +170,20 @@ public class Jsr303Test extends TestCase
         entity.setDecimalValue(new BigDecimal(401));
         Set<ConstraintViolation<MaxTestEntity>> violations = validator.validate(entity);
         assertEquals(4, violations.size());
+    }
+    
+    @Test
+    public void testConstraintValidatorResolutionAlgorithm2() {
+        thrown.expect(UnexpectedTypeException.class);
+        thrown.expectMessage("No validator could be found for type java.lang.Object. "
+                + "See: @Max at private java.lang.Object org.apache.bval.jsr.example."
+                + "NoValidatorTestEntity.anything");
 
         NoValidatorTestEntity entity2 = new NoValidatorTestEntity();
-        try {
-            validator.validate(entity2);
-            fail("UnexpectedTypeException expected but not thrown");
-        } catch (UnexpectedTypeException ex) {
-            // we expected this
-            assertEquals("No validator could be found for type java.lang.Object. "
-                + "See: @Max at private java.lang.Object " + "org.apache.bval.jsr.example."
-                + "NoValidatorTestEntity.anything", ex.getMessage());
-        }
+        validator.validate(entity2);
     }
 
+    @Test
     public void testSizeValidation() {
         SizeTestEntity en = new SizeTestEntity();
         en.ba = new byte[3];
@@ -258,14 +209,9 @@ public class Jsr303Test extends TestCase
     /**
      * JSR-303 Section 5.1.c, IllegalArgumentException should be thrown
      */
+    @Test(expected = IllegalArgumentException.class)
     public void testGetConstraintsForNullClass() {
-        try {
-            validator.getConstraintsForClass(null);
-            Assert.fail("No exception thrown on Validator.getConstraintsForClass(null)");
-        } catch (IllegalArgumentException e) {
-            // Correct
-            return;
-        }
+        validator.getConstraintsForClass(null);
     }
 
 }

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/PayloadTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/PayloadTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/PayloadTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/PayloadTest.java Wed Oct 19 20:36:26 2016
@@ -18,53 +18,25 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.TestCase;
-import org.apache.bval.jsr.util.TestUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.Payload;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
 import javax.validation.constraints.NotNull;
-import java.util.Locale;
-import java.util.Set;
+
+import org.apache.bval.jsr.util.TestUtils;
+import org.junit.Test;
 
 /**
  * Description: test that payload information can be retrieved
  * from error reports via the ConstraintDescriptor either accessed
  * through the ConstraintViolation objects<br/>
  */
-public class PayloadTest extends TestCase {
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
-    }
-
-    /**
-     * Create the validator instance.
-     * 
-     * @return Validator
-     */
-    protected Validator createValidator() {
-        return factory.getValidator();
-    }
+public class PayloadTest extends ValidationTestBase {
 
     static class Severity {
         static class Info implements Payload {
@@ -94,22 +66,20 @@ public class PayloadTest extends TestCas
         }
     }
 
+    @Test
     public void testPayload() {
-        Set<ConstraintViolation<Address>> violations;
         Address address = new Address(null, null);
-        violations = validator.validate(address);
+        final Set<ConstraintViolation<Address>> violations = validator.validate(address);
         assertEquals(2, violations.size());
-        ConstraintViolation<?> vio;
-        vio = TestUtils.getViolation(violations, "zipCode");
-        assertNotNull(vio);
-        assertEquals(1, vio.getConstraintDescriptor().getPayload().size());
-        assertTrue(
-              vio.getConstraintDescriptor().getPayload().contains(Severity.Info.class));
-
-        vio = TestUtils.getViolation(violations, "city");
-        assertNotNull(vio);
-        assertEquals(1, vio.getConstraintDescriptor().getPayload().size());
-        assertTrue(
-              vio.getConstraintDescriptor().getPayload().contains(Severity.Error.class));
+
+        final ConstraintViolation<?> zipViolation = TestUtils.getViolation(violations, "zipCode");
+        assertNotNull(zipViolation);
+        assertEquals(1, zipViolation.getConstraintDescriptor().getPayload().size());
+        assertTrue(zipViolation.getConstraintDescriptor().getPayload().contains(Severity.Info.class));
+
+        final ConstraintViolation<?> cityViolation = TestUtils.getViolation(violations, "city");
+        assertNotNull(cityViolation);
+        assertEquals(1, cityViolation.getConstraintDescriptor().getPayload().size());
+        assertTrue(cityViolation.getConstraintDescriptor().getPayload().contains(Severity.Error.class));
     }
 }

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/TckReproducerTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/TckReproducerTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/TckReproducerTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/TckReproducerTest.java Wed Oct 19 20:36:26 2016
@@ -19,16 +19,15 @@
 
 package org.apache.bval.jsr;
 
-import junit.framework.TestCase;
-import org.apache.bval.util.PropertyAccess;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Set;
 
 import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
 import javax.validation.constraints.Pattern;
-import java.util.Locale;
-import java.util.Set;
+
+import org.apache.bval.util.PropertyAccess;
+import org.junit.Test;
 
 /**
  * Description: <br>
@@ -36,60 +35,28 @@ import java.util.Set;
  * Date: 21.04.2010<br>
  * Time: 14:21:45<br>
  */
-public class TckReproducerTest extends TestCase {
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
-    }
-
-    /**
-     * Create the validator instance.
-     * 
-     * @return Validator
-     */
-    protected Validator createValidator() {
-        return factory.getValidator();
-    }
+public class TckReproducerTest extends ValidationTestBase {
 
-    public static <T> void assertCorrectNumberOfViolations(Set<ConstraintViolation<T>> violations,
+    private static <T> void assertCorrectNumberOfViolations(Set<ConstraintViolation<T>> violations,
         int expectedViolations) {
         assertEquals("Wrong number of constraint violations. Expected: " + expectedViolations + " Actual: "
             + violations.size(), expectedViolations, violations.size());
     }
 
+    @Test
     public void testPropertyAccessOnNonPublicClass() throws Exception {
         Car car = new Car("USd-298");
         assertEquals(car.getLicensePlateNumber(), PropertyAccess.getProperty(car, "licensePlateNumber"));
 
-        Set<ConstraintViolation<Car>> violations =
-            validator.validateProperty(car, "licensePlateNumber", First.class,
-                org.apache.bval.jsr.example.Second.class);
-        assertCorrectNumberOfViolations(violations, 1);
+        assertCorrectNumberOfViolations(validator.validateProperty(car, "licensePlateNumber", First.class,
+            org.apache.bval.jsr.example.Second.class), 1);
 
         car.setLicensePlateNumber("USD-298");
-        violations =
-            validator.validateProperty(car, "licensePlateNumber", First.class,
-                org.apache.bval.jsr.example.Second.class);
-        assertCorrectNumberOfViolations(violations, 0);
+        assertCorrectNumberOfViolations(validator.validateProperty(car, "licensePlateNumber", First.class,
+            org.apache.bval.jsr.example.Second.class), 0);
     }
 
-    class Car {
+    static class Car {
         @Pattern(regexp = "[A-Z][A-Z][A-Z]-[0-9][0-9][0-9]", groups = { First.class, Second.class })
         private String licensePlateNumber;
 

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidationTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidationTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidationTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidationTest.java Wed Oct 19 20:36:26 2016
@@ -18,8 +18,32 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
 import org.apache.bval.constraints.NotNullValidator;
 import org.apache.bval.jsr.example.AccessTestBusinessObject;
 import org.apache.bval.jsr.example.AccessTestBusinessObjectSub;
@@ -33,121 +57,67 @@ import org.apache.bval.jsr.example.First
 import org.apache.bval.jsr.example.Last;
 import org.apache.bval.jsr.example.RecursiveFoo;
 import org.apache.bval.jsr.util.TestUtils;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import javax.validation.groups.Default;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Description: <br/>
  */
-public class ValidationTest extends TestCase {
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
-    }
-
-    /**
-     * Create the validator instance.
-     * 
-     * @return Validator
-     */
-    protected Validator createValidator() {
-        return factory.getValidator();
-    }
+public class ValidationTest extends ValidationTestBase {
 
+    @Before
     public void testCache() {
         factory.getValidator().getConstraintsForClass(AccessTestBusinessObject.class);
         factory.getValidator().getConstraintsForClass(AccessTestBusinessObject.class);
     }
+
+    @Test
     public void testAccessStrategies_field_method() {
         AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
+        assertTrue(validator.validate(o1).isEmpty());
+
         AccessTestBusinessObjectSub o2 = new AccessTestBusinessObjectSub("3");
-        Set<ConstraintViolation<AccessTestBusinessObject>> errors = validator.validate(o1);
-        assertTrue(errors.isEmpty());
-        Set<ConstraintViolation<AccessTestBusinessObjectSub>> errors2 = validator.validate(o2);
-        assertTrue(errors2.isEmpty());
+        assertTrue(validator.validate(o2).isEmpty());
 
         o2 = new AccessTestBusinessObjectSub("1");
-        errors2 = validator.validate(o2);
-        assertEquals(1, errors2.size());
+        assertEquals(1, validator.validate(o2).size());
 
         // assert, that getvar2() and getVar2() are both validated with their
         // getter method
         o2 = new AccessTestBusinessObjectSub("3");
         o2.setVar2("1");
         o2.setvar2("2");
-        errors2 = validator.validate(o2);
-        assertEquals(2, errors2.size());
+        assertEquals(2, validator.validate(o2).size());
 
         o2.setvar2("5");
         o2.setVar2("6");
-        errors2 = validator.validate(o2);
-        assertEquals(0, errors2.size());
+        assertTrue(validator.validate(o2).isEmpty());
 
         o2.setvar2("5");
         o2.setVar2("-1");
-        errors2 = validator.validate(o2);
-        assertEquals(1, errors2.size());
+        assertEquals(1, validator.validate(o2).size());
     }
 
+    @Test
     public void testAccessStrategies_on_children() {
         AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
         AccessTestBusinessObject o2 = new AccessTestBusinessObject("2");
         o1.next(o2);
-        Set<ConstraintViolation<AccessTestBusinessObject>> errors = validator.validate(o1);
-        // assert, that field access 'next' is used and not getNext() is
-        // called!!!
-        assertEquals(1, errors.size());
+        // assert, that field access 'next' is used and not getNext() is called!!!
+        assertEquals(1, validator.validate(o1).size());
         o2 = new AccessTestBusinessObject("1");
         o1.next(o2);
-        errors = validator.validate(o1);
-        assertEquals(0, errors.size());
+        assertTrue(validator.validate(o1).isEmpty());
 
-        // assert that toBeIgnored not validated, because not annotated with
-        // @Valid
+        // assert that toBeIgnored not validated, because not annotated with @Valid
         o1.setToBeIgnored(new AccessTestBusinessObject("99"));
-        errors = validator.validate(o1);
-        assertEquals(0, errors.size());
+        assertTrue(validator.validate(o1).isEmpty());
 
         o1.setNext(new AccessTestBusinessObject("99"));
-        errors = validator.validate(o1);
-        assertEquals(1, errors.size());
+        assertEquals(1, validator.validate(o1).size());
     }
 
+    @Test
     public void testBook() {
         Author author = new Author();
         author.setLastName("Baudelaire");
@@ -158,7 +128,7 @@ public class ValidationTest extends Test
 
         // NotEmpty failure on the title field
         Set<ConstraintViolation<Book>> errors = validator.validate(book, Book.All.class);
-        Assert.assertTrue(!errors.isEmpty());
+        assertFalse(errors.isEmpty());
 
         book.setTitle("Les fleurs du mal");
         author.setCompany("Some random publisher with a very very very long name");
@@ -171,6 +141,7 @@ public class ValidationTest extends Test
      * test: - dynamic resolution of associated object types. - inheritance of validation constraints - complex
      * valiation, different groups, nested object net
      */
+    @Test
     public void testValidAnnotation() {
         Author a = new Author();
         a.setAddresses(new ArrayList<Address>());
@@ -186,18 +157,19 @@ public class ValidationTest extends Test
         a.setLastName("May");
 
         Set<ConstraintViolation<Author>> found = validator.validate(a, Default.class, First.class, Last.class);
-        Assert.assertTrue(!found.isEmpty());
-        Assert.assertEquals(4, found.size());
+        assertTrue(!found.isEmpty());
+        assertEquals(4, found.size());
 
         adr.setCity("Berlin");
         adr.setZipCode("12345");
         adr.setCompany("apache");
         found = validator.validate(a, Default.class, First.class, Last.class);
-        Assert.assertEquals(1, found.size());
+        assertEquals(1, found.size());
         ConstraintViolation<Author> ic = found.iterator().next();
-        Assert.assertEquals("addresses[0].country.name", ic.getPropertyPath().toString());
+        assertEquals("addresses[0].country.name", ic.getPropertyPath().toString());
     }
 
+    @Test
     public void testPropertyPathWithIndex() {
         Author a = new Author();
         a.setAddresses(new ArrayList<Address>());
@@ -215,7 +187,7 @@ public class ValidationTest extends Test
         a.getAddresses().add(adr);
 
         Set<ConstraintViolation<Author>> constraints = validator.validate(a);
-        Assert.assertTrue(!constraints.isEmpty());
+        assertFalse(constraints.isEmpty());
 
         assertPropertyPath("addresses[0].country", constraints);
         assertPropertyPath("addresses[1].country", constraints);
@@ -225,6 +197,7 @@ public class ValidationTest extends Test
     /**
      * Check correct path reporting when validating a set of beans.
      */
+    @Test
     public void testPropertyPathOnSet() {
         Continent c = new Continent();
         c.name = "c1";
@@ -235,19 +208,21 @@ public class ValidationTest extends Test
         c.countries.add(country);
 
         Set<ConstraintViolation<Continent>> constraints = validator.validate(c);
-        Assert.assertEquals("Incorrect number of violations detected", 1, constraints.size());
+        assertEquals("Incorrect number of violations detected", 1, constraints.size());
         assertPropertyPath("countries[].name", constraints);
 
     }
 
-    private <T> void assertPropertyPath(String propertyPath, Set<ConstraintViolation<T>> constraints) {
+    private static <T> void assertPropertyPath(String propertyPath, Set<ConstraintViolation<T>> constraints) {
         for (ConstraintViolation<T> each : constraints) {
-            if (each.getPropertyPath().toString().equals(propertyPath))
+            if (each.getPropertyPath().toString().equals(propertyPath)) {
                 return;
+            }
         }
-        Assert.fail(propertyPath + " not found in " + constraints);
+        fail(propertyPath + " not found in " + constraints);
     }
 
+    @Test
     public void testPropertyPathRecursive() {
         RecursiveFoo foo1 = new RecursiveFoo(); // root
         RecursiveFoo foo11 = new RecursiveFoo();
@@ -262,23 +237,20 @@ public class ValidationTest extends Test
         assertPropertyPath("foos[1].foos", constraints);
     }
 
+    @Test
     public void testNullElementInCollection() {
-        try {
-            validator.validate(null);
-            Assert.fail();
-        } catch (IllegalArgumentException ex) {
-        }
         RecursiveFoo foo = new RecursiveFoo();
         foo.getFoos().add(new RecursiveFoo());
         foo.getFoos().add(null);
-        Assert.assertTrue(!validator.validate(foo).isEmpty());
+        assertFalse(validator.validate(foo).isEmpty());
         // check that no nullpointer exception gets thrown
     }
 
+    @Test
     public void testGroups() {
-        Author author = new Author();
+        final Author author = new Author();
         author.setCompany("ACME");
-        Book book = new Book();
+        final Book book = new Book();
         book.setTitle("");
         book.setAuthor(author);
         boolean foundTitleConstraint = false;
@@ -286,19 +258,19 @@ public class ValidationTest extends Test
         assertEquals(1, constraintViolations.size());
         // assuming an english locale, the interpolated message is returned
         for (ConstraintViolation<Book> constraintViolation : constraintViolations) {
-            if (constraintViolation.getRootBean().getClass() == Book.class) {
-                Assert.assertEquals("may not be empty", constraintViolation.getMessage());
-                Assert.assertTrue(book == constraintViolation.getRootBean());
+            if (Book.class.equals(constraintViolation.getRootBean().getClass())) {
+                assertEquals("may not be empty", constraintViolation.getMessage());
+                assertSame(book, constraintViolation.getRootBean());
 
                 // the offending property
-                if (constraintViolation.getPropertyPath().toString().equals("title")) {
+                if ("title".equals(constraintViolation.getPropertyPath().toString())) {
                     foundTitleConstraint = true;
                     // the offending value
-                    Assert.assertEquals(book.getTitle(), constraintViolation.getInvalidValue());
+                    assertEquals(book.getTitle(), constraintViolation.getInvalidValue());
                 }
             }
         }
-        Assert.assertTrue(foundTitleConstraint);
+        assertTrue(foundTitleConstraint);
     }
 
     /**
@@ -306,6 +278,7 @@ public class ValidationTest extends Test
      * {@link org.apache.bval.constraints.ZipCodeCityCoherenceValidator} adds custom messages to the context and
      * suppresses the default message
      */
+    @Test
     public void testConstraintValidatorContextFluentAPI() {
         Address ad = new Address();
         ad.setCity("error");
@@ -314,14 +287,15 @@ public class ValidationTest extends Test
         ad.setCountry(new Country());
         ad.getCountry().setName("something");
         Set<ConstraintViolation<Address>> violations = validator.validate(ad);
-        Assert.assertEquals(2, violations.size());
+        assertEquals(2, violations.size());
         for (ConstraintViolation<Address> each : violations) {
-            Assert.assertTrue(each.getMessage().endsWith(" not OK"));
+            assertTrue(each.getMessage().endsWith(" not OK"));
         }
         assertNotNull(TestUtils.getViolation(violations, "city"));
         assertNotNull(TestUtils.getViolation(violations, ""));
     }
 
+    @Test
     public void testValidateNestedPropertyPath() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "addresses[0].country.ISO2Code";
@@ -335,7 +309,7 @@ public class ValidationTest extends Test
         country.setISO2Code("too_long");
 
         Set<ConstraintViolation<Author>> iv = validator.validateProperty(author, propPath);
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
         ConstraintViolation<Author> vio = iv.iterator().next();
         assertEquals(propPath, vio.getPropertyPath().toString());
         assertSame(author, vio.getRootBean());
@@ -343,19 +317,19 @@ public class ValidationTest extends Test
 
         country.setISO2Code("23");
         iv = validator.validateProperty(author, propPath);
-        Assert.assertEquals(0, iv.size());
+        assertTrue(iv.isEmpty());
 
         iv = validator.validateValue(Author.class, propPath, "345");
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
         vio = iv.iterator().next();
         assertEquals(propPath, vio.getPropertyPath().toString());
         assertNull(vio.getRootBean());
         assertNull(vio.getLeafBean());
 
-        iv = validator.validateValue(Author.class, propPath, "34");
-        Assert.assertEquals(0, iv.size());
+        assertTrue(validator.validateValue(Author.class, propPath, "34").isEmpty());
     }
 
+    @Test
     public void testValidateCascadingNestedBean() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "addresses[0]";
@@ -370,17 +344,17 @@ public class ValidationTest extends Test
         adr.setCountry(country);
 
         Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
-        Assert.assertEquals(1, iv.size()); // null address line 1 (no cascade)
+        assertEquals(1, iv.size()); // null address line 1 (no cascade)
 
         country.setISO2Code("too_long");
         iv = v.validateProperty(author, propPath, true);
-        Assert.assertEquals(3, iv.size()); // null address line 1 + null
+        assertEquals(3, iv.size()); // null address line 1 + null
         // country.name + too long
         // country.iso2code
 
         country.setISO2Code("23");
         iv = v.validateProperty(author, propPath, true);
-        Assert.assertEquals(2, iv.size()); // null address line 1 + null
+        assertEquals(2, iv.size()); // null address line 1 + null
         // country.name, country.iso2code
         // fixed
 
@@ -388,17 +362,18 @@ public class ValidationTest extends Test
         value.setCity("whatever");
         value.setAddressline1("1 address line");
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(1, iv.size()); // null country
+        assertEquals(1, iv.size()); // null country
 
         value.setCountry(new Country());
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(1, iv.size()); // null country.name
+        assertEquals(1, iv.size()); // null country.name
 
         value.getCountry().setName("NWO");
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(0, iv.size());
+        assertEquals(0, iv.size());
     }
 
+    @Test
     public void testValidateCascadingNestedProperty() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "addresses[0].country";
@@ -413,32 +388,33 @@ public class ValidationTest extends Test
         adr.setCountry(country);
 
         Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
-        Assert.assertEquals(0, iv.size());
+        assertEquals(0, iv.size());
 
         country.setISO2Code("too_long");
         iv = v.validateProperty(author, propPath, true);
-        Assert.assertEquals(2, iv.size());
+        assertEquals(2, iv.size());
         // country.name + too long
         // country.iso2code
 
         country.setISO2Code("23");
         iv = v.validateProperty(author, propPath, true);
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
         // country.name, country.iso2code
 
         Country value = null;
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(1, iv.size()); // null country
+        assertEquals(1, iv.size()); // null country
 
         value = new Country();
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(1, iv.size()); // null country.name
+        assertEquals(1, iv.size()); // null country.name
 
         value.setName("NWO");
         iv = v.validateValue(Author.class, propPath, value, true);
-        Assert.assertEquals(0, iv.size());
+        assertEquals(0, iv.size());
     }
 
+    @Test
     public void testValidateCascadingNestedTipProperty() {
         final String propPath = "addresses[0].country.name";
 
@@ -452,12 +428,13 @@ public class ValidationTest extends Test
         adr.setCountry(country);
 
         Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
 
         iv = v.validateProperty(author, propPath, true);
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
     }
 
+    @Test
     public void testValidateCascadingKeyedElement() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "[foo]";
@@ -474,17 +451,17 @@ public class ValidationTest extends Test
         adr.setCity("dark");
         adr.setCountry(country);
         Set<ConstraintViolation<Object>> iv = v.validateProperty(map, propPath);
-        Assert.assertEquals(1, iv.size()); // null address line 1 (no cascade)
+        assertEquals(1, iv.size()); // null address line 1 (no cascade)
 
         country.setISO2Code("too_long");
         iv = v.validateProperty(map, propPath, true);
-        Assert.assertEquals(3, iv.size()); // null address line 1 + null
+        assertEquals(3, iv.size()); // null address line 1 + null
         // country.name + too long
         // country.iso2code
 
         country.setISO2Code("23");
         iv = v.validateProperty(map, propPath, true);
-        Assert.assertEquals(2, iv.size()); // null address line 1 + null
+        assertEquals(2, iv.size()); // null address line 1 + null
         // country.name, country.iso2code
         // fixed
 
@@ -493,18 +470,19 @@ public class ValidationTest extends Test
         value.setAddressline1("1 address line");
 
         Set<?> iv2 = v.validateValue(map.getClass(), propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country
+        assertEquals(1, iv2.size()); // null country
 
         value.setCountry(new Country());
         iv2 = v.validateValue(map.getClass(), propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country.name
+        assertEquals(1, iv2.size()); // null country.name
 
         value.getCountry().setName("NWO");
         iv2 = v.validateValue(map.getClass(), propPath, value, true);
-        Assert.assertEquals(0, iv2.size());
+        assertEquals(0, iv2.size());
     }
 
     @SuppressWarnings("unchecked")
+    @Test
     public void testValidateCascadingKeyedGenericElement() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "[foo]";
@@ -517,17 +495,17 @@ public class ValidationTest extends Test
         adr.setCity("dark");
         adr.setCountry(country);
         Set<?> iv = v.validateProperty(map, propPath);
-        Assert.assertEquals(1, iv.size()); // null address line 1 (no cascade)
+        assertEquals(1, iv.size()); // null address line 1 (no cascade)
 
         country.setISO2Code("too_long");
         iv = v.validateProperty(map, propPath, true);
-        Assert.assertEquals(3, iv.size()); // null address line 1 + null
+        assertEquals(3, iv.size()); // null address line 1 + null
         // country.name + too long
         // country.iso2code
 
         country.setISO2Code("23");
         iv = v.validateProperty(map, propPath, true);
-        Assert.assertEquals(2, iv.size()); // null address line 1 + null
+        assertEquals(2, iv.size()); // null address line 1 + null
         // country.name, country.iso2code
         // fixed
 
@@ -536,17 +514,18 @@ public class ValidationTest extends Test
         value.setAddressline1("1 address line");
 
         Set<?> iv2 = v.validateValue(Map.class, propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country
+        assertEquals(1, iv2.size()); // null country
 
         value.setCountry(new Country());
         iv2 = v.validateValue(Map.class, propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country.name
+        assertEquals(1, iv2.size()); // null country.name
 
         value.getCountry().setName("NWO");
         iv2 = v.validateValue(Map.class, propPath, value, true);
-        Assert.assertEquals(0, iv2.size());
+        assertEquals(0, iv2.size());
     }
 
+    @Test
     public void testValidateCascadingIndexedElement() throws InvocationTargetException, NoSuchMethodException,
         IllegalAccessException {
         final String propPath = "[0]";
@@ -557,34 +536,35 @@ public class ValidationTest extends Test
         Set<ConstraintViolation<Address[]>> iv;
         Address[] array = { value };
         iv = v.validateProperty(array, propPath, true);
-        Assert.assertEquals(1, iv.size()); // null country
+        assertEquals(1, iv.size()); // null country
 
         value.setCountry(new Country());
         iv = v.validateProperty(array, propPath, true);
-        Assert.assertEquals(1, iv.size()); // null country.name
+        assertEquals(1, iv.size()); // null country.name
 
         value.getCountry().setName("NWO");
         iv = v.validateProperty(array, propPath, true);
-        Assert.assertEquals(0, iv.size());
+        assertEquals(0, iv.size());
 
         value = new Address();
         value.setCity("whatever");
         value.setAddressline1("1 address line");
         Set<?> iv2;
         iv2 = v.validateValue(array.getClass(), propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country
+        assertEquals(1, iv2.size()); // null country
 
         value.setCountry(new Country());
         iv2 = v.validateValue(array.getClass(), propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country.name
+        assertEquals(1, iv2.size()); // null country.name
 
         value.getCountry().setName("NWO");
         iv2 = v.validateValue(array.getClass(), propPath, value, true);
-        Assert.assertEquals(0, iv2.size());
+        assertEquals(0, iv2.size());
     }
 
-    public void testValidateCascadingIndexedGenericElement() throws InvocationTargetException, NoSuchMethodException,
-    IllegalAccessException {
+    @Test
+    public void testValidateCascadingIndexedGenericElement()
+        throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
         final String propPath = "[0]";
         CascadingPropertyValidator v = validator.unwrap(CascadingPropertyValidator.class);
         Address value = new Address();
@@ -593,30 +573,30 @@ public class ValidationTest extends Test
         Set<?> iv;
         Object list = Collections.singletonList(value);
         iv = v.validateProperty(list, propPath, true);
-        Assert.assertEquals(1, iv.size()); // null country
+        assertEquals(1, iv.size()); // null country
         
         value.setCountry(new Country());
         iv = v.validateProperty(list, propPath, true);
-        Assert.assertEquals(1, iv.size()); // null country.name
+        assertEquals(1, iv.size()); // null country.name
         
         value.getCountry().setName("NWO");
         iv = v.validateProperty(list, propPath, true);
-        Assert.assertEquals(0, iv.size());
+        assertEquals(0, iv.size());
         
         value = new Address();
         value.setCity("whatever");
         value.setAddressline1("1 address line");
         Set<?> iv2;
         iv2 = v.validateValue(List.class, propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country
+        assertEquals(1, iv2.size()); // null country
         
         value.setCountry(new Country());
         iv2 = v.validateValue(List.class, propPath, value, true);
-        Assert.assertEquals(1, iv2.size()); // null country.name
+        assertEquals(1, iv2.size()); // null country.name
         
         value.getCountry().setName("NWO");
         iv2 = v.validateValue(List.class, propPath, value, true);
-        Assert.assertEquals(0, iv2.size());
+        assertEquals(0, iv2.size());
     }
     
     public interface Foo {
@@ -633,6 +613,7 @@ public class ValidationTest extends Test
         }
     }
 
+    @Test
     public void testValidateCascadingPropertyWithMultipleGroupsIgnoresSiblingProperties() {
         final String propPath = "addresses[0].country";
 
@@ -645,27 +626,28 @@ public class ValidationTest extends Test
         adr.setCountry(country);
 
         Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath, true, Default.class, Foo.class);
-        Assert.assertEquals(1, iv.size());
+        assertEquals(1, iv.size());
     }
 
+    @Test
     public void testMetadataAPI() {
         BeanDescriptor bookBeanDescriptor = validator.getConstraintsForClass(Book.class);
 
         // expect no constraints on Book's Class-Level
-        Assert.assertFalse(bookBeanDescriptor.hasConstraints());
+        assertFalse(bookBeanDescriptor.hasConstraints());
         // but there are constraints on Book's Property-Level
-        Assert.assertTrue(bookBeanDescriptor.isBeanConstrained());
-        Assert.assertTrue(bookBeanDescriptor.getConstraintDescriptors().size() == 0); // no
+        assertTrue(bookBeanDescriptor.isBeanConstrained());
+        assertTrue(bookBeanDescriptor.getConstraintDescriptors().isEmpty()); // no
         // constraint
         // more specifically "author" and "title"
-        Assert.assertEquals(4, bookBeanDescriptor.getConstrainedProperties().size());
+        assertEquals(4, bookBeanDescriptor.getConstrainedProperties().size());
         // not a property
-        Assert.assertTrue(bookBeanDescriptor.getConstraintsForProperty("doesNotExist") == null);
+        assertNull(bookBeanDescriptor.getConstraintsForProperty("doesNotExist"));
         // property with no constraint
-        Assert.assertTrue(bookBeanDescriptor.getConstraintsForProperty("description") == null);
+        assertNull(bookBeanDescriptor.getConstraintsForProperty("description"));
         PropertyDescriptor propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("title");
-        Assert.assertEquals(2, propertyDescriptor.getConstraintDescriptors().size());
-        Assert.assertTrue("title".equals(propertyDescriptor.getPropertyName()));
+        assertEquals(2, propertyDescriptor.getConstraintDescriptors().size());
+        assertEquals("title", propertyDescriptor.getPropertyName());
         // assuming the implementation returns the NotEmpty constraint first
         Iterator<ConstraintDescriptor<?>> iter = propertyDescriptor.getConstraintDescriptors().iterator();
         ConstraintDescriptor<?> constraintDescriptor = null;
@@ -676,57 +658,61 @@ public class ValidationTest extends Test
             }
 
         }
-        Assert.assertTrue(constraintDescriptor != null);
-        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1); // "first"
-        Assert.assertEquals(NotNullValidator.class, constraintDescriptor.getConstraintValidatorClasses().get(0));
+        assertNotNull(constraintDescriptor);
+        assertEquals(1, constraintDescriptor.getGroups().size()); // "first"
+        assertEquals(NotNullValidator.class, constraintDescriptor.getConstraintValidatorClasses().get(0));
         // assuming the implementation returns the Size constraint first
         propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("subtitle");
         Iterator<ConstraintDescriptor<?>> iterator = propertyDescriptor.getConstraintDescriptors().iterator();
         constraintDescriptor = iterator.next();
-        Assert.assertTrue(constraintDescriptor.getAnnotation().annotationType().equals(Size.class));
-        Assert.assertTrue(((Integer) constraintDescriptor.getAttributes().get("max")) == 30);
-        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1);
+        assertTrue(constraintDescriptor.getAnnotation().annotationType().equals(Size.class));
+        assertEquals(30, ((Integer) constraintDescriptor.getAttributes().get("max")).intValue());
+        assertEquals(1, constraintDescriptor.getGroups().size());
         propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("author");
-        Assert.assertTrue(propertyDescriptor.getConstraintDescriptors().size() == 1);
-        Assert.assertTrue(propertyDescriptor.isCascaded());
-        Assert.assertNull(bookBeanDescriptor.getConstraintsForProperty("unconstraintField"));
+        assertEquals(1, propertyDescriptor.getConstraintDescriptors().size());
+        assertTrue(propertyDescriptor.isCascaded());
+        assertNull(bookBeanDescriptor.getConstraintsForProperty("unconstraintField"));
     }
 
+    @Test
     public void testKeyedMetadata() {
         @SuppressWarnings("serial")
         BeanDescriptor beanDescriptor = validator.getConstraintsForClass(new HashMap<String, Object>() {}.getClass());
-        Assert.assertNotNull(beanDescriptor);
-        Assert.assertFalse(beanDescriptor.isBeanConstrained());
-        Assert.assertNull(beanDescriptor.getConstraintsForProperty("[foo]"));
+        assertNotNull(beanDescriptor);
+        assertFalse(beanDescriptor.isBeanConstrained());
+        assertNull(beanDescriptor.getConstraintsForProperty("[foo]"));
     }
 
+    @Test
     public void testGenericKeyedMetadata() {
         BeanDescriptor beanDescriptor = validator.getConstraintsForClass(Map.class);
-        Assert.assertNotNull(beanDescriptor);
-        Assert.assertFalse(beanDescriptor.isBeanConstrained());
-        Assert.assertNull(beanDescriptor.getConstraintsForProperty("[foo]"));
+        assertNotNull(beanDescriptor);
+        assertFalse(beanDescriptor.isBeanConstrained());
+        assertNull(beanDescriptor.getConstraintsForProperty("[foo]"));
     }
-    
+
+    @Test
     public void testIndexedMetadata() {
         BeanDescriptor beanDescriptor = validator.getConstraintsForClass(Array.newInstance(Author.class, 0).getClass());
-        Assert.assertNotNull(beanDescriptor);
-        Assert.assertFalse(beanDescriptor.isBeanConstrained());
-        Assert.assertNull(beanDescriptor.getConstraintsForProperty("[0]"));
+        assertNotNull(beanDescriptor);
+        assertFalse(beanDescriptor.isBeanConstrained());
+        assertNull(beanDescriptor.getConstraintsForProperty("[0]"));
     }
-    
+
+    @Test
     public void testGenericIndexedMetadata() {
         BeanDescriptor beanDescriptor = validator.getConstraintsForClass(List.class);
-        Assert.assertNotNull(beanDescriptor);
-        Assert.assertFalse(beanDescriptor.isBeanConstrained());
-        Assert.assertNull(beanDescriptor.getConstraintsForProperty("[0]"));
+        assertNotNull(beanDescriptor);
+        assertFalse(beanDescriptor.isBeanConstrained());
+        assertNull(beanDescriptor.getConstraintsForProperty("[0]"));
     }
-    
+
+    @Test
     public void testValidateClassImplementingCloneable() {
     	Set<ConstraintViolation<TestCloneableClass>> errors = validator.validate(new TestCloneableClass());
-    	Assert.assertTrue(errors.isEmpty());
+    	assertTrue(errors.isEmpty());
     }
-    
-    private static class TestCloneableClass implements Cloneable {
 
+    private static class TestCloneableClass implements Cloneable {
     }
 }

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidatorResolutionTest.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidatorResolutionTest.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidatorResolutionTest.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/ValidatorResolutionTest.java Wed Oct 19 20:36:26 2016
@@ -18,26 +18,23 @@
  */
 package org.apache.bval.jsr;
 
-import junit.framework.TestCase;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
 
 import javax.validation.Constraint;
 import javax.validation.ConstraintDefinitionException;
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 import javax.validation.Payload;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
 import javax.validation.constraints.NotNull;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.util.Locale;
 
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import org.junit.Test;
 
 
 /**
@@ -45,48 +42,15 @@ import static java.lang.annotation.Reten
  * 
  * @author Carlos Vara
  */
-public class ValidatorResolutionTest extends TestCase {
-    static ValidatorFactory factory;
-
-    static {
-        factory = Validation.buildDefaultValidatorFactory();
-        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
-    }
-
-    /**
-     * Validator instance to test
-     */
-    protected Validator validator;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        validator = createValidator();
-    }
-
-    /**
-     * Create the validator instance.
-     * 
-     * @return Validator
-     */
-    protected Validator createValidator() {
-        return factory.getValidator();
-    }
+public class ValidatorResolutionTest extends ValidationTestBase {
 
     /**
      * Check that a {@link ConstraintDefinitionException} is thrown when the
      * only available validator is associated with a different annotation type.
      */
+    @Test(expected = ConstraintDefinitionException.class)
     public void testInvalidValidator() {
-        try {
-            validator.validate(new Person());
-            fail("No exception thrown, but no valid validator available.");
-        } catch (ConstraintDefinitionException e) {
-            // correct
-        }
+        validator.validate(new Person());
     }
 
     public static class Person {

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/AccessTestBusinessObject.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/AccessTestBusinessObject.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/AccessTestBusinessObject.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/AccessTestBusinessObject.java Wed Oct 19 20:36:26 2016
@@ -32,7 +32,6 @@ public class AccessTestBusinessObject {
     protected String var1;
 
     // test that field-access is used, not method-access
-    @SuppressWarnings("unused")
     @Valid
     private AccessTestBusinessObject next;
 

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/Book.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/Book.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/Book.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/Book.java Wed Oct 19 20:36:26 2016
@@ -39,7 +39,6 @@ public class Book {
     @NotNull(groups = First.class)
     private Author author;
 
-    @SuppressWarnings("unused")
     @NotNull
     private int uselessField;
 

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/CompanyAddress.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/CompanyAddress.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/CompanyAddress.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/CompanyAddress.java Wed Oct 19 20:36:26 2016
@@ -24,7 +24,6 @@ import org.apache.bval.constraints.Compa
  * Description: <br/>
  */
 public class CompanyAddress {
-    @SuppressWarnings("unused")
     @CompanyEmail
     private String email;
 

Modified: bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/NoValidatorTestEntity.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/NoValidatorTestEntity.java?rev=1765712&r1=1765711&r2=1765712&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/NoValidatorTestEntity.java (original)
+++ bval/trunk/bval-jsr/src/test/java/org/apache/bval/jsr/example/NoValidatorTestEntity.java Wed Oct 19 20:36:26 2016
@@ -24,7 +24,6 @@ import javax.validation.constraints.Max;
  * Description: <br/>
  */
 public class NoValidatorTestEntity {
-    @SuppressWarnings("unused")
     @Max(20)
     private Object anything;