summaryrefslogtreecommitdiffstats
path: root/tests/server-side/com/vaadin
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server-side/com/vaadin')
-rw-r--r--tests/server-side/com/vaadin/data/util/BeanItemTest.java7
-rw-r--r--tests/server-side/com/vaadin/data/util/NestedMethodPropertyTest.java89
-rw-r--r--tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java8
-rw-r--r--tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java11
-rw-r--r--tests/server-side/com/vaadin/data/util/PropertySetItemTest.java8
-rw-r--r--tests/server-side/com/vaadin/data/util/TestContainerSorting.java23
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java9
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/AndOrFilterTest.java4
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/CompareFilterTest.java2
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/IsNullFilterTest.java4
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/NotFilterTest.java4
-rw-r--r--tests/server-side/com/vaadin/data/util/filter/SimpleStringFilterTest.java5
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java2
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java2
-rw-r--r--tests/server-side/com/vaadin/terminal/gwt/server/TestAbstractApplicationServletStaticFilesLocation.java9
-rw-r--r--tests/server-side/com/vaadin/tests/VaadinClasses.java14
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/Address.java63
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/BeanToValidate.java56
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/Country.java18
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/Person.java133
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/PersonWithBeanValidationAnnotations.java156
-rw-r--r--tests/server-side/com/vaadin/tests/data/bean/Sex.java20
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java15
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestKeyMapper.java14
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestSerialization.java19
-rw-r--r--tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java6
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java53
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java162
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java48
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java5
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java7
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java61
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java98
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/slider/SliderTest.java25
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java64
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java14
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java13
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java20
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java201
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java10
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java5
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java11
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestWindow.java2
-rw-r--r--tests/server-side/com/vaadin/tests/server/validation/RangeValidatorTest.java52
-rw-r--r--tests/server-side/com/vaadin/tests/server/validation/TestBeanValidation.java57
-rw-r--r--tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java2
-rw-r--r--tests/server-side/com/vaadin/tests/util/GraphVizClassHierarchyCreator.java149
-rw-r--r--tests/server-side/com/vaadin/tests/util/TestUtil.java43
48 files changed, 1484 insertions, 319 deletions
diff --git a/tests/server-side/com/vaadin/data/util/BeanItemTest.java b/tests/server-side/com/vaadin/data/util/BeanItemTest.java
index 044a410803..51e11260f5 100644
--- a/tests/server-side/com/vaadin/data/util/BeanItemTest.java
+++ b/tests/server-side/com/vaadin/data/util/BeanItemTest.java
@@ -12,11 +12,6 @@ import java.util.Map;
import junit.framework.Assert;
import junit.framework.TestCase;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.MethodProperty;
-import com.vaadin.data.util.MethodPropertyDescriptor;
-import com.vaadin.data.util.VaadinPropertyDescriptor;
-
/**
* Test BeanItem specific features.
*
@@ -322,7 +317,7 @@ public class BeanItemTest extends TestCase {
MyClass.class.getDeclaredMethod("getName"),
MyClass.class.getDeclaredMethod("setName", String.class));
- BeanItem<MyClass> item = new BeanItem(new MyClass("bean1"));
+ BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1"));
Assert.assertEquals(6, item.getItemPropertyIds().size());
Assert.assertEquals(null, item.getItemProperty("myname"));
diff --git a/tests/server-side/com/vaadin/data/util/NestedMethodPropertyTest.java b/tests/server-side/com/vaadin/data/util/NestedMethodPropertyTest.java
index b110ea1c6b..640ede8743 100644
--- a/tests/server-side/com/vaadin/data/util/NestedMethodPropertyTest.java
+++ b/tests/server-side/com/vaadin/data/util/NestedMethodPropertyTest.java
@@ -10,8 +10,6 @@ import java.io.Serializable;
import junit.framework.Assert;
import junit.framework.TestCase;
-import com.vaadin.data.util.NestedMethodProperty;
-
public class NestedMethodPropertyTest extends TestCase {
public static class Address implements Serializable {
@@ -126,34 +124,34 @@ public class NestedMethodPropertyTest extends TestCase {
}
public void testSingleLevelNestedSimpleProperty() {
- NestedMethodProperty nameProperty = new NestedMethodProperty(vaadin,
- "name");
+ NestedMethodProperty<String> nameProperty = new NestedMethodProperty<String>(
+ vaadin, "name");
Assert.assertEquals(String.class, nameProperty.getType());
Assert.assertEquals("Vaadin", nameProperty.getValue());
}
public void testSingleLevelNestedObjectProperty() {
- NestedMethodProperty managerProperty = new NestedMethodProperty(vaadin,
- "manager");
+ NestedMethodProperty<Person> managerProperty = new NestedMethodProperty<Person>(
+ vaadin, "manager");
Assert.assertEquals(Person.class, managerProperty.getType());
Assert.assertEquals(joonas, managerProperty.getValue());
}
public void testMultiLevelNestedProperty() {
- NestedMethodProperty managerNameProperty = new NestedMethodProperty(
+ NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
vaadin, "manager.name");
- NestedMethodProperty addressProperty = new NestedMethodProperty(vaadin,
- "manager.address");
- NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin,
- "manager.address.street");
- NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty(
+ NestedMethodProperty<Address> addressProperty = new NestedMethodProperty<Address>(
+ vaadin, "manager.address");
+ NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
+ vaadin, "manager.address.street");
+ NestedMethodProperty<Integer> postalCodePrimitiveProperty = new NestedMethodProperty<Integer>(
vaadin, "manager.address.postalCodePrimitive");
- NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty(
+ NestedMethodProperty<Integer> postalCodeObjectProperty = new NestedMethodProperty<Integer>(
vaadin, "manager.address.postalCodeObject");
- NestedMethodProperty booleanProperty = new NestedMethodProperty(vaadin,
- "manager.address.boolean");
+ NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>(
+ vaadin, "manager.address.boolean");
Assert.assertEquals(String.class, managerNameProperty.getType());
Assert.assertEquals("Joonas", managerNameProperty.getValue());
@@ -166,25 +164,27 @@ public class NestedMethodPropertyTest extends TestCase {
Assert.assertEquals(Integer.class,
postalCodePrimitiveProperty.getType());
- Assert.assertEquals(20540, postalCodePrimitiveProperty.getValue());
+ Assert.assertEquals(Integer.valueOf(20540),
+ postalCodePrimitiveProperty.getValue());
Assert.assertEquals(Integer.class, postalCodeObjectProperty.getType());
- Assert.assertEquals(20540, postalCodeObjectProperty.getValue());
+ Assert.assertEquals(Integer.valueOf(20540),
+ postalCodeObjectProperty.getValue());
Assert.assertEquals(Boolean.class, booleanProperty.getType());
- Assert.assertEquals(true, booleanProperty.getValue());
+ Assert.assertEquals(Boolean.TRUE, booleanProperty.getValue());
}
public void testEmptyPropertyName() {
try {
- new NestedMethodProperty(vaadin, "");
+ new NestedMethodProperty<Object>(vaadin, "");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, " ");
+ new NestedMethodProperty<Object>(vaadin, " ");
fail();
} catch (IllegalArgumentException e) {
// should get exception
@@ -193,25 +193,25 @@ public class NestedMethodPropertyTest extends TestCase {
public void testInvalidPropertyName() {
try {
- new NestedMethodProperty(vaadin, ".");
+ new NestedMethodProperty<Object>(vaadin, ".");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, ".manager");
+ new NestedMethodProperty<Object>(vaadin, ".manager");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, "manager.");
+ new NestedMethodProperty<Object>(vaadin, "manager.");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, "manager..name");
+ new NestedMethodProperty<Object>(vaadin, "manager..name");
fail();
} catch (IllegalArgumentException e) {
// should get exception
@@ -220,21 +220,21 @@ public class NestedMethodPropertyTest extends TestCase {
public void testInvalidNestedPropertyName() {
try {
- new NestedMethodProperty(vaadin, "member");
+ new NestedMethodProperty<Object>(vaadin, "member");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, "manager.pet");
+ new NestedMethodProperty<Object>(vaadin, "manager.pet");
fail();
} catch (IllegalArgumentException e) {
// should get exception
}
try {
- new NestedMethodProperty(vaadin, "manager.address.city");
+ new NestedMethodProperty<Object>(vaadin, "manager.address.city");
fail();
} catch (IllegalArgumentException e) {
// should get exception
@@ -242,10 +242,10 @@ public class NestedMethodPropertyTest extends TestCase {
}
public void testNullNestedProperty() {
- NestedMethodProperty managerNameProperty = new NestedMethodProperty(
+ NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
vaadin, "manager.name");
- NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin,
- "manager.address.street");
+ NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
+ vaadin, "manager.address.street");
joonas.setAddress(null);
try {
@@ -274,15 +274,15 @@ public class NestedMethodPropertyTest extends TestCase {
}
public void testMultiLevelNestedPropertySetValue() {
- NestedMethodProperty managerNameProperty = new NestedMethodProperty(
+ NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
vaadin, "manager.name");
- NestedMethodProperty addressProperty = new NestedMethodProperty(vaadin,
- "manager.address");
- NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin,
- "manager.address.street");
- NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty(
+ NestedMethodProperty<Address> addressProperty = new NestedMethodProperty<Address>(
+ vaadin, "manager.address");
+ NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
+ vaadin, "manager.address.street");
+ NestedMethodProperty<Integer> postalCodePrimitiveProperty = new NestedMethodProperty<Integer>(
vaadin, "manager.address.postalCodePrimitive");
- NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty(
+ NestedMethodProperty<Integer> postalCodeObjectProperty = new NestedMethodProperty<Integer>(
vaadin, "manager.address.postalCodeObject");
managerNameProperty.setValue("Joonas L");
@@ -303,21 +303,22 @@ public class NestedMethodPropertyTest extends TestCase {
}
public void testSerialization() throws IOException, ClassNotFoundException {
- NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin,
- "manager.address.street");
+ NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
+ vaadin, "manager.address.street");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(streetProperty);
- NestedMethodProperty property2 = (NestedMethodProperty) new ObjectInputStream(
+ @SuppressWarnings("unchecked")
+ NestedMethodProperty<String> property2 = (NestedMethodProperty<String>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
Assert.assertEquals("Ruukinkatu 2-4", property2.getValue());
}
public void testIsReadOnly() {
- NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin,
- "manager.address.street");
- NestedMethodProperty booleanProperty = new NestedMethodProperty(vaadin,
- "manager.address.boolean");
+ NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
+ vaadin, "manager.address.street");
+ NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>(
+ vaadin, "manager.address.boolean");
Assert.assertFalse(streetProperty.isReadOnly());
Assert.assertTrue(booleanProperty.isReadOnly());
diff --git a/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java b/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
index 11676099e6..99ca58ba42 100644
--- a/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
+++ b/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
@@ -4,8 +4,6 @@ import junit.framework.TestCase;
import org.junit.Assert;
-import com.vaadin.data.util.ObjectProperty;
-
public class ObjectPropertyTest extends TestCase {
public static class TestSuperClass {
@@ -70,7 +68,7 @@ public class ObjectPropertyTest extends TestCase {
ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
super1, TestSuperClass.class);
Assert.assertEquals("super1", prop.getValue().getName());
- prop.setValue("super2");
+ prop.setValue(new TestSuperClass("super2"));
Assert.assertEquals("super1", super1.getName());
Assert.assertEquals("super2", prop.getValue().getName());
}
@@ -79,7 +77,7 @@ public class ObjectPropertyTest extends TestCase {
ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
sub1, TestSubClass.class);
Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
- prop.setValue("sub2");
+ prop.setValue(new TestSubClass("sub2"));
Assert.assertEquals("Subclass: sub1", sub1.getName());
Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
}
@@ -92,7 +90,7 @@ public class ObjectPropertyTest extends TestCase {
// create correct subclass based on the runtime type of the instance
// given to ObjectProperty constructor, which is a subclass of the type
// parameter
- prop.setValue("sub2");
+ prop.setValue(new TestSubClass("sub2"));
Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
}
diff --git a/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java b/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java
index c3621fa99b..14e70d76d4 100644
--- a/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java
+++ b/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java
@@ -11,9 +11,6 @@ import junit.framework.Assert;
import junit.framework.TestCase;
import com.vaadin.data.Property;
-import com.vaadin.data.util.MethodPropertyDescriptor;
-import com.vaadin.data.util.NestedPropertyDescriptor;
-import com.vaadin.data.util.VaadinPropertyDescriptor;
import com.vaadin.data.util.NestedMethodPropertyTest.Person;
public class PropertyDescriptorTest extends TestCase {
@@ -33,11 +30,12 @@ public class PropertyDescriptorTest extends TestCase {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(descriptor);
+ @SuppressWarnings("unchecked")
VaadinPropertyDescriptor<Person> descriptor2 = (VaadinPropertyDescriptor<Person>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
- Property property = descriptor2
- .createProperty(new Person("John", null));
+ Property<?> property = descriptor2.createProperty(new Person("John",
+ null));
Assert.assertEquals("John", property.getValue());
}
@@ -47,10 +45,11 @@ public class PropertyDescriptorTest extends TestCase {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(pd);
+ @SuppressWarnings("unchecked")
VaadinPropertyDescriptor<Person> pd2 = (VaadinPropertyDescriptor<Person>) new ObjectInputStream(
new ByteArrayInputStream(baos.toByteArray())).readObject();
- Property property = pd2.createProperty(new Person("John", null));
+ Property<?> property = pd2.createProperty(new Person("John", null));
Assert.assertEquals("John", property.getValue());
}
}
diff --git a/tests/server-side/com/vaadin/data/util/PropertySetItemTest.java b/tests/server-side/com/vaadin/data/util/PropertySetItemTest.java
index 4516e8d109..a3169332ec 100644
--- a/tests/server-side/com/vaadin/data/util/PropertySetItemTest.java
+++ b/tests/server-side/com/vaadin/data/util/PropertySetItemTest.java
@@ -9,8 +9,6 @@ import org.easymock.EasyMock;
import com.vaadin.data.Item.PropertySetChangeEvent;
import com.vaadin.data.Item.PropertySetChangeListener;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.data.util.PropertysetItem;
public class PropertySetItemTest extends TestCase {
@@ -395,13 +393,13 @@ public class PropertySetItemTest extends TestCase {
item.addItemProperty(ID1, prop1);
- Assert.assertEquals(String.valueOf(prop1), item.toString());
+ Assert.assertEquals(String.valueOf(prop1.getValue()), item.toString());
item.addItemProperty(ID2, prop2);
Assert.assertEquals(
- String.valueOf(prop1) + " " + String.valueOf(prop2),
- item.toString());
+ String.valueOf(prop1.getValue()) + " "
+ + String.valueOf(prop2.getValue()), item.toString());
}
}
diff --git a/tests/server-side/com/vaadin/data/util/TestContainerSorting.java b/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
index d9a8e6e51c..9e69b94fbb 100644
--- a/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
+++ b/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
@@ -8,8 +8,7 @@ import junit.framework.TestCase;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.util.TestUtil;
public class TestContainerSorting extends TestCase {
@@ -93,12 +92,12 @@ public class TestContainerSorting extends TestCase {
"Might and Magic", "Natural languages", "PHP",
"Programming languages", "Python", "Red Alert", "Swedish",
"Toyota", "Volvo" });
- assertArrays(
+ TestUtil.assertArrays(
hc.rootItemIds().toArray(),
new Integer[] { nameToId.get("Cars"), nameToId.get("Games"),
nameToId.get("Natural languages"),
nameToId.get("Programming languages") });
- assertArrays(
+ TestUtil.assertArrays(
hc.getChildren(nameToId.get("Games")).toArray(),
new Integer[] { nameToId.get("Call of Duty"),
nameToId.get("Fallout"),
@@ -168,21 +167,7 @@ public class TestContainerSorting extends TestCase {
actual[index++] = o;
}
- assertArrays(actual, idOrder);
-
- }
-
- private void assertArrays(Object[] actualObjects, Object[] expectedObjects) {
- assertEquals(
- "Actual contains a different number of values than was expected",
- expectedObjects.length, actualObjects.length);
-
- for (int i = 0; i < actualObjects.length; i++) {
- Object actual = actualObjects[i];
- Object expected = expectedObjects[i];
-
- assertEquals("Item[" + i + "] does not match", expected, actual);
- }
+ TestUtil.assertArrays(actual, idOrder);
}
diff --git a/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java
index beaa1c4e8f..efc31f0bd4 100644
--- a/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java
@@ -22,18 +22,17 @@ public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends
}
}
- protected static class NullProperty implements Property {
+ protected static class NullProperty implements Property<String> {
- public Object getValue() {
+ public String getValue() {
return null;
}
- public void setValue(Object newValue) throws ReadOnlyException,
- ConversionException {
+ public void setValue(Object newValue) throws ReadOnlyException {
throw new ReadOnlyException();
}
- public Class<?> getType() {
+ public Class<String> getType() {
return String.class;
}
diff --git a/tests/server-side/com/vaadin/data/util/filter/AndOrFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/AndOrFilterTest.java
index bdd852bd41..fdd5b8a645 100644
--- a/tests/server-side/com/vaadin/data/util/filter/AndOrFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/AndOrFilterTest.java
@@ -5,10 +5,8 @@ import junit.framework.Assert;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.filter.And;
-import com.vaadin.data.util.filter.Or;
-public class AndOrFilterTest extends AbstractFilterTest {
+public class AndOrFilterTest extends AbstractFilterTest<AbstractJunctionFilter> {
protected Item item1 = new BeanItem<Integer>(1);
protected Item item2 = new BeanItem<Integer>(2);
diff --git a/tests/server-side/com/vaadin/data/util/filter/CompareFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/CompareFilterTest.java
index 4cd683bfde..99e8429a51 100644
--- a/tests/server-side/com/vaadin/data/util/filter/CompareFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/CompareFilterTest.java
@@ -14,7 +14,7 @@ import com.vaadin.data.util.filter.Compare.GreaterOrEqual;
import com.vaadin.data.util.filter.Compare.Less;
import com.vaadin.data.util.filter.Compare.LessOrEqual;
-public class CompareFilterTest extends AbstractFilterTest {
+public class CompareFilterTest extends AbstractFilterTest<Compare> {
protected Item itemNull;
protected Item itemEmpty;
diff --git a/tests/server-side/com/vaadin/data/util/filter/IsNullFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/IsNullFilterTest.java
index 24d5152cf7..6f90273de1 100644
--- a/tests/server-side/com/vaadin/data/util/filter/IsNullFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/IsNullFilterTest.java
@@ -6,10 +6,8 @@ import com.vaadin.data.Container.Filter;
import com.vaadin.data.Item;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertysetItem;
-import com.vaadin.data.util.filter.And;
-import com.vaadin.data.util.filter.IsNull;
-public class IsNullFilterTest extends AbstractFilterTest {
+public class IsNullFilterTest extends AbstractFilterTest<IsNull> {
public void testIsNull() {
Item item1 = new PropertysetItem();
diff --git a/tests/server-side/com/vaadin/data/util/filter/NotFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/NotFilterTest.java
index be6417ccdf..c3b666e6f7 100644
--- a/tests/server-side/com/vaadin/data/util/filter/NotFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/NotFilterTest.java
@@ -5,10 +5,8 @@ import junit.framework.Assert;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.filter.And;
-import com.vaadin.data.util.filter.Not;
-public class NotFilterTest extends AbstractFilterTest {
+public class NotFilterTest extends AbstractFilterTest<Not> {
protected Item item1 = new BeanItem<Integer>(1);
protected Item item2 = new BeanItem<Integer>(2);
diff --git a/tests/server-side/com/vaadin/data/util/filter/SimpleStringFilterTest.java b/tests/server-side/com/vaadin/data/util/filter/SimpleStringFilterTest.java
index c36a764a54..bc63d57752 100644
--- a/tests/server-side/com/vaadin/data/util/filter/SimpleStringFilterTest.java
+++ b/tests/server-side/com/vaadin/data/util/filter/SimpleStringFilterTest.java
@@ -2,9 +2,8 @@ package com.vaadin.data.util.filter;
import junit.framework.Assert;
-import com.vaadin.data.util.filter.SimpleStringFilter;
-
-public class SimpleStringFilterTest extends AbstractFilterTest {
+public class SimpleStringFilterTest extends
+ AbstractFilterTest<SimpleStringFilter> {
protected static TestItem<String, String> createTestItem() {
return new TestItem<String, String>("abcde", "TeSt");
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java
index 56c9921a0b..c273bbf590 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java
@@ -1344,7 +1344,7 @@ public class SQLContainerTest {
Statement statement = conn.createStatement();
statement
.executeUpdate("DELETE FROM people WHERE \"ID\"="
- + item.getItemProperty("ID"));
+ + item.getItemProperty("ID").getValue());
statement.close();
return true;
}
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
index 5faa859b67..da4cfe4522 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/filters/BetweenTest.java
@@ -12,7 +12,7 @@ import com.vaadin.data.util.filter.Between;
public class BetweenTest {
private Item itemWithPropertyValue(Object propertyId, Object value) {
- Property property = EasyMock.createMock(Property.class);
+ Property<?> property = EasyMock.createMock(Property.class);
property.getValue();
EasyMock.expectLastCall().andReturn(value).anyTimes();
EasyMock.replay(property);
diff --git a/tests/server-side/com/vaadin/terminal/gwt/server/TestAbstractApplicationServletStaticFilesLocation.java b/tests/server-side/com/vaadin/terminal/gwt/server/TestAbstractApplicationServletStaticFilesLocation.java
index fcd9970717..7e45ea50d7 100644
--- a/tests/server-side/com/vaadin/terminal/gwt/server/TestAbstractApplicationServletStaticFilesLocation.java
+++ b/tests/server-side/com/vaadin/terminal/gwt/server/TestAbstractApplicationServletStaticFilesLocation.java
@@ -17,9 +17,6 @@ import javax.servlet.http.HttpServletRequest;
import junit.framework.TestCase;
-import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
-import com.vaadin.terminal.gwt.server.ApplicationServlet;
-
public class TestAbstractApplicationServletStaticFilesLocation extends TestCase {
ApplicationServlet servlet;
@@ -147,9 +144,6 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase
.andReturn(realContextPath).anyTimes();
expect(request.getAttribute("javax.servlet.include.servlet_path"))
.andReturn(realServletPath).anyTimes();
- expect(
- request.getAttribute(AbstractApplicationServlet.REQUEST_VAADIN_STATIC_FILE_PATH))
- .andReturn(null).anyTimes();
return request;
}
@@ -163,9 +157,6 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase
.andReturn(null).anyTimes();
expect(request.getAttribute("javax.servlet.include.servlet_path"))
.andReturn(null).anyTimes();
- expect(
- request.getAttribute(ApplicationServlet.REQUEST_VAADIN_STATIC_FILE_PATH))
- .andReturn(null).anyTimes();
return request;
}
diff --git a/tests/server-side/com/vaadin/tests/VaadinClasses.java b/tests/server-side/com/vaadin/tests/VaadinClasses.java
index e02c4f0b6e..b74af660e4 100644
--- a/tests/server-side/com/vaadin/tests/VaadinClasses.java
+++ b/tests/server-side/com/vaadin/tests/VaadinClasses.java
@@ -22,10 +22,11 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DragAndDropWrapper;
+import com.vaadin.ui.Field;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.PopupView;
-import com.vaadin.ui.SplitPanel;
+import com.vaadin.ui.Root;
import com.vaadin.ui.VerticalSplitPanel;
import com.vaadin.ui.Window;
@@ -61,6 +62,15 @@ public class VaadinClasses {
}
}
+ public static List<Class<? extends Field>> getFields() {
+ try {
+ return findClasses(Field.class, "com.vaadin.ui");
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
public static List<Class<? extends Object>> getAllServerSideClasses() {
try {
return findClassesNoTests(Object.class, "com.vaadin", new String[] {
@@ -87,13 +97,13 @@ public class VaadinClasses {
classes.remove(DragAndDropWrapper.class);
classes.remove(CustomComponent.class);
classes.remove(LoginForm.class);
+ classes.remove(Root.class);
return classes;
}
public static List<Class<? extends ComponentContainer>> getComponentContainersSupportingUnlimitedNumberOfComponents() {
List<Class<? extends ComponentContainer>> classes = getComponentContainersSupportingAddRemoveComponent();
- classes.remove(SplitPanel.class);
classes.remove(VerticalSplitPanel.class);
classes.remove(HorizontalSplitPanel.class);
classes.remove(Window.class);
diff --git a/tests/server-side/com/vaadin/tests/data/bean/Address.java b/tests/server-side/com/vaadin/tests/data/bean/Address.java
new file mode 100644
index 0000000000..15cdf34ae5
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/Address.java
@@ -0,0 +1,63 @@
+package com.vaadin.tests.data.bean;
+
+import java.io.Serializable;
+
+@SuppressWarnings("serial")
+public class Address implements Serializable {
+
+ private String streetAddress = "";
+ private Integer postalCode = null;
+ private String city = "";
+ private Country country = null;
+
+ public Address() {
+
+ }
+
+ public Address(String streetAddress, int postalCode, String city,
+ Country country) {
+ setStreetAddress(streetAddress);
+ setPostalCode(postalCode);
+ setCity(city);
+ setCountry(country);
+ }
+
+ @Override
+ public String toString() {
+ return "Address [streetAddress=" + streetAddress + ", postalCode="
+ + postalCode + ", city=" + city + ", country=" + country + "]";
+ }
+
+ public String getStreetAddress() {
+ return streetAddress;
+ }
+
+ public void setStreetAddress(String streetAddress) {
+ this.streetAddress = streetAddress;
+ }
+
+ public Integer getPostalCode() {
+ return postalCode;
+ }
+
+ public void setPostalCode(Integer postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public Country getCountry() {
+ return country;
+ }
+
+ public void setCountry(Country country) {
+ this.country = country;
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/data/bean/BeanToValidate.java b/tests/server-side/com/vaadin/tests/data/bean/BeanToValidate.java
new file mode 100644
index 0000000000..416563baba
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/BeanToValidate.java
@@ -0,0 +1,56 @@
+package com.vaadin.tests.data.bean;
+
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+public class BeanToValidate {
+ @NotNull
+ @Size(min = 3, max = 16)
+ private String firstname;
+
+ @NotNull(message = "Last name must not be empty")
+ private String lastname;
+
+ @Min(value = 18, message = "Must be 18 or above")
+ @Max(150)
+ private int age;
+
+ @Digits(integer = 3, fraction = 2)
+ private String decimals;
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getDecimals() {
+ return decimals;
+ }
+
+ public void setDecimals(String decimals) {
+ this.decimals = decimals;
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/data/bean/Country.java b/tests/server-side/com/vaadin/tests/data/bean/Country.java
new file mode 100644
index 0000000000..afdf8dcfa1
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/Country.java
@@ -0,0 +1,18 @@
+package com.vaadin.tests.data.bean;
+
+public enum Country {
+
+ FINLAND("Finland"), SWEDEN("Sweden"), USA("USA"), RUSSIA("Russia"), NETHERLANDS(
+ "Netherlands"), SOUTH_AFRICA("South Africa");
+
+ private String name;
+
+ private Country(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/data/bean/Person.java b/tests/server-side/com/vaadin/tests/data/bean/Person.java
new file mode 100644
index 0000000000..2cb3a29368
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/Person.java
@@ -0,0 +1,133 @@
+package com.vaadin.tests.data.bean;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class Person {
+ private String firstName;
+ private String lastName;
+ private String email;
+ private int age;
+ private Sex sex;
+ private Address address;
+ private boolean deceased;
+ private Date birthDate;
+
+ private Integer salary; // null if unknown
+ private Double salaryDouble; // null if unknown
+
+ private BigDecimal rent;
+
+ public Person() {
+
+ }
+
+ @Override
+ public String toString() {
+ return "Person [firstName=" + firstName + ", lastName=" + lastName
+ + ", email=" + email + ", age=" + age + ", sex=" + sex
+ + ", address=" + address + ", deceased=" + deceased
+ + ", salary=" + salary + ", salaryDouble=" + salaryDouble
+ + ", rent=" + rent + "]";
+ }
+
+ public Person(String firstName, String lastName, String email, int age,
+ Sex sex, Address address) {
+ super();
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.age = age;
+ this.sex = sex;
+ this.address = address;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+
+ public Sex getSex() {
+ return sex;
+ }
+
+ public void setSex(Sex sex) {
+ this.sex = sex;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public boolean getDeceased() {
+ return deceased;
+ }
+
+ public void setDeceased(boolean deceased) {
+ this.deceased = deceased;
+ }
+
+ public Integer getSalary() {
+ return salary;
+ }
+
+ public void setSalary(Integer salary) {
+ this.salary = salary;
+ }
+
+ public BigDecimal getRent() {
+ return rent;
+ }
+
+ public void setRent(BigDecimal rent) {
+ this.rent = rent;
+ }
+
+ public Double getSalaryDouble() {
+ return salaryDouble;
+ }
+
+ public void setSalaryDouble(Double salaryDouble) {
+ this.salaryDouble = salaryDouble;
+ }
+
+ public Date getBirthDate() {
+ return birthDate;
+ }
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/data/bean/PersonWithBeanValidationAnnotations.java b/tests/server-side/com/vaadin/tests/data/bean/PersonWithBeanValidationAnnotations.java
new file mode 100644
index 0000000000..93b2273263
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/PersonWithBeanValidationAnnotations.java
@@ -0,0 +1,156 @@
+package com.vaadin.tests.data.bean;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Past;
+import javax.validation.constraints.Size;
+
+public class PersonWithBeanValidationAnnotations {
+ @NotNull
+ @Size(min = 5, max = 20)
+ private String firstName;
+ @NotNull
+ private String lastName;
+
+ private String email;
+
+ @Min(0)
+ @Max(100)
+ private int age;
+
+ @NotNull
+ private Sex sex;
+
+ private Address address;
+ private boolean deceased;
+
+ @NotNull
+ @Past
+ private Date birthDate;
+
+ @Min(0)
+ private Integer salary; // null if unknown
+
+ @Digits(integer = 6, fraction = 2)
+ private Double salaryDouble; // null if unknown
+
+ private BigDecimal rent;
+
+ public PersonWithBeanValidationAnnotations() {
+
+ }
+
+ @Override
+ public String toString() {
+ return "Person [firstName=" + firstName + ", lastName=" + lastName
+ + ", email=" + email + ", age=" + age + ", sex=" + sex
+ + ", address=" + address + ", deceased=" + deceased
+ + ", salary=" + salary + ", salaryDouble=" + salaryDouble
+ + ", rent=" + rent + "]";
+ }
+
+ public PersonWithBeanValidationAnnotations(String firstName,
+ String lastName, String email, int age, Sex sex, Address address) {
+ super();
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.age = age;
+ this.sex = sex;
+ this.address = address;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+
+ public Sex getSex() {
+ return sex;
+ }
+
+ public void setSex(Sex sex) {
+ this.sex = sex;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public boolean getDeceased() {
+ return deceased;
+ }
+
+ public void setDeceased(boolean deceased) {
+ this.deceased = deceased;
+ }
+
+ public Integer getSalary() {
+ return salary;
+ }
+
+ public void setSalary(Integer salary) {
+ this.salary = salary;
+ }
+
+ public BigDecimal getRent() {
+ return rent;
+ }
+
+ public void setRent(BigDecimal rent) {
+ this.rent = rent;
+ }
+
+ public Double getSalaryDouble() {
+ return salaryDouble;
+ }
+
+ public void setSalaryDouble(Double salaryDouble) {
+ this.salaryDouble = salaryDouble;
+ }
+
+ public Date getBirthDate() {
+ return birthDate;
+ }
+
+ public void setBirthDate(Date birthDate) {
+ this.birthDate = birthDate;
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/data/bean/Sex.java b/tests/server-side/com/vaadin/tests/data/bean/Sex.java
new file mode 100644
index 0000000000..a4e3f20a11
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/bean/Sex.java
@@ -0,0 +1,20 @@
+package com.vaadin.tests.data.bean;
+
+public enum Sex {
+ MALE("Male"), FEMALE("Female"), UNKNOWN("Unknown");
+
+ private String stringRepresentation;
+
+ private Sex(String stringRepresentation) {
+ this.stringRepresentation = stringRepresentation;
+ }
+
+ public String getStringRepresentation() {
+ return stringRepresentation;
+ }
+
+ @Override
+ public String toString() {
+ return getStringRepresentation();
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
index c047565fcc..44a6a3b66d 100644
--- a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
+++ b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
@@ -47,7 +47,6 @@ public class TestClassesSerializable extends TestCase {
// class level filtering, also affecting nested classes and
// interfaces
"com\\.vaadin\\.terminal\\.gwt\\.server\\.AbstractCommunicationManager.*", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.ApplicationRunnerServlet.*", //
"com\\.vaadin\\.terminal\\.gwt\\.server\\.CommunicationManager.*", //
"com\\.vaadin\\.terminal\\.gwt\\.server\\.PortletCommunicationManager.*", //
};
@@ -98,9 +97,19 @@ public class TestClassesSerializable extends TestCase {
if (!nonSerializableClasses.isEmpty()) {
String nonSerializableString = "";
Iterator<Class<?>> it = nonSerializableClasses.iterator();
- nonSerializableString = it.next().getName();
while (it.hasNext()) {
- nonSerializableString += ", " + it.next().getName();
+ Class c = it.next();
+ nonSerializableString += ", " + c.getName();
+ if (c.isAnonymousClass()) {
+ nonSerializableString += "(super: ";
+ nonSerializableString += c.getSuperclass().getName();
+ nonSerializableString += ", interfaces: ";
+ for (Class i : c.getInterfaces()) {
+ nonSerializableString += i.getName();
+ nonSerializableString += ",";
+ }
+ nonSerializableString += ")";
+ }
}
fail("Serializable not implemented by the following classes and interfaces: "
+ nonSerializableString);
diff --git a/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java b/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
index ca33cf3314..4f5f0b1431 100644
--- a/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
+++ b/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
@@ -1,7 +1,7 @@
package com.vaadin.tests.server;
import java.lang.reflect.Field;
-import java.util.Hashtable;
+import java.util.HashMap;
import junit.framework.TestCase;
@@ -10,7 +10,7 @@ import com.vaadin.terminal.KeyMapper;
public class TestKeyMapper extends TestCase {
public void testAdd() {
- KeyMapper mapper = new KeyMapper();
+ KeyMapper<Object> mapper = new KeyMapper<Object>();
Object o1 = new Object();
Object o2 = new Object();
Object o3 = new Object();
@@ -41,7 +41,7 @@ public class TestKeyMapper extends TestCase {
}
public void testRemoveAll() {
- KeyMapper mapper = new KeyMapper();
+ KeyMapper<Object> mapper = new KeyMapper<Object>();
Object o1 = new Object();
Object o2 = new Object();
Object o3 = new Object();
@@ -58,7 +58,7 @@ public class TestKeyMapper extends TestCase {
}
public void testRemove() {
- KeyMapper mapper = new KeyMapper();
+ KeyMapper<Object> mapper = new KeyMapper<Object>();
Object o1 = new Object();
Object o2 = new Object();
Object o3 = new Object();
@@ -82,15 +82,15 @@ public class TestKeyMapper extends TestCase {
}
- private void assertSize(KeyMapper mapper, int i) {
+ private void assertSize(KeyMapper<?> mapper, int i) {
try {
Field f1 = KeyMapper.class.getDeclaredField("objectKeyMap");
Field f2 = KeyMapper.class.getDeclaredField("keyObjectMap");
f1.setAccessible(true);
f2.setAccessible(true);
- Hashtable<?, ?> h1 = (Hashtable<?, ?>) f1.get(mapper);
- Hashtable<?, ?> h2 = (Hashtable<?, ?>) f2.get(mapper);
+ HashMap<?, ?> h1 = (HashMap<?, ?>) f1.get(mapper);
+ HashMap<?, ?> h2 = (HashMap<?, ?>) f2.get(mapper);
assertEquals(i, h1.size());
assertEquals(i, h2.size());
diff --git a/tests/server-side/com/vaadin/tests/server/TestSerialization.java b/tests/server-side/com/vaadin/tests/server/TestSerialization.java
index 03a9d3e262..84ff5ad6fa 100644
--- a/tests/server-side/com/vaadin/tests/server/TestSerialization.java
+++ b/tests/server-side/com/vaadin/tests/server/TestSerialization.java
@@ -10,6 +10,7 @@ import java.io.Serializable;
import junit.framework.TestCase;
import com.vaadin.data.Item;
+import com.vaadin.data.Property;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.data.validator.RegexpValidator;
@@ -19,9 +20,9 @@ public class TestSerialization extends TestCase {
public void testValidators() throws Exception {
RegexpValidator validator = new RegexpValidator(".*", "Error");
- validator.isValid("aaa");
+ validator.validate("aaa");
RegexpValidator validator2 = (RegexpValidator) serializeAndDeserialize(validator);
- validator2.isValid("aaa");
+ validator2.validate("aaa");
}
public void testForm() throws Exception {
@@ -78,15 +79,25 @@ public class TestSerialization extends TestCase {
data));
Serializable s2 = (Serializable) in.readObject();
+ // using special toString(Object) method to avoid calling
+ // Property.toString(), which will be temporarily disabled
if (s.equals(s2)) {
- System.out.println(s + " equals " + s2);
+ System.out.println(toString(s) + " equals " + toString(s2));
} else {
- System.out.println(s + " does NOT equal " + s2);
+ System.out.println(toString(s) + " does NOT equal " + toString(s2));
}
return s2;
}
+ private static String toString(Object o) {
+ if (o instanceof Property) {
+ return String.valueOf(((Property<?>) o).getValue());
+ } else {
+ return String.valueOf(o);
+ }
+ }
+
public static class Data implements Serializable {
private String dummyGetter;
private String dummyGetterAndSetter;
diff --git a/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java b/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
index 224c9f5964..e430cb6103 100644
--- a/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
+++ b/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
@@ -20,6 +20,7 @@ import junit.framework.TestCase;
import org.easymock.EasyMock;
import com.vaadin.Application;
+import com.vaadin.Application.ApplicationStartEvent;
import com.vaadin.service.ApplicationContext.TransactionListener;
import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
@@ -70,8 +71,9 @@ public class TransactionListenersConcurrency extends TestCase {
// called later on.
try {
- app.start(new URL("http://localhost/"),
- new Properties(), context);
+ app.start(new ApplicationStartEvent(new URL(
+ "http://localhost/"), new Properties(),
+ context, true, null));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
index ee8ef6bfbc..4458872c79 100644
--- a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
+++ b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
@@ -3,6 +3,7 @@ package com.vaadin.tests.server.component.absolutelayout;
import junit.framework.TestCase;
import com.vaadin.terminal.Sizeable;
+import com.vaadin.terminal.Sizeable.Unit;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
@@ -12,7 +13,7 @@ public class ComponentPosition extends TestCase {
private static final String PARTIAL_CSS = "top:7.0px;left:7.0em;";
private static final Float CSS_VALUE = Float.valueOf(7);
- private static final int UNIT_UNSET = Sizeable.UNITS_PIXELS;
+ private static final Unit UNIT_UNSET = Sizeable.Unit.PIXELS;
/**
* Add component w/o giving positions, assert that everything is unset
@@ -51,11 +52,11 @@ public class ComponentPosition extends TestCase {
assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
assertEquals(CSS_VALUE, layout.getPosition(b).getRightValue());
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_PICAS, layout.getPosition(b)
+ assertEquals(Sizeable.Unit.PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.Unit.PICAS, layout.getPosition(b)
.getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
- assertEquals(Sizeable.UNITS_PERCENTAGE, layout.getPosition(b)
+ assertEquals(Sizeable.Unit.EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.Unit.PERCENTAGE, layout.getPosition(b)
.getRightUnits());
assertEquals(7, layout.getPosition(b).getZIndex());
@@ -77,9 +78,9 @@ public class ComponentPosition extends TestCase {
assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
assertNull(layout.getPosition(b).getRightValue());
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.Unit.PIXELS, layout.getPosition(b).getTopUnits());
assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.Unit.EM, layout.getPosition(b).getLeftUnits());
assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
assertEquals(-1, layout.getPosition(b).getZIndex());
@@ -104,9 +105,9 @@ public class ComponentPosition extends TestCase {
assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
assertNull(layout.getPosition(b).getRightValue());
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.Unit.PIXELS, layout.getPosition(b).getTopUnits());
assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.Unit.EM, layout.getPosition(b).getLeftUnits());
assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
assertEquals(-1, layout.getPosition(b).getZIndex());
@@ -131,21 +132,20 @@ public class ComponentPosition extends TestCase {
layout.getPosition(b).setBottomValue(SIZE);
layout.getPosition(b).setLeftValue(SIZE);
- layout.getPosition(b).setTopUnits(Sizeable.UNITS_CM);
- layout.getPosition(b).setRightUnits(Sizeable.UNITS_EX);
- layout.getPosition(b).setBottomUnits(Sizeable.UNITS_INCH);
- layout.getPosition(b).setLeftUnits(Sizeable.UNITS_MM);
+ layout.getPosition(b).setTopUnits(Sizeable.Unit.CM);
+ layout.getPosition(b).setRightUnits(Sizeable.Unit.EX);
+ layout.getPosition(b).setBottomUnits(Sizeable.Unit.INCH);
+ layout.getPosition(b).setLeftUnits(Sizeable.Unit.MM);
assertEquals(SIZE, layout.getPosition(b).getTopValue());
assertEquals(SIZE, layout.getPosition(b).getRightValue());
assertEquals(SIZE, layout.getPosition(b).getBottomValue());
assertEquals(SIZE, layout.getPosition(b).getLeftValue());
- assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
- assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
- .getBottomUnits());
- assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.Unit.CM, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.Unit.EX, layout.getPosition(b).getRightUnits());
+ assertEquals(Sizeable.Unit.INCH, layout.getPosition(b).getBottomUnits());
+ assertEquals(Sizeable.Unit.MM, layout.getPosition(b).getLeftUnits());
}
@@ -159,21 +159,20 @@ public class ComponentPosition extends TestCase {
Button b = new Button();
layout.addComponent(b);
- layout.getPosition(b).setTop(SIZE, Sizeable.UNITS_CM);
- layout.getPosition(b).setRight(SIZE, Sizeable.UNITS_EX);
- layout.getPosition(b).setBottom(SIZE, Sizeable.UNITS_INCH);
- layout.getPosition(b).setLeft(SIZE, Sizeable.UNITS_MM);
+ layout.getPosition(b).setTop(SIZE, Sizeable.Unit.CM);
+ layout.getPosition(b).setRight(SIZE, Sizeable.Unit.EX);
+ layout.getPosition(b).setBottom(SIZE, Sizeable.Unit.INCH);
+ layout.getPosition(b).setLeft(SIZE, Sizeable.Unit.MM);
assertEquals(SIZE, layout.getPosition(b).getTopValue());
assertEquals(SIZE, layout.getPosition(b).getRightValue());
assertEquals(SIZE, layout.getPosition(b).getBottomValue());
assertEquals(SIZE, layout.getPosition(b).getLeftValue());
- assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
- assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
- .getBottomUnits());
- assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.Unit.CM, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.Unit.EX, layout.getPosition(b).getRightUnits());
+ assertEquals(Sizeable.Unit.INCH, layout.getPosition(b).getBottomUnits());
+ assertEquals(Sizeable.Unit.MM, layout.getPosition(b).getLeftUnits());
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
new file mode 100644
index 0000000000..050ab282a6
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
@@ -0,0 +1,162 @@
+package com.vaadin.tests.server.component.abstractfield;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.data.util.converter.StringToIntegerConverter;
+import com.vaadin.tests.data.bean.Address;
+import com.vaadin.tests.data.bean.Country;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.TextField;
+
+public class AbstractFieldValueConversions extends TestCase {
+
+ Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com",
+ 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town",
+ Country.FINLAND));
+
+ public void testWithoutConversion() {
+ TextField tf = new TextField();
+ tf.setPropertyDataSource(new MethodProperty<String>(paulaBean,
+ "firstName"));
+ assertEquals("Paula", tf.getValue());
+ assertEquals("Paula", tf.getPropertyDataSource().getValue());
+ tf.setValue("abc");
+ assertEquals("abc", tf.getValue());
+ assertEquals("abc", tf.getPropertyDataSource().getValue());
+ assertEquals("abc", paulaBean.getFirstName());
+ }
+
+ public void testStringIdentityConversion() {
+ TextField tf = new TextField();
+ tf.setConverter(new Converter<String, String>() {
+
+ public String convertToModel(String value, Locale locale) {
+ return value;
+ }
+
+ public String convertToPresentation(String value, Locale locale) {
+ return value;
+ }
+
+ public Class<String> getModelType() {
+ return String.class;
+ }
+
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+ });
+ tf.setPropertyDataSource(new MethodProperty<String>(paulaBean,
+ "firstName"));
+ assertEquals("Paula", tf.getValue());
+ assertEquals("Paula", tf.getPropertyDataSource().getValue());
+ tf.setValue("abc");
+ assertEquals("abc", tf.getValue());
+ assertEquals("abc", tf.getPropertyDataSource().getValue());
+ assertEquals("abc", paulaBean.getFirstName());
+ }
+
+ public void testFailingConversion() {
+ TextField tf = new TextField();
+ tf.setConverter(new Converter<String, Integer>() {
+
+ public Integer convertToModel(String value, Locale locale) {
+ throw new ConversionException("Failed");
+ }
+
+ public String convertToPresentation(Integer value, Locale locale) {
+ throw new ConversionException("Failed");
+ }
+
+ public Class<Integer> getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Class<String> getPresentationType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ });
+ try {
+ tf.setValue(1);
+ fail("setValue(Integer) should throw an exception");
+ } catch (Converter.ConversionException e) {
+ // OK, expected
+ }
+ }
+
+ public void testIntegerStringConversion() {
+ TextField tf = new TextField();
+
+ tf.setConverter(new StringToIntegerConverter());
+ tf.setPropertyDataSource(new MethodProperty<Integer>(paulaBean, "age"));
+ assertEquals(34, tf.getPropertyDataSource().getValue());
+ assertEquals("34", tf.getValue());
+ tf.setValue("12");
+ assertEquals(12, tf.getPropertyDataSource().getValue());
+ assertEquals("12", tf.getValue());
+ tf.getPropertyDataSource().setValue(42);
+ assertEquals(42, tf.getPropertyDataSource().getValue());
+ assertEquals("42", tf.getValue());
+ }
+
+ public void testBooleanNullConversion() {
+ CheckBox cb = new CheckBox();
+ cb.setConverter(new Converter<Boolean, Boolean>() {
+
+ public Boolean convertToModel(Boolean value, Locale locale) {
+ // value from a CheckBox should never be null as long as it is
+ // not set to null (handled by conversion below).
+ assertNotNull(value);
+ return value;
+ }
+
+ public Boolean convertToPresentation(Boolean value, Locale locale) {
+ // Datamodel -> field
+ if (value == null) {
+ return false;
+ }
+
+ return value;
+ }
+
+ public Class<Boolean> getModelType() {
+ return Boolean.class;
+ }
+
+ public Class<Boolean> getPresentationType() {
+ return Boolean.class;
+ }
+
+ });
+ MethodProperty<Boolean> property = new MethodProperty<Boolean>(
+ paulaBean, "deceased");
+ cb.setPropertyDataSource(property);
+ assertEquals(Boolean.FALSE, property.getValue());
+ assertEquals(Boolean.FALSE, cb.getValue());
+ Boolean newDmValue = cb.getConverter().convertToPresentation(
+ cb.getValue(), new Locale("fi", "FI"));
+ assertEquals(Boolean.FALSE, newDmValue);
+
+ // FIXME: Should be able to set to false here to cause datamodel to be
+ // set to false but the change will not be propagated to the Property
+ // (field value is already false)
+
+ cb.setValue(true);
+ assertEquals(Boolean.TRUE, cb.getValue());
+ assertEquals(Boolean.TRUE, property.getValue());
+
+ cb.setValue(false);
+ assertEquals(Boolean.FALSE, cb.getValue());
+ assertEquals(Boolean.FALSE, property.getValue());
+
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
new file mode 100644
index 0000000000..e39b5d6629
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.server.component.abstractfield;
+
+import java.math.BigDecimal;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import com.vaadin.Application;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.tests.data.bean.Address;
+import com.vaadin.tests.data.bean.Country;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.ui.TextField;
+
+public class DefaultConverterFactory extends TestCase {
+
+ Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com",
+ 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town",
+ Country.FINLAND));
+ {
+ paulaBean.setSalary(49000);
+ BigDecimal rent = new BigDecimal(57223);
+ rent = rent.scaleByPowerOfTen(-2);
+ paulaBean.setRent(rent);
+ }
+
+ public void testDefaultNumberConversion() {
+ Application app = new Application();
+ Application.setCurrentApplication(app);
+ TextField tf = new TextField();
+ tf.setLocale(new Locale("en", "US"));
+ tf.setPropertyDataSource(new MethodProperty<Integer>(paulaBean,
+ "salary"));
+ assertEquals("49,000", tf.getValue());
+
+ tf.setLocale(new Locale("fi", "FI"));
+ // FIXME: The following line should not be necessary and should be
+ // removed
+ tf.setPropertyDataSource(new MethodProperty<Integer>(paulaBean,
+ "salary"));
+ String value = tf.getValue();
+ // Java uses a non-breaking space (ascii 160) instead of space when
+ // formatting
+ String expected = "49" + (char) 160 + "000";
+ assertEquals(expected, value);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
index 32b80e0bcd..9aeccdb56f 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
@@ -2,12 +2,13 @@ package com.vaadin.tests.server.component.abstractfield;
import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
import com.vaadin.data.Property;
import com.vaadin.data.util.AbstractProperty;
+import com.vaadin.data.util.converter.Converter.ConversionException;
import com.vaadin.ui.AbstractField;
-import org.junit.Test;
-
public class RemoveListenersOnDetach {
int numValueChanges = 0;
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
index 7ee70bde13..9937bf92d5 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
@@ -5,16 +5,17 @@ import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
public class TestAbstractFieldListeners extends AbstractListenerMethodsTest {
public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, ReadOnlyStatusChangeEvent.class,
+ testListenerAddGetRemove(CheckBox.class,
+ ReadOnlyStatusChangeEvent.class,
ReadOnlyStatusChangeListener.class);
}
public void testValueChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, ValueChangeEvent.class,
+ testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class,
ValueChangeListener.class);
}
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java b/tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java
new file mode 100644
index 0000000000..00b5c60dad
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java
@@ -0,0 +1,61 @@
+package com.vaadin.tests.server.component.datefield;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+import com.vaadin.tests.util.TestUtil;
+import com.vaadin.ui.DateField.Resolution;
+
+public class ResolutionTest extends TestCase {
+
+ public void testResolutionHigherOrEqualToYear() {
+ Iterable<Resolution> higherOrEqual = Resolution
+ .getResolutionsHigherOrEqualTo(Resolution.YEAR);
+ ArrayList<Resolution> expected = new ArrayList<Resolution>();
+ expected.add(Resolution.YEAR);
+ TestUtil.assertIterableEquals(expected, higherOrEqual);
+ }
+
+ public void testResolutionHigherOrEqualToDay() {
+ Iterable<Resolution> higherOrEqual = Resolution
+ .getResolutionsHigherOrEqualTo(Resolution.DAY);
+ ArrayList<Resolution> expected = new ArrayList<Resolution>();
+ expected.add(Resolution.DAY);
+ expected.add(Resolution.MONTH);
+ expected.add(Resolution.YEAR);
+ TestUtil.assertIterableEquals(expected, higherOrEqual);
+
+ }
+
+ public void testResolutionLowerThanDay() {
+ Iterable<Resolution> higherOrEqual = Resolution
+ .getResolutionsLowerThan(Resolution.DAY);
+ ArrayList<Resolution> expected = new ArrayList<Resolution>();
+ expected.add(Resolution.HOUR);
+ expected.add(Resolution.MINUTE);
+ expected.add(Resolution.SECOND);
+ TestUtil.assertIterableEquals(expected, higherOrEqual);
+
+ }
+
+ public void testResolutionLowerThanSecond() {
+ Iterable<Resolution> higherOrEqual = Resolution
+ .getResolutionsLowerThan(Resolution.SECOND);
+ ArrayList<Resolution> expected = new ArrayList<Resolution>();
+ TestUtil.assertIterableEquals(expected, higherOrEqual);
+ }
+
+ public void testResolutionLowerThanYear() {
+ Iterable<Resolution> higherOrEqual = Resolution
+ .getResolutionsLowerThan(Resolution.YEAR);
+ ArrayList<Resolution> expected = new ArrayList<Resolution>();
+ expected.add(Resolution.MONTH);
+ expected.add(Resolution.DAY);
+ expected.add(Resolution.HOUR);
+ expected.add(Resolution.MINUTE);
+ expected.add(Resolution.SECOND);
+ TestUtil.assertIterableEquals(expected, higherOrEqual);
+
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
new file mode 100644
index 0000000000..99b77b0d29
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
@@ -0,0 +1,98 @@
+package com.vaadin.tests.server.component.root;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.vaadin.Application;
+import com.vaadin.Application.ApplicationStartEvent;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.ui.Root;
+
+public class CustomRootClassLoader extends TestCase {
+
+ /**
+ * Stub root
+ */
+ public static class MyRoot extends Root {
+ @Override
+ protected void init(WrappedRequest request) {
+ // Nothing to see here
+ }
+ }
+
+ /**
+ * Dummy ClassLoader that just saves the name of the requested class before
+ * delegating to the default implementation.
+ */
+ public class LoggingClassLoader extends ClassLoader {
+
+ private List<String> requestedClasses = new ArrayList<String>();
+
+ @Override
+ protected synchronized Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException {
+ requestedClasses.add(name);
+ return super.loadClass(name, resolve);
+ }
+ }
+
+ /**
+ * Tests that a Root class can be loaded even if no classloader has been
+ * provided.
+ *
+ * @throws Exception
+ * if thrown
+ */
+ public void testWithNullClassLoader() throws Exception {
+ Application application = createStubApplication();
+ application.start(new ApplicationStartEvent(null, new Properties(),
+ null, false, null));
+
+ Root root = application.getRootForRequest(null);
+ assertTrue(root instanceof MyRoot);
+ }
+
+ /**
+ * Tests that the ClassLoader passed in the ApplicationStartEvent is used to
+ * load Root classes.
+ *
+ * @throws Exception
+ * if thrown
+ */
+ public void testWithClassLoader() throws Exception {
+ LoggingClassLoader loggingClassLoader = new LoggingClassLoader();
+
+ Application application = createStubApplication();
+ application.start(new ApplicationStartEvent(null, new Properties(),
+ null, false, loggingClassLoader));
+
+ Root root = application.getRootForRequest(null);
+ assertTrue(root instanceof MyRoot);
+ assertEquals(1, loggingClassLoader.requestedClasses.size());
+ assertEquals(MyRoot.class.getName(),
+ loggingClassLoader.requestedClasses.get(0));
+
+ }
+
+ private Application createStubApplication() {
+ return new Application() {
+ @Override
+ protected String getRootClassName(WrappedRequest request) {
+ // Always use the same root class
+ return MyRoot.class.getName();
+ }
+
+ @Override
+ public Root getRootForRequest(WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ // Always create a new root for testing (can't directly use
+ // getRoot as it's protected)
+ return getRoot(request);
+ }
+ };
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/slider/SliderTest.java b/tests/server-side/com/vaadin/tests/server/component/slider/SliderTest.java
new file mode 100644
index 0000000000..b969bf5e53
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/slider/SliderTest.java
@@ -0,0 +1,25 @@
+package com.vaadin.tests.server.component.slider;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import com.vaadin.ui.Slider;
+import com.vaadin.ui.Slider.ValueOutOfBoundsException;
+
+public class SliderTest extends TestCase {
+
+ public void testOutOfBounds() {
+ Slider s = new Slider(0, 10);
+ s.setValue(0);
+ Assert.assertEquals(0.0, s.getValue());
+ s.setValue(10);
+ Assert.assertEquals(10.0, s.getValue());
+ try {
+ s.setValue(20);
+ fail("Should throw out of bounds exception");
+ } catch (ValueOutOfBoundsException e) {
+ // TODO: handle exception
+ }
+
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java b/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
index 04f436f5c4..299f9c79d4 100644
--- a/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
+++ b/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.Align;
public class TableColumnAlignments {
@@ -15,7 +16,7 @@ public class TableColumnAlignments {
properties, 10);
Object[] expected = new Object[properties];
for (int i = 0; i < properties; i++) {
- expected[i] = Table.ALIGN_LEFT;
+ expected[i] = Align.LEFT;
}
org.junit.Assert.assertArrayEquals("getColumnAlignments", expected,
t.getColumnAlignments());
@@ -27,9 +28,8 @@ public class TableColumnAlignments {
int properties = 5;
Table t = TableGenerator
.createTableWithDefaultContainer(properties, 10);
- String[] explicitAlignments = new String[] { Table.ALIGN_CENTER,
- Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT,
- Table.ALIGN_LEFT };
+ Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT,
+ Align.RIGHT, Align.RIGHT, Align.LEFT };
t.setColumnAlignments(explicitAlignments);
@@ -40,28 +40,10 @@ public class TableColumnAlignments {
@Test
public void invalidColumnAlignmentStrings() {
Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT };
try {
- t.setColumnAlignments(new String[] { "a", "b", "c" });
- junit.framework.Assert
- .fail("No exception thrown for invalid array length");
- } catch (IllegalArgumentException e) {
- // Ok, expected
- }
-
- assertArrayEquals("Invalid change affected alignments",
- defaultAlignments, t.getColumnAlignments());
-
- }
-
- @Test
- public void invalidColumnAlignmentString() {
- Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
- try {
- t.setColumnAlignment("Property 1", "a");
+ t.setColumnAlignments(new Align[] { Align.RIGHT, Align.RIGHT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -76,10 +58,10 @@ public class TableColumnAlignments {
@Test
public void columnAlignmentForPropertyNotInContainer() {
Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT };
try {
- t.setColumnAlignment("Property 1200", Table.ALIGN_LEFT);
+ t.setColumnAlignment("Property 1200", Align.LEFT);
// FIXME: Uncomment as there should be an exception (#6475)
// junit.framework.Assert
// .fail("No exception thrown for property not in container");
@@ -100,12 +82,11 @@ public class TableColumnAlignments {
@Test
public void invalidColumnAlignmentsLength() {
Table t = TableGenerator.createTableWithDefaultContainer(7, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT };
try {
- t.setColumnAlignments(new String[] { Table.ALIGN_LEFT });
+ t.setColumnAlignments(new Align[] { Align.LEFT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -115,7 +96,7 @@ public class TableColumnAlignments {
defaultAlignments, t.getColumnAlignments());
try {
- t.setColumnAlignments(new String[] {});
+ t.setColumnAlignments(new Align[] {});
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -125,10 +106,9 @@ public class TableColumnAlignments {
defaultAlignments, t.getColumnAlignments());
try {
- t.setColumnAlignments(new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT });
+ t.setColumnAlignments(new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT,
+ Align.LEFT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -144,13 +124,11 @@ public class TableColumnAlignments {
int properties = 5;
Table t = TableGenerator
.createTableWithDefaultContainer(properties, 10);
- String[] explicitAlignments = new String[] { Table.ALIGN_CENTER,
- Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT,
- Table.ALIGN_LEFT };
+ Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT,
+ Align.RIGHT, Align.RIGHT, Align.LEFT };
- String[] currentAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT };
+ Align[] currentAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT };
for (int i = 0; i < properties; i++) {
t.setColumnAlignment("Property " + i, explicitAlignments[i]);
diff --git a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
index 5a494b8ccd..d7b38cecfc 100644
--- a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
+++ b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
@@ -2,6 +2,8 @@ package com.vaadin.tests.server.component.textfield;
import java.util.Collections;
+import junit.framework.TestCase;
+
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
@@ -11,8 +13,6 @@ import com.vaadin.terminal.Paintable;
import com.vaadin.terminal.Paintable.RepaintRequestEvent;
import com.vaadin.ui.TextField;
-import junit.framework.TestCase;
-
public class TextFieldWithPropertyFormatter extends TestCase {
private static final String INPUT_VALUE = "foo";
@@ -20,7 +20,7 @@ public class TextFieldWithPropertyFormatter extends TestCase {
private static final String FORMATTED_VALUE = "FOOBAR";
private static final String ORIGINAL_VALUE = "Original";
private TextField field;
- private PropertyFormatter formatter;
+ private PropertyFormatter<String> formatter;
private ObjectProperty<String> property;
private ValueChangeListener listener;
private int listenerCalled;
@@ -32,16 +32,16 @@ public class TextFieldWithPropertyFormatter extends TestCase {
field = new TextField();
- formatter = new PropertyFormatter() {
+ formatter = new PropertyFormatter<String>() {
@Override
- public Object parse(String formattedValue) throws Exception {
+ public String parse(String formattedValue) throws Exception {
assertEquals(INPUT_VALUE, formattedValue);
return PARSED_VALUE;
}
@Override
- public String format(Object value) {
+ public String format(String value) {
return FORMATTED_VALUE;
}
};
@@ -59,7 +59,7 @@ public class TextFieldWithPropertyFormatter extends TestCase {
assertEquals(FORMATTED_VALUE, event.getProperty().getValue());
}
};
-
+
field.addListener(listener);
field.addListener(new Paintable.RepaintRequestListener() {
public void repaintRequested(RepaintRequestEvent event) {
diff --git a/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java b/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java
deleted file mode 100644
index 70fb68b9ec..0000000000
--- a/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.vaadin.tests.server.component.urifragmentutility;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.UriFragmentUtility;
-import com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent;
-import com.vaadin.ui.UriFragmentUtility.FragmentChangedListener;
-
-public class UriFragmentUtilityListeners extends AbstractListenerMethodsTest {
- public void testFragmentChangedListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(UriFragmentUtility.class,
- FragmentChangedEvent.class, FragmentChangedListener.class);
- }
-}
diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
index 50de91e2af..f8901803c3 100644
--- a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
@@ -1,22 +1,23 @@
package com.vaadin.tests.server.component.window;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.Application;
+import com.vaadin.ui.Root;
+import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.Window;
public class AddRemoveSubWindow {
- public class TestApp extends Application {
+ public class TestApp extends Application.LegacyApplication {
@Override
public void init() {
- Window w = new Window("Main window");
+ LegacyWindow w = new LegacyWindow("Main window");
setMainWindow(w);
}
}
@@ -26,7 +27,7 @@ public class AddRemoveSubWindow {
TestApp app = new TestApp();
app.init();
Window subWindow = new Window("Sub window");
- Window mainWindow = app.getMainWindow();
+ Root mainWindow = app.getMainWindow();
mainWindow.addWindow(subWindow);
// Added to main window so the parent of the sub window should be the
@@ -44,7 +45,7 @@ public class AddRemoveSubWindow {
// Try to add the same sub window to another window
try {
- Window w = new Window();
+ LegacyWindow w = new LegacyWindow();
w.addWindow(subWindow);
assertTrue("Window.addWindow did not throw the expected exception",
false);
@@ -60,23 +61,18 @@ public class AddRemoveSubWindow {
TestApp app = new TestApp();
app.init();
Window subWindow = new Window("Sub window");
- Window mainWindow = app.getMainWindow();
+ Root mainWindow = app.getMainWindow();
mainWindow.addWindow(subWindow);
// Added to main window so the parent of the sub window should be the
// main window
assertEquals(subWindow.getParent(), mainWindow);
- // Remove from the wrong window, should result in an exception
- boolean removed = subWindow.removeWindow(subWindow);
- assertFalse("Window was removed even though it should not have been",
- removed);
-
// Parent should still be set
assertEquals(subWindow.getParent(), mainWindow);
// Remove from the main window and assert it has been removed
- removed = mainWindow.removeWindow(subWindow);
+ boolean removed = mainWindow.removeWindow(subWindow);
assertTrue("Window was not removed correctly", removed);
assertNull(subWindow.getParent());
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
index 5fabe40bb7..a67c7bb387 100644
--- a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
@@ -3,61 +3,36 @@ package com.vaadin.tests.server.component.window;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
import com.vaadin.Application;
-import com.vaadin.ui.Component;
+import com.vaadin.terminal.WrappedRequest;
import com.vaadin.ui.Label;
+import com.vaadin.ui.Root;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
-import org.junit.Test;
-
public class AttachDetachWindow {
- private Application testApp = new Application() {
- @Override
- public void init() {
- }
- };
+ private Application testApp = new Application();
+
+ private interface TestContainer {
+ public boolean attachCalled();
+
+ public boolean detachCalled();
- private class TestWindow extends Window {
+ public TestContent getTestContent();
+
+ public Application getApplication();
+ }
+
+ private class TestWindow extends Window implements TestContainer {
boolean windowAttachCalled = false;
- boolean contentAttachCalled = false;
- boolean childAttachCalled = false;
boolean windowDetachCalled = false;
- boolean contentDetachCalled = false;
- boolean childDetachCalled = false;
+ private TestContent testContent = new TestContent();;
TestWindow() {
- setContent(new VerticalLayout() {
- @Override
- public void attach() {
- super.attach();
- contentAttachCalled = true;
- }
-
- @Override
- public void detach() {
- super.detach();
- contentDetachCalled = true;
- }
- });
- addComponent(new Label() {
- @Override
- public void attach() {
- super.attach();
- childAttachCalled = true;
- }
-
- @Override
- public void detach() {
- super.detach();
- childDetachCalled = true;
- }
- });
- }
-
- Component getChild() {
- return getComponentIterator().next();
+ setContent(testContent);
}
@Override
@@ -71,9 +46,97 @@ public class AttachDetachWindow {
super.detach();
windowDetachCalled = true;
}
+
+ public boolean attachCalled() {
+ return windowAttachCalled;
+ }
+
+ public boolean detachCalled() {
+ return windowDetachCalled;
+ }
+
+ public TestContent getTestContent() {
+ return testContent;
+ }
}
- TestWindow main = new TestWindow();
+ private class TestContent extends VerticalLayout {
+ boolean contentDetachCalled = false;
+ boolean childDetachCalled = false;
+ boolean contentAttachCalled = false;
+ boolean childAttachCalled = false;
+
+ private Label child = new Label() {
+ @Override
+ public void attach() {
+ super.attach();
+ childAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ childDetachCalled = true;
+ }
+ };
+
+ public TestContent() {
+ addComponent(child);
+ }
+
+ @Override
+ public void attach() {
+ super.attach();
+ contentAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ contentDetachCalled = true;
+ }
+ }
+
+ private class TestRoot extends Root implements TestContainer {
+ boolean rootAttachCalled = false;
+ boolean rootDetachCalled = false;
+ private TestContent testContent = new TestContent();;
+
+ public TestRoot() {
+ setContent(testContent);
+ }
+
+ @Override
+ protected void init(WrappedRequest request) {
+ // Do nothing
+ }
+
+ public boolean attachCalled() {
+ return rootAttachCalled;
+ }
+
+ public boolean detachCalled() {
+ return rootDetachCalled;
+ }
+
+ public TestContent getTestContent() {
+ return testContent;
+ }
+
+ @Override
+ public void attach() {
+ super.attach();
+ rootAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ rootDetachCalled = true;
+ }
+ }
+
+ TestRoot main = new TestRoot();
TestWindow sub = new TestWindow();
@Test
@@ -86,7 +149,7 @@ public class AttachDetachWindow {
assertUnattached(sub);
// attaching main should recurse to sub
- testApp.setMainWindow(main);
+ main.setApplication(testApp);
assertAttached(main);
assertAttached(sub);
}
@@ -96,7 +159,7 @@ public class AttachDetachWindow {
assertUnattached(main);
assertUnattached(sub);
- testApp.setMainWindow(main);
+ main.setApplication(testApp);
assertAttached(main);
assertUnattached(sub);
@@ -108,7 +171,7 @@ public class AttachDetachWindow {
@Test
public void removeSubWindowBeforeDetachingMainWindow() {
- testApp.addWindow(main);
+ main.setApplication(testApp);
main.addWindow(sub);
// sub should be detached when removing from attached main
@@ -117,18 +180,18 @@ public class AttachDetachWindow {
assertDetached(sub);
// main detach should recurse to sub
- testApp.removeWindow(main);
+ main.setApplication(null);
assertDetached(main);
assertDetached(sub);
}
@Test
public void removeSubWindowAfterDetachingMainWindow() {
- testApp.addWindow(main);
+ main.setApplication(testApp);
main.addWindow(sub);
// main detach should recurse to sub
- testApp.removeWindow(main);
+ main.setApplication(null);
assertDetached(main);
assertDetached(sub);
@@ -141,27 +204,31 @@ public class AttachDetachWindow {
* Asserts that win and its children are attached to testApp and their
* attach() methods have been called.
*/
- private void assertAttached(TestWindow win) {
- assertTrue("window attach not called", win.windowAttachCalled);
- assertTrue("window content attach not called", win.contentAttachCalled);
- assertTrue("window child attach not called", win.childAttachCalled);
+ private void assertAttached(TestContainer win) {
+ TestContent testContent = win.getTestContent();
+
+ assertTrue("window attach not called", win.attachCalled());
+ assertTrue("window content attach not called",
+ testContent.contentAttachCalled);
+ assertTrue("window child attach not called",
+ testContent.childAttachCalled);
assertSame("window not attached", win.getApplication(), testApp);
- assertSame("window content not attached", win.getContent()
- .getApplication(), testApp);
- assertSame("window children not attached", win.getChild()
- .getApplication(), testApp);
+ assertSame("window content not attached", testContent.getApplication(),
+ testApp);
+ assertSame("window children not attached",
+ testContent.child.getApplication(), testApp);
}
/**
* Asserts that win and its children are not attached.
*/
- private void assertUnattached(TestWindow win) {
+ private void assertUnattached(TestContainer win) {
assertSame("window not detached", win.getApplication(), null);
- assertSame("window content not detached", win.getContent()
- .getApplication(), null);
- assertSame("window children not detached", win.getChild()
+ assertSame("window content not detached", win.getTestContent()
.getApplication(), null);
+ assertSame("window children not detached",
+ win.getTestContent().child.getApplication(), null);
}
/**
@@ -170,10 +237,12 @@ public class AttachDetachWindow {
*
* @param win
*/
- private void assertDetached(TestWindow win) {
+ private void assertDetached(TestContainer win) {
assertUnattached(win);
- assertTrue("window detach not called", win.windowDetachCalled);
- assertTrue("window content detach not called", win.contentDetachCalled);
- assertTrue("window child detach not called", win.childDetachCalled);
+ assertTrue("window detach not called", win.detachCalled());
+ assertTrue("window content detach not called",
+ win.getTestContent().contentDetachCalled);
+ assertTrue("window child detach not called",
+ win.getTestContent().childDetachCalled);
}
}
diff --git a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
index fcea309e84..3512f555c9 100644
--- a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
@@ -22,12 +22,12 @@ import com.vaadin.ui.AbstractField;
* override {@link #setValue(AbstractField)} to set the field value via
* <code>changeVariables()</code>.
*/
-public abstract class AbstractTestFieldValueChange extends TestCase {
+public abstract class AbstractTestFieldValueChange<T> extends TestCase {
- private AbstractField field;
+ private AbstractField<T> field;
private ValueChangeListener listener;
- protected void setUp(AbstractField field) throws Exception {
+ protected void setUp(AbstractField<T> field) throws Exception {
this.field = field;
listener = EasyMock.createStrictMock(ValueChangeListener.class);
@@ -155,14 +155,14 @@ public abstract class AbstractTestFieldValueChange extends TestCase {
EasyMock.verify(listener);
}
- protected AbstractField getField() {
+ protected AbstractField<T> getField() {
return field;
}
/**
* Override in subclasses to set value with changeVariables().
*/
- protected void setValue(AbstractField field) {
+ protected void setValue(AbstractField<T> field) {
field.setValue("newValue");
}
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
index 3fbe1406f2..1ca06a86aa 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
@@ -12,7 +12,8 @@ import com.vaadin.ui.ComboBox;
*
* See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
*/
-public class TestComboBoxValueChange extends AbstractTestFieldValueChange {
+public class TestComboBoxValueChange extends
+ AbstractTestFieldValueChange<Object> {
@Override
protected void setUp() throws Exception {
ComboBox combo = new ComboBox();
@@ -21,7 +22,7 @@ public class TestComboBoxValueChange extends AbstractTestFieldValueChange {
}
@Override
- protected void setValue(AbstractField field) {
+ protected void setValue(AbstractField<Object> field) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("selected", new String[] { "myvalue" });
field.changeVariables(field, variables);
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
index 2c911d5f3f..758c09d66e 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
@@ -18,7 +18,8 @@ import com.vaadin.ui.TextField;
*
* See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
*/
-public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
+public class TestTextFieldValueChange extends
+ AbstractTestFieldValueChange<String> {
@Override
protected void setUp() throws Exception {
@@ -36,7 +37,7 @@ public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
}
@Override
- protected void setValue(AbstractField field) {
+ protected void setValue(AbstractField<String> field) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("text", "newValue");
field.changeVariables(field, variables);
@@ -54,8 +55,7 @@ public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
getField().setPropertyDataSource(property);
// defaults, buffering off
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
+ getField().setBuffered(false);
// Expectations and start test
getListener().valueChange(EasyMock.isA(ValueChangeEvent.class));
@@ -142,8 +142,7 @@ public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
initialValue);
// set buffering
- getField().setWriteThrough(false);
- getField().setReadThrough(false);
+ getField().setBuffered(true);
// Value change should only happen once, when setting the property,
// further changes via property should not cause value change listener
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
index 89d018c8a5..7713f69f68 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
@@ -7,6 +7,7 @@ import junit.framework.TestCase;
import org.easymock.EasyMock;
+import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.CloseEvent;
import com.vaadin.ui.Window.CloseListener;
@@ -20,6 +21,7 @@ public class TestWindow extends TestCase {
@Override
protected void setUp() throws Exception {
window = new Window();
+ new LegacyWindow().addWindow(window);
}
public void testCloseListener() {
diff --git a/tests/server-side/com/vaadin/tests/server/validation/RangeValidatorTest.java b/tests/server-side/com/vaadin/tests/server/validation/RangeValidatorTest.java
new file mode 100644
index 0000000000..e3320b8699
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/validation/RangeValidatorTest.java
@@ -0,0 +1,52 @@
+package com.vaadin.tests.server.validation;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.validator.IntegerRangeValidator;
+
+public class RangeValidatorTest extends TestCase {
+
+ // This test uses IntegerRangeValidator for simplicity.
+ // IntegerRangeValidator contains no code so we really are testing
+ // RangeValidator
+ public void testMinValueNonInclusive() {
+ IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10);
+ iv.setMinValueIncluded(false);
+ assertFalse(iv.isValid(0));
+ assertTrue(iv.isValid(10));
+ assertFalse(iv.isValid(11));
+ assertFalse(iv.isValid(-1));
+ }
+
+ public void testMinMaxValuesInclusive() {
+ IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10);
+ assertTrue(iv.isValid(0));
+ assertTrue(iv.isValid(1));
+ assertTrue(iv.isValid(10));
+ assertFalse(iv.isValid(11));
+ assertFalse(iv.isValid(-1));
+ }
+
+ public void testMaxValueNonInclusive() {
+ IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10);
+ iv.setMaxValueIncluded(false);
+ assertTrue(iv.isValid(0));
+ assertTrue(iv.isValid(9));
+ assertFalse(iv.isValid(10));
+ assertFalse(iv.isValid(11));
+ assertFalse(iv.isValid(-1));
+ }
+
+ public void testMinMaxValuesNonInclusive() {
+ IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10);
+ iv.setMinValueIncluded(false);
+ iv.setMaxValueIncluded(false);
+
+ assertFalse(iv.isValid(0));
+ assertTrue(iv.isValid(1));
+ assertTrue(iv.isValid(9));
+ assertFalse(iv.isValid(10));
+ assertFalse(iv.isValid(11));
+ assertFalse(iv.isValid(-1));
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/validation/TestBeanValidation.java b/tests/server-side/com/vaadin/tests/server/validation/TestBeanValidation.java
new file mode 100644
index 0000000000..8f6928fc35
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/validation/TestBeanValidation.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.server.validation;
+
+import org.junit.Test;
+
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.BeanValidator;
+import com.vaadin.tests.data.bean.BeanToValidate;
+
+public class TestBeanValidation {
+ @Test(expected = InvalidValueException.class)
+ public void testBeanValidationNull() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class,
+ "firstname");
+ validator.validate(null);
+ }
+
+ @Test(expected = InvalidValueException.class)
+ public void testBeanValidationStringTooShort() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class,
+ "firstname");
+ validator.validate("aa");
+ }
+
+ @Test
+ public void testBeanValidationStringOk() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class,
+ "firstname");
+ validator.validate("aaa");
+ }
+
+ @Test(expected = InvalidValueException.class)
+ public void testBeanValidationIntegerTooSmall() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class, "age");
+ validator.validate(17);
+ }
+
+ @Test
+ public void testBeanValidationIntegerOk() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class, "age");
+ validator.validate(18);
+ }
+
+ @Test(expected = InvalidValueException.class)
+ public void testBeanValidationTooManyDigits() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class,
+ "decimals");
+ validator.validate("1234.567");
+ }
+
+ @Test
+ public void testBeanValidationDigitsOk() {
+ BeanValidator validator = new BeanValidator(BeanToValidate.class,
+ "decimals");
+ validator.validate("123.45");
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java b/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
index c4052c2db8..e37b97e02c 100644
--- a/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
+++ b/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
@@ -11,7 +11,7 @@ public class TestReadOnlyValidation {
public void testIntegerValidation() {
TextField field = new TextField();
field.addValidator(new IntegerValidator("Enter a Valid Number"));
- field.setValue(Integer.valueOf(10));
+ field.setValue(String.valueOf(10));
field.validate();
}
}
diff --git a/tests/server-side/com/vaadin/tests/util/GraphVizClassHierarchyCreator.java b/tests/server-side/com/vaadin/tests/util/GraphVizClassHierarchyCreator.java
new file mode 100644
index 0000000000..9e791500b0
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/util/GraphVizClassHierarchyCreator.java
@@ -0,0 +1,149 @@
+package com.vaadin.tests.util;
+
+import java.lang.reflect.Modifier;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.vaadin.tests.VaadinClasses;
+
+public class GraphVizClassHierarchyCreator {
+
+ public static void main(String[] args) {
+ String gv = getGraphVizHierarchy((List) VaadinClasses.getComponents(),
+ "com.vaadin");
+ System.out.println(gv);
+ }
+
+ private static String getGraphVizHierarchy(List<Class> classes,
+ String packageToInclude) {
+ boolean includeInterfaces = false;
+
+ StringBuilder header = new StringBuilder();
+ header.append("digraph finite_state_machine {\n"
+ + " rankdir=BT;\n" + " dpi=\"150\";\n"
+ + " ratio=\"0.25\";\n");
+
+ StringBuilder sb = new StringBuilder();
+
+ Set<Class> classesAndParents = new HashSet<Class>();
+ for (Class<?> cls : classes) {
+ addClassAndParents(classesAndParents, cls, packageToInclude);
+ }
+
+ Set<Class> interfaces = new HashSet<Class>();
+ for (Object cls : classesAndParents.toArray()) {
+ for (Class<?> c : ((Class) cls).getInterfaces()) {
+ addClassAndParentInterfaces(classesAndParents, c,
+ packageToInclude);
+ }
+ }
+
+ for (Class<?> c : classesAndParents) {
+ appendClass(sb, c, c.getSuperclass(), packageToInclude,
+ includeInterfaces);
+ for (Class ci : c.getInterfaces()) {
+ appendClass(sb, c, ci, packageToInclude, includeInterfaces);
+ }
+ }
+
+ header.append(" node [shape = ellipse, style=\"dotted\"] ");
+ for (Class c : classesAndParents) {
+ if (!c.isInterface() && Modifier.isAbstract(c.getModifiers())) {
+ header.append(c.getSimpleName() + " ");
+ }
+ }
+ if (includeInterfaces) {
+ System.out.print(" node [shape = ellipse, style=\"solid\"] ");
+ for (Class c : classesAndParents) {
+ if (c.isInterface()) {
+ header.append(c.getSimpleName() + " ");
+ }
+ }
+ header.append(";\n");
+ }
+ header.append(";\n");
+ header.append(" node [shape = rectangle, style=\"solid\"];\n");
+ return header.toString() + sb.toString() + "}";
+ }
+
+ private static void addClassAndParents(Set<Class> classesAndParents,
+ Class<?> cls, String packageToInclude) {
+
+ if (cls == null) {
+ return;
+ }
+
+ if (classesAndParents.contains(cls)) {
+ return;
+ }
+
+ if (!cls.getPackage().getName().startsWith(packageToInclude)) {
+ return;
+ }
+
+ classesAndParents.add(cls);
+ addClassAndParents(classesAndParents, cls.getSuperclass(),
+ packageToInclude);
+
+ }
+
+ private static void addClassAndParentInterfaces(
+ Set<Class> classesAndParents, Class<?> cls, String packageToInclude) {
+
+ if (cls == null) {
+ return;
+ }
+
+ if (classesAndParents.contains(cls)) {
+ return;
+ }
+
+ if (!cls.getPackage().getName().startsWith(packageToInclude)) {
+ return;
+ }
+
+ classesAndParents.add(cls);
+ for (Class iClass : cls.getInterfaces()) {
+ addClassAndParentInterfaces(classesAndParents, iClass,
+ packageToInclude);
+ }
+
+ }
+
+ private static void appendClass(StringBuilder sb, Class<?> c,
+ Class<?> superClass, String packageToInclude,
+ boolean includeInterfaces) {
+ if (superClass == null) {
+ return;
+ }
+ if (!c.getPackage().getName().startsWith(packageToInclude)) {
+ return;
+ }
+ if (!superClass.getPackage().getName().startsWith(packageToInclude)) {
+ return;
+ }
+ if (!includeInterfaces && (c.isInterface() || superClass.isInterface())) {
+ return;
+ }
+
+ sb.append(c.getSimpleName()).append(" -> ")
+ .append(superClass.getSimpleName()).append("\n");
+
+ }
+
+ private static void addInterfaces(Set<Class> interfaces, Class<?> cls) {
+ if (interfaces.contains(cls)) {
+ return;
+ }
+
+ if (cls.isInterface()) {
+ interfaces.add(cls);
+ }
+
+ for (Class c : cls.getInterfaces()) {
+ addInterfaces(interfaces, c);
+ }
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/util/TestUtil.java b/tests/server-side/com/vaadin/tests/util/TestUtil.java
new file mode 100644
index 0000000000..e84f9dd8b9
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/util/TestUtil.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.util;
+
+import java.util.Iterator;
+
+import junit.framework.Assert;
+
+public class TestUtil {
+ public static void assertArrays(Object[] actualObjects,
+ Object[] expectedObjects) {
+ Assert.assertEquals(
+ "Actual contains a different number of values than was expected",
+ expectedObjects.length, actualObjects.length);
+
+ for (int i = 0; i < actualObjects.length; i++) {
+ Object actual = actualObjects[i];
+ Object expected = expectedObjects[i];
+
+ Assert.assertEquals("Item[" + i + "] does not match", expected,
+ actual);
+ }
+
+ }
+
+ public static void assertIterableEquals(Iterable<?> iterable1,
+ Iterable<?> iterable2) {
+ Iterator<?> i1 = iterable1.iterator();
+ Iterator<?> i2 = iterable2.iterator();
+
+ while (i1.hasNext()) {
+ Object o1 = i1.next();
+ if (!i2.hasNext()) {
+ Assert.fail("The second iterable contains fewer items than the first. The object "
+ + o1 + " has no match in the second iterable.");
+ }
+ Object o2 = i2.next();
+ Assert.assertEquals(o1, o2);
+ }
+ if (i2.hasNext()) {
+ Assert.fail("The second iterable contains more items than the first. The object "
+ + i2.next() + " has no match in the first iterable.");
+ }
+ }
+}