summaryrefslogtreecommitdiffstats
path: root/tests/server-side
diff options
context:
space:
mode:
authorAutomerge <automerge@vaadin.com>2012-04-04 13:07:03 +0000
committerAutomerge <automerge@vaadin.com>2012-04-04 13:07:03 +0000
commitc48774888da8fc7b073d715c97a0ee08aa52cf8c (patch)
treeb743c4bac6c5b9f36e4b4eea7c8b6ad460599fd0 /tests/server-side
parent149855812fc206a58d9e027106f4e88b8e2b5682 (diff)
downloadvaadin-framework-c48774888da8fc7b073d715c97a0ee08aa52cf8c.tar.gz
vaadin-framework-c48774888da8fc7b073d715c97a0ee08aa52cf8c.zip
[merge from 6.7] Test for #8328
svn changeset:23402/svn branch:6.8
Diffstat (limited to 'tests/server-side')
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java60
1 files changed, 57 insertions, 3 deletions
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java
index fac9fc98db..b9621d518a 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java
@@ -1,14 +1,19 @@
package com.vaadin.data.util.sqlcontainer;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Arrays;
+import com.vaadin.data.Property.ReadOnlyException;
+import com.vaadin.data.util.sqlcontainer.ColumnProperty.NotNullableException;
+import com.vaadin.data.util.sqlcontainer.query.QueryDelegate;
+
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.data.Property.ReadOnlyException;
-import com.vaadin.data.util.sqlcontainer.ColumnProperty.NotNullableException;
-
public class ColumnPropertyTest {
@Test
@@ -175,4 +180,53 @@ public class ColumnPropertyTest {
cp.setValue(null);
Assert.assertNull(cp.getValue());
}
+
+ @Test
+ public void setValue_sendsItemChangeNotification() throws SQLException {
+
+ class TestContainer extends SQLContainer {
+ Object value = null;
+ boolean modified = false;
+
+ public TestContainer(QueryDelegate delegate) throws SQLException {
+ super(delegate);
+ }
+
+ @Override
+ public void itemChangeNotification(RowItem changedItem) {
+ ColumnProperty cp = (ColumnProperty) changedItem
+ .getItemProperty("NAME");
+ value = cp.getValue();
+ modified = cp.isModified();
+ }
+ }
+
+ ColumnProperty property = new ColumnProperty("NAME", false, true, true,
+ "Ville", String.class);
+
+ Statement statement = EasyMock.createNiceMock(Statement.class);
+ EasyMock.replay(statement);
+
+ ResultSetMetaData metadata = EasyMock
+ .createNiceMock(ResultSetMetaData.class);
+ EasyMock.replay(metadata);
+
+ ResultSet resultSet = EasyMock.createNiceMock(ResultSet.class);
+ EasyMock.expect(resultSet.getStatement()).andReturn(statement);
+ EasyMock.expect(resultSet.getMetaData()).andReturn(metadata);
+ EasyMock.replay(resultSet);
+
+ QueryDelegate delegate = EasyMock.createNiceMock(QueryDelegate.class);
+ EasyMock.expect(delegate.getResults(0, 1)).andReturn(resultSet);
+ EasyMock.replay(delegate);
+
+ TestContainer container = new TestContainer(delegate);
+
+ new RowItem(container, new RowId(new Object[] { 1 }),
+ Arrays.asList(property));
+
+ property.setValue("Kalle");
+ Assert.assertEquals("Kalle", container.value);
+ Assert.assertTrue(container.modified);
+ }
}