aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-05-14 15:25:58 +0300
committerVaadin Code Review <review@vaadin.com>2013-05-14 13:37:25 +0000
commit67696f3dcb968bde52bee4bb841b642c41fc6009 (patch)
tree0d6ca3c4d2213cf716eefc4509346a7ab37c4412 /uitest/src/com/vaadin
parent1a6200e19b1e366383286dfa7074c4183d8dcfb9 (diff)
downloadvaadin-framework-67696f3dcb968bde52bee4bb841b642c41fc6009.tar.gz
vaadin-framework-67696f3dcb968bde52bee4bb841b642c41fc6009.zip
SQLContainer.indexOfId() also searches backwards (#11849, #10376)
Change-Id: Iea3f832cd50314f747b82b774c3be57797f9ac1d
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java34
-rw-r--r--uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java47
2 files changed, 81 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
index 287d772901..7e95a41742 100644
--- a/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
+++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
@@ -15,6 +15,8 @@ class DatabaseHelper {
private JDBCConnectionPool connectionPool = null;
private SQLContainer testContainer = null;
private static final String TABLENAME = "testtable";
+ private SQLContainer largeContainer = null;
+ private static final String LARGE_TABLENAME = "largetable";
public DatabaseHelper() {
initConnectionPool();
@@ -32,24 +34,42 @@ class DatabaseHelper {
// Will fail if table doesn't exist, which is OK.
conn.rollback();
}
+ try {
+ statement.execute("drop table " + LARGE_TABLENAME);
+ } catch (SQLException e) {
+ // Will fail if table doesn't exist, which is OK.
+ conn.rollback();
+ }
switch (SQLTestsConstants.db) {
case HSQLDB:
statement
.execute("create table "
+ TABLENAME
+ " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), field2 boolean, primary key(id))");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), primary key(id))");
break;
case MYSQL:
statement
.execute("create table "
+ TABLENAME
+ " (id integer auto_increment not null, field1 varchar(100), field2 boolean, primary key(id))");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (id integer auto_increment not null, field1 varchar(100), primary key(id))");
break;
case POSTGRESQL:
statement
.execute("create table "
+ TABLENAME
+ " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (\"id\" serial primary key, \"field1\" varchar(100))");
break;
}
statement.executeUpdate("insert into " + TABLENAME
@@ -58,6 +78,12 @@ class DatabaseHelper {
+ " values(default, 'Ville', 'true')");
statement.executeUpdate("insert into " + TABLENAME
+ " values(default, 'Jussi', 'true')");
+
+ for (int i = 0; i < 400; ++i) {
+ statement.executeUpdate("insert into " + LARGE_TABLENAME
+ + " values(default, 'User " + i + "')");
+ }
+
statement.close();
conn.commit();
connectionPool.releaseConnection(conn);
@@ -71,6 +97,10 @@ class DatabaseHelper {
TableQuery q1 = new TableQuery(TABLENAME, connectionPool);
q1.setVersionColumn("id");
testContainer = new SQLContainer(q1);
+
+ TableQuery q2 = new TableQuery(LARGE_TABLENAME, connectionPool);
+ q2.setVersionColumn("id");
+ largeContainer = new SQLContainer(q2);
} catch (SQLException e) {
e.printStackTrace();
}
@@ -89,4 +119,8 @@ class DatabaseHelper {
public SQLContainer getTestContainer() {
return testContainer;
}
+
+ public SQLContainer getLargeContainer() {
+ return largeContainer;
+ }
} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java
new file mode 100644
index 0000000000..8d4f1c5842
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java
@@ -0,0 +1,47 @@
+package com.vaadin.tests.containers.sqlcontainer;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.LegacyApplication;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.Table;
+
+public class SqlcontainertableApplication extends LegacyApplication {
+ private LegacyWindow mainWindow;
+ private Table table;
+ private HorizontalSplitPanel panel;
+ private Label label = new Label();
+
+ @Override
+ public void init() {
+ mainWindow = new LegacyWindow("SQLContainer Test");
+ setMainWindow(mainWindow);
+ mainWindow.getContent().setSizeFull();
+
+ panel = new HorizontalSplitPanel();
+ panel.setSecondComponent(label);
+
+ final DatabaseHelper helper = new DatabaseHelper();
+ table = new Table();
+ table.setSizeFull();
+ table.setContainerDataSource(helper.getLargeContainer());
+ table.setSelectable(true);
+ table.setImmediate(true);
+ table.setMultiSelect(true);
+ table.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ label.setValue(table.getValue().toString());
+ }
+ });
+
+ panel.setSizeFull();
+ panel.addComponent(table);
+
+ mainWindow.addComponent(panel);
+
+ }
+
+} \ No newline at end of file