summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-08-31 15:09:50 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-31 13:03:35 +0000
commitff3a48e73bb7318793746aa9c9ff1cf61b632c7f (patch)
treec7b8589397b6ce4ee24c995451d2f8f8eb61fbc2 /uitest
parenta9b001ddb6e358af872987836afd812763859200 (diff)
downloadvaadin-framework-ff3a48e73bb7318793746aa9c9ff1cf61b632c7f.tar.gz
vaadin-framework-ff3a48e73bb7318793746aa9c9ff1cf61b632c7f.zip
Enable assertions for TestingWidgetset, add test to verify this
Change-Id: I0c5fc24e490edc6e0d3fb7a9b1d2a71d564bb13c
Diffstat (limited to 'uitest')
-rw-r--r--uitest/pom.xml6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/widgetset/client/AssertionFailureWidget.java18
-rw-r--r--uitest/src/main/java/com/vaadin/tests/widgetset/server/AssertionsEnabled.java16
-rw-r--r--uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java30
4 files changed, 68 insertions, 2 deletions
diff --git a/uitest/pom.xml b/uitest/pom.xml
index 63e1f92a42..6a6c94a627 100644
--- a/uitest/pom.xml
+++ b/uitest/pom.xml
@@ -50,7 +50,8 @@
</dependency>
<!-- jetty-servlets needed by ProxyTest, but not by jetty-runner -->
- <!-- Jetty before vaadin-* on the classpath to make Eclipse use the right version -->
+ <!-- Jetty before vaadin-* on the classpath to make Eclipse use the right
+ version -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
@@ -169,7 +170,7 @@
<!-- Servlet API -->
<dependency>
- <!-- Jetty requires 3.1.0 -->
+ <!-- Jetty requires 3.1.0 -->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
@@ -244,6 +245,7 @@
<warSourceDirectory>src/main/themes</warSourceDirectory>
<webappDirectory>${project.build.outputDirectory}/VAADIN/widgetsets</webappDirectory>
<persistentunitcachedir>${project.build.directory}/gwt-unitCache</persistentunitcachedir>
+ <checkAssertions>true</checkAssertions>
</configuration>
<executions>
<execution>
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/AssertionFailureWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/AssertionFailureWidget.java
new file mode 100644
index 0000000000..91e50fdf06
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/AssertionFailureWidget.java
@@ -0,0 +1,18 @@
+package com.vaadin.tests.widgetset.client;
+
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.vaadin.client.ui.VLabel;
+
+public class AssertionFailureWidget extends SimplePanel {
+
+ public AssertionFailureWidget() {
+ Scheduler.get().scheduleDeferred(() -> {
+ assert 1 == 2 : "This should fail.";
+ VLabel w = new VLabel();
+ add(w);
+ w.setText("This should not be here.");
+ w.addStyleName("non-existent-widget");
+ });
+ }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/AssertionsEnabled.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/AssertionsEnabled.java
new file mode 100644
index 0000000000..a844a68e23
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/AssertionsEnabled.java
@@ -0,0 +1,16 @@
+package com.vaadin.tests.widgetset.server;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.client.AssertionFailureWidget;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class AssertionsEnabled extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new TestWidgetComponent(AssertionFailureWidget.class));
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java
new file mode 100644
index 0000000000..f6bbe2dc0a
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.widgetset.server;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class AssertionsEnabledTest extends SingleBrowserTest {
+
+ private static final String FAILING_CLASSNAME = "non-existent-widget";
+
+ @Test
+ public void testAssertionsAreEnabled() {
+ setDebug(true);
+ openTestURL();
+
+ // If assertions are disabled, the AssertionFailureWidget will add a
+ // label to the UI.
+ Assert.assertFalse(
+ "Label with classname " + FAILING_CLASSNAME
+ + " should not exist",
+ isElementPresent(By.className(FAILING_CLASSNAME)));
+
+ Assert.assertTrue("Assertion error Notification is not present",
+ isElementPresent(NotificationElement.class));
+ }
+
+}