From 61a1899fc70a568e79b32c07a0e016cb8ebb1f10 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 19 Feb 2014 12:13:52 +0200 Subject: Fix SQLContainer paging and caching issue (#11199) Change-Id: I884c0f0a27a124a49698b141ac63c93950df428d --- .../table/TableScrollingWithSQLContainer.java | 74 ++++++++++++++++++++++ .../table/TableScrollingWithSQLContainerTest.java | 35 ++++++++++ 2 files changed, 109 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java create mode 100644 uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainerTest.java (limited to 'uitest') 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..f6a6f24021 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java @@ -0,0 +1,74 @@ +package com.vaadin.tests.components.table; + +import java.sql.SQLException; + +import com.vaadin.data.util.sqlcontainer.DataGenerator; +import com.vaadin.data.util.sqlcontainer.SQLContainer; +import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; +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.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"); + } + } + + static final String TABLE = "table"; + + @Override + public void init(VaadinRequest request) { + try { + SimpleJDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool( + SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, + SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); + DataGenerator.addPeopleToDatabase(connectionPool); + DataGenerator.addFiveThousandPeople(connectionPool); + + TableQuery query = new TableQuery("people", connectionPool, + SQLTestsConstants.sqlGen); + + 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 diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainerTest.java b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainerTest.java new file mode 100644 index 0000000000..97c780e0e8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainerTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.table; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableScrollingWithSQLContainerTest extends MultiBrowserTest { + + @Test + public void verifySQLContainerIndexOfIDNotCalled() { + openTestURL(); + + vaadinElement("/VVerticalLayout[0]/VButton[0]").click(); + + Assert.assertTrue("SQLContainer indexOfId was called", driver + .findElements(By.className("v-errorindicator")).isEmpty()); + } +} -- cgit v1.2.3 From 19dde496756148cf893ab61cceefe58a71efa99b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 25 Feb 2014 11:09:01 +0200 Subject: Remove applet test which does not work reliably As long as nobody is constantly updating the java version on the test cluster and additionally ensures that no manual interaction is needed for Java applets to run, this test is not useful Change-Id: Ic9b3e190567e8949bbb514d5fedefc3c720402e7 --- .../tests/components/embedded/EmbeddedApplet.html | 36 ---------------------- 1 file changed, 36 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/embedded/EmbeddedApplet.html (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedApplet.html b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedApplet.html deleted file mode 100644 index d8fb0593d1..0000000000 --- a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedApplet.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -EmbeddedClickListenerRelativeCoordinates - - - - - - - - - - - - - - - - - - - - - - - - - - -
EmbeddedClickListenerRelativeCoordinates
open/run/com.vaadin.tests.components.embedded.EmbeddedApplet?restartApplication
screenCapturewith-applet
clickvaadin=runcomvaadintestscomponentsembeddedEmbeddedApplet::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturewithout-applet
- - -- cgit v1.2.3 From a73c9efcfd3f9897c3feb56160345ffa4ccfc156 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 25 Feb 2014 12:31:29 +0200 Subject: Fix broken TableScrollingWithSQLContainer test UI Change-Id: I67bcb7a473d147c46e24cb3c116fd9115a3bda6b --- .../table/TableScrollingWithSQLContainer.java | 39 ++++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java index f6a6f24021..764207ff13 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java +++ b/uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java @@ -1,13 +1,15 @@ package com.vaadin.tests.components.table; +import java.sql.Connection; import java.sql.SQLException; +import java.sql.Statement; -import com.vaadin.data.util.sqlcontainer.DataGenerator; import com.vaadin.data.util.sqlcontainer.SQLContainer; -import com.vaadin.data.util.sqlcontainer.SQLTestsConstants; +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; @@ -32,19 +34,42 @@ public class TableScrollingWithSQLContainer extends UI { } } + 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( - SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, - SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); - DataGenerator.addPeopleToDatabase(connectionPool); - DataGenerator.addFiveThousandPeople(connectionPool); + "org.hsqldb.jdbc.JDBCDriver", + "jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 20); + generateTestData(connectionPool); TableQuery query = new TableQuery("people", connectionPool, - SQLTestsConstants.sqlGen); + new DefaultSQLGenerator()); SQLContainer container = new LimitedSQLContainer(query); -- cgit v1.2.3 From fbce1270b1ea9260a6bb1842f5a5747d173b6f0a Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 27 Feb 2014 10:24:38 +0200 Subject: Use Chrome 33 for testing Change-Id: I6362097ff836c10b7001c5fd8acd8adf91a94b2f --- uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java | 2 +- uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java index bb0b40e2d1..c2dc400d8b 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -46,7 +46,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"); expectedUserAgent .put(Browser.CHROME.getDesiredCapabilities(), - "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"); + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"); } diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index e166e421ef..fa55b82390 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -41,7 +41,7 @@ import org.openqa.selenium.remote.DesiredCapabilities; public abstract class MultiBrowserTest extends PrivateTB3Configuration { public enum Browser { - FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(29)), SAFARI( + FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI( BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil .ie(9)), IE10(BrowserUtil.ie(10)), IE11(BrowserUtil.ie(11)), OPERA( BrowserUtil.opera(17)); -- cgit v1.2.3