From ccad305464af83826de4a4bd25a383360fb356d0 Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Tue, 3 Oct 2017 12:56:25 +0200 Subject: Use static import of Assert in tests (#10126) Also removes dependency on junit.framework.TestCase . --- .../java/com/vaadin/client/DateTimeServiceTest.java | 9 +++++---- .../test/java/com/vaadin/client/LocatorUtilTest.java | 19 ++++++++++--------- .../client/VBrowserDetailsUserAgentParserTest.java | 6 +++--- .../communication/ServerMessageHandlerTest.java | 12 +++++++----- 4 files changed, 25 insertions(+), 21 deletions(-) (limited to 'client/src/test/java') diff --git a/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java b/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java index 1329b7fdc9..563f16c334 100755 --- a/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java +++ b/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java @@ -1,11 +1,12 @@ package com.vaadin.client; +import static org.junit.Assert.assertEquals; + import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Test; public class DateTimeServiceTest { @@ -77,7 +78,7 @@ public class DateTimeServiceTest { Date d = new Date(start + i * MILLISECONDS_PER_DAY); int expected = getCalendarISOWeekNr(d); int calculated = DateTimeService.getISOWeekNumber(d); - Assert.assertEquals(d + " should be week " + expected, expected, + assertEquals(d + " should be week " + expected, expected, calculated); } @@ -94,11 +95,11 @@ public class DateTimeServiceTest { // System.out.println("Sample: " + d); int expected = isoWeekNumbers.get(d); int calculated = DateTimeService.getISOWeekNumber(d); - Assert.assertEquals( + assertEquals( d + " should be week " + expected + " (Java Calendar is wrong?)", expected, getCalendarISOWeekNr(d)); - Assert.assertEquals(d + " should be week " + expected, expected, + assertEquals(d + " should be week " + expected, expected, calculated); } diff --git a/client/src/test/java/com/vaadin/client/LocatorUtilTest.java b/client/src/test/java/com/vaadin/client/LocatorUtilTest.java index 1a771c5281..3f785d6115 100644 --- a/client/src/test/java/com/vaadin/client/LocatorUtilTest.java +++ b/client/src/test/java/com/vaadin/client/LocatorUtilTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.client; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.client.componentlocator.LocatorUtil; @@ -28,53 +29,53 @@ public class LocatorUtilTest { @Test public void testIsUI1() { boolean isUI = LocatorUtil.isUIElement("com.vaadin.ui.UI"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI2() { boolean isUI = LocatorUtil.isUIElement("/com.vaadin.ui.UI"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI3() { boolean isUI = LocatorUtil .isUIElement("//com.vaadin.ui.UI[RandomString"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI4() { boolean isUI = LocatorUtil.isUIElement("//com.vaadin.ui.UI[0]"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification1() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.VNotification"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification2() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.Notification"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification3() { boolean isUI = LocatorUtil .isNotificationElement("/com.vaadin.ui.VNotification["); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification4() { boolean isUI = LocatorUtil .isNotificationElement("//com.vaadin.ui.VNotification[0]"); - Assert.assertTrue(isUI); + assertTrue(isUI); } } diff --git a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java index 2594b3d09d..79d278acd1 100644 --- a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java +++ b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java @@ -441,10 +441,10 @@ public class VBrowserDetailsUserAgentParserTest { @Test public void checkFFsupportedVersions() { VBrowserDetails details = new VBrowserDetails(FIREFOX_40B11_WIN); - Assert.assertTrue(details.isTooOldToFunctionProperly()); + assertTrue(details.isTooOldToFunctionProperly()); details = new VBrowserDetails(FIREFOX_SUPPORTED); - Assert.assertFalse(details.isTooOldToFunctionProperly()); + assertFalse(details.isTooOldToFunctionProperly()); } /* @@ -634,7 +634,7 @@ public class VBrowserDetailsUserAgentParserTest { assertFalse(browserDetails.isIOS()); assertFalse(browserDetails.isAndroid()); assertFalse(browserDetails.isChromeOS()); - Assert.assertEquals(isWindowsPhone, browserDetails.isWindowsPhone()); + assertEquals(isWindowsPhone, browserDetails.isWindowsPhone()); } private void assertLinux(VBrowserDetails browserDetails) { diff --git a/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java b/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java index ee39492bbf..278bc67414 100644 --- a/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java +++ b/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.client.communication; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import org.junit.Test; /** @@ -28,7 +30,7 @@ public class ServerMessageHandlerTest { @Test public void unwrapValidJson() { String payload = "{'foo': 'bar'}"; - Assert.assertEquals(payload, + assertEquals(payload, MessageHandler.stripJSONWrapping("for(;;);[" + payload + "]")); } @@ -36,19 +38,19 @@ public class ServerMessageHandlerTest { @Test public void unwrapUnwrappedJson() { String payload = "{'foo': 'bar'}"; - Assert.assertNull(MessageHandler.stripJSONWrapping(payload)); + assertNull(MessageHandler.stripJSONWrapping(payload)); } @Test public void unwrapNull() { - Assert.assertNull(MessageHandler.stripJSONWrapping(null)); + assertNull(MessageHandler.stripJSONWrapping(null)); } @Test public void unwrapEmpty() { - Assert.assertNull(MessageHandler.stripJSONWrapping("")); + assertNull(MessageHandler.stripJSONWrapping("")); } } -- cgit v1.2.3