diff options
Diffstat (limited to 'tests/server-side/com/vaadin/data')
22 files changed, 149 insertions, 128 deletions
diff --git a/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java b/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java index 6cbe675fa1..d703fb0364 100644 --- a/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java +++ b/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java @@ -62,6 +62,7 @@ public abstract class AbstractContainerTest extends TestCase { protected static class ItemSetChangeCounter extends AbstractEventCounter implements ItemSetChangeListener { + @Override public void containerItemSetChange(ItemSetChangeEvent event) { increment(); } diff --git a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java index d9fa8d896e..9037e303a8 100644 --- a/tests/server-side/com/vaadin/data/util/BeanContainerTest.java +++ b/tests/server-side/com/vaadin/data/util/BeanContainerTest.java @@ -18,6 +18,7 @@ public class BeanContainerTest extends AbstractBeanContainerTest { protected static class PersonNameResolver implements BeanIdResolver<String, Person> { + @Override public String getIdForBean(Person bean) { return bean != null ? bean.getName() : null; } @@ -27,6 +28,7 @@ public class BeanContainerTest extends AbstractBeanContainerTest { protected static class NullResolver implements BeanIdResolver<String, Person> { + @Override public String getIdForBean(Person bean) { return null; } @@ -332,6 +334,7 @@ public class BeanContainerTest extends AbstractBeanContainerTest { container .setBeanIdResolver(new BeanIdResolver<String, AbstractBeanContainerTest.Person>() { + @Override public String getIdForBean(Person bean) { return bean.getName(); } diff --git a/tests/server-side/com/vaadin/data/util/BeanItemTest.java b/tests/server-side/com/vaadin/data/util/BeanItemTest.java index 044a410803..e1ad75796c 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. * @@ -132,6 +127,7 @@ public class BeanItemTest extends TestCase { public void setSub(int i); + @Override public int getOverride(); public void setOverride(int i); @@ -322,7 +318,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..497699605a 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); } @@ -220,6 +205,7 @@ public class TestContainerSorting extends TestCase { public class MyObject implements Comparable<MyObject> { private String data; + @Override public int compareTo(MyObject o) { if (o == null) { return 1; diff --git a/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java b/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java index 60894dbe6f..9e0558a122 100644 --- a/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java +++ b/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java @@ -176,11 +176,13 @@ public class TestHierarchicalContainer extends // Dummy filter that does not remove any items c.addContainerFilter(new Filter() { + @Override public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException { return true; } + @Override public boolean appliesToProperty(Object propertyId) { return true; } 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..6f96c3a51a 100644 --- a/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java +++ b/tests/server-side/com/vaadin/data/util/filter/AbstractFilterTest.java @@ -22,25 +22,29 @@ public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends } } - protected static class NullProperty implements Property { + protected static class NullProperty implements Property<String> { - public Object getValue() { + @Override + public String getValue() { return null; } - public void setValue(Object newValue) throws ReadOnlyException, - ConversionException { + @Override + public void setValue(Object newValue) throws ReadOnlyException { throw new ReadOnlyException(); } - public Class<?> getType() { + @Override + public Class<String> getType() { return String.class; } + @Override public boolean isReadOnly() { return true; } + @Override public void setReadOnly(boolean newStatus) { // do nothing } @@ -61,11 +65,13 @@ public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends this.propertyId = propertyId; } + @Override public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException { return this.item == item; } + @Override public boolean appliesToProperty(Object propertyId) { return this.propertyId != null ? this.propertyId.equals(propertyId) : true; 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/DataGenerator.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/DataGenerator.java index 6fa807b007..489f780d61 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/DataGenerator.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/DataGenerator.java @@ -12,11 +12,12 @@ import com.vaadin.data.util.sqlcontainer.AllTests.DB; import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; public class DataGenerator { - - @Test - public void testDummy(){ - // Added dummy test so JUnit will not complain about "No runnable methods". - } + + @Test + public void testDummy() { + // Added dummy test so JUnit will not complain about + // "No runnable methods". + } public static void addPeopleToDatabase(JDBCConnectionPool connectionPool) throws SQLException { diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java index 2579a38aa1..b0e2a232ca 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java @@ -11,11 +11,12 @@ import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; public class FreeformQueryUtil { - @Test - public void testDummy(){ - // Added dummy test so JUnit will not complain about "No runnable methods". - } - + @Test + public void testDummy() { + // Added dummy test so JUnit will not complain about + // "No runnable methods". + } + public static StatementHelper getQueryWithFilters(List<Filter> filters, int offset, int limit) { StatementHelper sh = new StatementHelper(); @@ -30,8 +31,7 @@ public class FreeformQueryUtil { query.append(") AS rownum, * FROM \"PEOPLE\""); if (!filters.isEmpty()) { - query.append(QueryBuilder.getWhereStringForFilters( - filters, sh)); + query.append(QueryBuilder.getWhereStringForFilters(filters, sh)); } query.append(") AS a WHERE a.rownum BETWEEN ").append(offset) .append(" AND ").append(Integer.toString(offset + limit)); @@ -46,8 +46,7 @@ public class FreeformQueryUtil { query.append("SELECT * FROM (SELECT x.*, ROWNUM AS " + "\"rownum\" FROM (SELECT * FROM \"PEOPLE\""); if (!filters.isEmpty()) { - query.append(QueryBuilder.getWhereStringForFilters( - filters, sh)); + query.append(QueryBuilder.getWhereStringForFilters(filters, sh)); } query.append(") x) WHERE \"rownum\" BETWEEN ? AND ?"); sh.addParameterValue(offset); @@ -57,8 +56,7 @@ public class FreeformQueryUtil { } else { StringBuilder query = new StringBuilder("SELECT * FROM people"); if (!filters.isEmpty()) { - query.append(QueryBuilder.getWhereStringForFilters( - filters, sh)); + query.append(QueryBuilder.getWhereStringForFilters(filters, sh)); } if (limit != 0 || offset != 0) { query.append(" LIMIT ? OFFSET ?"); 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..6649bc16e8 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTest.java @@ -323,6 +323,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1132,6 +1133,7 @@ public class SQLContainerTest { delegate.storeRow(EasyMock.isA(Connection.class), EasyMock.isA(RowItem.class))) .andAnswer(new IAnswer<Integer>() { + @Override public Integer answer() throws Throwable { Connection conn = (Connection) EasyMock .getCurrentArguments()[0]; @@ -1163,6 +1165,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1231,6 +1234,7 @@ public class SQLContainerTest { delegate.storeRow(EasyMock.isA(Connection.class), EasyMock.isA(RowItem.class))) .andAnswer(new IAnswer<Integer>() { + @Override public Integer answer() throws Throwable { Connection conn = (Connection) EasyMock .getCurrentArguments()[0]; @@ -1262,6 +1266,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1337,6 +1342,7 @@ public class SQLContainerTest { delegate.removeRow(EasyMock.isA(Connection.class), EasyMock.isA(RowItem.class))) .andAnswer(new IAnswer<Boolean>() { + @Override public Boolean answer() throws Throwable { Connection conn = (Connection) EasyMock .getCurrentArguments()[0]; @@ -1344,7 +1350,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; } @@ -1352,6 +1358,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1414,6 +1421,7 @@ public class SQLContainerTest { delegate.storeRow(EasyMock.isA(Connection.class), EasyMock.isA(RowItem.class))) .andAnswer(new IAnswer<Integer>() { + @Override public Integer answer() throws Throwable { Connection conn = (Connection) EasyMock .getCurrentArguments()[0]; @@ -1432,6 +1440,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1644,6 +1653,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setOrderBy(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<OrderBy> orders = (List<OrderBy>) EasyMock .getCurrentArguments()[0]; @@ -1655,6 +1665,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1756,6 +1767,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setOrderBy(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<OrderBy> orders = (List<OrderBy>) EasyMock .getCurrentArguments()[0]; @@ -1767,6 +1779,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1861,6 +1874,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -1872,6 +1886,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1882,6 +1897,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); @@ -1931,6 +1947,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -1942,6 +1959,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -1952,6 +1970,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); @@ -2000,6 +2019,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -2011,6 +2031,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -2021,6 +2042,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); StringBuffer query = new StringBuffer( @@ -2069,6 +2091,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -2080,6 +2103,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -2090,6 +2114,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); @@ -2145,6 +2170,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -2156,6 +2182,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -2166,6 +2193,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); @@ -2221,6 +2249,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -2232,6 +2261,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -2242,6 +2272,7 @@ public class SQLContainerTest { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); @@ -2323,6 +2354,7 @@ public class SQLContainerTest { EasyMock.expectLastCall().anyTimes(); delegate.setOrderBy(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<OrderBy> orders = (List<OrderBy>) EasyMock .getCurrentArguments()[0]; @@ -2334,6 +2366,7 @@ public class SQLContainerTest { EasyMock.expect( delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<String>() { + @Override public String answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/TicketTests.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/TicketTests.java index 75ab455678..a12786f13a 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/TicketTests.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/TicketTests.java @@ -64,6 +64,7 @@ public class TicketTests { EasyMock.expectLastCall().anyTimes(); delegate.setFilters(EasyMock.isA(List.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() { + @Override public Object answer() throws Throwable { List<Filter> orders = (List<Filter>) EasyMock .getCurrentArguments()[0]; @@ -75,6 +76,7 @@ public class TicketTests { EasyMock.expect( delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt())) .andAnswer(new IAnswer<StatementHelper>() { + @Override public StatementHelper answer() throws Throwable { Object[] args = EasyMock.getCurrentArguments(); int offset = (Integer) (args[0]); @@ -85,6 +87,7 @@ public class TicketTests { }).anyTimes(); EasyMock.expect(delegate.getCountStatement()) .andAnswer(new IAnswer<StatementHelper>() { + @Override @SuppressWarnings("deprecation") public StatementHelper answer() throws Throwable { StatementHelper sh = new StatementHelper(); diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/UtilTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/UtilTest.java index d6a6a72300..31bdf2b81b 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/UtilTest.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/UtilTest.java @@ -21,7 +21,7 @@ public class UtilTest { @Test public void escapeSQL_severalQuotes_returnsEscapedString() { Assert.assertEquals("asdf''ghjk''qwerty", - SQLUtil.escapeSQL("asdf'ghjk'qwerty")); + SQLUtil.escapeSQL("asdf'ghjk'qwerty")); } @Test @@ -32,12 +32,13 @@ public class UtilTest { @Test public void escapeSQL_multipleDoubleQuotes_returnsEscapedString() { Assert.assertEquals("asdf\\\"foo\\\"bar", - SQLUtil.escapeSQL("asdf\"foo\"bar")); + SQLUtil.escapeSQL("asdf\"foo\"bar")); } @Test public void escapeSQL_backslashes_returnsEscapedString() { - Assert.assertEquals("foo\\\\nbar\\\\r", SQLUtil.escapeSQL("foo\\nbar\\r")); + Assert.assertEquals("foo\\\\nbar\\\\r", + SQLUtil.escapeSQL("foo\\nbar\\r")); } @Test diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java index 19019eed0b..324899e373 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java @@ -11,16 +11,18 @@ import org.junit.Test; */ public class MockInitialContextFactory implements InitialContextFactory { private static Context mockCtx = null; - + @Test - public void testDummy(){ - // Added dummy test so JUnit will not complain about "No runnable methods". - } + public void testDummy() { + // Added dummy test so JUnit will not complain about + // "No runnable methods". + } public static void setMockContext(Context ctx) { mockCtx = ctx; } + @Override public Context getInitialContext(java.util.Hashtable<?, ?> environment) throws NamingException { if (mockCtx == null) { 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); |