aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-11-29 11:53:20 +0200
committerVaadin Code Review <review@vaadin.com>2013-11-30 07:32:25 +0000
commit8d6256e98a63222f4b4969612d8d777a31974613 (patch)
tree05a7b9435e793e421c5eed7849ec0d6eab414998 /server/tests
parentde1c343ea9079f74276484c7d5f1623b5391eaba (diff)
downloadvaadin-framework-8d6256e98a63222f4b4969612d8d777a31974613.tar.gz
vaadin-framework-8d6256e98a63222f4b4969612d8d777a31974613.zip
Simplified support for null intermediate properties (#11435)
Removed support for explicitly throwing NPE for intermediate properties as no use case could be identified where this would be the expected or wanted behavior. Change-Id: I10696467f792e234326075bbcdd5aad487905a7e
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/data/util/BeanContainerTest.java11
-rw-r--r--server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java14
-rw-r--r--server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java43
-rw-r--r--server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java8
4 files changed, 14 insertions, 62 deletions
diff --git a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java
index 2dcbb4aed8..a6c3bb0b8b 100644
--- a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java
@@ -465,20 +465,11 @@ public class BeanContainerTest extends AbstractBeanContainerTest {
container.addBean(new NestedMethodPropertyTest.Person("John", null));
assertTrue(container
.addNestedContainerProperty("address.postalCodeObject"));
- assertTrue(container.addNestedContainerProperty("address.street", true));
+ assertTrue(container.addNestedContainerProperty("address.street"));
// the nested properties added with allowNullBean setting should return
// null
assertNull(container.getContainerProperty("John", "address.street")
.getValue());
- // nested properties added without allowNullBean setting should throw
- // exception
- try {
- container.getContainerProperty("John", "address.postalCodeObject")
- .getValue();
- fail();
- } catch (Exception e) {
- // should throw exception
- }
}
}
diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
index 35f09fc8f3..b9633753b4 100644
--- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
@@ -729,20 +729,10 @@ public class BeanItemContainerTest extends AbstractBeanContainerTest {
assertNotNull(container.addBean(john));
assertTrue(container
.addNestedContainerProperty("address.postalCodeObject"));
- assertTrue(container.addNestedContainerProperty("address.street", true));
- // the nested properties added with allowNullBean setting should return
- // null
+ assertTrue(container.addNestedContainerProperty("address.street"));
+ // the nested properties should return null
assertNull(container.getContainerProperty(john, "address.street")
.getValue());
- // nested properties added without allowNullBean setting should throw
- // exception
- try {
- container.getContainerProperty(john, "address.postalCodeObject")
- .getValue();
- fail();
- } catch (Exception e) {
- // should throw exception
- }
}
public void testItemAddedEvent() {
diff --git a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java
index d517322010..1133626df9 100644
--- a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java
+++ b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java
@@ -7,9 +7,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-import junit.framework.Assert;
import junit.framework.TestCase;
+import org.junit.Assert;
+
public class NestedMethodPropertyTest extends TestCase {
public static class Address implements Serializable {
@@ -248,46 +249,16 @@ public class NestedMethodPropertyTest extends TestCase {
vaadin, "manager.address.street");
joonas.setAddress(null);
- try {
- streetProperty.getValue();
- fail();
- } catch (Exception e) {
- // should get exception
- }
+ assertNull(streetProperty.getValue());
vaadin.setManager(null);
- try {
- managerNameProperty.getValue();
- fail();
- } catch (Exception e) {
- // should get exception
- }
- try {
- streetProperty.getValue();
- fail();
- } catch (Exception e) {
- // should get exception
- }
+ assertNull(managerNameProperty.getValue());
+ assertNull(streetProperty.getValue());
vaadin.setManager(joonas);
Assert.assertEquals("Joonas", managerNameProperty.getValue());
- }
-
- public void testNullNestedPropertyWithAllowNullBeans() {
- NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
- vaadin, "manager.name", true);
- NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
- vaadin, "manager.address.street", true);
-
- joonas.setAddress(null);
- // should return null
Assert.assertNull(streetProperty.getValue());
- vaadin.setManager(null);
- Assert.assertNull(managerNameProperty.getValue());
- vaadin.setManager(joonas);
- Assert.assertEquals("Joonas", managerNameProperty.getValue());
- Assert.assertNull(streetProperty.getValue());
}
public void testMultiLevelNestedPropertySetValue() {
@@ -331,11 +302,11 @@ public class NestedMethodPropertyTest extends TestCase {
Assert.assertEquals("Ruukinkatu 2-4", property2.getValue());
}
- public void testSerializationWithNullBeansAllowed() throws IOException,
+ public void testSerializationWithIntermediateNull() throws IOException,
ClassNotFoundException {
vaadin.setManager(null);
NestedMethodProperty<String> streetProperty = new NestedMethodProperty<String>(
- vaadin, "manager.address.street", true);
+ vaadin, "manager.address.street");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(streetProperty);
@SuppressWarnings("unchecked")
diff --git a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java
index 0ae76430f6..12ded84fe2 100644
--- a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java
+++ b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java
@@ -39,7 +39,8 @@ public class PropertyDescriptorTest extends TestCase {
Assert.assertEquals("John", property.getValue());
}
- public void testNestedPropertyDescriptorSerialization() throws Exception {
+ public void testSimpleNestedPropertyDescriptorSerialization()
+ throws Exception {
NestedPropertyDescriptor<Person> pd = new NestedPropertyDescriptor<Person>(
"name", Person.class);
@@ -53,10 +54,9 @@ public class PropertyDescriptorTest extends TestCase {
Assert.assertEquals("John", property.getValue());
}
- public void testNestedPropertyDescriptorWithNullBeansAllowedSerialization()
- throws Exception {
+ public void testNestedPropertyDescriptorSerialization() throws Exception {
NestedPropertyDescriptor<Person> pd = new NestedPropertyDescriptor<Person>(
- "address.street", Person.class, true);
+ "address.street", Person.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(pd);