diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-08 10:14:31 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-08 10:14:31 +0000 |
commit | 8c104cd1c5db142097a99dbef0e7b43a8663e5c2 (patch) | |
tree | 642474f89fa4adf259c784b7fe89d52c8b5e2c6b /tests | |
parent | f80720108b9502fce75bce0b66c7ae6b8efd44b9 (diff) | |
download | vaadin-framework-8c104cd1c5db142097a99dbef0e7b43a8663e5c2.tar.gz vaadin-framework-8c104cd1c5db142097a99dbef0e7b43a8663e5c2.zip |
Fix for #7434
svn changeset:20923/svn branch:6.7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/vaadin/tests/server/container/sqlcontainer/ColumnPropertyTest.java | 28 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/server/container/sqlcontainer/TicketTests.java | 26 |
2 files changed, 50 insertions, 4 deletions
diff --git a/tests/src/com/vaadin/tests/server/container/sqlcontainer/ColumnPropertyTest.java b/tests/src/com/vaadin/tests/server/container/sqlcontainer/ColumnPropertyTest.java index efe539f2c7..464c65d9ce 100644 --- a/tests/src/com/vaadin/tests/server/container/sqlcontainer/ColumnPropertyTest.java +++ b/tests/src/com/vaadin/tests/server/container/sqlcontainer/ColumnPropertyTest.java @@ -11,7 +11,6 @@ import com.vaadin.data.util.sqlcontainer.ColumnProperty; import com.vaadin.data.util.sqlcontainer.RowId; import com.vaadin.data.util.sqlcontainer.RowItem; import com.vaadin.data.util.sqlcontainer.SQLContainer; -import com.vaadin.data.util.sqlcontainer.ColumnProperty.NotNullableException; public class ColumnPropertyTest { @@ -56,7 +55,7 @@ public class ColumnPropertyTest { Assert.assertEquals("Kalle", cp.getValue()); EasyMock.verify(container); } - */ + */ @Test(expected = ReadOnlyException.class) public void setValue_readOnlyNullable_shouldFail() { @@ -101,7 +100,7 @@ public class ColumnPropertyTest { Assert.assertNotNull(cp.getValue()); EasyMock.verify(container); } - */ + */ @Test public void getType_normal_returnsStringClass() { @@ -165,7 +164,7 @@ public class ColumnPropertyTest { Assert.assertTrue(cp.isModified()); EasyMock.verify(container); } - */ + */ @Test public void isModified_valueNotModified_returnsFalse() { @@ -174,4 +173,25 @@ public class ColumnPropertyTest { Assert.assertFalse(cp.isModified()); } + @Test + public void setValue_nullOnNullable_shouldWork() { + ColumnProperty cp = new ColumnProperty("NAME", false, true, true, + "asdf", String.class); + SQLContainer container = EasyMock.createMock(SQLContainer.class); + new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); + cp.setValue(null); + Assert.assertNull(cp.getValue()); + } + + @Test + public void setValue_resetTonullOnNullable_shouldWork() { + ColumnProperty cp = new ColumnProperty("NAME", false, true, true, null, + String.class); + SQLContainer container = EasyMock.createMock(SQLContainer.class); + new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); + cp.setValue("asdf"); + Assert.assertEquals("asdf", cp.getValue()); + cp.setValue(null); + Assert.assertNull(cp.getValue()); + } } diff --git a/tests/src/com/vaadin/tests/server/container/sqlcontainer/TicketTests.java b/tests/src/com/vaadin/tests/server/container/sqlcontainer/TicketTests.java index 8123cdb516..8c86bc8df1 100644 --- a/tests/src/com/vaadin/tests/server/container/sqlcontainer/TicketTests.java +++ b/tests/src/com/vaadin/tests/server/container/sqlcontainer/TicketTests.java @@ -13,6 +13,7 @@ import org.junit.Before; import org.junit.Test; import com.vaadin.data.Container.Filter; +import com.vaadin.data.Item; import com.vaadin.data.util.filter.Compare.Equal; import com.vaadin.data.util.sqlcontainer.SQLContainer; import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; @@ -154,4 +155,29 @@ public class TicketTests { } } + @Test + public void ticket7434_getItem_Modified_Changed_Unchanged() + throws SQLException { + SQLContainer container = new SQLContainer(new TableQuery("people", + connectionPool, AllTests.sqlGen)); + + Object id = container.firstItemId(); + Item item = container.getItem(id); + String name = (String) item.getItemProperty("NAME").getValue(); + + // set a different name + item.getItemProperty("NAME").setValue("otherName"); + Assert.assertEquals("otherName", item.getItemProperty("NAME") + .getValue()); + + // access the item and reset the name to its old value + Item item2 = container.getItem(id); + item2.getItemProperty("NAME").setValue(name); + Assert.assertEquals(name, item2.getItemProperty("NAME").getValue()); + + Item item3 = container.getItem(id); + String name3 = (String) item3.getItemProperty("NAME").getValue(); + + Assert.assertEquals(name, name3); + } } |