From 63fc9d04820822e60f7ac5946344d32711a55e2c Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 10 Nov 2011 16:06:30 +0200 Subject: Eliminate many generics related warnings in tests. Most of the warnings eliminated are related to generics for Property, Field or field factories. Not all such warnings are eliminated in this changeset. --- .../com/vaadin/data/util/BeanItemTest.java | 7 +- .../vaadin/data/util/NestedMethodPropertyTest.java | 89 +++++++++++----------- .../vaadin/data/util/PropertyDescriptorTest.java | 5 +- .../vaadin/data/util/filter/AndOrFilterTest.java | 4 +- .../vaadin/data/util/filter/CompareFilterTest.java | 2 +- .../vaadin/data/util/filter/IsNullFilterTest.java | 4 +- .../com/vaadin/data/util/filter/NotFilterTest.java | 4 +- .../data/util/filter/SimpleStringFilterTest.java | 5 +- .../com/vaadin/tests/server/TestSerialization.java | 2 +- .../textfield/TextFieldWithPropertyFormatter.java | 14 ++-- 10 files changed, 62 insertions(+), 74 deletions(-) (limited to 'tests/server-side') 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 item = new BeanItem(new MyClass("bean1")); + BeanItem item = new BeanItem(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 nameProperty = new NestedMethodProperty( + vaadin, "name"); Assert.assertEquals(String.class, nameProperty.getType()); Assert.assertEquals("Vaadin", nameProperty.getValue()); } public void testSingleLevelNestedObjectProperty() { - NestedMethodProperty managerProperty = new NestedMethodProperty(vaadin, - "manager"); + NestedMethodProperty managerProperty = new NestedMethodProperty( + vaadin, "manager"); Assert.assertEquals(Person.class, managerProperty.getType()); Assert.assertEquals(joonas, managerProperty.getValue()); } public void testMultiLevelNestedProperty() { - NestedMethodProperty managerNameProperty = new NestedMethodProperty( + NestedMethodProperty managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); - NestedMethodProperty addressProperty = new NestedMethodProperty(vaadin, - "manager.address"); - NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin, - "manager.address.street"); - NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty( + NestedMethodProperty
addressProperty = new NestedMethodProperty
( + vaadin, "manager.address"); + NestedMethodProperty streetProperty = new NestedMethodProperty( + vaadin, "manager.address.street"); + NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty( vaadin, "manager.address.postalCodePrimitive"); - NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty( + NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty( vaadin, "manager.address.postalCodeObject"); - NestedMethodProperty booleanProperty = new NestedMethodProperty(vaadin, - "manager.address.boolean"); + NestedMethodProperty booleanProperty = new NestedMethodProperty( + 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(vaadin, ""); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, " "); + new NestedMethodProperty(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(vaadin, "."); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, ".manager"); + new NestedMethodProperty(vaadin, ".manager"); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, "manager."); + new NestedMethodProperty(vaadin, "manager."); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, "manager..name"); + new NestedMethodProperty(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(vaadin, "member"); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, "manager.pet"); + new NestedMethodProperty(vaadin, "manager.pet"); fail(); } catch (IllegalArgumentException e) { // should get exception } try { - new NestedMethodProperty(vaadin, "manager.address.city"); + new NestedMethodProperty(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 managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); - NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin, - "manager.address.street"); + NestedMethodProperty streetProperty = new NestedMethodProperty( + 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 managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); - NestedMethodProperty addressProperty = new NestedMethodProperty(vaadin, - "manager.address"); - NestedMethodProperty streetProperty = new NestedMethodProperty(vaadin, - "manager.address.street"); - NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty( + NestedMethodProperty
addressProperty = new NestedMethodProperty
( + vaadin, "manager.address"); + NestedMethodProperty streetProperty = new NestedMethodProperty( + vaadin, "manager.address.street"); + NestedMethodProperty postalCodePrimitiveProperty = new NestedMethodProperty( vaadin, "manager.address.postalCodePrimitive"); - NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty( + NestedMethodProperty postalCodeObjectProperty = new NestedMethodProperty( 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 streetProperty = new NestedMethodProperty( + vaadin, "manager.address.street"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ObjectOutputStream(baos).writeObject(streetProperty); - NestedMethodProperty property2 = (NestedMethodProperty) new ObjectInputStream( + @SuppressWarnings("unchecked") + NestedMethodProperty property2 = (NestedMethodProperty) 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 streetProperty = new NestedMethodProperty( + vaadin, "manager.address.street"); + NestedMethodProperty booleanProperty = new NestedMethodProperty( + vaadin, "manager.address.boolean"); Assert.assertFalse(streetProperty.isReadOnly()); Assert.assertTrue(booleanProperty.isReadOnly()); diff --git a/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java b/tests/server-side/com/vaadin/data/util/PropertyDescriptorTest.java index c3621fa99b..d722a9e23b 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,6 +30,7 @@ public class PropertyDescriptorTest extends TestCase { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ObjectOutputStream(baos).writeObject(descriptor); + @SuppressWarnings("unchecked") VaadinPropertyDescriptor descriptor2 = (VaadinPropertyDescriptor) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); @@ -47,6 +45,7 @@ public class PropertyDescriptorTest extends TestCase { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ObjectOutputStream(baos).writeObject(pd); + @SuppressWarnings("unchecked") VaadinPropertyDescriptor pd2 = (VaadinPropertyDescriptor) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); 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 { protected Item item1 = new BeanItem(1); protected Item item2 = new BeanItem(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 { 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 { 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 { protected Item item1 = new BeanItem(1); protected Item item2 = new BeanItem(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 { protected static TestItem createTestItem() { return new TestItem("abcde", "TeSt"); diff --git a/tests/server-side/com/vaadin/tests/server/TestSerialization.java b/tests/server-side/com/vaadin/tests/server/TestSerialization.java index e3b6a47855..bed109d99a 100644 --- a/tests/server-side/com/vaadin/tests/server/TestSerialization.java +++ b/tests/server-side/com/vaadin/tests/server/TestSerialization.java @@ -92,7 +92,7 @@ public class TestSerialization extends TestCase { private static String toString(Object o) { if (o instanceof Property) { - return String.valueOf(((Property) o).getValue()); + return String.valueOf(((Property) o).getValue()); } else { return String.valueOf(o); } 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 formatter; private ObjectProperty 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() { @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) { -- cgit v1.2.3