incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosv...@apache.org
Subject svn commit: r978905 - in /incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints: AssertFalseValidatorTest.java AssertTrueValidatorTest.java NotNullValidatorTest.java NullValidatorTest.java
Date Sat, 24 Jul 2010 17:22:57 GMT
Author: carlosvara
Date: Sat Jul 24 17:22:56 2010
New Revision: 978905

URL: http://svn.apache.org/viewvc?rev=978905&view=rev
Log:
Test coverage for null/notnull assert true/false validators

Added:
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
  (with props)
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
  (with props)
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
  (with props)
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
  (with props)

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java?rev=978905&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
(added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
Sat Jul 24 17:22:56 2010
@@ -0,0 +1,43 @@
+package org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link AssertFalseValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be false.</li>
+ * <li><code>null</code> elements are considered valid.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.4"
+ * 
+ * @author Carlos Vara
+ */
+public class AssertFalseValidatorTest extends TestCase {
+	
+    public static Test suite() {
+        return new TestSuite(AssertFalseValidatorTest.class);
+    }
+    
+    public AssertFalseValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link AssertFalseValidator} with <code>null</code> context.
+     */
+    public void testAssertFalseValidator() {
+    	AssertFalseValidator afv = new AssertFalseValidator();
+    	assertFalse("True value validation must fail", afv.isValid(true, null));
+    	assertTrue("False value validation must succeed", afv.isValid(false, null));
+    	assertTrue("Null value validation must succeed", afv.isValid(null, null));
+    }
+
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java?rev=978905&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
(added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
Sat Jul 24 17:22:56 2010
@@ -0,0 +1,43 @@
+package org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link AssertTrueValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be true.</li>
+ * <li><code>null</code> elements are considered valid.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.3"
+ * 
+ * @author Carlos Vara
+ */
+public class AssertTrueValidatorTest extends TestCase {
+	
+    public static Test suite() {
+        return new TestSuite(AssertTrueValidatorTest.class);
+    }
+    
+    public AssertTrueValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link AssertTrueValidator} with null context.
+     */
+    public void testAssertTrueValidator() {
+    	AssertTrueValidator atv = new AssertTrueValidator();
+    	assertTrue("True value validation must succeed", atv.isValid(true, null));
+    	assertFalse("False value validation must fail", atv.isValid(false, null));
+    	assertTrue("Null value validation must succeed", atv.isValid(null, null));
+    }
+
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java?rev=978905&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
(added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
Sat Jul 24 17:22:56 2010
@@ -0,0 +1,41 @@
+package org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link NotNullValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must not be null.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.2"
+ * 
+ * @author Carlos Vara
+ */
+public class NotNullValidatorTest extends TestCase {
+
+    public static Test suite() {
+        return new TestSuite(NotNullValidatorTest.class);
+    }
+    
+    public NotNullValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link NotNullValidator} with null context.
+     */
+    public void testNotNullValidator() {
+    	NotNullValidator nnv = new NotNullValidator();
+    	assertTrue("Non null value validation must succeed", nnv.isValid("hello", null));
+    	assertFalse("Null value validation must fail", nnv.isValid(null, null));    	
+    }
+	
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java?rev=978905&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
(added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
Sat Jul 24 17:22:56 2010
@@ -0,0 +1,41 @@
+package org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link NullValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be null.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.1"
+ * 
+ * @author Carlos Vara
+ */
+public class NullValidatorTest extends TestCase {
+
+    public static Test suite() {
+        return new TestSuite(NullValidatorTest.class);
+    }
+    
+    public NullValidatorTest(String name) {
+    	super(name);
+    }
+	
+    /**
+     * Test {@link AssertFalseValidator} with null context.
+     */
+    public void testNullValidator() {
+    	NullValidator nv = new NullValidator();
+    	assertTrue("Null value validation must succeed", nv.isValid(null, null));
+    	assertFalse("Non null value validation must fail", nv.isValid("hello", null));    	
+    }
+    
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message