diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-03-29 15:52:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 15:52:45 +0300 |
commit | fe37cc443d2268d813aadfa09d0f2f881d5c464c (patch) | |
tree | b893ca52e3158287d898186dc4eb5de8d3fc2f06 /uitest | |
parent | 8570d58f959de2baf438295b204da0576bed3402 (diff) | |
download | vaadin-framework-fe37cc443d2268d813aadfa09d0f2f881d5c464c.tar.gz vaadin-framework-fe37cc443d2268d813aadfa09d0f2f881d5c464c.zip |
Add ErrorHandler to AbstractTestUI (#12256)
* Add ErrorHandler to AbstractTestUI
Diffstat (limited to 'uitest')
7 files changed, 36 insertions, 28 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java index 7089a2e810..8a4499b101 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java @@ -754,6 +754,7 @@ public abstract class AbstractComponentTest<T extends AbstractComponent> extends return options; } + @Override protected void log(String msg) { log.log(msg); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUI.java index b030382ca6..8255a21546 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUI.java @@ -3,6 +3,8 @@ package com.vaadin.tests.components; import java.io.File; import com.vaadin.annotations.Widgetset; +import com.vaadin.server.DefaultErrorHandler; +import com.vaadin.server.ErrorHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServlet; import com.vaadin.server.WebBrowser; @@ -19,12 +21,14 @@ import com.vaadin.ui.PushConfiguration; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -public abstract class AbstractTestUI extends UI { +public abstract class AbstractTestUI extends UI implements ErrorHandler { @Override public void init(VaadinRequest request) { getPage().setTitle(getClass().getName()); + setErrorHandler(this); + Label label = new Label(getTestDescription(), ContentMode.HTML); label.setWidth("100%"); @@ -227,4 +231,18 @@ public abstract class AbstractTestUI extends UI { } }.start(); } + + @Override + public void error(com.vaadin.server.ErrorEvent event) { + final Throwable throwable = DefaultErrorHandler + .findRelevantThrowable(event.getThrowable()); + + log("Exception occurred, " + throwable.getClass().getName() + ": " + + throwable.getMessage()); + throwable.printStackTrace(); + } + + protected void log(String message) { + // NOP + } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUIWithLog.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUIWithLog.java index 3905ea0ed5..2e2be536f9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUIWithLog.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractTestUIWithLog.java @@ -14,6 +14,7 @@ public abstract class AbstractTestUIWithLog extends AbstractTestUI { ((VerticalLayout) getContent()).addComponent(log, 0); } + @Override protected void log(String message) { log.log(message); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridNullSafeNestedPropertyColumn.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridNullSafeNestedPropertyColumn.java index 888296d5f8..845a23ea48 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridNullSafeNestedPropertyColumn.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridNullSafeNestedPropertyColumn.java @@ -1,5 +1,8 @@ package com.vaadin.tests.components.grid; +import java.util.ArrayList; +import java.util.List; + import com.vaadin.annotations.Widgetset; import com.vaadin.data.provider.ListDataProvider; import com.vaadin.server.VaadinRequest; @@ -10,12 +13,8 @@ import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; import com.vaadin.ui.Button; import com.vaadin.ui.Grid; -import com.vaadin.ui.TextField; import com.vaadin.ui.renderers.TextRenderer; -import java.util.ArrayList; -import java.util.List; - @Widgetset("com.vaadin.DefaultWidgetSet") public class GridNullSafeNestedPropertyColumn extends AbstractTestUI { @@ -26,6 +25,8 @@ public class GridNullSafeNestedPropertyColumn extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { + setErrorHandler(null); + Grid<Person> grid = new Grid<>(Person.class); grid.setSizeFull(); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeatures.java index cb9d4a25bd..41a2d7b57e 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -14,8 +14,6 @@ import java.util.Map; import java.util.Random; import com.vaadin.annotations.Theme; -import com.vaadin.server.DefaultErrorHandler; -import com.vaadin.server.ErrorHandler; import com.vaadin.shared.data.sort.SortDirection; import com.vaadin.shared.ui.ContentMode; import com.vaadin.tests.components.AbstractComponentTest; @@ -78,8 +76,7 @@ import com.vaadin.v7.ui.renderers.NumberRenderer; * @author Vaadin Ltd */ @Theme("valo") -public class GridBasicFeatures extends AbstractComponentTest<Grid> - implements ErrorHandler { +public class GridBasicFeatures extends AbstractComponentTest<Grid> { public static final String ROW_STYLE_GENERATOR_ROW_NUMBERS_FOR_3_OF_4 = "Row numbers for 3/4"; public static final String ROW_STYLE_GENERATOR_NONE = "None"; @@ -237,11 +234,6 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> } }; - public GridBasicFeatures() { - super(); - setErrorHandler(this); - } - @Override protected void createActions() { super.createActions(); @@ -1711,14 +1703,4 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> return Grid.class; } - @Override - public void error(com.vaadin.server.ErrorEvent event) { - final Throwable throwable = DefaultErrorHandler - .findRelevantThrowable(event.getThrowable()); - - log("Exception occurred, " + throwable.getClass().getName() + ": " - + throwable.getMessage()); - throwable.printStackTrace(); - } - } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java index f1ac5a5841..3202d95e64 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java @@ -60,9 +60,11 @@ public class UIAccessTest extends MultiBrowserTest { $(ButtonElement.class).get(2).click(); assertTrue(logContainsText("0. Throwing exception in access")); - assertTrue(logContainsText("1. firstFuture is done? true")); assertTrue(logContainsText( - "2. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can")); + "1. Exception occurred, java.lang.RuntimeException: Catch me if you can")); + assertTrue(logContainsText("2. firstFuture is done? true")); + assertTrue(logContainsText( + "3. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can")); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java index a7e8a4e3ce..a55029c249 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadChangeListenerTest.java @@ -30,12 +30,15 @@ public class UploadChangeListenerTest extends MultiBrowserTest { upload.click(); - assertEquals("2. finished", getLogRow(0)); + assertEquals("2. finished", getLogRow(1)); + assertEquals( + "3. Exception occurred, com.vaadin.server.UploadException: Upload failed", + getLogRow(0)); tempFile = createTempFile(); fillPathToUploadInput(tempFile.getPath()); - assertEquals("3. change", getLogRow(0)); + assertEquals("4. change", getLogRow(0)); } /** |