1 package com.vaadin.tests.components.abstractfield;
3 import com.vaadin.tests.components.TestBase;
4 import com.vaadin.ui.Button;
5 import com.vaadin.ui.Button.ClickEvent;
6 import com.vaadin.ui.Button.ClickListener;
7 import com.vaadin.ui.Notification;
8 import com.vaadin.v7.data.util.ObjectProperty;
9 import com.vaadin.v7.data.validator.StringLengthValidator;
10 import com.vaadin.v7.ui.TextField;
12 public class AbstractFieldCommitWithInvalidValues extends TestBase {
17 protected String getDescription() {
18 return "Commiting a field with invalid values should throw an exception";
22 protected Integer getTicketNumber() {
27 protected void setup() {
28 tf = new TextField("A field, must contain 1-2 chars",
29 new ObjectProperty<String>("a"));
31 new StringLengthValidator("Invalid length", 1, 2, false));
35 Button b = new Button("Commit", new ClickListener() {
38 public void buttonClick(ClickEvent event) {
42 getMainWindow().showNotification(
43 "OK! Form validated and no error was thrown",
44 Notification.TYPE_HUMANIZED_MESSAGE);
46 getMainWindow().showNotification(
47 "Form is invalid but no exception was thrown",
48 Notification.TYPE_ERROR_MESSAGE);
50 } catch (Exception e) {
52 getMainWindow().showNotification(
53 "Form is valid but an exception was thrown",
54 Notification.TYPE_ERROR_MESSAGE);
56 getMainWindow().showNotification(
57 "OK! Error was thrown for an invalid input",
58 Notification.TYPE_HUMANIZED_MESSAGE);