]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed test case for #5927.
authorMarko Grönroos <magi@iki.fi>
Tue, 4 Jan 2011 15:07:20 +0000 (15:07 +0000)
committerMarko Grönroos <magi@iki.fi>
Tue, 4 Jan 2011 15:07:20 +0000 (15:07 +0000)
svn changeset:16792/svn branch:6.5

tests/src/com/vaadin/tests/components/datefield/CommitInvalid.java

index 9ce38624e83e83de85e18526e318a7deb3ce87d6..9745f28e23a0e66c81d3825767b81a4dbeabe70a 100644 (file)
@@ -2,13 +2,16 @@ package com.vaadin.tests.components.datefield;
 
 import java.util.Date;
 
+import com.vaadin.data.Property;
 import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.data.validator.IntegerValidator;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.DateField;
 import com.vaadin.ui.Form;
 import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
 
 public class CommitInvalid extends TestBase {
 
@@ -28,15 +31,33 @@ public class CommitInvalid extends TestBase {
         addComponent(form);
 
         @SuppressWarnings("deprecation")
-        ObjectProperty<Date> property = new ObjectProperty<Date>(new Date(
+        ObjectProperty property = new ObjectProperty(new Date(
                 2009 - 1900, 4 - 1, 1));
 
-        final DateField df = new DateField("Year", property);
+        final DateField df = new DateField("Year", property) {
+            @Override
+            protected Date handleUnparsableDateString(String dateString)
+                    throws ConversionException {
+                throw new Property.ConversionException(
+                        "Date format not recognized");
+            }
+        };
         df.setResolution(DateField.RESOLUTION_DAY);
-        df.setReadThrough(false);
-        df.setWriteThrough(false);
-        df.setImmediate(true);
+        // df.setReadThrough(false);
+        // df.setWriteThrough(false);
+        // df.setImmediate(true);
         form.addField("date", df);
+        form.setValidationVisible(true);
+
+        final ObjectProperty integer = new ObjectProperty("42");
+        final TextField another = new TextField("Another Field", integer);
+        another.addValidator(new IntegerValidator("Not an integer"));
+        // another.setReadThrough(false);
+        // another.setWriteThrough(false);
+        form.addField("text", another);
+
+        // form.setReadThrough(false);
+        form.setWriteThrough(false);
 
         Button validate = new Button("Validate");
         form.getFooter().addComponent(validate);
@@ -44,22 +65,27 @@ public class CommitInvalid extends TestBase {
         Button commit = new Button("Commit");
         form.getFooter().addComponent(commit);
 
-        Label value = new Label("Value");
-        addComponent(value);
-        value.setPropertyDataSource(property);
-
         validate.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
-                df.validate();
+                form.validate();
             }
         });
 
         commit.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
-                df.commit();
+                form.commit();
+                System.out.println("Field value: "
+                        + ((String) another.getValue()) + ", property value: "
+                        + ((String) integer.getValue()));
             }
         });
 
+        Label value = new Label("Date Value");
+        addComponent(value);
+        value.setPropertyDataSource(property);
 
+        Label value2 = new Label("Text Value");
+        addComponent(value2);
+        value2.setPropertyDataSource(integer);
     }
 }