summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAnna Koskinen <anna@vaadin.com>2013-01-29 16:35:27 +0200
committerAnna Koskinen <anna@vaadin.com>2013-02-01 15:04:22 +0200
commit7c5aec1e34616d89726252f36c9650084c871ab9 (patch)
tree974ed77d632a797311541fd213a51db0d71e18e9 /uitest/src
parent9c6f83505896145c6d84534c610720ede83993e0 (diff)
downloadvaadin-framework-7c5aec1e34616d89726252f36c9650084c871ab9.tar.gz
vaadin-framework-7c5aec1e34616d89726252f36c9650084c871ab9.zip
Merge of (#10312) to Vaadin 7.
Cache update exception handling to Table. Change-Id: I882e78c3a2eb1ceaab484be748b6890ee321c290
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html178
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java181
2 files changed, 359 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html
new file mode 100644
index 0000000000..c2481e6be6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:9999/" />
+<title>TableWithBrokenGeneratorAndContainer</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TableWithBrokenGeneratorAndContainer</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableWithBrokenGeneratorAndContainer?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>item1/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>item2/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>item3/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[4]/domChild[0]</td>
+ <td>Generated item1/Gen</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[4]/domChild[0]</td>
+ <td>Generated item2/Gen</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[4]/domChild[0]</td>
+ <td>Generated item3/Gen</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td>
+ <td>12,6</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<!--error indicator should be present-->
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>v-errorindicator</td>
+</tr>
+<!--error notification should not be present-->
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::Root/VNotification[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>item2/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>item3/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[4]/domChild[0]</td>
+ <td>Generated item1/Gen</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[4]/domChild[0]</td>
+ <td>Generated item2/Gen</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[4]/domChild[0]</td>
+ <td>Generated item3/Gen</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VCheckBox[0]/domChild[0]</td>
+ <td>9,6</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[1]</td>
+ <td></td>
+</tr>
+<!--error indicator should be present-->
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>v-errorindicator</td>
+</tr>
+<!--error notification should not be present-->
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::Root/VNotification[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>item2/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>item3/prop1</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[4]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[4]/domChild[0]</td>
+ <td>Generated item2/Gen</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[4]/domChild[0]</td>
+ <td>Generated item3/Gen</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VCheckBox[0]/domChild[0]</td>
+ <td>9,8</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[1]</td>
+ <td></td>
+</tr>
+<!--error notification-->
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::Root/VNotification[0]/HTML[0]/domChild[0]</td>
+ <td>Problem updating table. Please try again later</td>
+</tr>
+<!--table should be empty-->
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java
new file mode 100644
index 0000000000..9c5ce9dc0c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java
@@ -0,0 +1,181 @@
+/*
+ * 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 java.lang.reflect.InvocationTargetException;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.ListenerMethod.MethodException;
+import com.vaadin.server.ErrorEvent;
+import com.vaadin.server.ErrorHandler;
+import com.vaadin.server.ServerRpcManager.RpcInvocationException;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.CacheUpdateException;
+import com.vaadin.ui.Table.ColumnGenerator;
+
+public class TableWithBrokenGeneratorAndContainer extends TestBase {
+
+ private CheckBox brokenContainer = new CheckBox("Broken container");
+ private CheckBox brokenGenerator = new CheckBox("Broken generator");
+ private CheckBox clearTableOnError = new CheckBox("Clear Table on Error");
+
+ /**
+ * Container which throws an exception on every fifth call to
+ * {@link #getContainerProperty(Object, Object)}.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
+ public class BrokenContainer extends IndexedContainer {
+ private int counter = 0;
+
+ public BrokenContainer() {
+ super();
+ }
+
+ @Override
+ public Property getContainerProperty(Object itemId, Object propertyId) {
+ if (counter++ % 5 == 0
+ && Boolean.TRUE.equals(brokenContainer.getValue())) {
+ throw new RuntimeException(getClass().getSimpleName()
+ + " cannot fetch the property for " + itemId + "/"
+ + propertyId + " right now");
+ }
+ return super.getContainerProperty(itemId, propertyId);
+ }
+ }
+
+ public class BrokenColumnGenerator implements ColumnGenerator {
+ private int brokenInterval;
+ private int counter = 0;
+
+ public BrokenColumnGenerator(int brokenInterval) {
+ this.brokenInterval = brokenInterval;
+ }
+
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ if (counter++ % brokenInterval == 0
+ && Boolean.TRUE.equals(brokenGenerator.getValue())) {
+ throw new IllegalArgumentException("Broken generator for "
+ + itemId + "/" + columnId);
+ } else {
+ return "Generated " + itemId + "/" + columnId;
+ }
+ }
+
+ }
+
+ @Override
+ protected void setup() {
+ brokenContainer.setImmediate(true);
+ brokenGenerator.setImmediate(true);
+ clearTableOnError.setImmediate(true);
+ clearTableOnError.addValueChangeListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ Boolean value = clearTableOnError.getValue();
+ setErrorHandler(value != null ? value : false);
+ }
+ });
+ final Table table = new Table("Semi-broken table");
+ table.setContainerDataSource(createBrokenContainer(10, 4));
+ table.addGeneratedColumn("Gen", new BrokenColumnGenerator(4));
+ table.setPageLength(20);
+
+ Button refreshTableCache = new Button("Refresh table cache",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.markAsDirty();
+ table.refreshRowCache();
+ }
+ });
+ addComponent(refreshTableCache);
+ addComponent(brokenContainer);
+ addComponent(brokenGenerator);
+ addComponent(clearTableOnError);
+ addComponent(table);
+ }
+
+ protected void setErrorHandler(boolean enabled) {
+ if (enabled) {
+ VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() {
+
+ @Override
+ public void error(ErrorEvent event) {
+ Throwable t = event.getThrowable();
+ if (t instanceof RpcInvocationException) {
+ t = t.getCause();
+ if (t instanceof InvocationTargetException) {
+ t = t.getCause();
+ if (t instanceof MethodException) {
+ t = t.getCause();
+ if (t instanceof CacheUpdateException) {
+ Table table = ((CacheUpdateException) t)
+ .getTable();
+ table.removeAllItems();
+ Notification
+ .show("Problem updating table. Please try again later",
+ Notification.Type.ERROR_MESSAGE);
+ }
+ }
+ }
+ }
+ }
+ });
+ } else {
+ VaadinSession.getCurrent().setErrorHandler(this);
+ }
+ }
+
+ private BrokenContainer createBrokenContainer(int rows, int cols) {
+ BrokenContainer container = new BrokenContainer();
+ for (int j = 1; j <= cols; j++) {
+ container.addContainerProperty("prop" + j, String.class, null);
+ }
+ for (int i = 1; i <= rows; i++) {
+ Item item = container.addItem("item" + i);
+ for (int j = 1; j <= cols; j++) {
+ item.getItemProperty("prop" + j).setValue(
+ "item" + i + "/prop" + j);
+ }
+ }
+ return container;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10312;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A Table should not show 'Internal Error' just because a column generator or container throws an exception during filling of the cache";
+ }
+
+}