1 package com.vaadin.tests.server.component.textfield;
3 import junit.framework.TestCase;
5 import com.vaadin.data.util.ObjectProperty;
6 import com.vaadin.data.validator.RangeValidator;
7 import com.vaadin.tests.data.converter.ConverterFactoryTest.ConvertTo42;
8 import com.vaadin.ui.TextField;
10 public class TextFieldWithConverterAndValidatorTest extends TestCase {
12 private TextField field;
13 private ObjectProperty<Integer> property;
16 protected void setUp() throws Exception {
19 field = new TextField();
20 field.setInvalidAllowed(false);
23 public void testConvert42AndValidator() {
24 property = new ObjectProperty<Integer>(123);
25 field.setConverter(new ConvertTo42());
26 field.setPropertyDataSource(property);
28 field.addValidator(new RangeValidator<Integer>("Incorrect value",
29 Integer.class, 42, 42));
35 // succeeds - no validation
36 property.setValue(42);
40 // succeeds - validate() converts field value back to property type
42 property.setValue(null);
48 // TODO test converter changing value to null with validator