You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/02/12 18:13:26 UTC

svn commit: r377208 - /myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java

Author: mmarinschek
Date: Sun Feb 12 09:13:26 2006
New Revision: 377208

URL: http://svn.apache.org/viewcvs?rev=377208&view=rev
Log:
fixed problem with RI in phase-listener, expanded DateTimeConverterTest

Modified:
    myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java

Modified: myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java
URL: http://svn.apache.org/viewcvs/myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java?rev=377208&r1=377207&r2=377208&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/convert/DateTimeConverterTest.java Sun Feb 12 09:13:26 2006
@@ -21,6 +21,8 @@
 
 import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
+import java.util.Date;
+import java.text.SimpleDateFormat;
 
 public class DateTimeConverterTest extends AbstractTestCase
 {
@@ -60,9 +62,9 @@
 
         UIInput input = new UIInput();
 
-        mock.setPattern("dd/MM/yyyy");
+        mock.setPattern("MM/dd/yyyy");
 
-        // defaults to true
+        //should trow a ConverterException
         try
         {
             mock.getAsObject(FacesContext.getCurrentInstance(),input,"15/15/15");
@@ -72,6 +74,28 @@
         catch (ConverterException e)
         {
 
+        }
+
+        //should not trow a ConverterException
+        try
+        {
+            Date date = (Date) mock.getAsObject(FacesContext.getCurrentInstance(),input,"12/01/01");
+
+            SimpleDateFormat format = new SimpleDateFormat("MM/dd/yy");
+
+            String str = format.format(date);
+
+            assertEquals("12/01/01",str);
+
+            format = new SimpleDateFormat("MM/dd/yyyy");
+
+            str = format.format(date);
+
+            assertEquals("12/01/0001",str);            
+        }
+        catch (ConverterException e)
+        {
+            assertTrue("this date should not be parsable - and it is, so this is wrong.",false);
         }
     }
 }