diff options
author | Henri Sara <henri.sara@itmill.com> | 2012-07-27 10:01:38 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2012-07-27 10:01:38 +0000 |
commit | 9148b35e9ea0cc6882ba2f8560d97138d7ca362a (patch) | |
tree | 4f4b9979fea08b97545bb0168556c052c5e6b39c /tests/testbench | |
parent | ca9fab0922d9db510c51f2d363b46577f7f6c0c4 (diff) | |
download | vaadin-framework-9148b35e9ea0cc6882ba2f8560d97138d7ca362a.tar.gz vaadin-framework-9148b35e9ea0cc6882ba2f8560d97138d7ca362a.zip |
#9155 Add refresh() to SQLContainer.removeContainerFilter(), one more (manual) test for SQLContainer and refactoring another test.
svn changeset:24029/svn branch:6.8
Diffstat (limited to 'tests/testbench')
3 files changed, 118 insertions, 78 deletions
diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java index 86aee2d5ab..e06db94589 100644 --- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java @@ -1,8 +1,6 @@ package com.vaadin.tests.containers.sqlcontainer; -import java.sql.Connection; import java.sql.SQLException; -import java.sql.Statement; import com.vaadin.Application; import com.vaadin.data.Container.ItemSetChangeEvent; @@ -10,11 +8,6 @@ import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Item; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.sqlcontainer.AllTests; -import com.vaadin.data.util.sqlcontainer.SQLContainer; -import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; -import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; -import com.vaadin.data.util.sqlcontainer.query.TableQuery; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -116,75 +109,4 @@ public class CheckboxUpdateProblem extends Application implements } - private class DatabaseHelper { - - private JDBCConnectionPool connectionPool = null; - private SQLContainer testContainer = null; - private static final String TABLENAME = "testtable"; - - public DatabaseHelper() { - initConnectionPool(); - initDatabase(); - initContainers(); - } - - private void initDatabase() { - try { - Connection conn = connectionPool.reserveConnection(); - Statement statement = conn.createStatement(); - try { - statement.execute("drop table " + TABLENAME); - } catch (SQLException e) { - // Will fail if table doesn't exist, which is OK. - conn.rollback(); - } - switch (AllTests.db) { - case MYSQL: - statement - .execute("create table " - + TABLENAME - + " (id integer auto_increment not null, field1 varchar(100), field2 boolean, primary key(id))"); - break; - case POSTGRESQL: - statement - .execute("create table " - + TABLENAME - + " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)"); - break; - } - statement.executeUpdate("insert into " + TABLENAME - + " values(default, 'Kalle', 'true')"); - statement.close(); - conn.commit(); - connectionPool.releaseConnection(conn); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private void initContainers() { - try { - TableQuery q1 = new TableQuery(TABLENAME, connectionPool); - q1.setVersionColumn("id"); - testContainer = new SQLContainer(q1); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private void initConnectionPool() { - try { - connectionPool = new SimpleJDBCConnectionPool( - AllTests.dbDriver, AllTests.dbURL, AllTests.dbUser, - AllTests.dbPwd, 2, 5); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - public SQLContainer getTestContainer() { - return testContainer; - } - } - }
\ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java new file mode 100644 index 0000000000..ed6d39bb62 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.containers.sqlcontainer; + +import com.vaadin.Application; +import com.vaadin.ui.AbstractSelect.Filtering; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Window; + +/** + * See http://dev.vaadin.com/ticket/9155 . + */ +public class ComboBoxUpdateProblem extends Application { + private final DatabaseHelper databaseHelper = new DatabaseHelper(); + + @Override + public void init() { + setMainWindow(new Window("Test window")); + + ComboBox combo = new ComboBox("Names", + databaseHelper.getTestContainer()); + combo.setItemCaptionPropertyId("FIELD1"); + combo.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); + combo.setImmediate(true); + + getMainWindow().addComponent(combo); + } + +}
\ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java new file mode 100644 index 0000000000..b7b1e74eb0 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java @@ -0,0 +1,91 @@ +package com.vaadin.tests.containers.sqlcontainer; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +import com.vaadin.data.util.sqlcontainer.AllTests; +import com.vaadin.data.util.sqlcontainer.SQLContainer; +import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; +import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; +import com.vaadin.data.util.sqlcontainer.query.TableQuery; + +class DatabaseHelper { + + private JDBCConnectionPool connectionPool = null; + private SQLContainer testContainer = null; + private static final String TABLENAME = "testtable"; + + public DatabaseHelper() { + initConnectionPool(); + initDatabase(); + initContainers(); + } + + private void initDatabase() { + try { + Connection conn = connectionPool.reserveConnection(); + Statement statement = conn.createStatement(); + try { + statement.execute("drop table " + TABLENAME); + } catch (SQLException e) { + // Will fail if table doesn't exist, which is OK. + conn.rollback(); + } + switch (AllTests.db) { + case HSQLDB: + statement + .execute("create table " + + TABLENAME + + " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), field2 boolean, 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))"); + break; + case POSTGRESQL: + statement + .execute("create table " + + TABLENAME + + " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)"); + break; + } + statement.executeUpdate("insert into " + TABLENAME + + " values(default, 'Kalle', 'true')"); + statement.executeUpdate("insert into " + TABLENAME + + " values(default, 'Ville', 'true')"); + statement.executeUpdate("insert into " + TABLENAME + + " values(default, 'Jussi', 'true')"); + statement.close(); + conn.commit(); + connectionPool.releaseConnection(conn); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void initContainers() { + try { + TableQuery q1 = new TableQuery(TABLENAME, connectionPool); + q1.setVersionColumn("id"); + testContainer = new SQLContainer(q1); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void initConnectionPool() { + try { + connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver, + AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 5); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public SQLContainer getTestContainer() { + return testContainer; + } +}
\ No newline at end of file |