aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java
diff options
context:
space:
mode:
authorBuild Agent <build@vaadin.com>2014-02-27 13:14:00 +0200
committerBuild Agent <build@vaadin.com>2014-02-27 13:14:01 +0200
commit45bae7affeeb1feb9da1857f73b17cdc363d25d2 (patch)
treea9cb764f1bb0d7bf663d2687613e9bf466694a1b /uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java
parentca9f91d8b537f5cf3e0694cbb538052c2a25f608 (diff)
parentfbce1270b1ea9260a6bb1842f5a5747d173b6f0a (diff)
downloadvaadin-framework-45bae7affeeb1feb9da1857f73b17cdc363d25d2.tar.gz
vaadin-framework-45bae7affeeb1feb9da1857f73b17cdc363d25d2.zip
Merge changes from origin/7.1
badf9f2 Do not prevent deployment if Atmosphere init fails (#13199) be827f8 Enable on-the-fly SASS compilation in OSGi (#10307) 61a1899 Fix SQLContainer paging and caching issue (#11199) 19dde49 Remove applet test which does not work reliably a73c9ef Fix broken TableScrollingWithSQLContainer test UI fbce127 Use Chrome 33 for testing Change-Id: I4a09cdfcc8187604a24391a73ea6c04c6d50bb5f
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java99
1 files changed, 99 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java
new file mode 100644
index 0000000000..764207ff13
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java
@@ -0,0 +1,99 @@
+package com.vaadin.tests.components.table;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+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.QueryDelegate;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+@SuppressWarnings("serial")
+public class TableScrollingWithSQLContainer extends UI {
+
+ /** Table should never end up calling indexOfId in this case */
+ private class LimitedSQLContainer extends SQLContainer {
+
+ public LimitedSQLContainer(QueryDelegate delegate) throws SQLException {
+ super(delegate);
+ }
+
+ @Override
+ public int indexOfId(Object itemId) {
+ throw new RuntimeException("This function should not be called");
+ }
+ }
+
+ private void generateTestData(JDBCConnectionPool connectionPool)
+ throws SQLException {
+ Connection conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+ try {
+ statement.execute("drop table PEOPLE");
+ } catch (SQLException e) {
+ // Will fail if table doesn't exist, which is OK.
+ conn.rollback();
+ }
+ statement
+ .execute("create table people (id integer generated always as identity,"
+ + " name varchar(32), AGE INTEGER)");
+ statement.execute("alter table people add primary key (id)");
+ for (int i = 0; i < 5000; i++) {
+ statement
+ .executeUpdate("insert into people values(default, 'Person "
+ + i + "', '" + i % 99 + "')");
+ }
+ statement.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+ }
+
+ static final String TABLE = "table";
+
+ @Override
+ public void init(VaadinRequest request) {
+ try {
+ SimpleJDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool(
+ "org.hsqldb.jdbc.JDBCDriver",
+ "jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 20);
+ generateTestData(connectionPool);
+
+ TableQuery query = new TableQuery("people", connectionPool,
+ new DefaultSQLGenerator());
+
+ SQLContainer container = new LimitedSQLContainer(query);
+
+ final VerticalLayout rootLayout = new VerticalLayout();
+
+ final Table table = new Table();
+ table.setContainerDataSource(container);
+ table.setCurrentPageFirstItemIndex(300);
+ rootLayout.addComponent(table);
+
+ table.setImmediate(true);
+
+ rootLayout.addComponent(new Button("GOTO 200", new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setCurrentPageFirstItemIndex(200);
+ }
+ }));
+
+ setContent(rootLayout);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file