EXTVAL-124, EXTVAL-125, EXTVAL-126

git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk@1066035 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestBean.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestBean.java
new file mode 100644
index 0000000..9fa2f56
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestBean.java
@@ -0,0 +1,38 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

+

+import java.util.Date;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs1TestBean

+{

+

+    private Date property1;

+

+    @DateIs(valueOf = "property1", type = DateIsType.before)

+    private Date property2;

+

+    public Date getProperty1()

+    {

+        return property1;

+    }

+

+    public void setProperty1(Date property1)

+    {

+        this.property1 = property1;

+    }

+

+    public Date getProperty2()

+    {

+        return property2;

+    }

+

+    public void setProperty2(Date property2)

+    {

+        this.property2 = property2;

+    }

+}

diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestCase.java
new file mode 100644
index 0000000..42bd5ed
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs1TestCase.java
@@ -0,0 +1,138 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;

+import org.junit.Test;

+

+import javax.faces.application.FacesMessage;

+import javax.faces.component.UIViewRoot;

+import javax.faces.component.html.HtmlForm;

+import javax.faces.component.html.HtmlInputText;

+import javax.faces.convert.DateTimeConverter;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs1TestCase extends AbstractPropertyValidationTestCase

+{

+

+    HtmlInputText inputComponent1 = null;

+    HtmlInputText inputComponent2 = null;

+

+    UIViewRoot rootComponent = null;

+

+    public DateIs1TestCase()

+    {

+        inputComponent1 = null;

+        inputComponent2 = null;

+        rootComponent = null;

+    }

+

+

+    @Override

+    protected void setUpTestCase()

+    {

+        super.setUpTestCase();

+        DateIs1TestBean bean = new DateIs1TestBean();

+        createValueBinding(null, "value", "#{testBean}");

+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);

+

+        rootComponent = new UIViewRoot();

+        HtmlForm form = new HtmlForm();

+        form.setId("form");

+        rootComponent.getChildren().add(form);

+        inputComponent1 = new HtmlInputText();

+        form.getChildren().add(inputComponent1);

+        inputComponent1.setId("input1");

+        inputComponent2 = new HtmlInputText();

+        form.getChildren().add(inputComponent2);

+        inputComponent2.setId("input2");

+

+        DateTimeConverter converter = new DateTimeConverter();

+        converter.setPattern("DD/MM/yyyy");

+        inputComponent1.setConverter(converter);

+        inputComponent2.setConverter(converter);

+    }

+

+    @Test

+    public void testDateIsBeforeCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("23/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsBeforeWrong() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("23/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+    }

+

+    @Test

+    public void testDateIsBeforeTargetNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsBeforeSourceNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+}
\ No newline at end of file
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestBean.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestBean.java
new file mode 100644
index 0000000..1a36fff
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestBean.java
@@ -0,0 +1,38 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

+

+import java.util.Date;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs2TestBean

+{

+    private Date property1;

+

+    @DateIs(valueOf = "property1", type = DateIsType.after)

+    private Date property2;

+

+    public Date getProperty1()

+    {

+        return property1;

+    }

+

+    public void setProperty1(Date property1)

+    {

+        this.property1 = property1;

+    }

+

+    public Date getProperty2()

+    {

+        return property2;

+    }

+

+    public void setProperty2(Date property2)

+    {

+        this.property2 = property2;

+    }

+

+}

diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestCase.java
new file mode 100644
index 0000000..6875726
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs2TestCase.java
@@ -0,0 +1,138 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;

+import org.junit.Test;

+

+import javax.faces.application.FacesMessage;

+import javax.faces.component.UIViewRoot;

+import javax.faces.component.html.HtmlForm;

+import javax.faces.component.html.HtmlInputText;

+import javax.faces.convert.DateTimeConverter;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs2TestCase extends AbstractPropertyValidationTestCase

+{

+

+    HtmlInputText inputComponent1 = null;

+    HtmlInputText inputComponent2 = null;

+

+    UIViewRoot rootComponent = null;

+

+    public DateIs2TestCase()

+    {

+        inputComponent1 = null;

+        inputComponent2 = null;

+        rootComponent = null;

+    }

+

+

+    @Override

+    protected void setUpTestCase()

+    {

+        super.setUpTestCase();

+        DateIs2TestBean bean = new DateIs2TestBean();

+        createValueBinding(null, "value", "#{testBean}");

+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);

+

+        rootComponent = new UIViewRoot();

+        HtmlForm form = new HtmlForm();

+        form.setId("form");

+        rootComponent.getChildren().add(form);

+        inputComponent1 = new HtmlInputText();

+        form.getChildren().add(inputComponent1);

+        inputComponent1.setId("input1");

+        inputComponent2 = new HtmlInputText();

+        form.getChildren().add(inputComponent2);

+        inputComponent2.setId("input2");

+

+        DateTimeConverter converter = new DateTimeConverter();

+        converter.setPattern("DD/MM/yyyy");

+        inputComponent1.setConverter(converter);

+        inputComponent2.setConverter(converter);

+    }

+

+    @Test

+    public void testDateIsAfterCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("23/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsAfterWrong() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("23/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+    }

+

+    @Test

+    public void testDateIsAfterTargetNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsAfterSourceNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+}
\ No newline at end of file
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestBean.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestBean.java
new file mode 100644
index 0000000..c0d1c22
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestBean.java
@@ -0,0 +1,38 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

+

+import java.util.Date;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs3TestBean

+{

+    private Date property1;

+

+    @DateIs(valueOf = "property1", type = DateIsType.same)

+    private Date property2;

+

+    public Date getProperty1()

+    {

+        return property1;

+    }

+

+    public void setProperty1(Date property1)

+    {

+        this.property1 = property1;

+    }

+

+    public Date getProperty2()

+    {

+        return property2;

+    }

+

+    public void setProperty2(Date property2)

+    {

+        this.property2 = property2;

+    }

+

+}

diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestCase.java
new file mode 100644
index 0000000..6e6f5ce
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs3TestCase.java
@@ -0,0 +1,143 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;

+import org.junit.Test;

+

+import javax.faces.application.FacesMessage;

+import javax.faces.component.UIViewRoot;

+import javax.faces.component.html.HtmlForm;

+import javax.faces.component.html.HtmlInputText;

+import javax.faces.convert.DateTimeConverter;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs3TestCase extends AbstractPropertyValidationTestCase

+{

+

+    HtmlInputText inputComponent1 = null;

+    HtmlInputText inputComponent2 = null;

+

+    UIViewRoot rootComponent = null;

+

+    public DateIs3TestCase()

+    {

+        inputComponent1 = null;

+        inputComponent2 = null;

+        rootComponent = null;

+    }

+

+

+    @Override

+    protected void setUpTestCase()

+    {

+        super.setUpTestCase();

+        DateIs3TestBean bean = new DateIs3TestBean();

+        createValueBinding(null, "value", "#{testBean}");

+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);

+

+        rootComponent = new UIViewRoot();

+        HtmlForm form = new HtmlForm();

+        form.setId("form");

+        rootComponent.getChildren().add(form);

+        inputComponent1 = new HtmlInputText();

+        form.getChildren().add(inputComponent1);

+        inputComponent1.setId("input1");

+        inputComponent2 = new HtmlInputText();

+        form.getChildren().add(inputComponent2);

+        inputComponent2.setId("input2");

+

+        DateTimeConverter converter = new DateTimeConverter();

+        converter.setPattern("DD/MM/yyyy");

+        inputComponent1.setConverter(converter);

+        inputComponent2.setConverter(converter);

+    }

+

+    @Test

+    public void testDateIsSameCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsSameWrong() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("23/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+    }

+

+    @Test

+    public void testDateIsSameTargetNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+

+

+    }

+

+    @Test

+    public void testDateIssSameSourceNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+

+    }

+

+}
\ No newline at end of file
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestBean.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestBean.java
new file mode 100644
index 0000000..aff314c
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestBean.java
@@ -0,0 +1,38 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

+

+import java.util.Date;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs4TestBean

+{

+    private Date property1;

+

+    @DateIs(valueOf = "property1", type = DateIsType.beforeOrSame)

+    private Date property2;

+

+    public Date getProperty1()

+    {

+        return property1;

+    }

+

+    public void setProperty1(Date property1)

+    {

+        this.property1 = property1;

+    }

+

+    public Date getProperty2()

+    {

+        return property2;

+    }

+

+    public void setProperty2(Date property2)

+    {

+        this.property2 = property2;

+    }

+

+}

diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestCase.java
new file mode 100644
index 0000000..869978b
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs4TestCase.java
@@ -0,0 +1,158 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;

+import org.junit.Test;

+

+import javax.faces.application.FacesMessage;

+import javax.faces.component.UIViewRoot;

+import javax.faces.component.html.HtmlForm;

+import javax.faces.component.html.HtmlInputText;

+import javax.faces.convert.DateTimeConverter;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs4TestCase extends AbstractPropertyValidationTestCase

+{

+

+    HtmlInputText inputComponent1 = null;

+    HtmlInputText inputComponent2 = null;

+

+    UIViewRoot rootComponent = null;

+

+    public DateIs4TestCase()

+    {

+        inputComponent1 = null;

+        inputComponent2 = null;

+        rootComponent = null;

+    }

+

+

+    @Override

+    protected void setUpTestCase()

+    {

+        super.setUpTestCase();

+        DateIs4TestBean bean = new DateIs4TestBean();

+        createValueBinding(null, "value", "#{testBean}");

+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);

+

+        rootComponent = new UIViewRoot();

+        HtmlForm form = new HtmlForm();

+        form.setId("form");

+        rootComponent.getChildren().add(form);

+        inputComponent1 = new HtmlInputText();

+        form.getChildren().add(inputComponent1);

+        inputComponent1.setId("input1");

+        inputComponent2 = new HtmlInputText();

+        form.getChildren().add(inputComponent2);

+        inputComponent2.setId("input2");

+

+        DateTimeConverter converter = new DateTimeConverter();

+        converter.setPattern("DD/MM/yyyy");

+        inputComponent1.setConverter(converter);

+        inputComponent2.setConverter(converter);

+    }

+

+    @Test

+    public void testDateIsBeforeCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("23/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsBeforeSameCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsBeforeWrong() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("23/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+    }

+

+    @Test

+    public void testDateIsBeforeSourceNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsBeforeTargetNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+}
\ No newline at end of file
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestBean.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestBean.java
new file mode 100644
index 0000000..3ea52c1
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestBean.java
@@ -0,0 +1,38 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

+

+import java.util.Date;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs5TestBean

+{

+    private Date property1;

+

+    @DateIs(valueOf = "property1", type = DateIsType.afterOrSame)

+    private Date property2;

+

+    public Date getProperty1()

+    {

+        return property1;

+    }

+

+    public void setProperty1(Date property1)

+    {

+        this.property1 = property1;

+    }

+

+    public Date getProperty2()

+    {

+        return property2;

+    }

+

+    public void setProperty2(Date property2)

+    {

+        this.property2 = property2;

+    }

+

+}

diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestCase.java
new file mode 100644
index 0000000..43730d2
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/DateIs5TestCase.java
@@ -0,0 +1,158 @@
+package org.apache.myfaces.extensions.validator.test.propval.crossval;

+

+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;

+import org.junit.Test;

+

+import javax.faces.application.FacesMessage;

+import javax.faces.component.UIViewRoot;

+import javax.faces.component.html.HtmlForm;

+import javax.faces.component.html.HtmlInputText;

+import javax.faces.convert.DateTimeConverter;

+

+/**

+ * @author Rudy De Busscher

+ */

+public class DateIs5TestCase extends AbstractPropertyValidationTestCase

+{

+

+    HtmlInputText inputComponent1 = null;

+    HtmlInputText inputComponent2 = null;

+

+    UIViewRoot rootComponent = null;

+

+    public DateIs5TestCase()

+    {

+        inputComponent1 = null;

+        inputComponent2 = null;

+        rootComponent = null;

+    }

+

+

+    @Override

+    protected void setUpTestCase()

+    {

+        super.setUpTestCase();

+        DateIs5TestBean bean = new DateIs5TestBean();

+        createValueBinding(null, "value", "#{testBean}");

+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);

+

+        rootComponent = new UIViewRoot();

+        HtmlForm form = new HtmlForm();

+        form.setId("form");

+        rootComponent.getChildren().add(form);

+        inputComponent1 = new HtmlInputText();

+        form.getChildren().add(inputComponent1);

+        inputComponent1.setId("input1");

+        inputComponent2 = new HtmlInputText();

+        form.getChildren().add(inputComponent2);

+        inputComponent2.setId("input2");

+

+        DateTimeConverter converter = new DateTimeConverter();

+        converter.setPattern("DD/MM/yyyy");

+        inputComponent1.setConverter(converter);

+        inputComponent2.setConverter(converter);

+    }

+

+    @Test

+    public void testDateIsAfterCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("23/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsAfterSameCorrect() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsAfterSameWrong() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("23/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(1);

+

+        assertNavigationBlocked(true);

+

+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);

+    }

+

+    @Test

+    public void testDateIsAfterSameSourceNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("");

+        inputComponent2.setSubmittedValue("25/01/2011");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+    @Test

+    public void testDateIsAfterSameTargetNull() throws Exception

+    {

+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");

+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");

+

+        //decode

+        inputComponent1.setSubmittedValue("25/01/2011");

+        inputComponent2.setSubmittedValue("");

+

+        //validate

+        inputComponent1.validate(facesContext);

+        inputComponent2.validate(facesContext);

+

+        processCrossValidation();

+        checkMessageCount(0);

+

+        assertNavigationBlocked(false);

+    }

+

+}
\ No newline at end of file
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java
index 92e7916..47a7473 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java
@@ -57,9 +57,15 @@
 

     String notAfterErrorMsgKey() default "wrong_date_not_after";

 

+    String notBeforeOrSameErrorMsgKey() default "wrong_date_not_before_or_same";

+

+    String notAfterOrSameErrorMsgKey() default "wrong_date_not_after_or_same";

+

     String notEqualErrorMsgKey() default "wrong_date_not_equal";

 

     int errorMessageDateStyle() default DateFormat.MEDIUM;

 

+    String errorMessageDatePattern() default "";

+

     Class<? extends ValidationParameter>[] parameters() default ViolationSeverity.Error.class;

 }
\ No newline at end of file
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java
index 7c5f482..92b9915 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java
@@ -18,8 +18,6 @@
  */

 package org.apache.myfaces.extensions.validator.crossval.annotation;

 

-import org.apache.myfaces.extensions.validator.internal.ToDo;

-import org.apache.myfaces.extensions.validator.internal.Priority;

 import org.apache.myfaces.extensions.validator.internal.UsageInformation;

 import org.apache.myfaces.extensions.validator.internal.UsageCategory;

 

@@ -27,9 +25,8 @@
  * @author Gerhard Petracek

  * @since 1.x.1

  */

-@ToDo(value = Priority.MEDIUM, description = "beforeOrSame, afterOrSame")

 @UsageInformation(UsageCategory.API)

 public enum DateIsType

 {

-    before, after, same

+    before, after, same, beforeOrSame, afterOrSame

 }

diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java
index 6074d9d..63f6bbe 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java
@@ -19,7 +19,6 @@
 package org.apache.myfaces.extensions.validator.crossval.strategy;

 

 import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;

-import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;

 import org.apache.myfaces.extensions.validator.crossval.annotation.MessageTarget;

 import org.apache.myfaces.extensions.validator.baseval.annotation.SkipValidationSupport;

 import org.apache.myfaces.extensions.validator.internal.UsageInformation;

@@ -27,6 +26,7 @@
 

 import javax.faces.context.FacesContext;

 import java.text.DateFormat;

+import java.text.SimpleDateFormat;

 import java.util.Date;

 import java.util.MissingResourceException;

 import java.util.logging.Level;

@@ -41,6 +41,8 @@
 {

     protected static final String TOO_EARLY = "early";

     protected static final String TOO_LATE = "late";

+    protected static final String TOO_EARLY_SAME = "earlyNotSame";

+    protected static final String TOO_LATE_SAME = "lateNotSame";

     protected static final String NOT_EQUAL_DATE_TIME = "not equal";

     protected static final String RESULT_KEY = "result";

     protected static final String COMPARED_VALUE_KEY = "target value";

@@ -53,36 +55,55 @@
 

     public boolean isViolation(Object object1, Object object2, DateIs annotation)

     {

-        boolean violationFound;

-

-        if (annotation.type().equals(DateIsType.same))

+        boolean violationFound = false;

+        switch (annotation.type())

         {

-            violationFound = object1 != null && !object1.equals(object2);

+            case before:

+                violationFound = object1 != null && object2 != null &&

+                              (!new Date(((Date) object1).getTime()).before((Date) object2) || object1.equals(object2));

 

-            if (violationFound)

-            {

-                this.violationResultStorage.put(RESULT_KEY, NOT_EQUAL_DATE_TIME);

-            }

-        }

-        else if (annotation.type().equals(DateIsType.before))

-        {

-            violationFound = object1 != null && object2 != null &&

-                            (!new Date(((Date) object1).getTime()).before((Date) object2) || object1.equals(object2));

+                if (violationFound)

+                {

+                    this.violationResultStorage.put(RESULT_KEY, TOO_LATE);

+                }

+                break;

+            case after:

+                violationFound = object1 != null && object2 != null &&

+                               (!new Date(((Date) object1).getTime()).after((Date) object2) || object1.equals(object2));

 

-            if (violationFound)

-            {

-                this.violationResultStorage.put(RESULT_KEY, TOO_LATE);

-            }

-        }

-        else

-        {

-            violationFound = object1 != null && object2 != null &&

-                            (!new Date(((Date) object1).getTime()).after((Date) object2) || object1.equals(object2));

+                if (violationFound)

+                {

+                    this.violationResultStorage.put(RESULT_KEY, TOO_EARLY);

+                }

+                break;

+            case same:

+                violationFound = object1 != null && !object1.equals(object2);

 

-            if (violationFound)

-            {

-                this.violationResultStorage.put(RESULT_KEY, TOO_EARLY);

-            }

+                if (violationFound)

+                {

+                    this.violationResultStorage.put(RESULT_KEY, NOT_EQUAL_DATE_TIME);

+                }

+                break;

+            case beforeOrSame:

+                violationFound = object1 != null && object2 != null &&

+                                new Date(((Date) object1).getTime()).after((Date) object2);

+

+                if (violationFound)

+                {

+                    this.violationResultStorage.put(RESULT_KEY, TOO_LATE_SAME);

+                }

+                break;

+            case afterOrSame:

+                violationFound = object1 != null && object2 != null &&

+                                new Date(((Date) object1).getTime()).before((Date) object2);

+

+                if (violationFound)

+                {

+                    this.violationResultStorage.put(RESULT_KEY, TOO_EARLY_SAME);

+                }

+                break;

+            default:

+                // Nothing to do.

         }

 

         if (violationFound)

@@ -115,10 +136,18 @@
         {

             return getNotAfterErrorMsgKey(annotation);

         }

+        else if (TOO_EARLY_SAME.equals(result))

+        {

+            return getNotAfterOrSameErrorMsgKey(annotation);

+        }

         else if (TOO_LATE.equals(result))

         {

             return getNotBeforeErrorMsgKey(annotation);

         }

+        else if (TOO_LATE_SAME.equals(result))

+        {

+            return getNotBeforeOrSameErrorMsgKey(annotation);

+        }

         else

         {

             return getNotEqualErrorMsgKey(annotation);

@@ -127,35 +156,47 @@
 

     private String reverseResult(String result)

     {

+

         if (TOO_EARLY.equals(result))

         {

             return TOO_LATE;

         }

-        else

+        else if (TOO_EARLY_SAME.equals(result))

+        {

+            return TOO_LATE_SAME;

+        }

+        else if (TOO_LATE_SAME.equals(result))

+        {

+            return TOO_EARLY_SAME;

+        }

+        else if (TOO_LATE.equals(result))

         {

             return TOO_EARLY;

         }

+        return result;

     }

 

     @Override

     protected String getErrorMessageSummary(DateIs annotation, boolean isTargetComponent)

     {

+        /*

         if (!isTargetComponent)

         {

             return super.getErrorMessageSummary(annotation, isTargetComponent);

         }

-

+        */

         return getErrorMessage(getValidationErrorMsgKey(annotation, isTargetComponent), annotation, isTargetComponent);

     }

 

     @Override

     protected String getErrorMessageDetail(DateIs annotation, boolean isTargetComponent)

     {

+        /*

         if (!isTargetComponent)

         {

             return super.getErrorMessageDetail(annotation, isTargetComponent);

         }

-

+        */

         try

         {

             return getErrorMessage(getValidationErrorMsgKey(annotation, isTargetComponent)

@@ -195,8 +236,8 @@
     {

         String message = resolveMessage(key);

 

-        DateFormat dateFormat = DateFormat.getDateInstance(annotation.errorMessageDateStyle(),

-            FacesContext.getCurrentInstance().getViewRoot().getLocale());

+        DateFormat dateFormat = getDateFormat(annotation.errorMessageDateStyle(),

+                annotation.errorMessageDatePattern());

 

         String result;

 

@@ -215,6 +256,15 @@
         return result;

     }

 

+    private DateFormat getDateFormat(int dateStyle, String datePattern)

+    {

+        if (datePattern == null || datePattern.length() == 0)

+        {

+            return DateFormat.getDateInstance(dateStyle, FacesContext.getCurrentInstance().getViewRoot().getLocale());

+        }

+        return new SimpleDateFormat(datePattern, FacesContext.getCurrentInstance().getViewRoot().getLocale());

+    }

+

     /*

      * private

      */

@@ -227,6 +277,15 @@
         return annotation.validationErrorMsgKey();

     }

 

+    private String getNotAfterOrSameErrorMsgKey(DateIs annotation)

+    {

+        if (annotation.validationErrorMsgKey().equals(""))

+        {

+            return annotation.notAfterOrSameErrorMsgKey();

+        }

+        return annotation.validationErrorMsgKey();

+    }

+

     private String getNotBeforeErrorMsgKey(DateIs annotation)

     {

         if (annotation.validationErrorMsgKey().equals(""))

@@ -236,6 +295,15 @@
         return annotation.validationErrorMsgKey();

     }

 

+    private String getNotBeforeOrSameErrorMsgKey(DateIs annotation)

+    {

+        if (annotation.validationErrorMsgKey().equals(""))

+        {

+            return annotation.notBeforeOrSameErrorMsgKey();

+        }

+        return annotation.validationErrorMsgKey();

+    }

+

     private String getNotEqualErrorMsgKey(DateIs annotation)

     {

         if (annotation.validationErrorMsgKey().equals(""))

diff --git a/validation-modules/property-validation/src/main/resources/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages.properties b/validation-modules/property-validation/src/main/resources/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages.properties
index ef60759..9cdc0ab 100644
--- a/validation-modules/property-validation/src/main/resources/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages.properties
+++ b/validation-modules/property-validation/src/main/resources/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages.properties
@@ -27,8 +27,14 @@
 wrong_date_not_before=Date has to be after {0}

 wrong_date_not_before_detail=Date has to be after {0}

 

+wrong_date_not_before_or_same=Date has to be after or equals to {0}

+wrong_date_not_before_or_same_detail=Date has to be after or equals to {0}

+

 wrong_date_not_after=Date has to be before {0}

 wrong_date_not_after_detail=Date has to be before {0}

 

+wrong_date_not_after_or_same=Date has to be before or equals to {0}

+wrong_date_not_after_or_same_detail=Date has to be before or equals to {0}

+

 wrong_date_not_equal=Date isn't equal to {0}

 wrong_date_not_equal_detail=Date isn't equal to {0}
\ No newline at end of file