summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-09-24 15:01:26 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2012-09-24 15:02:12 +0300
commit0cd118248d77eeb197f2480ce59b35c6c3963e5c (patch)
treedd5a1387709546cfb9dd49a5b236712446c36658 /server/tests
parent1d97c958748ebdf06abd28a0f2acec8c179e9d1d (diff)
downloadvaadin-framework-0cd118248d77eeb197f2480ce59b35c6c3963e5c.tar.gz
vaadin-framework-0cd118248d77eeb197f2480ce59b35c6c3963e5c.zip
Test AbstractField add/remove/removeAll/getValidators() (#9542, #9723)
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java
new file mode 100644
index 0000000000..19c58fe6d3
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java
@@ -0,0 +1,64 @@
+package com.vaadin.tests.server.component.abstractfield;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.data.Validator;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Field;
+
+public class AbstractFieldValidators extends TestCase {
+
+ Field<Object> field = new AbstractField<Object>() {
+ @Override
+ public Class getType() {
+ return Object.class;
+ }
+ };
+
+ Validator validator = EasyMock.createMock(Validator.class);
+ Validator validator2 = EasyMock.createMock(Validator.class);
+
+ public void testAddValidator() {
+ assertNotNull(field.getValidators());
+ assertEquals(0, field.getValidators().size());
+
+ field.addValidator(validator);
+ assertEquals(1, field.getValidators().size());
+ assertTrue(field.getValidators().contains(validator));
+
+ field.addValidator(validator2);
+ assertEquals(2, field.getValidators().size());
+ assertTrue(field.getValidators().contains(validator));
+ assertTrue(field.getValidators().contains(validator2));
+ }
+
+ public void testRemoveValidator() {
+ field.addValidator(validator);
+ field.addValidator(validator2);
+
+ field.removeValidator(validator);
+ assertNotNull(field.getValidators());
+ assertEquals(1, field.getValidators().size());
+ assertFalse(field.getValidators().contains(validator));
+ assertTrue(field.getValidators().contains(validator2));
+
+ field.removeValidator(validator2);
+ assertNotNull(field.getValidators());
+ assertEquals(0, field.getValidators().size());
+ assertFalse(field.getValidators().contains(validator));
+ assertFalse(field.getValidators().contains(validator2));
+ }
+
+ public void testRemoveAllValidators() {
+ field.addValidator(validator);
+ field.addValidator(validator2);
+
+ field.removeAllValidators();
+ assertNotNull(field.getValidators());
+ assertEquals(0, field.getValidators().size());
+ assertFalse(field.getValidators().contains(validator));
+ assertFalse(field.getValidators().contains(validator2));
+ }
+}