You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BeanValidationTest.java 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.vaadin.data;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertNotNull;
  4. import javax.validation.Validation;
  5. import org.junit.Test;
  6. import com.vaadin.ui.TextField;
  7. /**
  8. * @author Vaadin Ltd
  9. *
  10. */
  11. public class BeanValidationTest {
  12. public static class Bean {
  13. private String property;
  14. public String getProperty() {
  15. return property;
  16. }
  17. public void setProperty(String property) {
  18. this.property = property;
  19. }
  20. }
  21. @Test
  22. public void binderWorksWithoutBeanValidationImpl() {
  23. // Just to make sure that it's available at the compilation time and in
  24. // runtime
  25. assertNotNull(Validation.class);
  26. Binder<Bean> binder = new Binder<>(Bean.class);
  27. TextField field = new TextField();
  28. binder.forField(field).bind("property");
  29. Bean bean = new Bean();
  30. binder.setBean(bean);
  31. field.setValue("foo");
  32. assertEquals(field.getValue(), bean.getProperty());
  33. }
  34. }