diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-03 12:56:25 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-03 13:56:25 +0300 |
commit | ccad305464af83826de4a4bd25a383360fb356d0 (patch) | |
tree | d399448d2910c4cf373e64c690b053740dff43ba /test | |
parent | 28b52d687dade66154a4fcd545415bf0d01b0a53 (diff) | |
download | vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.tar.gz vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.zip |
Use static import of Assert in tests (#10126)
Also removes dependency on junit.framework.TestCase .
Diffstat (limited to 'test')
7 files changed, 38 insertions, 28 deletions
diff --git a/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java b/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java index 2c9bcb5895..dd7c158692 100644 --- a/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java +++ b/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.ui.TextField; @@ -44,7 +46,7 @@ public class BeanValidationTest { public void binderWorksWithoutBeanValidationLib() { try { Class.forName("javax.validation.Validation"); - Assert.fail(); + fail(); } catch (ClassNotFoundException ignored) { } @@ -57,7 +59,7 @@ public class BeanValidationTest { binder.setBean(bean); field.setValue("foo"); - Assert.assertEquals(field.getValue(), bean.getProperty()); + assertEquals(field.getValue(), bean.getProperty()); } } diff --git a/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java b/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java index a3b2fdc2c0..e495ee279b 100644 --- a/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java +++ b/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import javax.validation.Validation; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.TextField; @@ -46,7 +48,7 @@ public class BeanValidationTest { public void binderWorksWithoutBeanValidationImpl() { // Just to make sure that it's available at the compilation time and in // runtime - Assert.assertNotNull(Validation.class); + assertNotNull(Validation.class); Binder<Bean> binder = new Binder<>(Bean.class); @@ -57,7 +59,7 @@ public class BeanValidationTest { binder.setBean(bean); field.setValue("foo"); - Assert.assertEquals(field.getValue(), bean.getProperty()); + assertEquals(field.getValue(), bean.getProperty()); } } diff --git a/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java index d3244417db..95cebdc974 100644 --- a/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java +++ b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java @@ -1,6 +1,8 @@ package com.vaadin.test.cdi; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -29,8 +31,8 @@ public class VaadinCDISmokeIT extends TestBenchTestCase { $(ButtonElement.class).first().click(); - Assert.assertTrue($(NotificationElement.class).exists()); - Assert.assertEquals(ThankYouServiceImpl.THANK_YOU_TEXT, + assertTrue($(NotificationElement.class).exists()); + assertEquals(ThankYouServiceImpl.THANK_YOU_TEXT, $(NotificationElement.class).first().getText()); } } diff --git a/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java b/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java index 5256def3f5..09f0d333a2 100644 --- a/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java +++ b/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java @@ -1,6 +1,7 @@ package com.vaadin.test.dependencyrewrite; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.phantomjs.PhantomJSDriver; @@ -13,7 +14,7 @@ public class DependencyFilterIT extends TestBenchTestCase { public void dynamicallyAddedResources() { setDriver(new PhantomJSDriver()); getDriver().get("http://localhost:8080/dynamic/"); - Assert.assertEquals(1L, ((JavascriptExecutor) getDriver()) + assertEquals(1L, ((JavascriptExecutor) getDriver()) .executeScript("return window.jqueryLoaded")); } @@ -22,7 +23,7 @@ public class DependencyFilterIT extends TestBenchTestCase { setDriver(new PhantomJSDriver()); getDriver().get("http://localhost:8080/initial/"); // 2 because of https://github.com/vaadin/framework/issues/9181 - Assert.assertEquals(2L, ((JavascriptExecutor) getDriver()) + assertEquals(2L, ((JavascriptExecutor) getDriver()) .executeScript("return window.jqueryLoaded")); } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java index dc1fe4e6a8..aa8f87686a 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.integration.push; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -67,14 +68,14 @@ public class LongPollingProxyServerIT extends AbstractIntegrationTest { // The wildfly9-nginx server has a configured timeout of 10s for // *-timeout urls Thread.sleep(15000); - Assert.assertEquals(0, getClientCounter()); + assertEquals(0, getClientCounter()); getIncrementButton().click(); - Assert.assertEquals(1, getClientCounter()); + assertEquals(1, getClientCounter()); } @Test public void basicPush() { - Assert.assertEquals(0, getServerCounter()); + assertEquals(0, getServerCounter()); getServerCounterStartButton().click(); waitUntil(e -> getServerCounter() > 1, 10); } diff --git a/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java index 76fc8790e2..d0e3b4c4ae 100644 --- a/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java +++ b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java @@ -1,6 +1,8 @@ package com.example; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -43,8 +45,8 @@ public class VaadinSpringBootSmokeIT extends TestBenchTestCase { public void testPageLoadsAndButtonWorks() { getDriver().navigate().to("http://localhost:" + port + ""); $(ButtonElement.class).first().click(); - Assert.assertTrue($(NotificationElement.class).exists()); - Assert.assertEquals(ThankYouService.THANK_YOU_TEXT, + assertTrue($(NotificationElement.class).exists()); + assertEquals(ThankYouService.THANK_YOU_TEXT, $(NotificationElement.class).first().getText()); } } diff --git a/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java b/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java index c6d4f1756b..28657067d3 100644 --- a/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java +++ b/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java @@ -1,8 +1,10 @@ package com.vaadin.test.defaultwidgetset; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.openqa.selenium.By; @@ -44,26 +46,25 @@ public abstract class AbstractWidgetSetIT extends TestBenchTestCase { $(ButtonElement.class).first().click(); - Assert.assertEquals("Label shown", 2, - $(LabelElement.class).all().size()); + assertEquals("Label shown", 2, $(LabelElement.class).all().size()); - Assert.assertEquals("Thanks John Dåe, it works!", + assertEquals("Thanks John Dåe, it works!", $(LabelElement.class).get(1).getText()); - Assert.assertEquals(expectedWidgetSet, + assertEquals(expectedWidgetSet, findElement(By.id("widgetsetinfo")).getText()); } protected void assertNoUnknownComponentShown() { - Assert.assertEquals(0, + assertEquals(0, findElements(By.className("vaadin-unknown-caption")).size()); } protected void assertUnknownComponentShown(String componentClass) { WebElement unknownComponentCaption = findElement( By.className("vaadin-unknown-caption")); - Assert.assertTrue(unknownComponentCaption.getText().contains( + assertTrue(unknownComponentCaption.getText().contains( "does not contain implementation for " + componentClass)); } @@ -77,8 +78,7 @@ public abstract class AbstractWidgetSetIT extends TestBenchTestCase { break; } } - Assert.assertTrue( - "Cannot find debug message containing '" + message + "'", + assertTrue("Cannot find debug message containing '" + message + "'", found); } |