From 11a2b5263fbd77d8ea045ddcf62ef65158e7c6c9 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 17 Mar 2016 11:37:12 +0200 Subject: [PATCH] Add @Test annotations, rename test classes Change-Id: Iac29db81c0c7ff425da73e7ae3d69eadabf5de77 --- .../vaadin/client/DateTimeServiceTest.java | 13 ++- .../com/vaadin/client/LocatorUtilTest.java | 13 ++- .../VBrowserDetailsUserAgentParserTest.java | 44 ++++++++- ...eldGroupTests.java => FieldGroupTest.java} | 2 +- .../data/util/AbstractContainerTestBase.java | 10 +- ...AbstractHierarchicalContainerTestBase.java | 6 ++ .../vaadin/data/util/BeanContainerTest.java | 31 +++++- .../data/util/BeanItemContainerTest.java | 51 ++++++++-- .../com/vaadin/data/util/BeanItemTest.java | 20 +++- .../ContainerHierarchicalWrapperTest.java | 4 + .../util/ContainerOrderedWrapperTest.java | 4 + .../data/util/ContainerSortingTest.java | 13 ++- .../GeneratedPropertyContainerBasicTest.java | 32 ++++++ ...erarchicalContainerOrderedWrapperTest.java | 6 ++ .../data/util/HierarchicalContainerTest.java | 19 ++++ .../data/util/IndexedContainerTest.java | 99 +++++++++---------- .../data/util/NestedMethodPropertyTest.java | 29 +++--- .../vaadin/data/util/ObjectPropertyTest.java | 11 ++- .../PerformanceTestIndexedContainerTest.java | 10 +- .../data/util/PropertyDescriptorTest.java | 10 +- .../vaadin/data/util/PropertySetItemTest.java | 42 ++++++-- .../data/util/filter/AndOrFilterTest.java | 13 +++ .../data/util/filter/CompareFilterTest.java | 8 ++ .../data/util/filter/IsNullFilterTest.java | 4 + .../data/util/filter/LikeFilterTest.java | 2 + .../data/util/filter/NotFilterTest.java | 4 + .../util/filter/SimpleStringFilterTest.java | 9 ++ .../data/util/sqlcontainer/AllTests.java | 2 +- .../{TicketTests.java => TicketTest.java} | 2 +- .../com/vaadin/server/JSONSerializerTest.java | 30 +++--- ...ApplicationServletStaticFilesLocation.java | 23 ++--- ...sts.java => VaadinPortletRequestTest.java} | 2 +- ...sts.java => VaadinPortletServiceTest.java} | 2 +- ...rtletTests.java => VaadinPortletTest.java} | 2 +- .../AtmospherePushConnectionTest.java | 3 - .../data/converter/ConverterFactoryTest.java | 14 ++- .../converter/DateToLongConverterTest.java | 12 ++- .../converter/DateToSqlDateConverterTest.java | 11 ++- .../StringToBigDecimalConverterTest.java | 18 ++-- .../StringToBigIntegerConverterTest.java | 19 ++-- .../StringToBooleanConverterTest.java | 62 +++++++----- .../converter/StringToByteConverterTest.java | 28 +++--- .../converter/StringToDateConverterTest.java | 16 ++- .../StringToDoubleConverterTest.java | 17 +++- .../converter/StringToFloatConverterTest.java | 16 ++- .../StringToIntegerConverterTest.java | 19 ++-- .../converter/StringToLongConverterTest.java | 31 +++--- .../converter/StringToShortConverterTest.java | 28 +++--- .../BigDecimalRangeValidatorTest.java | 37 ++++--- .../BigIntegerRangeValidatorTest.java | 37 ++++--- .../validator/ByteRangeValidatorTest.java | 11 ++- .../validator/CompositeValidatorTest.java | 20 ++-- .../validator/DateRangeValidatorTest.java | 17 +++- .../validator/DoubleRangeValidatorTest.java | 11 ++- .../data/validator/EmailValidatorTest.java | 17 ++-- .../validator/FloatRangeValidatorTest.java | 11 ++- .../validator/IntegerRangeValidatorTest.java | 11 ++- .../validator/LongRangeValidatorTest.java | 11 ++- .../data/validator/NullValidatorTest.java | 9 +- .../data/validator/RegexpValidatorTest.java | 13 ++- .../validator/ShortRangeValidatorTest.java | 11 ++- .../validator/StringLengthValidatorTest.java | 15 ++- ...TagNames.java => InvalidTagNamesTest.java} | 2 +- .../AbstractContainerListenersTest.java | 4 + .../server/AbstractPropertyListenersTest.java | 5 + .../tests/server/AssertionsEnabledTest.java | 8 +- .../tests/server/AtmosphereVersionTest.java | 7 +- .../tests/server/ClassesSerializableTest.java | 8 +- .../server/ClientMethodSerializationTest.java | 11 ++- .../vaadin/tests/server/EventRouterTest.java | 5 +- .../tests/server/FileTypeResolverTest.java | 9 +- .../server/IndexedContainerListenersTest.java | 5 + .../vaadin/tests/server/KeyMapperTest.java | 11 ++- .../vaadin/tests/server/MimeTypesTest.java | 7 +- .../tests/server/PropertyFormatterTest.java | 6 +- .../tests/server/SerializationTest.java | 13 ++- .../SimpleMultiPartInputStreamTest.java | 12 ++- .../server/StreamVariableMappingTest.java | 17 ++-- .../AbstractListenerMethodsTestBase.java | 6 +- .../component/ComponentSizeParseTest.java | 6 +- ...alues.java => FieldDefaultValuesTest.java} | 2 +- .../server/component/FinalMethodTest.java | 5 +- .../server/component/ReadEmptyDesignTest.java | 18 ++-- .../StateGetDoesNotMarkDirtyTest.java | 11 ++- .../component/WriteEmptyDesignTest.java | 12 ++- .../absolutelayout/ComponentPositionTest.java | 14 ++- .../AbstractComponentStyleNamesTest.java | 13 ++- ...stractComponentContainerListenersTest.java | 5 + .../AbsFieldValueConversionErrorTest.java | 9 +- .../AbsFieldValueConversionsTest.java | 16 ++- .../AbstractFieldListenersTest.java | 5 + .../DefaultConverterFactoryTest.java | 9 +- .../AbstractSelectListenersTest.java | 5 + ...s.java => OptionGroupDeclarativeTest.java} | 2 +- ...onGroupTests.java => OptionGroupTest.java} | 2 +- .../AbstractTextFieldListenersTest.java | 6 ++ .../component/button/ButtonListenersTest.java | 6 ++ .../calendar/ContainerDataSourceTest.java | 10 +- .../datefield/DateFieldConverterTest.java | 8 +- .../datefield/DateFieldListenersTest.java | 5 + .../component/datefield/ResolutionTest.java | 9 +- ...ridChildren.java => GridChildrenTest.java} | 2 +- ...{GridColumns.java => GridColumnsTest.java} | 2 +- ...dSelection.java => GridSelectionTest.java} | 2 +- .../component/label/LabelListenersTest.java | 7 ++ .../component/menubar/MenuBarIdsTest.java | 14 ++- .../optiongroup/OptionGroupListenersTest.java | 5 + .../orderedlayout/OrderedLayoutTest.java | 6 +- .../component/select/SelectListenersTest.java | 5 + .../server/component/table/FooterTest.java | 13 ++- .../table/MultipleSelectionTest.java | 9 +- .../component/table/TableListenersTest.java | 8 ++ .../TablePropertyValueConverterTest.java | 16 ++- ...lectable.java => TableSelectableTest.java} | 2 +- .../table/TableSerializationTest.java | 7 +- ...extFieldWithConverterAndValidatorTest.java | 12 +-- .../TextFieldWithPropertyFormatterTest.java | 15 ++- .../textfield/TextFieldWithValidatorTest.java | 17 +++- .../server/component/tree/ListenersTest.java | 14 ++- .../component/tree/TreeListenersTest.java | 6 ++ .../treetable/EmptyTreeTableTest.java | 8 +- .../TreeTableSetContainerNullTest.java | 5 +- .../component/ui/CustomUIClassLoaderTest.java | 9 +- .../component/upload/UploadListenersTest.java | 8 ++ .../component/window/WindowListenersTest.java | 7 ++ .../AbstractIndexedLayoutTestBase.java | 15 ++- .../AddRemoveComponentTest.java | 11 ++- .../componentcontainer/FormLayoutTest.java | 4 + .../AbstractFieldValueChangeTestBase.java | 9 +- .../components/ComboBoxValueChangeTest.java | 7 +- .../ComponentAttachDetachListenerTest.java | 27 ++++- .../GridLayoutLastRowRemovalTest.java | 9 +- .../components/TextFieldValueChangeTest.java | 9 +- .../tests/server/components/WindowTest.java | 12 ++- .../navigator/ClassBasedViewProviderTest.java | 33 ++++--- .../tests/server/navigator/NavigatorTest.java | 70 ++++++++----- .../server/validation/BeanValidationTest.java | 12 ++- .../server/validation/RangeValidatorTest.java | 11 ++- .../tests/util/UniqueSerializableTest.java | 10 +- ...FieldTests.java => DateFieldTestCase.java} | 2 +- 140 files changed, 1321 insertions(+), 530 deletions(-) rename server/src/test/java/com/vaadin/data/fieldgroup/{FieldGroupTests.java => FieldGroupTest.java} (98%) rename server/src/test/java/com/vaadin/data/util/sqlcontainer/{TicketTests.java => TicketTest.java} (99%) rename server/src/test/java/com/vaadin/server/{VaadinPortletRequestTests.java => VaadinPortletRequestTest.java} (97%) rename server/src/test/java/com/vaadin/server/{VaadinPortletServiceTests.java => VaadinPortletServiceTest.java} (99%) rename server/src/test/java/com/vaadin/server/{VaadinPortletTests.java => VaadinPortletTest.java} (98%) rename server/src/test/java/com/vaadin/tests/design/{InvalidTagNames.java => InvalidTagNamesTest.java} (98%) rename server/src/test/java/com/vaadin/tests/server/component/{FieldDefaultValues.java => FieldDefaultValuesTest.java} (98%) rename server/src/test/java/com/vaadin/tests/server/component/abstractselect/{OptionGroupDeclarativeTests.java => OptionGroupDeclarativeTest.java} (98%) rename server/src/test/java/com/vaadin/tests/server/component/abstractselect/{OptionGroupTests.java => OptionGroupTest.java} (95%) rename server/src/test/java/com/vaadin/tests/server/component/grid/{GridChildren.java => GridChildrenTest.java} (98%) rename server/src/test/java/com/vaadin/tests/server/component/grid/{GridColumns.java => GridColumnsTest.java} (99%) rename server/src/test/java/com/vaadin/tests/server/component/grid/{GridSelection.java => GridSelectionTest.java} (99%) rename server/src/test/java/com/vaadin/tests/server/component/table/{TableSelectable.java => TableSelectableTest.java} (98%) rename server/src/test/java/com/vaadin/ui/{DateFieldTests.java => DateFieldTestCase.java} (97%) diff --git a/client/tests/src/com/vaadin/client/DateTimeServiceTest.java b/client/tests/src/com/vaadin/client/DateTimeServiceTest.java index f9351d1cc0..e5e6cbd7db 100755 --- a/client/tests/src/com/vaadin/client/DateTimeServiceTest.java +++ b/client/tests/src/com/vaadin/client/DateTimeServiceTest.java @@ -5,9 +5,10 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; -public class DateTimeServiceTest extends TestCase { +public class DateTimeServiceTest { final long MILLISECONDS_PER_DAY = 24 * 3600 * 1000; @@ -66,6 +67,7 @@ public class DateTimeServiceTest extends TestCase { * calculates the ISO week number like we do. * */ + @Test public void testISOWeekNumbers() { Calendar c = Calendar.getInstance(); c.set(1990, 1, 1); @@ -75,7 +77,7 @@ public class DateTimeServiceTest extends TestCase { Date d = new Date(start + i * MILLISECONDS_PER_DAY); int expected = getCalendarISOWeekNr(d); int calculated = DateTimeService.getISOWeekNumber(d); - assertEquals(d + " should be week " + expected, expected, + Assert.assertEquals(d + " should be week " + expected, expected, calculated); } @@ -86,15 +88,16 @@ public class DateTimeServiceTest extends TestCase { * {@link Calendar}). * */ + @Test public void testSampleISOWeekNumbers() { for (Date d : isoWeekNumbers.keySet()) { // System.out.println("Sample: " + d); int expected = isoWeekNumbers.get(d); int calculated = DateTimeService.getISOWeekNumber(d); - assertEquals(d + " should be week " + expected + Assert.assertEquals(d + " should be week " + expected + " (Java Calendar is wrong?)", expected, getCalendarISOWeekNr(d)); - assertEquals(d + " should be week " + expected, expected, + Assert.assertEquals(d + " should be week " + expected, expected, calculated); } diff --git a/client/tests/src/com/vaadin/client/LocatorUtilTest.java b/client/tests/src/com/vaadin/client/LocatorUtilTest.java index 15536ac6fc..971688e1c5 100644 --- a/client/tests/src/com/vaadin/client/LocatorUtilTest.java +++ b/client/tests/src/com/vaadin/client/LocatorUtilTest.java @@ -15,56 +15,63 @@ */ package com.vaadin.client; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.client.componentlocator.LocatorUtil; /* * Test LocatorUtil.isUIElement() & isNotificaitonElement methods */ -public class LocatorUtilTest extends TestCase { +public class LocatorUtilTest { + @Test public void testIsUI1() { boolean isUI = LocatorUtil.isUIElement("com.vaadin.ui.UI"); Assert.assertTrue(isUI); } + @Test public void testIsUI2() { boolean isUI = LocatorUtil.isUIElement("/com.vaadin.ui.UI"); Assert.assertTrue(isUI); } + @Test public void testIsUI3() { boolean isUI = LocatorUtil .isUIElement("//com.vaadin.ui.UI[RandomString"); Assert.assertTrue(isUI); } + @Test public void testIsUI4() { boolean isUI = LocatorUtil.isUIElement("//com.vaadin.ui.UI[0]"); Assert.assertTrue(isUI); } + @Test public void testIsNotification1() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.VNotification"); Assert.assertTrue(isUI); } + @Test public void testIsNotification2() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.Notification"); Assert.assertTrue(isUI); } + @Test public void testIsNotification3() { boolean isUI = LocatorUtil .isNotificationElement("/com.vaadin.ui.VNotification["); Assert.assertTrue(isUI); } + @Test public void testIsNotification4() { boolean isUI = LocatorUtil .isNotificationElement("//com.vaadin.ui.VNotification[0]"); diff --git a/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java index 24bf9b6558..5522b8e2bc 100644 --- a/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java +++ b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java @@ -1,12 +1,15 @@ package com.vaadin.client; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.junit.Assert; +import org.junit.Test; import com.vaadin.shared.VBrowserDetails; -public class VBrowserDetailsUserAgentParserTest extends TestCase { +public class VBrowserDetailsUserAgentParserTest { private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"; private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12"; @@ -58,6 +61,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { private static final String EDGE_WINDOWS_10 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240"; + @Test public void testSafari3() { VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS); assertWebKit(bd); @@ -68,6 +72,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testSafari4() { VBrowserDetails bd = new VBrowserDetails(SAFARI4_MAC); assertWebKit(bd); @@ -78,6 +83,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertMacOSX(bd); } + @Test public void testIPhoneIOS6Homescreen() { VBrowserDetails bd = new VBrowserDetails( IPHONE_IOS_6_1_HOMESCREEN_SIMULATOR); @@ -91,6 +97,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertIPhone(bd); } + @Test public void testIPhoneIOS5() { VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_5_1); assertWebKit(bd); @@ -102,6 +109,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertIPhone(bd); } + @Test public void testIPhoneIOS4() { VBrowserDetails bd = new VBrowserDetails(IPHONE_IOS_4_0); assertWebKit(bd); @@ -113,6 +121,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertIPhone(bd); } + @Test public void testIPadIOS4() { VBrowserDetails bd = new VBrowserDetails(IPAD_IOS_4_3_1); assertWebKit(bd); @@ -124,6 +133,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertIPad(bd); } + @Test public void testAndroid21() { VBrowserDetails bd = new VBrowserDetails(ANDROID_HTC_2_1); assertWebKit(bd); @@ -135,6 +145,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { } + @Test public void testAndroid22() { VBrowserDetails bd = new VBrowserDetails(ANDROID_GOOGLE_NEXUS_2_2); assertWebKit(bd); @@ -145,6 +156,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertAndroid(bd, 2, 2); } + @Test public void testAndroid30() { VBrowserDetails bd = new VBrowserDetails(ANDROID_MOTOROLA_3_0); assertWebKit(bd); @@ -155,6 +167,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertAndroid(bd, 3, 0); } + @Test public void testAndroid40Chrome() { VBrowserDetails bd = new VBrowserDetails( ANDROID_GALAXY_NEXUS_4_0_4_CHROME); @@ -174,6 +187,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertEquals(i, bd.getOperatingSystemMinorVersion()); } + @Test public void testChrome3() { VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC); assertWebKit(bd); @@ -184,6 +198,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertMacOSX(bd); } + @Test public void testChrome4() { VBrowserDetails bd = new VBrowserDetails(CHROME4_WINDOWS); assertWebKit(bd); @@ -194,6 +209,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testFirefox3() { VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS); assertGecko(bd); @@ -212,6 +228,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertLinux(bd); } + @Test public void testFirefox33Android() { VBrowserDetails bd = new VBrowserDetails(FIREFOX33_ANDROID); assertGecko(bd); @@ -221,6 +238,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertAndroid(bd, -1, -1); } + @Test public void testFirefox35() { VBrowserDetails bd = new VBrowserDetails(FIREFOX35_WINDOWS); assertGecko(bd); @@ -231,6 +249,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testFirefox36() { VBrowserDetails bd = new VBrowserDetails(FIREFOX36_WINDOWS); assertGecko(bd); @@ -241,6 +260,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testFirefox30b5() { VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC); assertGecko(bd); @@ -251,6 +271,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertMacOSX(bd); } + @Test public void testFirefox40b11() { VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN); assertGecko(bd); @@ -261,6 +282,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testFirefox40b7() { VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN); assertGecko(bd); @@ -271,12 +293,14 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testKonquerorLinux() { // Just ensure detection does not crash VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX); assertLinux(bd); } + @Test public void testFirefox36b() { VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC); assertGecko(bd); @@ -287,6 +311,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertMacOSX(bd); } + @Test public void testOpera964() { VBrowserDetails bd = new VBrowserDetails(OPERA964_WINDOWS); assertPresto(bd); @@ -296,6 +321,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testOpera1010() { VBrowserDetails bd = new VBrowserDetails(OPERA1010_WINDOWS); assertPresto(bd); @@ -305,6 +331,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testOpera1050() { VBrowserDetails bd = new VBrowserDetails(OPERA1050_WINDOWS); assertPresto(bd); @@ -314,6 +341,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE6() { VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS); assertEngineVersion(bd, -1); @@ -323,6 +351,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE7() { VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS); assertEngineVersion(bd, -1); @@ -332,6 +361,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE8() { VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS); assertTrident(bd); @@ -342,6 +372,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE8CompatibilityMode() { VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS); bd.setIEMode(7); @@ -355,6 +386,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE9() { VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7); assertTrident(bd); @@ -365,6 +397,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE9InIE7CompatibilityMode() { VBrowserDetails bd = new VBrowserDetails(IE9_IN_IE7_MODE_WINDOWS_7); // bd.setIE8InCompatibilityMode(); @@ -378,6 +411,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE9InIE8CompatibilityMode() { VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7); // bd.setIE8InCompatibilityMode(); @@ -395,6 +429,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE10() { VBrowserDetails bd = new VBrowserDetails(IE10_WINDOWS_8); assertTrident(bd); @@ -405,6 +440,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE11() { VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7); assertTrident(bd); @@ -415,6 +451,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd); } + @Test public void testIE11WindowsPhone81Update() { VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_PHONE_8_1_UPDATE); assertTrident(bd); @@ -425,6 +462,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { assertWindows(bd, true); } + @Test public void testEdgeWindows10() { VBrowserDetails bd = new VBrowserDetails(EDGE_WINDOWS_10); assertEdge(bd); @@ -439,7 +477,7 @@ public class VBrowserDetailsUserAgentParserTest extends TestCase { private void assertEngineVersion(VBrowserDetails browserDetails, float version) { - assertEquals(version, browserDetails.getBrowserEngineVersion()); + assertEquals(version, browserDetails.getBrowserEngineVersion(), 0.01d); } diff --git a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java similarity index 98% rename from server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java rename to server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java index dce9f656b9..f8e4d1c2d0 100644 --- a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java +++ b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java @@ -16,7 +16,7 @@ import com.vaadin.data.util.TransactionalPropertyWrapper; import com.vaadin.ui.Field; import com.vaadin.ui.TextField; -public class FieldGroupTests { +public class FieldGroupTest { private FieldGroup sut; private Field field; diff --git a/server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java b/server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java index 52acc5ab76..c70cf98449 100644 --- a/server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java +++ b/server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java @@ -1,11 +1,15 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import junit.framework.TestCase; - import org.junit.Assert; import com.vaadin.data.Container; @@ -17,7 +21,7 @@ import com.vaadin.data.Container.Sortable; import com.vaadin.data.Item; import com.vaadin.data.util.filter.SimpleStringFilter; -public abstract class AbstractContainerTestBase extends TestCase { +public abstract class AbstractContainerTestBase { /** * Helper class for testing e.g. listeners expecting events to be fired. diff --git a/server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java b/server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java index 9cede77162..7a07c553f7 100644 --- a/server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java +++ b/server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java @@ -1,5 +1,11 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Collection; import com.vaadin.data.Container; diff --git a/server/src/test/java/com/vaadin/data/util/BeanContainerTest.java b/server/src/test/java/com/vaadin/data/util/BeanContainerTest.java index 3d755f4397..d990f3d123 100644 --- a/server/src/test/java/com/vaadin/data/util/BeanContainerTest.java +++ b/server/src/test/java/com/vaadin/data/util/BeanContainerTest.java @@ -1,5 +1,11 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; @@ -8,6 +14,8 @@ import java.util.Map; import java.util.Map.Entry; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.Item; @@ -41,7 +49,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { return new BeanContainer(ClassName.class); } - @Override + @Before public void setUp() { nameToBean.clear(); @@ -68,6 +76,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { return false; } + @Test public void testGetType_existingProperty_typeReturned() { BeanContainer container = getContainer(); Assert.assertEquals( @@ -75,30 +84,36 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { String.class, container.getType("simpleName")); } + @Test public void testGetType_notExistingProperty_nullReturned() { BeanContainer container = getContainer(); Assert.assertNull("Not null type is returned for property ''", container.getType("")); } + @Test public void testBasicOperations() { testBasicContainerOperations(getContainer()); } + @Test public void testFiltering() { testContainerFiltering(getContainer()); } + @Test public void testSorting() { testContainerSorting(getContainer()); } + @Test public void testSortingAndFiltering() { testContainerSortingAndFiltering(getContainer()); } // duplicated from parent class and modified - adding items to // BeanContainer differs from other containers + @Test public void testContainerOrdered() { BeanContainer container = new BeanContainer( String.class); @@ -175,6 +190,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { // TODO test Container.Indexed interface operation - testContainerIndexed()? + @Test public void testAddItemAt() { BeanContainer container = new BeanContainer( String.class); @@ -198,6 +214,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals("id4", container.getIdByIndex(3)); } + @Test public void testUnsupportedMethods() { BeanContainer container = new BeanContainer( Person.class); @@ -255,6 +272,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, container.size()); } + @Test public void testRemoveContainerProperty() { BeanContainer container = new BeanContainer( Person.class); @@ -271,6 +289,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { Assert.assertNull(container.getItem("John").getItemProperty("name")); } + @Test public void testAddNullBeans() { BeanContainer container = new BeanContainer( Person.class); @@ -282,6 +301,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(0, container.size()); } + @Test public void testAddNullId() { BeanContainer container = new BeanContainer( Person.class); @@ -295,6 +315,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(0, container.size()); } + @Test public void testEmptyContainer() { BeanContainer container = new BeanContainer( Person.class); @@ -307,6 +328,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { // could test more about empty container } + @Test public void testAddBeanWithoutResolver() { BeanContainer container = new BeanContainer( Person.class); @@ -340,6 +362,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(0, container.size()); } + @Test public void testAddAllWithNullItemId() { BeanContainer container = new BeanContainer( Person.class); @@ -372,6 +395,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(3, container.size()); } + @Test public void testAddBeanWithNullResolver() { BeanContainer container = new BeanContainer( Person.class); @@ -400,6 +424,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(0, container.size()); } + @Test public void testAddBeanWithResolver() { BeanContainer container = new BeanContainer( Person.class); @@ -422,6 +447,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(5, container.size()); } + @Test public void testAddNullBeansWithResolver() { BeanContainer container = new BeanContainer( Person.class); @@ -434,6 +460,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(0, container.size()); } + @Test public void testAddBeanWithPropertyResolver() { BeanContainer container = new BeanContainer( Person.class); @@ -456,6 +483,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { assertEquals(5, container.size()); } + @Test public void testAddNestedContainerProperty() { BeanContainer container = new BeanContainer( NestedMethodPropertyTest.Person.class); @@ -470,6 +498,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { .getValue()); } + @Test public void testNestedContainerPropertyWithNullBean() { BeanContainer container = new BeanContainer( NestedMethodPropertyTest.Person.class); diff --git a/server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java b/server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java index 3c30b41d39..0298e57dcc 100644 --- a/server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java +++ b/server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java @@ -1,5 +1,11 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -11,6 +17,8 @@ import java.util.Map; import org.easymock.Capture; import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.Container.Indexed.ItemAddEvent; @@ -35,7 +43,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { return new BeanItemContainer(ClassName.class); } - @Override + @Before public void setUp() { nameToBean.clear(); @@ -78,6 +86,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { return false; } + @Test public void testGetType_existingProperty_typeReturned() { BeanItemContainer container = getContainer(); Assert.assertEquals( @@ -85,30 +94,36 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { String.class, container.getType("simpleName")); } + @Test public void testGetType_notExistingProperty_nullReturned() { BeanItemContainer container = getContainer(); Assert.assertNull("Not null type is returned for property ''", container.getType("")); } + @Test public void testBasicOperations() { testBasicContainerOperations(getContainer()); } + @Test public void testFiltering() { testContainerFiltering(getContainer()); } + @Test public void testSorting() { testContainerSorting(getContainer()); } + @Test public void testSortingAndFiltering() { testContainerSortingAndFiltering(getContainer()); } // duplicated from parent class and modified - adding items to // BeanItemContainer differs from other containers + @Test public void testContainerOrdered() { BeanItemContainer container = new BeanItemContainer( String.class); @@ -181,12 +196,14 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { } + @Test public void testContainerIndexed() { testContainerIndexed(getContainer(), nameToBean.get(sampleData[2]), 2, false, new ClassName("org.vaadin.test.Test", 8888), true); } @SuppressWarnings("deprecation") + @Test public void testCollectionConstructors() { List classNames = new ArrayList(); classNames.add(new ClassName("a.b.c.Def", 1)); @@ -215,6 +232,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { // this only applies to the collection constructor with no type parameter @SuppressWarnings("deprecation") + @Test public void testEmptyCollectionConstructor() { try { new BeanItemContainer((Collection) null); @@ -230,6 +248,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { } } + @Test public void testItemSetChangeListeners() { BeanItemContainer container = getContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -328,6 +347,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { } + @Test public void testItemSetChangeListenersFiltering() { BeanItemContainer container = getContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -496,6 +516,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.assertNone(); } + @Test public void testAddRemoveWhileFiltering() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -573,6 +594,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(michael, container.lastItemId()); } + @Test public void testRefilterOnPropertyModification() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -608,6 +630,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(3, container.size()); } + @Test public void testAddAll() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -637,6 +660,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(michael, container.nextItemId(jack)); } + @Test public void testUnsupportedMethods() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -673,6 +697,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, container.size()); } + @Test public void testRemoveContainerProperty() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -689,6 +714,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { Assert.assertNull(container.getItem(john).getItemProperty("name")); } + @Test public void testAddNullBean() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -703,6 +729,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, container.size()); } + @Test public void testBeanIdResolver() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -711,14 +738,12 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertSame(john, container.getBeanIdResolver().getIdForBean(john)); } + @Test(expected = IllegalArgumentException.class) public void testNullBeanClass() { - try { - new BeanItemContainer((Class) null); - } catch (IllegalArgumentException e) { - // should get exception - } + new BeanItemContainer((Class) null); } + @Test public void testAddNestedContainerProperty() { BeanItemContainer container = new BeanItemContainer( NestedMethodPropertyTest.Person.class); @@ -734,6 +759,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { .getValue()); } + @Test public void testNestedContainerPropertyWithNullBean() { BeanItemContainer container = new BeanItemContainer( NestedMethodPropertyTest.Person.class); @@ -748,6 +774,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { .getValue()); } + @Test public void testItemAddedEvent() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -761,6 +788,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { EasyMock.verify(addListener); } + @Test public void testItemAddedEvent_AddedItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -774,6 +802,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(bean, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemAddedEvent_addItemAt_IndexOfAddedItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -788,6 +817,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemAddedEvent_addItemAfter_IndexOfAddedItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -802,6 +832,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemAddedEvent_amountOfAddedItems() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -816,6 +847,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(2, capturedEvent.getValue().getAddedItemsCount()); } + @Test public void testItemAddedEvent_someItemsAreFiltered_amountOfAddedItemsIsReducedByAmountOfFilteredItems() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -831,6 +863,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, capturedEvent.getValue().getAddedItemsCount()); } + @Test public void testItemAddedEvent_someItemsAreFiltered_addedItemIsTheFirstVisibleItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -846,6 +879,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(bean, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemRemovedEvent() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -861,6 +895,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { EasyMock.verify(removeListener); } + @Test public void testItemRemovedEvent_RemovedItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -875,6 +910,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(bean, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemRemovedEvent_indexOfRemovedItem() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -890,6 +926,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemRemovedEvent_amountOfRemovedItems() { BeanItemContainer container = new BeanItemContainer( Person.class); @@ -926,6 +963,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { return listener; } + @Test public void testAddNestedContainerBeanBeforeData() { BeanItemContainer container = new BeanItemContainer( NestedMethodPropertyTest.Person.class); @@ -947,6 +985,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { } + @Test public void testAddNestedContainerBeanAfterData() { BeanItemContainer container = new BeanItemContainer( NestedMethodPropertyTest.Person.class); diff --git a/server/src/test/java/com/vaadin/data/util/BeanItemTest.java b/server/src/test/java/com/vaadin/data/util/BeanItemTest.java index 89c56b1779..e78d518a25 100644 --- a/server/src/test/java/com/vaadin/data/util/BeanItemTest.java +++ b/server/src/test/java/com/vaadin/data/util/BeanItemTest.java @@ -9,9 +9,8 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Property; @@ -22,7 +21,7 @@ import com.vaadin.data.Property; * * See also {@link PropertySetItemTest}, which tests the base class. */ -public class BeanItemTest extends TestCase { +public class BeanItemTest { @SuppressWarnings("unused") protected static class MySuperClass { @@ -161,6 +160,7 @@ public class BeanItemTest extends TestCase { public void setOverride(int i); } + @Test public void testGetProperties() { BeanItem item = new BeanItem( new MySuperClass()); @@ -172,6 +172,7 @@ public class BeanItemTest extends TestCase { Assert.assertTrue(itemPropertyIds.contains("superPublic")); } + @Test public void testGetSuperClassProperties() { BeanItem item = new BeanItem(new MyClass("bean1")); @@ -185,6 +186,7 @@ public class BeanItemTest extends TestCase { Assert.assertTrue(itemPropertyIds.contains("name2")); } + @Test public void testOverridingProperties() { BeanItem item = new BeanItem(new MyClass2("bean2")); @@ -197,6 +199,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(item.getItemProperty("name2").isReadOnly()); } + @Test public void testGetInterfaceProperties() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { @@ -215,6 +218,7 @@ public class BeanItemTest extends TestCase { Assert.assertTrue(property.isReadOnly()); } + @Test public void testGetSuperInterfaceProperties() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { @@ -235,6 +239,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(property.isReadOnly()); } + @Test public void testPropertyExplicitOrder() { Collection ids = new ArrayList(); ids.add("name"); @@ -253,6 +258,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(it.hasNext()); } + @Test public void testPropertyExplicitOrder2() { BeanItem item = new BeanItem(new MyClass("bean1"), new String[] { "name", "superPublic", "name2", "noField" }); @@ -265,6 +271,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(it.hasNext()); } + @Test public void testPropertyBadPropertyName() { Collection ids = new ArrayList(); ids.add("name3"); @@ -279,6 +286,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(it.hasNext()); } + @Test public void testRemoveProperty() { BeanItem item = new BeanItem(new MyClass("bean1")); @@ -290,6 +298,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(itemPropertyIds.contains("name2")); } + @Test public void testRemoveSuperProperty() { BeanItem item = new BeanItem(new MyClass("bean1")); @@ -301,6 +310,7 @@ public class BeanItemTest extends TestCase { Assert.assertFalse(itemPropertyIds.contains("superPrivate")); } + @Test public void testPropertyTypes() { BeanItem item = new BeanItem(new MyClass("bean1")); @@ -314,6 +324,7 @@ public class BeanItemTest extends TestCase { .getType())); } + @Test public void testPropertyReadOnly() { BeanItem item = new BeanItem(new MyClass("bean1")); @@ -321,6 +332,7 @@ public class BeanItemTest extends TestCase { Assert.assertTrue(item.getItemProperty("name2").isReadOnly()); } + @Test public void testCustomProperties() throws Exception { LinkedHashMap> propertyDescriptors = new LinkedHashMap>(); propertyDescriptors.put( @@ -340,6 +352,7 @@ public class BeanItemTest extends TestCase { Assert.assertEquals("bean1", item.getItemProperty("myname").getValue()); } + @Test public void testAddRemoveProperty() throws Exception { MethodPropertyDescriptor pd = new MethodPropertyDescriptor( "myname", MyClass.class, @@ -359,6 +372,7 @@ public class BeanItemTest extends TestCase { Assert.assertEquals(null, item.getItemProperty("myname")); } + @Test public void testOverridenGenericMethods() { BeanItem item = new BeanItem(new SubClass()); diff --git a/server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java b/server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java index 8e554d5030..a6fec6670b 100644 --- a/server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java +++ b/server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java @@ -1,19 +1,23 @@ package com.vaadin.data.util; +import org.junit.Test; public class ContainerHierarchicalWrapperTest extends AbstractHierarchicalContainerTestBase { + @Test public void testBasicOperations() { testBasicContainerOperations(new ContainerHierarchicalWrapper( new IndexedContainer())); } + @Test public void testHierarchicalContainer() { testHierarchicalContainer(new ContainerHierarchicalWrapper( new IndexedContainer())); } + @Test public void testRemoveSubtree() { testRemoveHierarchicalWrapperSubtree(new ContainerHierarchicalWrapper( new IndexedContainer())); diff --git a/server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java b/server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java index 422e9756f8..7e720071be 100644 --- a/server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java +++ b/server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java @@ -2,6 +2,8 @@ package com.vaadin.data.util; import java.util.Collection; +import org.junit.Test; + import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.Property; @@ -89,11 +91,13 @@ public class ContainerOrderedWrapperTest extends AbstractContainerTestBase { } + @Test public void testBasicOperations() { testBasicContainerOperations(new ContainerOrderedWrapper( new NotOrderedContainer())); } + @Test public void testOrdered() { testContainerOrdered(new ContainerOrderedWrapper( new NotOrderedContainer())); diff --git a/server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java b/server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java index dd713dd7b0..dced4b4e72 100644 --- a/server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java +++ b/server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java @@ -4,13 +4,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.tests.util.TestUtil; -public class ContainerSortingTest extends TestCase { +public class ContainerSortingTest { private static final String ITEM_DATA_MINUS2_NULL = "Data -2 null"; private static final String ITEM_DATA_MINUS2 = "Data -2"; @@ -26,11 +26,7 @@ public class ContainerSortingTest extends TestCase { private static final String PROPERTY_STRING_NULL = "string-null"; private static final String PROPERTY_STRING_ID = "string-not-null"; - @Override - protected void setUp() throws Exception { - super.setUp(); - } - + @Test public void testEmptyFilteredIndexedContainer() { IndexedContainer ic = new IndexedContainer(); @@ -42,6 +38,7 @@ public class ContainerSortingTest extends TestCase { } + @Test public void testFilteredIndexedContainer() { IndexedContainer ic = new IndexedContainer(); @@ -56,6 +53,7 @@ public class ContainerSortingTest extends TestCase { ITEM_DATA_MINUS2_NULL, }); } + @Test public void testIndexedContainer() { IndexedContainer ic = new IndexedContainer(); @@ -83,6 +81,7 @@ public class ContainerSortingTest extends TestCase { } + @Test public void testHierarchicalContainer() { HierarchicalContainer hc = new HierarchicalContainer(); populateContainer(hc); diff --git a/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java b/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java index 90ec893f4d..5f7f965c69 100644 --- a/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java +++ b/server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java @@ -1,10 +1,16 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; import org.easymock.Capture; import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.Container.Indexed.ItemAddEvent; @@ -17,6 +23,7 @@ import com.vaadin.data.util.filter.SimpleStringFilter; public class GeneratedPropertyContainerBasicTest extends AbstractInMemoryContainerTestBase { + @Test public void testBasicOperations() { testBasicContainerOperations(createContainer()); } @@ -25,27 +32,33 @@ public class GeneratedPropertyContainerBasicTest extends return new GeneratedPropertyContainer(new IndexedContainer()); } + @Test public void testFiltering() { testContainerFiltering(createContainer()); } + @Test public void testSorting() { testContainerSorting(createContainer()); } + @Test public void testSortingAndFiltering() { testContainerSortingAndFiltering(createContainer()); } + @Test public void testContainerOrdered() { testContainerOrdered(createContainer()); } + @Test public void testContainerIndexed() { testContainerIndexed(createContainer(), sampleData[2], 2, true, "newItemId", true); } + @Test public void testItemSetChangeListeners() { GeneratedPropertyContainer container = createContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -117,6 +130,7 @@ public class GeneratedPropertyContainerBasicTest extends } + @Test public void testAddRemoveContainerFilter() { GeneratedPropertyContainer container = createContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -142,6 +156,7 @@ public class GeneratedPropertyContainerBasicTest extends // TODO other tests should check positions after removing filter etc, // here concentrating on listeners + @Test public void testItemSetChangeListenersFiltering() { Container.Indexed container = createContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -289,6 +304,7 @@ public class GeneratedPropertyContainerBasicTest extends counter.assertNone(); } + @Test public void testItemAdd_idSequence() { GeneratedPropertyContainer container = createContainer(); Object itemId; @@ -306,6 +322,7 @@ public class GeneratedPropertyContainerBasicTest extends assertEquals(Integer.valueOf(4), itemId); } + @Test public void testItemAddRemove_idSequence() { GeneratedPropertyContainer container = createContainer(); Object itemId; @@ -321,6 +338,7 @@ public class GeneratedPropertyContainerBasicTest extends Integer.valueOf(2), itemId); } + @Test public void testItemAddedEvent() { GeneratedPropertyContainer container = createContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -332,6 +350,7 @@ public class GeneratedPropertyContainerBasicTest extends EasyMock.verify(addListener); } + @Test public void testItemAddedEvent_AddedItem() { GeneratedPropertyContainer container = createContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -343,6 +362,7 @@ public class GeneratedPropertyContainerBasicTest extends assertEquals(itemId, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemAddedEvent_IndexOfAddedItem() { GeneratedPropertyContainer container = createContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -355,6 +375,7 @@ public class GeneratedPropertyContainerBasicTest extends assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemRemovedEvent() { GeneratedPropertyContainer container = createContainer(); Object itemId = container.addItem(); @@ -368,6 +389,7 @@ public class GeneratedPropertyContainerBasicTest extends EasyMock.verify(removeListener); } + @Test public void testItemRemovedEvent_RemovedItem() { GeneratedPropertyContainer container = createContainer(); Object itemId = container.addItem(); @@ -380,6 +402,7 @@ public class GeneratedPropertyContainerBasicTest extends assertEquals(itemId, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemRemovedEvent_indexOfRemovedItem() { GeneratedPropertyContainer container = createContainer(); container.addItem(); @@ -393,6 +416,7 @@ public class GeneratedPropertyContainerBasicTest extends assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemRemovedEvent_amountOfRemovedItems() { GeneratedPropertyContainer container = createContainer(); container.addItem(); @@ -429,6 +453,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeIndexOutOfBounds() { GeneratedPropertyContainer ic = createContainer(); try { @@ -444,6 +469,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeIndexOutOfBounds2() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); @@ -460,6 +486,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeZeroRange() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); @@ -477,6 +504,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeNegativeRange() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); @@ -497,6 +525,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); @@ -506,6 +535,7 @@ public class GeneratedPropertyContainerBasicTest extends } // Ticket 8028 + @Test public void testGetItemIdsRangeBaseCase() { GeneratedPropertyContainer ic = createContainer(); String object1 = new String("Obj1"); @@ -534,6 +564,7 @@ public class GeneratedPropertyContainerBasicTest extends } // test getting non-existing property (#10445) + @Test public void testNonExistingProperty() { Container ic = createContainer(); String object1 = new String("Obj1"); @@ -542,6 +573,7 @@ public class GeneratedPropertyContainerBasicTest extends } // test getting null property id (#10445) + @Test public void testNullPropertyId() { Container ic = createContainer(); String object1 = new String("Obj1"); diff --git a/server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java b/server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java index 7ecf59c309..8c7970e554 100644 --- a/server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java +++ b/server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java @@ -1,5 +1,7 @@ package com.vaadin.data.util; +import org.junit.Test; + public class HierarchicalContainerOrderedWrapperTest extends AbstractHierarchicalContainerTestBase { @@ -8,18 +10,22 @@ public class HierarchicalContainerOrderedWrapperTest extends new ContainerHierarchicalWrapper(new IndexedContainer())); } + @Test public void testBasicOperations() { testBasicContainerOperations(createContainer()); } + @Test public void testHierarchicalContainer() { testHierarchicalContainer(createContainer()); } + @Test public void testContainerOrdered() { testContainerOrdered(createContainer()); } + @Test public void testRemoveSubtree() { testRemoveHierarchicalWrapperSubtree(createContainer()); } diff --git a/server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java b/server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java index 0b71b3dff9..280c46efcc 100644 --- a/server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java +++ b/server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java @@ -1,35 +1,48 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; public class HierarchicalContainerTest extends AbstractHierarchicalContainerTestBase { + @Test public void testBasicOperations() { testBasicContainerOperations(new HierarchicalContainer()); } + @Test public void testFiltering() { testContainerFiltering(new HierarchicalContainer()); } + @Test public void testSorting() { testContainerSorting(new HierarchicalContainer()); } + @Test public void testOrdered() { testContainerOrdered(new HierarchicalContainer()); } + @Test public void testHierarchicalSorting() { testHierarchicalSorting(new HierarchicalContainer()); } + @Test public void testSortingAndFiltering() { testContainerSortingAndFiltering(new HierarchicalContainer()); } + @Test public void testRemovingItemsFromFilteredContainer() { HierarchicalContainer container = new HierarchicalContainer(); initializeContainer(container); @@ -50,6 +63,7 @@ public class HierarchicalContainerTest extends } + @Test public void testParentWhenRemovingFilterFromContainer() { HierarchicalContainer container = new HierarchicalContainer(); initializeContainer(container); @@ -67,6 +81,7 @@ public class HierarchicalContainerTest extends } + @Test public void testChangeParentInFilteredContainer() { HierarchicalContainer container = new HierarchicalContainer(); initializeContainer(container); @@ -93,6 +108,7 @@ public class HierarchicalContainerTest extends } + @Test public void testHierarchicalFilteringWithParents() { HierarchicalContainer container = new HierarchicalContainer(); initializeContainer(container); @@ -144,6 +160,7 @@ public class HierarchicalContainerTest extends } + @Test public void testRemoveLastChild() { HierarchicalContainer c = new HierarchicalContainer(); @@ -162,6 +179,7 @@ public class HierarchicalContainerTest extends assertFalse(c.hasChildren("root")); } + @Test public void testRemoveLastChildFromFiltered() { HierarchicalContainer c = new HierarchicalContainer(); @@ -195,6 +213,7 @@ public class HierarchicalContainerTest extends assertFalse(c.hasChildren("root")); } + @Test public void testHierarchicalFilteringWithoutParents() { HierarchicalContainer container = new HierarchicalContainer(); diff --git a/server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java b/server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java index 5828ac88cc..27632846de 100644 --- a/server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java +++ b/server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java @@ -1,10 +1,15 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.List; import org.easymock.Capture; import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container.Indexed.ItemAddEvent; import com.vaadin.data.Container.Indexed.ItemRemoveEvent; @@ -13,31 +18,38 @@ import com.vaadin.data.Item; public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { + @Test public void testBasicOperations() { testBasicContainerOperations(new IndexedContainer()); } + @Test public void testFiltering() { testContainerFiltering(new IndexedContainer()); } + @Test public void testSorting() { testContainerSorting(new IndexedContainer()); } + @Test public void testSortingAndFiltering() { testContainerSortingAndFiltering(new IndexedContainer()); } + @Test public void testContainerOrdered() { testContainerOrdered(new IndexedContainer()); } + @Test public void testContainerIndexed() { testContainerIndexed(new IndexedContainer(), sampleData[2], 2, true, "newItemId", true); } + @Test public void testItemSetChangeListeners() { IndexedContainer container = new IndexedContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -109,6 +121,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { } + @Test public void testAddRemoveContainerFilter() { IndexedContainer container = new IndexedContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -131,6 +144,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { // TODO other tests should check positions after removing filter etc, // here concentrating on listeners + @Test public void testItemSetChangeListenersFiltering() { IndexedContainer container = new IndexedContainer(); ItemSetChangeCounter counter = new ItemSetChangeCounter(); @@ -276,6 +290,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { counter.assertNone(); } + @Test public void testItemAdd_idSequence() { IndexedContainer container = new IndexedContainer(); Object itemId; @@ -293,6 +308,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { assertEquals(Integer.valueOf(4), itemId); } + @Test public void testItemAddRemove_idSequence() { IndexedContainer container = new IndexedContainer(); Object itemId; @@ -308,6 +324,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { Integer.valueOf(2), itemId); } + @Test public void testItemAddedEvent() { IndexedContainer container = new IndexedContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -319,6 +336,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { EasyMock.verify(addListener); } + @Test public void testItemAddedEvent_AddedItem() { IndexedContainer container = new IndexedContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -330,6 +348,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { assertEquals(itemId, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemAddedEvent_IndexOfAddedItem() { IndexedContainer container = new IndexedContainer(); ItemSetChangeListener addListener = createListenerMockFor(container); @@ -342,6 +361,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemRemovedEvent() { IndexedContainer container = new IndexedContainer(); Object itemId = container.addItem(); @@ -355,6 +375,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { EasyMock.verify(removeListener); } + @Test public void testItemRemovedEvent_RemovedItem() { IndexedContainer container = new IndexedContainer(); Object itemId = container.addItem(); @@ -367,6 +388,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { assertEquals(itemId, capturedEvent.getValue().getFirstItemId()); } + @Test public void testItemRemovedEvent_indexOfRemovedItem() { IndexedContainer container = new IndexedContainer(); container.addItem(); @@ -380,6 +402,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { assertEquals(1, capturedEvent.getValue().getFirstIndex()); } + @Test public void testItemRemovedEvent_amountOfRemovedItems() { IndexedContainer container = new IndexedContainer(); container.addItem(); @@ -416,74 +439,46 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { } // Ticket 8028 + @Test(expected = IndexOutOfBoundsException.class) public void testGetItemIdsRangeIndexOutOfBounds() { IndexedContainer ic = new IndexedContainer(); - try { - ic.getItemIds(-1, 10); - fail("Container returned items starting from index -1, something very wrong here!"); - } catch (IndexOutOfBoundsException e) { - // This is expected... - } catch (Exception e) { - // Should not happen! - fail("Container threw unspecified exception when fetching a range of items and the range started from -1"); - } - + ic.getItemIds(-1, 10); } // Ticket 8028 + @Test(expected = IndexOutOfBoundsException.class) public void testGetItemIdsRangeIndexOutOfBounds2() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); - try { - ic.getItemIds(2, 1); - fail("Container returned items starting from index -1, something very wrong here!"); - } catch (IndexOutOfBoundsException e) { - // This is expected... - } catch (Exception e) { - // Should not happen! - fail("Container threw unspecified exception when fetching a out of bounds range of items"); - } - + ic.getItemIds(2, 1); } // Ticket 8028 + @Test public void testGetItemIdsRangeZeroRange() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); - try { - List itemIds = ic.getItemIds(1, 0); - - assertTrue( - "Container returned actual values when asking for 0 items...", - itemIds.isEmpty()); - } catch (Exception e) { - // Should not happen! - fail("Container threw unspecified exception when fetching 0 items..."); - } + List itemIds = ic.getItemIds(1, 0); + assertTrue( + "Container returned actual values when asking for 0 items...", + itemIds.isEmpty()); } // Ticket 8028 + @Test(expected = IllegalArgumentException.class) public void testGetItemIdsRangeNegativeRange() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); - try { - List itemIds = ic.getItemIds(1, -1); - - assertTrue( - "Container returned actual values when asking for -1 items...", - itemIds.isEmpty()); - } catch (IllegalArgumentException e) { - // this is expected - - } catch (Exception e) { - // Should not happen! - fail("Container threw unspecified exception when fetching -1 items..."); - } + List itemIds = ic.getItemIds(1, -1); + assertTrue( + "Container returned actual values when asking for -1 items...", + itemIds.isEmpty()); } // Ticket 8028 + @Test public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); @@ -493,6 +488,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { } // Ticket 8028 + @Test public void testGetItemIdsRangeBaseCase() { IndexedContainer ic = new IndexedContainer(); String object1 = new String("Obj1"); @@ -507,20 +503,15 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { ic.addItem(object4); ic.addItem(object5); - try { - List itemIds = ic.getItemIds(1, 2); + List itemIds = ic.getItemIds(1, 2); - assertTrue(itemIds.contains(object2)); - assertTrue(itemIds.contains(object3)); - assertEquals(2, itemIds.size()); - - } catch (Exception e) { - // Should not happen! - fail("Container threw exception when fetching a range of items "); - } + assertTrue(itemIds.contains(object2)); + assertTrue(itemIds.contains(object3)); + assertEquals(2, itemIds.size()); } // test getting non-existing property (#10445) + @Test public void testNonExistingProperty() { IndexedContainer ic = new IndexedContainer(); String object1 = new String("Obj1"); @@ -529,11 +520,11 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { } // test getting null property id (#10445) + @Test public void testNullPropertyId() { IndexedContainer ic = new IndexedContainer(); String object1 = new String("Obj1"); ic.addItem(object1); assertNull(ic.getContainerProperty(object1, null)); } - } diff --git a/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java b/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java index 6535ba1870..79ce425bae 100644 --- a/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java +++ b/server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java @@ -1,5 +1,8 @@ package com.vaadin.data.util; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -7,11 +10,11 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class NestedMethodPropertyTest extends TestCase { +public class NestedMethodPropertyTest { public static class Address implements Serializable { private String street; @@ -125,20 +128,14 @@ public class NestedMethodPropertyTest extends TestCase { private Person joonas; private Team vaadin; - @Override + @Before public void setUp() { oldMill = new Address("Ruukinkatu 2-4", 20540); joonas = new Person("Joonas", oldMill); vaadin = new Team("Vaadin", joonas); } - @Override - public void tearDown() { - vaadin = null; - joonas = null; - oldMill = null; - } - + @Test public void testSingleLevelNestedSimpleProperty() { NestedMethodProperty nameProperty = new NestedMethodProperty( vaadin, "name"); @@ -147,6 +144,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals("Vaadin", nameProperty.getValue()); } + @Test public void testSingleLevelNestedObjectProperty() { NestedMethodProperty managerProperty = new NestedMethodProperty( vaadin, "manager"); @@ -155,6 +153,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals(joonas, managerProperty.getValue()); } + @Test public void testMultiLevelNestedProperty() { NestedMethodProperty managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); @@ -191,6 +190,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals(Boolean.TRUE, booleanProperty.getValue()); } + @Test public void testEmptyPropertyName() { try { new NestedMethodProperty(vaadin, ""); @@ -207,6 +207,7 @@ public class NestedMethodPropertyTest extends TestCase { } } + @Test public void testInvalidPropertyName() { try { new NestedMethodProperty(vaadin, "."); @@ -234,6 +235,7 @@ public class NestedMethodPropertyTest extends TestCase { } } + @Test public void testInvalidNestedPropertyName() { try { new NestedMethodProperty(vaadin, "member"); @@ -257,6 +259,7 @@ public class NestedMethodPropertyTest extends TestCase { } } + @Test public void testNullNestedProperty() { NestedMethodProperty managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); @@ -276,6 +279,7 @@ public class NestedMethodPropertyTest extends TestCase { } + @Test public void testMultiLevelNestedPropertySetValue() { NestedMethodProperty managerNameProperty = new NestedMethodProperty( vaadin, "manager.name"); @@ -305,6 +309,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals("Other street", streetProperty.getValue()); } + @Test public void testSerialization() throws IOException, ClassNotFoundException { NestedMethodProperty streetProperty = new NestedMethodProperty( vaadin, "manager.address.street"); @@ -317,6 +322,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals("Ruukinkatu 2-4", property2.getValue()); } + @Test public void testSerializationWithIntermediateNull() throws IOException, ClassNotFoundException { vaadin.setManager(null); @@ -331,6 +337,7 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertNull(property2.getValue()); } + @Test public void testIsReadOnly() { NestedMethodProperty streetProperty = new NestedMethodProperty( vaadin, "manager.address.street"); diff --git a/server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java b/server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java index 99ca58ba42..e0307034cf 100644 --- a/server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java +++ b/server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java @@ -1,10 +1,9 @@ package com.vaadin.data.util; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; -public class ObjectPropertyTest extends TestCase { +public class ObjectPropertyTest { public static class TestSuperClass { private String name; @@ -32,6 +31,7 @@ public class ObjectPropertyTest extends TestCase { private TestSuperClass super1 = new TestSuperClass("super1"); private TestSubClass sub1 = new TestSubClass("sub1"); + @Test public void testSimple() { ObjectProperty prop1 = new ObjectProperty( super1, TestSuperClass.class); @@ -46,6 +46,7 @@ public class ObjectPropertyTest extends TestCase { Assert.assertEquals("Subclass: sub1", prop2.getValue().getName()); } + @Test public void testSetValueObjectSuper() { ObjectProperty prop = new ObjectProperty( super1, TestSuperClass.class); @@ -55,6 +56,7 @@ public class ObjectPropertyTest extends TestCase { Assert.assertEquals("super2", prop.getValue().getName()); } + @Test public void testSetValueObjectSub() { ObjectProperty prop = new ObjectProperty( sub1, TestSubClass.class); @@ -64,6 +66,7 @@ public class ObjectPropertyTest extends TestCase { Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); } + @Test public void testSetValueStringSuper() { ObjectProperty prop = new ObjectProperty( super1, TestSuperClass.class); @@ -73,6 +76,7 @@ public class ObjectPropertyTest extends TestCase { Assert.assertEquals("super2", prop.getValue().getName()); } + @Test public void testSetValueStringSub() { ObjectProperty prop = new ObjectProperty( sub1, TestSubClass.class); @@ -82,6 +86,7 @@ public class ObjectPropertyTest extends TestCase { Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); } + @Test public void testMixedGenerics() { ObjectProperty prop = new ObjectProperty( sub1); diff --git a/server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java b/server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java index 042f260be8..fdfc2199b6 100644 --- a/server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java +++ b/server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java @@ -6,11 +6,10 @@ import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; -public class PerformanceTestIndexedContainerTest extends TestCase { +public class PerformanceTestIndexedContainerTest { private static final int REPEATS = 10; private final static int ITEMS = 50000; @@ -21,6 +20,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase { private static final long ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD = 5000; private static final long ADD_ITEMS_CONSTRUCTOR_FAIL_THRESHOLD = 200; + @Test public void testAddItemPerformance() { Collection times = new ArrayList(); for (int j = 0; j < REPEATS; ++j) { @@ -35,6 +35,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase { ADD_ITEM_FAIL_THRESHOLD); } + @Test public void testAddItemAtPerformance() { Collection times = new ArrayList(); for (int j = 0; j < REPEATS; ++j) { @@ -49,6 +50,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase { ADD_ITEM_AT_FAIL_THRESHOLD); } + @Test public void testAddItemAfterPerformance() { Object initialId = "Item0"; Collection times = new ArrayList(); @@ -65,6 +67,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase { ADD_ITEM_AFTER_FAIL_THRESHOLD); } + @Test public void testAddItemAfterLastPerformance() { // TODO running with less items because slow otherwise Collection times = new ArrayList(); @@ -81,6 +84,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase { ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD); } + @Test public void testAddItemsConstructorPerformance() { Collection items = new ArrayList(50000); for (int i = 0; i < ITEMS; ++i) { diff --git a/server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java b/server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java index 9d662b2599..86f3968116 100644 --- a/server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java +++ b/server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java @@ -7,14 +7,15 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Property; import com.vaadin.data.util.NestedMethodPropertyTest.Person; -public class PropertyDescriptorTest extends TestCase { +public class PropertyDescriptorTest { + + @Test public void testMethodPropertyDescriptorSerialization() throws Exception { PropertyDescriptor[] pds = Introspector.getBeanInfo(Person.class) .getPropertyDescriptors(); @@ -40,6 +41,7 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertEquals("John", property.getValue()); } + @Test public void testSimpleNestedPropertyDescriptorSerialization() throws Exception { NestedPropertyDescriptor pd = new NestedPropertyDescriptor( @@ -55,6 +57,7 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertEquals("John", property.getValue()); } + @Test public void testNestedPropertyDescriptorSerialization() throws Exception { NestedPropertyDescriptor pd = new NestedPropertyDescriptor( "address.street", Person.class); @@ -69,6 +72,7 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertNull(property.getValue()); } + @Test public void testMethodPropertyDescriptorWithPrimitivePropertyType() throws Exception { MethodPropertyDescriptor pd = new MethodPropertyDescriptor( diff --git a/server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java b/server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java index ff83db4437..b957cb7f20 100644 --- a/server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java +++ b/server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java @@ -2,15 +2,16 @@ package com.vaadin.data.util; import java.util.Iterator; -import junit.framework.TestCase; - import org.easymock.EasyMock; +import org.junit.After; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Item.PropertySetChangeEvent; import com.vaadin.data.Item.PropertySetChangeListener; -public class PropertySetItemTest extends TestCase { +public class PropertySetItemTest { private static final String ID1 = "id1"; private static final String ID2 = "id2"; @@ -27,8 +28,8 @@ public class PropertySetItemTest extends TestCase { private PropertySetChangeListener propertySetListenerMock; private PropertySetChangeListener propertySetListenerMock2; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { prop1 = new ObjectProperty(VALUE1, String.class); prop2 = new ObjectProperty(VALUE2, String.class); prop3 = new ObjectProperty(VALUE3, String.class); @@ -39,8 +40,8 @@ public class PropertySetItemTest extends TestCase { .createMock(PropertySetChangeListener.class); } - @Override - protected void tearDown() throws Exception { + @After + public void tearDown() { prop1 = null; prop2 = null; prop3 = null; @@ -53,12 +54,14 @@ public class PropertySetItemTest extends TestCase { return new PropertysetItem(); } + @Test public void testEmptyItem() { PropertysetItem item = createPropertySetItem(); Assert.assertNotNull(item.getItemPropertyIds()); Assert.assertEquals(0, item.getItemPropertyIds().size()); } + @Test public void testGetProperty() { PropertysetItem item = createPropertySetItem(); @@ -70,6 +73,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertNull(item.getItemProperty(ID2)); } + @Test public void testAddSingleProperty() { PropertysetItem item = createPropertySetItem(); @@ -80,6 +84,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(prop1, item.getItemProperty(ID1)); } + @Test public void testAddMultipleProperties() { PropertysetItem item = createPropertySetItem(); @@ -96,6 +101,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(3, item.getItemPropertyIds().size()); } + @Test public void testAddedPropertyOrder() { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); @@ -108,6 +114,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(ID3, it.next()); } + @Test public void testAddPropertyTwice() { PropertysetItem item = createPropertySetItem(); Assert.assertTrue(item.addItemProperty(ID1, prop1)); @@ -117,6 +124,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(prop1, item.getItemProperty(ID1)); } + @Test public void testCannotChangeProperty() { PropertysetItem item = createPropertySetItem(); Assert.assertTrue(item.addItemProperty(ID1, prop1)); @@ -129,6 +137,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(prop1, item.getItemProperty(ID1)); } + @Test public void testRemoveProperty() { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); @@ -138,6 +147,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertNull(item.getItemProperty(ID1)); } + @Test public void testRemovePropertyOrder() { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); @@ -151,11 +161,13 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(ID3, it.next()); } + @Test public void testRemoveNonExistentListener() { PropertysetItem item = createPropertySetItem(); item.removeListener(propertySetListenerMock); } + @Test public void testRemoveListenerTwice() { PropertysetItem item = createPropertySetItem(); item.addListener(propertySetListenerMock); @@ -163,6 +175,7 @@ public class PropertySetItemTest extends TestCase { item.removeListener(propertySetListenerMock); } + @Test public void testAddPropertyNotification() { // exactly one notification each time PropertysetItem item = createPropertySetItem(); @@ -188,6 +201,7 @@ public class PropertySetItemTest extends TestCase { EasyMock.verify(propertySetListenerMock); } + @Test public void testRemovePropertyNotification() { // exactly one notification each time PropertysetItem item = createPropertySetItem(); @@ -214,12 +228,14 @@ public class PropertySetItemTest extends TestCase { EasyMock.verify(propertySetListenerMock); } + @Test public void testItemEqualsNull() { PropertysetItem item = createPropertySetItem(); Assert.assertFalse(item.equals(null)); } + @Test public void testEmptyItemEquals() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -227,6 +243,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertTrue(item1.equals(item2)); } + @Test public void testItemEqualsSingleProperty() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -255,6 +272,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertFalse(item2.equals(item1)); } + @Test public void testItemEqualsMultipleProperties() { PropertysetItem item1 = createPropertySetItem(); item1.addItemProperty(ID1, prop1); @@ -272,6 +290,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertTrue(item2.equals(item3)); } + @Test public void testItemEqualsPropertyOrder() { PropertysetItem item1 = createPropertySetItem(); item1.addItemProperty(ID1, prop1); @@ -284,6 +303,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertFalse(item1.equals(item2)); } + @Test public void testEqualsSingleListener() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -299,6 +319,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertTrue(item2.equals(item1)); } + @Test public void testEqualsMultipleListeners() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -317,6 +338,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertTrue(item2.equals(item1)); } + @Test public void testEqualsAddRemoveListener() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -328,6 +350,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertTrue(item2.equals(item1)); } + @Test public void testItemHashCodeEmpty() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -335,6 +358,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(item1.hashCode(), item2.hashCode()); } + @Test public void testItemHashCodeAddProperties() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -351,6 +375,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(item1.hashCode(), item2.hashCode()); } + @Test public void testItemHashCodeAddListeners() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -365,6 +390,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(item1.hashCode(), item2.hashCode()); } + @Test public void testItemHashCodeAddRemoveProperty() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -375,6 +401,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(item1.hashCode(), item2.hashCode()); } + @Test public void testItemHashCodeAddRemoveListener() { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); @@ -385,6 +412,7 @@ public class PropertySetItemTest extends TestCase { Assert.assertEquals(item1.hashCode(), item2.hashCode()); } + @Test public void testToString() { // toString() behavior is specified in the class javadoc PropertysetItem item = createPropertySetItem(); diff --git a/server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java index 1f42f4e935..21ce685445 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java @@ -1,6 +1,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; @@ -12,12 +13,14 @@ public class AndOrFilterTest extends protected Item item1 = new BeanItem(1); protected Item item2 = new BeanItem(2); + @Test public void testNoFilterAnd() { Filter filter = new And(); Assert.assertTrue(filter.passesFilter(null, item1)); } + @Test public void testSingleFilterAnd() { Filter filter = new And(new SameItemFilter(item1)); @@ -25,6 +28,7 @@ public class AndOrFilterTest extends Assert.assertFalse(filter.passesFilter(null, item2)); } + @Test public void testTwoFilterAnd() { Filter filter1 = new And(new SameItemFilter(item1), new SameItemFilter( item1)); @@ -38,6 +42,7 @@ public class AndOrFilterTest extends Assert.assertFalse(filter2.passesFilter(null, item2)); } + @Test public void testThreeFilterAnd() { Filter filter1 = new And(new SameItemFilter(item1), new SameItemFilter( item1), new SameItemFilter(item1)); @@ -51,12 +56,14 @@ public class AndOrFilterTest extends Assert.assertFalse(filter2.passesFilter(null, item2)); } + @Test public void testNoFilterOr() { Filter filter = new Or(); Assert.assertFalse(filter.passesFilter(null, item1)); } + @Test public void testSingleFilterOr() { Filter filter = new Or(new SameItemFilter(item1)); @@ -64,6 +71,7 @@ public class AndOrFilterTest extends Assert.assertFalse(filter.passesFilter(null, item2)); } + @Test public void testTwoFilterOr() { Filter filter1 = new Or(new SameItemFilter(item1), new SameItemFilter( item1)); @@ -77,6 +85,7 @@ public class AndOrFilterTest extends Assert.assertTrue(filter2.passesFilter(null, item2)); } + @Test public void testThreeFilterOr() { Filter filter1 = new Or(new SameItemFilter(item1), new SameItemFilter( item1), new SameItemFilter(item1)); @@ -90,6 +99,7 @@ public class AndOrFilterTest extends Assert.assertTrue(filter2.passesFilter(null, item2)); } + @Test public void testAndEqualsHashCode() { Filter filter0 = new And(); Filter filter0b = new And(); @@ -129,6 +139,7 @@ public class AndOrFilterTest extends Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } + @Test public void testOrEqualsHashCode() { Filter filter0 = new Or(); Filter filter0b = new Or(); @@ -168,6 +179,7 @@ public class AndOrFilterTest extends Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } + @Test public void testAndAppliesToProperty() { Filter filter0 = new And(); Filter filter1a = new And(new SameItemFilter(item1, "a")); @@ -199,6 +211,7 @@ public class AndOrFilterTest extends Assert.assertFalse(filter3abc.appliesToProperty("d")); } + @Test public void testOrAppliesToProperty() { Filter filter0 = new Or(); Filter filter1a = new Or(new SameItemFilter(item1, "a")); diff --git a/server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java index fc5ffb9b56..116d70e188 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import java.util.Date; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; @@ -65,6 +66,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { itemB = null; } + @Test public void testCompareString() { Assert.assertFalse(equalB.passesFilter(null, itemEmpty)); Assert.assertFalse(equalB.passesFilter(null, itemA)); @@ -92,6 +94,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { Assert.assertFalse(lessEqualB.passesFilter(null, itemC)); } + @Test public void testCompareWithNull() { // null comparisons: null is less than any other value Assert.assertFalse(equalB.passesFilter(null, itemNull)); @@ -113,6 +116,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { Assert.assertTrue(lessEqualNull.passesFilter(null, itemA)); } + @Test public void testCompareInteger() { int negative = -1; int zero = 0; @@ -154,6 +158,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive)); } + @Test public void testCompareBigDecimal() { BigDecimal negative = new BigDecimal(-1); BigDecimal zero = new BigDecimal(0); @@ -207,6 +212,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { } + @Test public void testCompareDate() { Date now = new Date(); // new Date() is only accurate to the millisecond, so repeating it gives @@ -250,6 +256,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { Assert.assertFalse(beforeOrNow.passesFilter(null, itemLater)); } + @Test public void testCompareAppliesToProperty() { Filter filterA = new Equal("a", 1); Filter filterB = new Equal("b", 1); @@ -260,6 +267,7 @@ public class CompareFilterTest extends AbstractFilterTestBase { Assert.assertTrue(filterB.appliesToProperty("b")); } + @Test public void testCompareEqualsHashCode() { // most checks with Equal filter, then only some with others Filter equalNull2 = new Equal(PROPERTY1, null); diff --git a/server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java index 953bf3cd65..7a2ab3af7e 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java @@ -1,6 +1,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; @@ -9,6 +10,7 @@ import com.vaadin.data.util.PropertysetItem; public class IsNullFilterTest extends AbstractFilterTestBase { + @Test public void testIsNull() { Item item1 = new PropertysetItem(); item1.addItemProperty("a", new ObjectProperty(null, @@ -30,6 +32,7 @@ public class IsNullFilterTest extends AbstractFilterTestBase { Assert.assertTrue(filter2.passesFilter(null, item2)); } + @Test public void testIsNullAppliesToProperty() { Filter filterA = new IsNull("a"); Filter filterB = new IsNull("b"); @@ -40,6 +43,7 @@ public class IsNullFilterTest extends AbstractFilterTestBase { Assert.assertTrue(filterB.appliesToProperty("b")); } + @Test public void testIsNullEqualsHashCode() { Filter filter1 = new IsNull("a"); Filter filter1b = new IsNull("a"); diff --git a/server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java index 9ba5168ac9..d43650101d 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java @@ -17,6 +17,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Item; import com.vaadin.data.util.ObjectProperty; @@ -28,6 +29,7 @@ public class LikeFilterTest extends AbstractFilterTestBase { protected Item item2 = new PropertysetItem(); protected Item item3 = new PropertysetItem(); + @Test public void testLikeWithNulls() { Like filter = new Like("value", "a"); diff --git a/server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java index 310b749ce2..e797b484f8 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java @@ -1,6 +1,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; @@ -11,6 +12,7 @@ public class NotFilterTest extends AbstractFilterTestBase { protected Item item1 = new BeanItem(1); protected Item item2 = new BeanItem(2); + @Test public void testNot() { Filter origFilter = new SameItemFilter(item1); Filter filter = new Not(origFilter); @@ -21,6 +23,7 @@ public class NotFilterTest extends AbstractFilterTestBase { Assert.assertTrue(filter.passesFilter(null, item2)); } + @Test public void testANotAppliesToProperty() { Filter filterA = new Not(new SameItemFilter(item1, "a")); Filter filterB = new Not(new SameItemFilter(item1, "b")); @@ -31,6 +34,7 @@ public class NotFilterTest extends AbstractFilterTestBase { Assert.assertTrue(filterB.appliesToProperty("b")); } + @Test public void testNotEqualsHashCode() { Filter origFilter = new SameItemFilter(item1); Filter filter1 = new Not(origFilter); diff --git a/server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java b/server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java index fcaff6f2c3..e085c934c9 100644 --- a/server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java +++ b/server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java @@ -1,6 +1,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; +import org.junit.Test; public class SimpleStringFilterTest extends AbstractFilterTestBase { @@ -25,6 +26,7 @@ public class SimpleStringFilterTest extends .passesFilter(null, getTestItem()); } + @Test public void testStartsWithCaseSensitive() { Assert.assertTrue(passes(PROPERTY1, "ab", false, true)); Assert.assertTrue(passes(PROPERTY1, "", false, true)); @@ -33,12 +35,14 @@ public class SimpleStringFilterTest extends Assert.assertFalse(passes(PROPERTY1, "AB", false, true)); } + @Test public void testStartsWithCaseInsensitive() { Assert.assertTrue(passes(PROPERTY1, "AB", true, true)); Assert.assertTrue(passes(PROPERTY2, "te", true, true)); Assert.assertFalse(passes(PROPERTY2, "AB", true, true)); } + @Test public void testContainsCaseSensitive() { Assert.assertTrue(passes(PROPERTY1, "ab", false, false)); Assert.assertTrue(passes(PROPERTY1, "abcde", false, false)); @@ -50,6 +54,7 @@ public class SimpleStringFilterTest extends Assert.assertFalse(passes(PROPERTY1, "es", false, false)); } + @Test public void testContainsCaseInsensitive() { Assert.assertTrue(passes(PROPERTY1, "AB", true, false)); Assert.assertTrue(passes(PROPERTY1, "aBcDe", true, false)); @@ -61,6 +66,7 @@ public class SimpleStringFilterTest extends Assert.assertFalse(passes(PROPERTY2, "ab", true, false)); } + @Test public void testAppliesToProperty() { SimpleStringFilter filter = f(PROPERTY1, "ab", false, true); Assert.assertTrue(filter.appliesToProperty(PROPERTY1)); @@ -68,6 +74,7 @@ public class SimpleStringFilterTest extends Assert.assertFalse(filter.appliesToProperty("other")); } + @Test public void testEqualsHashCode() { SimpleStringFilter filter = f(PROPERTY1, "ab", false, true); @@ -115,10 +122,12 @@ public class SimpleStringFilterTest extends Assert.assertEquals(f4.hashCode(), f4b.hashCode()); } + @Test public void testNonExistentProperty() { Assert.assertFalse(passes("other1", "ab", false, true)); } + @Test public void testNullValueForProperty() { TestItem item = createTestItem(); item.addItemProperty("other1", new NullProperty()); diff --git a/server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java b/server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java index d2c7ad85ed..9c3f6c0eaa 100644 --- a/server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java +++ b/server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java @@ -19,6 +19,6 @@ import com.vaadin.data.util.sqlcontainer.query.TableQueryTest; FreeformQueryTest.class, RowIdTest.class, SQLContainerTest.class, SQLContainerTableQueryTest.class, ColumnPropertyTest.class, TableQueryTest.class, SQLGeneratorsTest.class, UtilTest.class, - TicketTests.class, BetweenTest.class, ReadOnlyRowIdTest.class }) + TicketTest.class, BetweenTest.class, ReadOnlyRowIdTest.class }) public class AllTests { } diff --git a/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java b/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java similarity index 99% rename from server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java rename to server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java index e180e3f3e7..2030096e82 100644 --- a/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java +++ b/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java @@ -26,7 +26,7 @@ import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; import com.vaadin.ui.Table; import com.vaadin.ui.Window; -public class TicketTests { +public class TicketTest { private JDBCConnectionPool connectionPool; diff --git a/server/src/test/java/com/vaadin/server/JSONSerializerTest.java b/server/src/test/java/com/vaadin/server/JSONSerializerTest.java index 6c57445564..bb0be09870 100644 --- a/server/src/test/java/com/vaadin/server/JSONSerializerTest.java +++ b/server/src/test/java/com/vaadin/server/JSONSerializerTest.java @@ -21,8 +21,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.server.JsonCodec.BeanProperty; import com.vaadin.shared.communication.UidlValue; @@ -40,10 +40,11 @@ import elemental.json.JsonValue; * @since 7.0 * */ -public class JSONSerializerTest extends TestCase { +public class JSONSerializerTest { HashMap stringToStateMap; HashMap stateToStringMap; + @Test public void testStringToBeanMapSerialization() throws Exception { Type mapType = getClass().getDeclaredField("stringToStateMap") .getGenericType(); @@ -63,6 +64,7 @@ public class JSONSerializerTest extends TestCase { ensureDecodedCorrectly(stringToStateMap, encodedMap, mapType); } + @Test public void testBeanToStringMapSerialization() throws Exception { Type mapType = getClass().getDeclaredField("stateToStringMap") .getGenericType(); @@ -80,34 +82,30 @@ public class JSONSerializerTest extends TestCase { ensureDecodedCorrectly(stateToStringMap, encodedMap, mapType); } + @Test public void testNullLegacyValue() throws JsonException { JsonArray inputArray = Json.createArray(); inputArray.set(0, "n"); inputArray.set(1, Json.createNull()); UidlValue decodedObject = (UidlValue) JsonCodec.decodeInternalType( UidlValue.class, true, inputArray, null); - assertNull(decodedObject.getValue()); + Assert.assertNull(decodedObject.getValue()); } + @Test(expected = JsonException.class) public void testNullTypeOtherValue() { - try { - JsonArray inputArray = Json.createArray(); - inputArray.set(0, "n"); - inputArray.set(1, "a"); - UidlValue decodedObject = (UidlValue) JsonCodec.decodeInternalType( - UidlValue.class, true, inputArray, null); - - throw new AssertionFailedError("No JsonException thrown"); - } catch (JsonException e) { - // Should throw exception - } + JsonArray inputArray = Json.createArray(); + inputArray.set(0, "n"); + inputArray.set(1, "a"); + UidlValue decodedObject = (UidlValue) JsonCodec.decodeInternalType( + UidlValue.class, true, inputArray, null); } private void ensureDecodedCorrectly(Object original, JsonValue encoded, Type type) throws Exception { Object serverSideDecoded = JsonCodec.decodeInternalOrCustomType(type, encoded, null); - assertTrue("Server decoded", equals(original, serverSideDecoded)); + Assert.assertTrue("Server decoded", equals(original, serverSideDecoded)); } diff --git a/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index 3f940ae0a7..aba29bf9a5 100644 --- a/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -9,22 +9,23 @@ import java.net.URL; import javax.servlet.http.HttpServletRequest; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class TestAbstractApplicationServletStaticFilesLocation extends TestCase { +public class TestAbstractApplicationServletStaticFilesLocation { VaadinServlet servlet; // private Method getStaticFilesLocationMethod; - @Override - protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() throws Exception { servlet = new VaadinServlet(); servlet.init(new MockServletConfig()); } + @Test public void testWidgetSetLocation() throws Exception { String location; @@ -33,30 +34,30 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase // should return . (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", ""); - assertEquals(".", location); + Assert.assertEquals(".", location); // http://dummy.host:8080/contextpath/servlet/ // should return ./.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", "/"); - assertEquals("./..", location); + Assert.assertEquals("./..", location); // http://dummy.host:8080/servlet // should return "." location = testLocation("http://dummy.host:8080", "", "/servlet", ""); - assertEquals(".", location); + Assert.assertEquals(".", location); // http://dummy.host/contextpath/servlet/extra/stuff // should return ./../.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host", "/contextpath", "/servlet", "/extra/stuff"); - assertEquals("./../..", location); + Assert.assertEquals("./../..", location); // http://dummy.host/context/path/servlet/extra/stuff // should return ./../.. (relative url resolving to /context/path) location = testLocation("http://dummy.host", "/context/path", "/servlet", "/extra/stuff"); - assertEquals("./../..", location); + Assert.assertEquals("./../..", location); /* Include requests */ // Include request support dropped with support for portlet1 diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java similarity index 97% rename from server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java rename to server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java index bf2b809529..2d15826cb7 100644 --- a/server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java +++ b/server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java @@ -13,7 +13,7 @@ import static org.mockito.Matchers.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class VaadinPortletRequestTests { +public class VaadinPortletRequestTest { private PortletRequest request; private VaadinPortletRequest sut; diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java similarity index 99% rename from server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java rename to server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java index 38f3b85043..d8c66e312f 100644 --- a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java +++ b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java @@ -30,7 +30,7 @@ import org.mockito.Mockito; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.ui.UI; -public class VaadinPortletServiceTests { +public class VaadinPortletServiceTest { private VaadinPortletService sut; private VaadinPortletRequest request; diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletTest.java similarity index 98% rename from server/src/test/java/com/vaadin/server/VaadinPortletTests.java rename to server/src/test/java/com/vaadin/server/VaadinPortletTest.java index f92aa0dcaa..4e74f91708 100644 --- a/server/src/test/java/com/vaadin/server/VaadinPortletTests.java +++ b/server/src/test/java/com/vaadin/server/VaadinPortletTest.java @@ -30,7 +30,7 @@ import com.vaadin.server.VaadinPortlet.VaadinGateInRequest; import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest; import com.vaadin.server.VaadinPortlet.VaadinWebSpherePortalRequest; -public class VaadinPortletTests { +public class VaadinPortletTest { private VaadinPortlet sut; private PortletRequest portletRequest; diff --git a/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java b/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java index f9e12ce75f..a1a833e8af 100644 --- a/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java +++ b/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java @@ -28,9 +28,6 @@ import org.junit.Test; import com.vaadin.server.communication.AtmospherePushConnection.State; import com.vaadin.ui.UI; -/** - * @author Vaadin Ltd - */ public class AtmospherePushConnectionTest { @Test public void testSerialization() throws Exception { diff --git a/server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java b/server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java index a61c0c9986..766c2309a0 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java @@ -17,7 +17,8 @@ package com.vaadin.tests.data.converter; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.DefaultConverterFactory; @@ -25,7 +26,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; -public class ConverterFactoryTest extends TestCase { +public class ConverterFactoryTest { public static class ConvertTo42 implements Converter { @@ -67,6 +68,7 @@ public class ConverterFactoryTest extends TestCase { } } + @Test public void testApplicationConverterFactoryInBackgroundThread() { VaadinSession.setCurrent(null); final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession( @@ -83,9 +85,10 @@ public class ConverterFactoryTest extends TestCase { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - assertEquals(42, tf.getConvertedValue()); + Assert.assertEquals(42, tf.getConvertedValue()); } + @Test public void testApplicationConverterFactoryForDetachedComponent() { final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession( null); @@ -97,9 +100,10 @@ public class ConverterFactoryTest extends TestCase { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - assertEquals(42, tf.getConvertedValue()); + Assert.assertEquals(42, tf.getConvertedValue()); } + @Test public void testApplicationConverterFactoryForDifferentThanCurrentApplication() { final VaadinSession fieldAppWithCustomIntegerConverter = new AlwaysLockedVaadinSession( null); @@ -117,6 +121,6 @@ public class ConverterFactoryTest extends TestCase { // The application converter always returns 42. Application.getCurrent() // should not be used - assertEquals(42, tf.getConvertedValue()); + Assert.assertEquals(42, tf.getConvertedValue()); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java index d767430cc1..2dbdaceb3b 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java @@ -2,20 +2,24 @@ package com.vaadin.tests.data.converter; import java.util.Date; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.DateToLongConverter; -public class DateToLongConverterTest extends TestCase { +public class DateToLongConverterTest { DateToLongConverter converter = new DateToLongConverter(); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Long.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Long.class, null)); } + @Test public void testValueConversion() { - assertEquals(Long.valueOf(946677600000l), + Assert.assertEquals(Long.valueOf(946677600000l), converter.convertToModel(new Date(100, 0, 1), Long.class, null)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java index 46dca6d13e..dd71609d02 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java @@ -3,23 +3,26 @@ package com.vaadin.tests.data.converter; import java.util.Date; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.DateToSqlDateConverter; -public class DateToSqlDateConverterTest extends TestCase { +public class DateToSqlDateConverterTest { DateToSqlDateConverter converter = new DateToSqlDateConverter(); + @Test public void testNullConversion() { - assertEquals(null, + Assert.assertEquals(null, converter.convertToModel(null, java.sql.Date.class, null)); } + @Test public void testValueConversion() { Date testDate = new Date(100, 0, 1); long time = testDate.getTime(); - assertEquals(testDate, converter.convertToModel( + Assert.assertEquals(testDate, converter.convertToModel( new java.sql.Date(time), java.sql.Date.class, Locale.ENGLISH)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java index 06d407c9f4..48ebebdaff 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java @@ -18,36 +18,42 @@ package com.vaadin.tests.data.converter; import java.math.BigDecimal; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.StringToBigDecimalConverter; -public class StringToBigDecimalConverterTest extends TestCase { +public class StringToBigDecimalConverterTest { StringToBigDecimalConverter converter = new StringToBigDecimalConverter(); + @Test public void testNullConversion() { - assertEquals(null, + Assert.assertEquals(null, converter.convertToModel(null, BigDecimal.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", BigDecimal.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", BigDecimal.class, null)); } + @Test public void testValueParsing() { BigDecimal converted = converter.convertToModel("10", BigDecimal.class, null); BigDecimal expected = new BigDecimal(10); - assertEquals(expected, converted); + Assert.assertEquals(expected, converted); } + @Test public void testValueFormatting() { BigDecimal bd = new BigDecimal(12.5); String expected = "12,5"; String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - assertEquals(expected, converted); + Assert.assertEquals(expected, converted); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java index 057017790d..312595746d 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java @@ -18,40 +18,47 @@ package com.vaadin.tests.data.converter; import java.math.BigInteger; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.StringToBigIntegerConverter; -public class StringToBigIntegerConverterTest extends TestCase { +public class StringToBigIntegerConverterTest { StringToBigIntegerConverter converter = new StringToBigIntegerConverter(); + @Test public void testNullConversion() { - assertEquals("Null value was converted incorrectly", null, + Assert.assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, BigInteger.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals("Empty value was converted incorrectly", null, + Assert.assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", BigInteger.class, null)); } + @Test public void testValueParsing() { String bigInt = "1180591620717411303424"; // 2^70 > 2^63 - 1 BigInteger converted = converter.convertToModel(bigInt, BigInteger.class, null); BigInteger expected = new BigInteger(bigInt); - assertEquals("Value bigger than max long was converted incorrectly", + Assert.assertEquals( + "Value bigger than max long was converted incorrectly", expected, converted); } + @Test public void testValueFormatting() { BigInteger bd = new BigInteger("1000"); String expected = "1.000"; String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - assertEquals("Value with specific locale was converted incorrectly", + Assert.assertEquals( + "Value with specific locale was converted incorrectly", expected, converted); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java index 6e81af97a3..16bb5b1a64 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java @@ -1,57 +1,75 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; - -import com.vaadin.data.util.converter.StringToBooleanConverter; - import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -public class StringToBooleanConverterTest extends TestCase { +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.util.converter.StringToBooleanConverter; + +public class StringToBooleanConverterTest { StringToBooleanConverter converter = new StringToBooleanConverter(); - StringToBooleanConverter yesNoConverter = new StringToBooleanConverter("yes","no"); + StringToBooleanConverter yesNoConverter = new StringToBooleanConverter( + "yes", "no"); StringToBooleanConverter localeConverter = new StringToBooleanConverter() { @Override public String getFalseString(Locale locale) { - return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG,locale).format(new Date(3000000000000L)); + return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG, + locale).format(new Date(3000000000000L)); } @Override public String getTrueString(Locale locale) { - return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG,locale).format(new Date(2000000000000L)); + return SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG, + locale).format(new Date(2000000000000L)); } }; + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Boolean.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Boolean.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Boolean.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Boolean.class, null)); } + @Test public void testValueConversion() { - assertTrue(converter.convertToModel("true", Boolean.class, null)); - assertFalse(converter.convertToModel("false", Boolean.class, null)); + Assert.assertTrue(converter.convertToModel("true", Boolean.class, null)); + Assert.assertFalse(converter.convertToModel("false", Boolean.class, + null)); } + @Test public void testYesNoValueConversion() { - assertTrue(yesNoConverter.convertToModel("yes", Boolean.class, null)); - assertFalse(yesNoConverter.convertToModel("no", Boolean.class, null)); + Assert.assertTrue(yesNoConverter.convertToModel("yes", Boolean.class, + null)); + Assert.assertFalse(yesNoConverter.convertToModel("no", Boolean.class, + null)); - assertEquals("yes", yesNoConverter.convertToPresentation(true, String.class, null)); - assertEquals("no", yesNoConverter.convertToPresentation(false, String.class, null)); + Assert.assertEquals("yes", + yesNoConverter.convertToPresentation(true, String.class, null)); + Assert.assertEquals("no", + yesNoConverter.convertToPresentation(false, String.class, null)); } - + @Test public void testLocale() { - assertEquals("May 18, 2033", localeConverter.convertToPresentation(true, String.class, Locale.US)); - assertEquals("January 24, 2065", localeConverter.convertToPresentation(false, String.class, Locale.US)); + Assert.assertEquals("May 18, 2033", localeConverter + .convertToPresentation(true, String.class, Locale.US)); + Assert.assertEquals("January 24, 2065", localeConverter + .convertToPresentation(false, String.class, Locale.US)); - assertEquals("18. Mai 2033", localeConverter.convertToPresentation(true, String.class, Locale.GERMANY)); - assertEquals("24. Januar 2065", localeConverter.convertToPresentation(false, String.class, Locale.GERMANY)); + Assert.assertEquals("18. Mai 2033", localeConverter + .convertToPresentation(true, String.class, Locale.GERMANY)); + Assert.assertEquals("24. Januar 2065", localeConverter + .convertToPresentation(false, String.class, Locale.GERMANY)); } - } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java index 3859d03cc3..2de72093d8 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java @@ -1,55 +1,61 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToByteConverter; -public class StringToByteConverterTest extends TestCase { +public class StringToByteConverterTest { StringToByteConverter converter = new StringToByteConverter(); Converter reverseConverter = new ReverseConverter( converter); + @Test public void testNullConversion() { - assertEquals("Null value was converted incorrectly", null, + Assert.assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Byte.class, null)); } + @Test public void testReverseNullConversion() { - assertEquals("Null value reversely was converted incorrectly", null, - reverseConverter.convertToModel(null, String.class, null)); + Assert.assertEquals("Null value reversely was converted incorrectly", + null, reverseConverter.convertToModel(null, String.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals("Empty value was converted incorrectly", null, + Assert.assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Byte.class, null)); } + @Test public void testValueConversion() { - assertEquals("Byte value was converted incorrectly", + Assert.assertEquals("Byte value was converted incorrectly", Byte.valueOf((byte) 10), converter.convertToModel("10", Byte.class, null)); } + @Test public void testReverseValueConversion() { - assertEquals("Byte value reversely was converted incorrectly", + Assert.assertEquals("Byte value reversely was converted incorrectly", reverseConverter.convertToModel((byte) 10, String.class, null), "10"); } + @Test public void testExtremeByteValueConversion() { byte b = converter.convertToModel("127", Byte.class, null); Assert.assertEquals(Byte.MAX_VALUE, b); b = converter.convertToModel("-128", Byte.class, null); - assertEquals("Min byte value was converted incorrectly", + Assert.assertEquals("Min byte value was converted incorrectly", Byte.MIN_VALUE, b); } + @Test public void testValueOutOfRange() { Double[] values = new Double[] { Byte.MAX_VALUE * 2.0, Byte.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, @@ -64,6 +70,6 @@ public class StringToByteConverterTest extends TestCase { } catch (ConversionException expected) { } } - assertFalse("Accepted value outside range of int", accepted); + Assert.assertFalse("Accepted value outside range of int", accepted); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java index 16008d89c2..8bac8b535b 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java @@ -3,24 +3,30 @@ package com.vaadin.tests.data.converter; import java.util.Date; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.StringToDateConverter; -public class StringToDateConverterTest extends TestCase { +public class StringToDateConverterTest { StringToDateConverter converter = new StringToDateConverter(); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Date.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Date.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Date.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Date.class, null)); } + @Test public void testValueConversion() { - assertEquals(new Date(100, 0, 1), converter.convertToModel( + Assert.assertEquals(new Date(100, 0, 1), converter.convertToModel( "Jan 1, 2000 12:00:00 AM", Date.class, Locale.ENGLISH)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java index 7054587009..1c983d48f6 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java @@ -1,22 +1,29 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.StringToDoubleConverter; -public class StringToDoubleConverterTest extends TestCase { +public class StringToDoubleConverterTest { StringToDoubleConverter converter = new StringToDoubleConverter(); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Double.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Double.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Double.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Double.class, null)); } + @Test public void testValueConversion() { - assertEquals(10.0, converter.convertToModel("10", Double.class, null)); + Double value = converter.convertToModel("10", Double.class, null); + Assert.assertEquals(10.0d, value, 0.01d); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java index 86319e641c..b99ce313b4 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java @@ -1,23 +1,29 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.StringToFloatConverter; -public class StringToFloatConverterTest extends TestCase { +public class StringToFloatConverterTest { StringToFloatConverter converter = new StringToFloatConverter(); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Float.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Float.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Float.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Float.class, null)); } + @Test public void testValueConversion() { - assertEquals(Float.valueOf(10), + Assert.assertEquals(Float.valueOf(10), converter.convertToModel("10", Float.class, null)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java index 0076f2c9d1..56826b77c0 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java @@ -1,22 +1,28 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.StringToIntegerConverter; -public class StringToIntegerConverterTest extends TestCase { +public class StringToIntegerConverterTest { StringToIntegerConverter converter = new StringToIntegerConverter(); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Integer.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Integer.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Integer.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Integer.class, null)); } + @Test public void testValueOutOfRange() { Double[] values = new Double[] { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, @@ -31,11 +37,12 @@ public class StringToIntegerConverterTest extends TestCase { } catch (ConversionException expected) { } } - assertFalse("Accepted value outside range of int", accepted); + Assert.assertFalse("Accepted value outside range of int", accepted); } + @Test public void testValueConversion() { - assertEquals(Integer.valueOf(10), + Assert.assertEquals(Integer.valueOf(10), converter.convertToModel("10", Integer.class, null)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java index 989dbcbbf5..9ea0cea63c 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java @@ -2,51 +2,59 @@ package com.vaadin.tests.data.converter; import java.util.Locale; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToLongConverter; -public class StringToLongConverterTest extends TestCase { +public class StringToLongConverterTest { StringToLongConverter converter = new StringToLongConverter(); Converter reverseConverter = new ReverseConverter( converter); + @Test public void testNullConversion() { - assertEquals(null, converter.convertToModel(null, Long.class, null)); + Assert.assertEquals(null, + converter.convertToModel(null, Long.class, null)); } + @Test public void testReverseNullConversion() { - assertEquals(null, + Assert.assertEquals(null, reverseConverter.convertToModel(null, String.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals(null, converter.convertToModel("", Long.class, null)); + Assert.assertEquals(null, + converter.convertToModel("", Long.class, null)); } + @Test public void testValueConversion() { - assertEquals(Long.valueOf(10), + Assert.assertEquals(Long.valueOf(10), converter.convertToModel("10", Long.class, null)); } + @Test public void testReverseValueConversion() { - assertEquals(reverseConverter.convertToModel(10L, String.class, null), - "10"); + Assert.assertEquals( + reverseConverter.convertToModel(10L, String.class, null), "10"); } + @Test public void testExtremeLongValueConversion() { long l = converter.convertToModel("9223372036854775807", Long.class, null); Assert.assertEquals(Long.MAX_VALUE, l); l = converter.convertToModel("-9223372036854775808", Long.class, null); - assertEquals(Long.MIN_VALUE, l); + Assert.assertEquals(Long.MIN_VALUE, l); } + @Test public void testExtremeReverseLongValueConversion() { String str = reverseConverter.convertToModel(Long.MAX_VALUE, String.class, Locale.ENGLISH); @@ -56,6 +64,7 @@ public class StringToLongConverterTest extends TestCase { Assert.assertEquals("-9,223,372,036,854,775,808", str); } + @Test public void testOutOfBoundsValueConversion() { // Long.MAX_VALUE+1 is converted to Long.MAX_VALUE long l = converter.convertToModel("9223372036854775808", Long.class, @@ -63,7 +72,7 @@ public class StringToLongConverterTest extends TestCase { Assert.assertEquals(Long.MAX_VALUE, l); // Long.MIN_VALUE-1 is converted to Long.MIN_VALUE l = converter.convertToModel("-9223372036854775809", Long.class, null); - assertEquals(Long.MIN_VALUE, l); + Assert.assertEquals(Long.MIN_VALUE, l); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java index ab255bce80..3faa65c863 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java @@ -1,56 +1,62 @@ package com.vaadin.tests.data.converter; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToShortConverter; -public class StringToShortConverterTest extends TestCase { +public class StringToShortConverterTest { StringToShortConverter converter = new StringToShortConverter(); Converter reverseConverter = new ReverseConverter( converter); + @Test public void testNullConversion() { - assertEquals("Null value was converted incorrectly", null, + Assert.assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Short.class, null)); } + @Test public void testReverseNullConversion() { - assertEquals("Null value reversely was converted incorrectly", null, - reverseConverter.convertToModel(null, String.class, null)); + Assert.assertEquals("Null value reversely was converted incorrectly", + null, reverseConverter.convertToModel(null, String.class, null)); } + @Test public void testEmptyStringConversion() { - assertEquals("Empty value was converted incorrectly", null, + Assert.assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Short.class, null)); } + @Test public void testValueConversion() { - assertEquals("Short value was converted incorrectly", + Assert.assertEquals("Short value was converted incorrectly", Short.valueOf((short) 10), converter.convertToModel("10", Short.class, null)); } + @Test public void testReverseValueConversion() { - assertEquals( + Assert.assertEquals( "Short value reversely was converted incorrectly", reverseConverter.convertToModel((short) 10, String.class, null), "10"); } + @Test public void testExtremeShortValueConversion() { short b = converter.convertToModel("32767", Short.class, null); Assert.assertEquals(Short.MAX_VALUE, b); b = converter.convertToModel("-32768", Short.class, null); - assertEquals("Min short value was converted incorrectly", + Assert.assertEquals("Min short value was converted incorrectly", Short.MIN_VALUE, b); } + @Test public void testValueOutOfRange() { Double[] values = new Double[] { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, @@ -65,6 +71,6 @@ public class StringToShortConverterTest extends TestCase { } catch (ConversionException expected) { } } - assertFalse("Accepted value outside range of int", accepted); + Assert.assertFalse("Accepted value outside range of int", accepted); } } diff --git a/server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java index 36f120151b..abffae9c9e 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java @@ -2,11 +2,12 @@ package com.vaadin.tests.data.validator; import java.math.BigDecimal; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.validator.BigDecimalRangeValidator; -public class BigDecimalRangeValidatorTest extends TestCase { +public class BigDecimalRangeValidatorTest { private BigDecimalRangeValidator cleanValidator = new BigDecimalRangeValidator( "no values", null, null); @@ -17,39 +18,43 @@ public class BigDecimalRangeValidatorTest extends TestCase { private BigDecimalRangeValidator minMaxValidator = new BigDecimalRangeValidator( "no values", new BigDecimal(10.5), new BigDecimal(100.5)); + @Test public void testNullValue() { - assertTrue("Didn't accept null", cleanValidator.isValid(null)); - assertTrue("Didn't accept null", minValidator.isValid(null)); - assertTrue("Didn't accept null", maxValidator.isValid(null)); - assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { - assertTrue("Validator without ranges didn't accept value", + Assert.assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(-15.0))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minValidator.isValid(new BigDecimal(10.1))); - assertFalse("Accepted too small value", + Assert.assertFalse("Accepted too small value", minValidator.isValid(new BigDecimal(10.0))); } + @Test public void testMaxValue() { - assertTrue("Validator without ranges didn't accept value", + Assert.assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(1120.0))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", maxValidator.isValid(new BigDecimal(15.0))); - assertFalse("Accepted too large value", + Assert.assertFalse("Accepted too large value", maxValidator.isValid(new BigDecimal(100.6))); } + @Test public void testMinMaxValue() { - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(10.5))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(100.5))); - assertFalse("Accepted too small value", + Assert.assertFalse("Accepted too small value", minMaxValidator.isValid(new BigDecimal(10.4))); - assertFalse("Accepted too large value", + Assert.assertFalse("Accepted too large value", minMaxValidator.isValid(new BigDecimal(100.6))); } } diff --git a/server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java index 92fabbb02a..5f15a63f59 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java @@ -2,11 +2,12 @@ package com.vaadin.tests.data.validator; import java.math.BigInteger; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.validator.BigIntegerRangeValidator; -public class BigIntegerRangeValidatorTest extends TestCase { +public class BigIntegerRangeValidatorTest { private BigIntegerRangeValidator cleanValidator = new BigIntegerRangeValidator( "no values", null, null); @@ -17,39 +18,43 @@ public class BigIntegerRangeValidatorTest extends TestCase { private BigIntegerRangeValidator minMaxValidator = new BigIntegerRangeValidator( "no values", BigInteger.valueOf(10), BigInteger.valueOf(100)); + @Test public void testNullValue() { - assertTrue("Didn't accept null", cleanValidator.isValid(null)); - assertTrue("Didn't accept null", minValidator.isValid(null)); - assertTrue("Didn't accept null", maxValidator.isValid(null)); - assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); + Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { - assertTrue("Validator without ranges didn't accept value", + Assert.assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(-15))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minValidator.isValid(BigInteger.valueOf(15))); - assertFalse("Accepted too small value", + Assert.assertFalse("Accepted too small value", minValidator.isValid(BigInteger.valueOf(9))); } + @Test public void testMaxValue() { - assertTrue("Validator without ranges didn't accept value", + Assert.assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(1120))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", maxValidator.isValid(BigInteger.valueOf(15))); - assertFalse("Accepted too large value", + Assert.assertFalse("Accepted too large value", maxValidator.isValid(BigInteger.valueOf(120))); } + @Test public void testMinMaxValue() { - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(15))); - assertTrue("Didn't accept valid value", + Assert.assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(99))); - assertFalse("Accepted too small value", + Assert.assertFalse("Accepted too small value", minMaxValidator.isValid(BigInteger.valueOf(9))); - assertFalse("Accepted too large value", + Assert.assertFalse("Accepted too large value", minMaxValidator.isValid(BigInteger.valueOf(110))); } } diff --git a/server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java index 03f35fe1bb..203c7847e9 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.ByteRangeValidator; -public class ByteRangeValidatorTest extends TestCase { +public class ByteRangeValidatorTest { private ByteRangeValidator cleanValidator = new ByteRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class ByteRangeValidatorTest extends TestCase { private ByteRangeValidator minMaxValidator = new ByteRangeValidator( "no values", (byte) 10, (byte) 100); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class ByteRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid((byte) -15)); @@ -29,6 +34,7 @@ public class ByteRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid((byte) 9)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid((byte) 112)); @@ -37,6 +43,7 @@ public class ByteRangeValidatorTest extends TestCase { maxValidator.isValid((byte) 120)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid((byte) 15)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java index 8199419b67..12b84e129d 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java @@ -1,6 +1,12 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Validator; import com.vaadin.data.validator.CompositeValidator; @@ -8,7 +14,7 @@ import com.vaadin.data.validator.CompositeValidator.CombinationMode; import com.vaadin.data.validator.EmailValidator; import com.vaadin.data.validator.RegexpValidator; -public class CompositeValidatorTest extends TestCase { +public class CompositeValidatorTest { CompositeValidator and = new CompositeValidator(CombinationMode.AND, "One validator not valid"); @@ -18,10 +24,8 @@ public class CompositeValidatorTest extends TestCase { RegexpValidator regex = new RegexpValidator("@mail.com", false, "Partial match validator error"); - @Override - protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() { and.addValidator(email); and.addValidator(regex); @@ -29,6 +33,7 @@ public class CompositeValidatorTest extends TestCase { or.addValidator(regex); } + @Test public void testCorrectValue() { String testString = "user@mail.com"; assertTrue(email.isValid(testString)); @@ -49,6 +54,7 @@ public class CompositeValidatorTest extends TestCase { } } + @Test public void testCorrectRegex() { String testString = "@mail.com"; @@ -71,6 +77,7 @@ public class CompositeValidatorTest extends TestCase { } } + @Test public void testCorrectEmail() { String testString = "user@gmail.com"; @@ -91,6 +98,7 @@ public class CompositeValidatorTest extends TestCase { } } + @Test public void testBothFaulty() { String testString = "gmail.com"; diff --git a/server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java index 7bb3e20160..4beea35905 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java @@ -1,16 +1,20 @@ package com.vaadin.tests.data.validator; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.validator.DateRangeValidator; import com.vaadin.shared.ui.datefield.Resolution; -public class DateRangeValidatorTest extends TestCase { +public class DateRangeValidatorTest { Calendar startDate = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); Calendar endDate = new GregorianCalendar(TimeZone.getTimeZone("GMT"), @@ -21,9 +25,8 @@ public class DateRangeValidatorTest extends TestCase { private DateRangeValidator maxValidator; private DateRangeValidator minMaxValidator; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { startDate.set(2000, Calendar.JANUARY, 1, 12, 0, 0); endDate.set(2000, Calendar.FEBRUARY, 20, 12, 0, 0); @@ -37,6 +40,7 @@ public class DateRangeValidatorTest extends TestCase { startDate.getTime(), endDate.getTime(), Resolution.DAY); } + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -44,6 +48,7 @@ public class DateRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); @@ -61,6 +66,7 @@ public class DateRangeValidatorTest extends TestCase { minValidator.isValid(cal.getTime())); } + @Test public void testMaxValue() { Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); @@ -77,6 +83,7 @@ public class DateRangeValidatorTest extends TestCase { maxValidator.isValid(cal.getTime())); } + @Test public void testMinMaxValue() { Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java index b096937bd2..81fb9b0ac6 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.DoubleRangeValidator; -public class DoubleRangeValidatorTest extends TestCase { +public class DoubleRangeValidatorTest { private DoubleRangeValidator cleanValidator = new DoubleRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class DoubleRangeValidatorTest extends TestCase { private DoubleRangeValidator minMaxValidator = new DoubleRangeValidator( "no values", 10.5, 100.5); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class DoubleRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(-15.0)); @@ -29,6 +34,7 @@ public class DoubleRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid(10.0)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(1120.0)); @@ -36,6 +42,7 @@ public class DoubleRangeValidatorTest extends TestCase { assertFalse("Accepted too large value", maxValidator.isValid(100.6)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid(10.5)); assertTrue("Didn't accept valid value", minMaxValidator.isValid(100.5)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java index 19fe9e6580..97d304d7df 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java @@ -1,26 +1,31 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.validator.EmailValidator; -public class EmailValidatorTest extends TestCase { +public class EmailValidatorTest { private EmailValidator validator = new EmailValidator("Error"); + @Test public void testEmailValidatorWithNull() { - assertTrue(validator.isValid(null)); + Assert.assertTrue(validator.isValid(null)); } + @Test public void testEmailValidatorWithEmptyString() { - assertTrue(validator.isValid("")); + Assert.assertTrue(validator.isValid("")); } + @Test public void testEmailValidatorWithFaultyString() { - assertFalse(validator.isValid("not.an.email")); + Assert.assertFalse(validator.isValid("not.an.email")); } + @Test public void testEmailValidatorWithOkEmail() { - assertTrue(validator.isValid("my.name@email.com")); + Assert.assertTrue(validator.isValid("my.name@email.com")); } } diff --git a/server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java index c5a07be43f..db4b73fd1b 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.FloatRangeValidator; -public class FloatRangeValidatorTest extends TestCase { +public class FloatRangeValidatorTest { private FloatRangeValidator cleanValidator = new FloatRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class FloatRangeValidatorTest extends TestCase { private FloatRangeValidator minMaxValidator = new FloatRangeValidator( "no values", 10.5f, 100.5f); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class FloatRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(-15.0f)); @@ -29,6 +34,7 @@ public class FloatRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid(10.0f)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(1120.0f)); @@ -36,6 +42,7 @@ public class FloatRangeValidatorTest extends TestCase { assertFalse("Accepted too large value", maxValidator.isValid(100.6f)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid(10.5f)); assertTrue("Didn't accept valid value", minMaxValidator.isValid(100.5f)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java index 5e64d0107e..8a572cb327 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.IntegerRangeValidator; -public class IntegerRangeValidatorTest extends TestCase { +public class IntegerRangeValidatorTest { private IntegerRangeValidator cleanValidator = new IntegerRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class IntegerRangeValidatorTest extends TestCase { private IntegerRangeValidator minMaxValidator = new IntegerRangeValidator( "no values", 10, 100); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class IntegerRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(-15)); @@ -29,6 +34,7 @@ public class IntegerRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid(9)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(1120)); @@ -36,6 +42,7 @@ public class IntegerRangeValidatorTest extends TestCase { assertFalse("Accepted too large value", maxValidator.isValid(120)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid(15)); assertTrue("Didn't accept valid value", minMaxValidator.isValid(99)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java index 440e9c3fd2..436e3224a4 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.LongRangeValidator; -public class LongRangeValidatorTest extends TestCase { +public class LongRangeValidatorTest { private LongRangeValidator cleanValidator = new LongRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class LongRangeValidatorTest extends TestCase { private LongRangeValidator minMaxValidator = new LongRangeValidator( "no values", 10l, 100l); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class LongRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(-15l)); @@ -29,6 +34,7 @@ public class LongRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid(9l)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(1120l)); @@ -36,6 +42,7 @@ public class LongRangeValidatorTest extends TestCase { assertFalse("Accepted too large value", maxValidator.isValid(120l)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid(15l)); assertTrue("Didn't accept valid value", minMaxValidator.isValid(99l)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java index 1e08ea7e2c..336df617d1 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java @@ -1,15 +1,19 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.Test; import com.vaadin.data.Validator; import com.vaadin.data.validator.NullValidator; -public class NullValidatorTest extends TestCase { +public class NullValidatorTest { NullValidator notNull = new NullValidator("Null not accepted", false); NullValidator onlyNull = new NullValidator("Only null accepted", true); + @Test public void testNullValue() { try { notNull.validate(null); @@ -24,6 +28,7 @@ public class NullValidatorTest extends TestCase { } } + @Test public void testNonNullValue() { try { onlyNull.validate("Not a null value"); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java index 2a62d23059..7776d89293 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java @@ -1,40 +1,49 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.RegexpValidator; -public class RegexpValidatorTest extends TestCase { +public class RegexpValidatorTest { private RegexpValidator completeValidator = new RegexpValidator("pattern", true, "Complete match validator error"); private RegexpValidator partialValidator = new RegexpValidator("pattern", false, "Partial match validator error"); + @Test public void testRegexpValidatorWithNull() { assertTrue(completeValidator.isValid(null)); assertTrue(partialValidator.isValid(null)); } + @Test public void testRegexpValidatorWithEmptyString() { assertTrue(completeValidator.isValid("")); assertTrue(partialValidator.isValid("")); } + @Test public void testCompleteRegexpValidatorWithFaultyString() { assertFalse(completeValidator.isValid("mismatch")); assertFalse(completeValidator.isValid("pattern2")); assertFalse(completeValidator.isValid("1pattern")); } + @Test public void testCompleteRegexpValidatorWithOkString() { assertTrue(completeValidator.isValid("pattern")); } + @Test public void testPartialRegexpValidatorWithFaultyString() { assertFalse(partialValidator.isValid("mismatch")); } + @Test public void testPartialRegexpValidatorWithOkString() { assertTrue(partialValidator.isValid("pattern")); assertTrue(partialValidator.isValid("1pattern")); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java index 69d22eb91e..d3534ebe97 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.ShortRangeValidator; -public class ShortRangeValidatorTest extends TestCase { +public class ShortRangeValidatorTest { private ShortRangeValidator cleanValidator = new ShortRangeValidator( "no values", null, null); @@ -15,6 +18,7 @@ public class ShortRangeValidatorTest extends TestCase { private ShortRangeValidator minMaxValidator = new ShortRangeValidator( "no values", (short) 10, (short) 100); + @Test public void testNullValue() { assertTrue("Didn't accept null", cleanValidator.isValid(null)); assertTrue("Didn't accept null", minValidator.isValid(null)); @@ -22,6 +26,7 @@ public class ShortRangeValidatorTest extends TestCase { assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } + @Test public void testMinValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid((short) -15)); @@ -30,6 +35,7 @@ public class ShortRangeValidatorTest extends TestCase { assertFalse("Accepted too small value", minValidator.isValid((short) 9)); } + @Test public void testMaxValue() { assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid((short) 1120)); @@ -39,6 +45,7 @@ public class ShortRangeValidatorTest extends TestCase { maxValidator.isValid((short) 120)); } + @Test public void testMinMaxValue() { assertTrue("Didn't accept valid value", minMaxValidator.isValid((short) 15)); diff --git a/server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java b/server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java index 5f12367f09..de925f479f 100644 --- a/server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.data.validator; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.StringLengthValidator; -public class StringLengthValidatorTest extends TestCase { +public class StringLengthValidatorTest { private StringLengthValidator validator = new StringLengthValidator("Error"); private StringLengthValidator validatorNoNull = new StringLengthValidator( @@ -14,15 +17,18 @@ public class StringLengthValidatorTest extends TestCase { private StringLengthValidator validatorMaxValue = new StringLengthValidator( "Error", null, 15, true); + @Test public void testValidatorWithNull() { assertTrue("Didn't accept null", validator.isValid(null)); assertTrue("Didn't accept null", validatorMinValue.isValid(null)); } + @Test public void testValidatorNotAcceptingNull() { assertFalse("Accepted null", validatorNoNull.isValid(null)); } + @Test public void testEmptyString() { assertTrue("Didn't accept empty String", validator.isValid("")); assertTrue("Didn't accept empty String", validatorMaxValue.isValid("")); @@ -32,6 +38,7 @@ public class StringLengthValidatorTest extends TestCase { validatorMinValue.isValid("")); } + @Test public void testTooLongString() { assertFalse("Too long string was accepted", validatorNoNull.isValid("This string is too long")); @@ -39,6 +46,7 @@ public class StringLengthValidatorTest extends TestCase { validatorMaxValue.isValid("This string is too long")); } + @Test public void testNoUpperBound() { assertTrue( "String not accepted even though no upper bound", @@ -46,11 +54,13 @@ public class StringLengthValidatorTest extends TestCase { .isValid("This is a really long string to test that no upper bound exists")); } + @Test public void testNoLowerBound() { assertTrue("Didn't accept short string", validatorMaxValue.isValid("")); assertTrue("Didn't accept short string", validatorMaxValue.isValid("1")); } + @Test public void testStringLengthValidatorWithOkStringLength() { assertTrue("Didn't accept string of correct length", validatorNoNull.isValid("OK!")); @@ -58,6 +68,7 @@ public class StringLengthValidatorTest extends TestCase { validatorMaxValue.isValid("OK!")); } + @Test public void testTooShortStringLength() { assertFalse("Accepted a string that was too short.", validatorMinValue.isValid("shot")); diff --git a/server/src/test/java/com/vaadin/tests/design/InvalidTagNames.java b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java similarity index 98% rename from server/src/test/java/com/vaadin/tests/design/InvalidTagNames.java rename to server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java index 9f405f4e56..1b5bfcca4e 100644 --- a/server/src/test/java/com/vaadin/tests/design/InvalidTagNames.java +++ b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java @@ -26,7 +26,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.declarative.Design; import com.vaadin.ui.declarative.DesignException; -public class InvalidTagNames { +public class InvalidTagNamesTest { @Test(expected = DesignException.class) public void tagWithoutDash() { diff --git a/server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java b/server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java index 91036c03ed..cb7b91226e 100644 --- a/server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import org.junit.Test; + import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Container.PropertySetChangeEvent; @@ -10,11 +12,13 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; public class AbstractContainerListenersTest extends AbstractListenerMethodsTestBase { + @Test public void testItemSetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, ItemSetChangeEvent.class, ItemSetChangeListener.class); } + @Test public void testPropertySetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, PropertySetChangeEvent.class, PropertySetChangeListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java b/server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java index fd38b52a37..71a84eea6e 100644 --- a/server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import org.junit.Test; + import com.vaadin.data.Property.ReadOnlyStatusChangeEvent; import com.vaadin.data.Property.ReadOnlyStatusChangeListener; import com.vaadin.data.Property.ValueChangeEvent; @@ -10,12 +12,15 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; public class AbstractPropertyListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(AbstractProperty.class, ValueChangeEvent.class, ValueChangeListener.class, new ObjectProperty("")); } + @Test public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(AbstractProperty.class, ReadOnlyStatusChangeEvent.class, diff --git a/server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java b/server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java index 087a7fb0f5..f09db0ea99 100644 --- a/server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java +++ b/server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java @@ -16,9 +16,13 @@ package com.vaadin.tests.server; -import junit.framework.TestCase; +import static org.junit.Assert.assertTrue; -public class AssertionsEnabledTest extends TestCase { +import org.junit.Test; + +public class AssertionsEnabledTest { + + @Test public void testAssertionsEnabled() { boolean assertFailed = false; try { diff --git a/server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java b/server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java index 90a0283cda..ef5420229a 100644 --- a/server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java +++ b/server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java @@ -1,16 +1,19 @@ package com.vaadin.tests.server; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; import org.atmosphere.util.Version; +import org.junit.Test; import com.vaadin.server.Constants; -public class AtmosphereVersionTest extends TestCase { +public class AtmosphereVersionTest { + /** * Test that the atmosphere version constant matches the version on our * classpath */ + @Test public void testAtmosphereVersion() { assertEquals(Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION, Version.getRawVersion()); diff --git a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java index c22e289bc4..2aef09fa2a 100644 --- a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java +++ b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java @@ -14,11 +14,10 @@ import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import junit.framework.TestCase; - +import org.junit.Assert; import org.junit.Test; -public class ClassesSerializableTest extends TestCase { +public class ClassesSerializableTest { /** * JARs that will be scanned for classes to test, in addition to classpath @@ -89,6 +88,7 @@ public class ClassesSerializableTest extends TestCase { * * @throws Exception */ + @Test public void testClassesSerializable() throws Exception { List rawClasspathEntries = getRawClasspathEntries(); @@ -149,7 +149,7 @@ public class ClassesSerializableTest extends TestCase { nonSerializableString += ")"; } } - fail("Serializable not implemented by the following classes and interfaces: " + Assert.fail("Serializable not implemented by the following classes and interfaces: " + nonSerializableString); } } diff --git a/server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java b/server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java index 1ec19724d8..33f6e1f90a 100644 --- a/server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java +++ b/server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java @@ -15,6 +15,9 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -22,7 +25,7 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Method; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.server.ClientConnector; import com.vaadin.server.ClientMethodInvocation; @@ -36,7 +39,7 @@ import elemental.json.JsonArray; import elemental.json.JsonValue; import elemental.json.impl.JsonUtil; -public class ClientMethodSerializationTest extends TestCase { +public class ClientMethodSerializationTest { private static final Method JAVASCRIPT_CALLBACK_METHOD = ReflectTools .findMethod(JavaScriptCallbackRpc.class, "call", String.class, @@ -62,6 +65,7 @@ public class ClientMethodSerializationTest extends TestCase { * {@link JavaScriptCallbackHelper#invokeCallback(String, Object...)}. * #12532 */ + @Test public void testClientMethodSerialization_WithJSONArray_ContentStaysSame() throws Exception { JsonArray originalArray = Json.createArray(); @@ -78,6 +82,7 @@ public class ClientMethodSerializationTest extends TestCase { JsonUtil.stringify(copyArray)); } + @Test public void testClientMethodSerialization_WithBasicParams_NoChanges() throws Exception { String stringParam = "a string 123"; @@ -92,6 +97,7 @@ public class ClientMethodSerializationTest extends TestCase { assertEquals(copyInteger, integerParam); } + @Test public void testClientMethodSerialization_NoParams_NoExceptions() { ClientMethodInvocation original = new ClientMethodInvocation(null, "interfaceName", NO_PARAMS_CALL_METHOD, null); @@ -115,6 +121,7 @@ public class ClientMethodSerializationTest extends TestCase { return output; } + @Test public void testSerializeTwice() { String name = "javascriptFunctionName"; String[] arguments = { "1", "2", "3" }; diff --git a/server/src/test/java/com/vaadin/tests/server/EventRouterTest.java b/server/src/test/java/com/vaadin/tests/server/EventRouterTest.java index 67f39d301d..e7d8749c85 100644 --- a/server/src/test/java/com/vaadin/tests/server/EventRouterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/EventRouterTest.java @@ -1,15 +1,16 @@ package com.vaadin.tests.server; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.TextField; -public class EventRouterTest extends TestCase { +public class EventRouterTest { int innerListenerCalls = 0; + @Test public void testAddInEventListener() { final TextField tf = new TextField(); diff --git a/server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java b/server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java index 3c68e86afa..a8af915cdc 100644 --- a/server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java +++ b/server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java @@ -1,17 +1,20 @@ package com.vaadin.tests.server; +import static org.junit.Assert.assertEquals; + import java.io.File; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.util.FileTypeResolver; -public class FileTypeResolverTest extends TestCase { +public class FileTypeResolverTest { private static final String FLASH_MIME_TYPE = "application/x-shockwave-flash"; private static final String TEXT_MIME_TYPE = "text/plain"; private static final String HTML_MIME_TYPE = "text/html"; + @Test public void testMimeTypes() { File plainFlash = new File("MyFlash.swf"); File plainText = new File("/a/b/MyFlash.txt"); @@ -56,6 +59,7 @@ public class FileTypeResolverTest extends TestCase { } + @Test public void testExtensionCase() { assertEquals("image/jpeg", FileTypeResolver.getMIMEType("abc.jpg")); assertEquals("image/jpeg", FileTypeResolver.getMIMEType("abc.jPg")); @@ -65,6 +69,7 @@ public class FileTypeResolverTest extends TestCase { assertEquals("image/jpeg", FileTypeResolver.getMIMEType("abc.JPE")); } + @Test public void testCustomMimeType() { assertEquals(FileTypeResolver.DEFAULT_MIME_TYPE, FileTypeResolver.getMIMEType("vaadin.foo")); diff --git a/server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java b/server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java index 594f5627dd..bc2c5e3558 100644 --- a/server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import org.junit.Test; + import com.vaadin.data.Container.PropertySetChangeEvent; import com.vaadin.data.Container.PropertySetChangeListener; import com.vaadin.data.Property.ValueChangeEvent; @@ -9,11 +11,14 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; public class IndexedContainerListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, ValueChangeEvent.class, ValueChangeListener.class); } + @Test public void testPropertySetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, PropertySetChangeEvent.class, PropertySetChangeListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java b/server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java index d632e65c9f..7ca3c61a55 100644 --- a/server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java +++ b/server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java @@ -1,14 +1,19 @@ package com.vaadin.tests.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail; + import java.lang.reflect.Field; import java.util.HashMap; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.server.KeyMapper; -public class KeyMapperTest extends TestCase { +public class KeyMapperTest { + @Test public void testAdd() { KeyMapper mapper = new KeyMapper(); Object o1 = new Object(); @@ -40,6 +45,7 @@ public class KeyMapperTest extends TestCase { } + @Test public void testRemoveAll() { KeyMapper mapper = new KeyMapper(); Object o1 = new Object(); @@ -57,6 +63,7 @@ public class KeyMapperTest extends TestCase { } + @Test public void testRemove() { KeyMapper mapper = new KeyMapper(); Object o1 = new Object(); diff --git a/server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java b/server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java index 36007fae17..825c8b22ad 100644 --- a/server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java +++ b/server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java @@ -1,12 +1,15 @@ package com.vaadin.tests.server; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; import com.vaadin.server.ClassResource; import com.vaadin.ui.Embedded; -public class MimeTypesTest extends TestCase { +public class MimeTypesTest { + @Test public void testEmbeddedPDF() { Embedded e = new Embedded("A pdf", new ClassResource("file.pddf")); assertEquals("Invalid mimetype", "application/octet-stream", diff --git a/server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java b/server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java index 6563556a4e..14da1171c6 100644 --- a/server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java @@ -1,8 +1,8 @@ package com.vaadin.tests.server; -import java.util.Date; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.util.Date; import org.junit.Test; @@ -10,7 +10,7 @@ import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertyFormatter; @SuppressWarnings("unchecked") -public class PropertyFormatterTest extends TestCase { +public class PropertyFormatterTest { class TestFormatter extends PropertyFormatter { diff --git a/server/src/test/java/com/vaadin/tests/server/SerializationTest.java b/server/src/test/java/com/vaadin/tests/server/SerializationTest.java index 4de30e579e..349a2c525e 100644 --- a/server/src/test/java/com/vaadin/tests/server/SerializationTest.java +++ b/server/src/test/java/com/vaadin/tests/server/SerializationTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import static org.junit.Assert.assertNotNull; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -7,7 +9,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.data.Item; import com.vaadin.data.Property; @@ -17,8 +19,9 @@ import com.vaadin.data.validator.RegexpValidator; import com.vaadin.server.VaadinSession; import com.vaadin.ui.Form; -public class SerializationTest extends TestCase { +public class SerializationTest { + @Test public void testValidators() throws Exception { RegexpValidator validator = new RegexpValidator(".*", "Error"); validator.validate("aaa"); @@ -26,6 +29,7 @@ public class SerializationTest extends TestCase { validator2.validate("aaa"); } + @Test public void testForm() throws Exception { Form f = new Form(); String propertyId = "My property"; @@ -38,6 +42,7 @@ public class SerializationTest extends TestCase { } + @Test public void testIndedexContainerItemIds() throws Exception { IndexedContainer ic = new IndexedContainer(); ic.addContainerProperty("prop1", String.class, null); @@ -50,24 +55,28 @@ public class SerializationTest extends TestCase { serializeAndDeserialize(ic); } + @Test public void testMethodPropertyGetter() throws Exception { MethodProperty mp = new MethodProperty(new Data(), "dummyGetter"); serializeAndDeserialize(mp); } + @Test public void testMethodPropertyGetterAndSetter() throws Exception { MethodProperty mp = new MethodProperty(new Data(), "dummyGetterAndSetter"); serializeAndDeserialize(mp); } + @Test public void testMethodPropertyInt() throws Exception { MethodProperty mp = new MethodProperty(new Data(), "dummyInt"); serializeAndDeserialize(mp); } + @Test public void testVaadinSession() throws Exception { VaadinSession session = new VaadinSession(null); diff --git a/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java b/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java index 04e621d5d2..70a18d1fa6 100644 --- a/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java +++ b/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java @@ -5,11 +5,11 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.server.communication.FileUploadHandler.SimpleMultiPartInputStream; -public class SimpleMultiPartInputStreamTest extends TestCase { +public class SimpleMultiPartInputStreamTest { /** * Check that the output for a given stream until boundary is as expected. @@ -46,28 +46,34 @@ public class SimpleMultiPartInputStreamTest extends TestCase { checkBoundaryDetection(input.getBytes(), boundary, expected.getBytes()); } + @Test public void testSingleByteBoundaryAtEnd() throws Exception { checkBoundaryDetection("xyz123" + getFullBoundary("a"), "a", "xyz123"); } + @Test public void testSingleByteBoundaryInMiddle() throws Exception { checkBoundaryDetection("xyz" + getFullBoundary("a") + "123", "a", "xyz"); } + @Test public void testCorrectBoundaryAtEnd() throws Exception { checkBoundaryDetection("xyz123" + getFullBoundary("abc"), "abc", "xyz123"); } + @Test public void testCorrectBoundaryNearEnd() throws Exception { checkBoundaryDetection("xyz123" + getFullBoundary("abc") + "de", "abc", "xyz123"); } + @Test public void testCorrectBoundaryAtBeginning() throws Exception { checkBoundaryDetection(getFullBoundary("abc") + "xyz123", "abc", ""); } + @Test public void testRepeatingCharacterBoundary() throws Exception { checkBoundaryDetection(getFullBoundary("aa") + "xyz123", "aa", ""); checkBoundaryDetection("axyz" + getFullBoundary("aa") + "123", "aa", @@ -85,6 +91,7 @@ public class SimpleMultiPartInputStreamTest extends TestCase { // + "1234567890", "\n\n", ""); // } + @Test public void testRepeatingStringBoundary() throws Exception { checkBoundaryDetection(getFullBoundary("abab") + "xyz123", "abab", ""); checkBoundaryDetection("abaxyz" + getFullBoundary("abab") + "123", @@ -93,6 +100,7 @@ public class SimpleMultiPartInputStreamTest extends TestCase { "xyz123"); } + @Test public void testOverlappingBoundary() throws Exception { checkBoundaryDetection("abc" + getFullBoundary("abcabd") + "xyz123", "abcabd", "abc"); diff --git a/server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java b/server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java index b430c7cf84..f93d6095c1 100644 --- a/server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java +++ b/server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java @@ -1,8 +1,13 @@ package com.vaadin.tests.server; -import junit.framework.TestCase; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.MockServletConfig; @@ -17,7 +22,7 @@ import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.UI; import com.vaadin.ui.Upload; -public class StreamVariableMappingTest extends TestCase { +public class StreamVariableMappingTest { private static final String variableName = "myName"; private Upload owner; @@ -25,8 +30,8 @@ public class StreamVariableMappingTest extends TestCase { private LegacyCommunicationManager cm; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { final VaadinSession application = new AlwaysLockedVaadinSession(null); final UI uI = new UI() { @Override @@ -46,10 +51,9 @@ public class StreamVariableMappingTest extends TestCase { }; streamVariable = EasyMock.createMock(StreamVariable.class); cm = createCommunicationManager(); - - super.setUp(); } + @Test public void testAddStreamVariable() { owner.getUI().getConnectorTracker().registerConnector(owner); String targetUrl = cm.getStreamVariableTargetUrl(owner, variableName, @@ -63,6 +67,7 @@ public class StreamVariableMappingTest extends TestCase { assertSame(streamVariable, streamVariable2); } + @Test public void testRemoveVariable() { ConnectorTracker tracker = owner.getUI().getConnectorTracker(); tracker.registerConnector(owner); diff --git a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 4e8f987def..24201ce51d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -6,15 +6,13 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; - import org.easymock.EasyMock; import org.junit.Assert; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Component; -public abstract class AbstractListenerMethodsTestBase extends TestCase { +public abstract class AbstractListenerMethodsTestBase { public static void main(String[] args) { findAllListenerMethods(); @@ -163,7 +161,7 @@ public abstract class AbstractListenerMethodsTestBase extends TestCase { SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Collection registeredListeners = getListeners(c, eventClass); - assertEquals("Number of listeners", expectedListeners.length, + Assert.assertEquals("Number of listeners", expectedListeners.length, registeredListeners.size()); Assert.assertArrayEquals(expectedListeners, diff --git a/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java b/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java index 2083d1f473..335963ec1b 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java @@ -16,15 +16,14 @@ package com.vaadin.tests.server.component; -import junit.framework.TestCase; - import org.junit.Assert; +import org.junit.Test; import com.vaadin.server.Sizeable.Unit; import com.vaadin.shared.ui.label.LabelState; import com.vaadin.ui.Label; -public class ComponentSizeParseTest extends TestCase { +public class ComponentSizeParseTest { private final class LabelWithPublicState extends Label { @Override @@ -33,6 +32,7 @@ public class ComponentSizeParseTest extends TestCase { } } + @Test public void testAllTheUnit() { testUnit("10.0px", 10, Unit.PIXELS); testUnit("10.0pt", 10, Unit.POINTS); diff --git a/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValues.java b/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java similarity index 98% rename from server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValues.java rename to server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java index 16bbd7008f..32f5ef8850 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValues.java +++ b/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java @@ -25,7 +25,7 @@ import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Field; import com.vaadin.ui.Slider; -public class FieldDefaultValues { +public class FieldDefaultValuesTest { @Test public void testFieldsHaveDefaultValueAfterClear() throws Exception { diff --git a/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java b/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java index ad80007882..6dd451ac2a 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java @@ -4,12 +4,12 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashSet; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Component; -public class FinalMethodTest extends TestCase { +public class FinalMethodTest { // public void testThatContainersHaveNoFinalMethods() { // HashSet> tested = new HashSet>(); @@ -20,6 +20,7 @@ public class FinalMethodTest extends TestCase { // } // } + @Test public void testThatComponentsHaveNoFinalMethods() { HashSet> tested = new HashSet>(); for (Class c : VaadinClasses.getComponents()) { diff --git a/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java b/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java index 5cf3b9700e..146c633789 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java @@ -15,14 +15,18 @@ */ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.InputStream; -import junit.framework.TestCase; - import org.jsoup.nodes.Document; import org.jsoup.nodes.DocumentType; import org.jsoup.nodes.Element; +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.Component; import com.vaadin.ui.VerticalLayout; @@ -34,27 +38,29 @@ import com.vaadin.ui.declarative.DesignException; * Test cases for checking that reading a design with no elements in the html * body produces null as the root component. */ -public class ReadEmptyDesignTest extends TestCase { +public class ReadEmptyDesignTest { InputStream is; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { String html = createDesign().toString(); is = new ByteArrayInputStream(html.getBytes()); } + @Test public void testReadComponent() { Component root = Design.read(is); assertNull("The root component should be null.", root); } + @Test public void testReadContext() { DesignContext ctx = Design.read(is, null); assertNotNull("The design context should not be null.", ctx); assertNull("The root component should be null.", ctx.getRootComponent()); } + @Test public void testReadContextWithRootParameter() { try { Component rootComponent = new VerticalLayout(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java index da4d8a92d4..2ae845716d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java @@ -7,8 +7,8 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; -import junit.framework.TestCase; - +import org.junit.Before; +import org.junit.Test; import org.mockito.Mockito; import com.vaadin.tests.VaadinClasses; @@ -17,16 +17,17 @@ import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.Label; import com.vaadin.ui.UI; -public class StateGetDoesNotMarkDirtyTest extends TestCase { +public class StateGetDoesNotMarkDirtyTest { private Set excludedMethods = new HashSet(); - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { excludedMethods.add(Label.class.getName() + "getDataSourceValue"); excludedMethods.add("getConnectorId"); } + @Test public void testGetDoesntMarkStateDirty() throws Exception { for (Class c : VaadinClasses.getComponents()) { Component newInstance = construct(c); diff --git a/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java b/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java index a535de2b24..85d25aec79 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java @@ -19,11 +19,11 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import junit.framework.TestCase; - import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.ui.Component; import com.vaadin.ui.declarative.Design; @@ -33,14 +33,16 @@ import com.vaadin.ui.declarative.DesignContext; * Test cases for checking that writing a component hierarchy with null root * produces an html document that has no elements in the html body. */ -public class WriteEmptyDesignTest extends TestCase { +public class WriteEmptyDesignTest { + @Test public void testWriteComponent() throws IOException { OutputStream os = new ByteArrayOutputStream(); Design.write((Component) null, os); checkHtml(os.toString()); } + @Test public void testWriteContext() throws IOException { OutputStream os = new ByteArrayOutputStream(); DesignContext ctx = new DesignContext(); @@ -52,7 +54,7 @@ public class WriteEmptyDesignTest extends TestCase { private void checkHtml(String html) { Document doc = Jsoup.parse(html); Element body = doc.body(); - assertEquals("There should be no elements in the html body.", "", - body.html()); + Assert.assertEquals("There should be no elements in the html body.", + "", body.html()); } } \ No newline at end of file diff --git a/server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java b/server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java index eac7ff4d8a..20a85edea5 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java @@ -1,13 +1,16 @@ package com.vaadin.tests.server.component.absolutelayout; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; import com.vaadin.server.Sizeable; import com.vaadin.server.Sizeable.Unit; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; -public class ComponentPositionTest extends TestCase { +public class ComponentPositionTest { private static final String CSS = "top:7.0px;right:7.0%;bottom:7.0pc;left:7.0em;z-index:7;"; private static final String PARTIAL_CSS = "top:7.0px;left:7.0em;"; @@ -18,6 +21,7 @@ public class ComponentPositionTest extends TestCase { /** * Add component w/o giving positions, assert that everything is unset */ + @Test public void testNoPosition() { AbsoluteLayout layout = new AbsoluteLayout(); Button b = new Button(); @@ -42,6 +46,7 @@ public class ComponentPositionTest extends TestCase { /** * Add component, setting all attributes using CSS, assert getter agree */ + @Test public void testFullCss() { AbsoluteLayout layout = new AbsoluteLayout(); Button b = new Button(); @@ -68,6 +73,7 @@ public class ComponentPositionTest extends TestCase { /** * Add component, setting some attributes using CSS, assert getters agree */ + @Test public void testPartialCss() { AbsoluteLayout layout = new AbsoluteLayout(); Button b = new Button(); @@ -93,6 +99,7 @@ public class ComponentPositionTest extends TestCase { * Add component setting all attributes using CSS, then reset using partial * CSS; assert getters agree and the appropriate attributes are unset. */ + @Test public void testPartialCssReset() { AbsoluteLayout layout = new AbsoluteLayout(); Button b = new Button(); @@ -120,6 +127,7 @@ public class ComponentPositionTest extends TestCase { * Add component, then set all position attributes with individual setters * for value and units; assert getters agree. */ + @Test public void testSetPosition() { final Float SIZE = Float.valueOf(12); @@ -153,6 +161,7 @@ public class ComponentPositionTest extends TestCase { * Add component, then set all position attributes with combined setters for * value and units; assert getters agree. */ + @Test public void testSetPosition2() { final Float SIZE = Float.valueOf(12); AbsoluteLayout layout = new AbsoluteLayout(); @@ -180,6 +189,7 @@ public class ComponentPositionTest extends TestCase { * Add component, set all attributes using CSS, unset some using method * calls, assert getters agree. */ + @Test public void testUnsetPosition() { AbsoluteLayout layout = new AbsoluteLayout(); Button b = new Button(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java index 18eb79aadc..77c2fef7e8 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java @@ -1,17 +1,21 @@ package com.vaadin.tests.server.component.abstractcomponent; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; import com.vaadin.ui.AbstractComponent; -public class AbstractComponentStyleNamesTest extends TestCase { +public class AbstractComponentStyleNamesTest { + @Test public void testSetMultiple() { AbstractComponent component = getComponent(); component.setStyleName("style1 style2"); assertEquals(component.getStyleName(), "style1 style2"); } + @Test public void testSetAdd() { AbstractComponent component = getComponent(); component.setStyleName("style1"); @@ -19,6 +23,7 @@ public class AbstractComponentStyleNamesTest extends TestCase { assertEquals(component.getStyleName(), "style1 style2"); } + @Test public void testAddSame() { AbstractComponent component = getComponent(); component.setStyleName("style1 style2"); @@ -26,6 +31,7 @@ public class AbstractComponentStyleNamesTest extends TestCase { assertEquals(component.getStyleName(), "style1 style2"); } + @Test public void testSetRemove() { AbstractComponent component = getComponent(); component.setStyleName("style1 style2"); @@ -33,6 +39,7 @@ public class AbstractComponentStyleNamesTest extends TestCase { assertEquals(component.getStyleName(), "style2"); } + @Test public void testAddRemove() { AbstractComponent component = getComponent(); component.addStyleName("style1"); @@ -41,6 +48,7 @@ public class AbstractComponentStyleNamesTest extends TestCase { assertEquals(component.getStyleName(), "style2"); } + @Test public void testRemoveMultipleWithExtraSpaces() { AbstractComponent component = getComponent(); component.setStyleName("style1 style2 style3"); @@ -48,6 +56,7 @@ public class AbstractComponentStyleNamesTest extends TestCase { assertEquals(component.getStyleName(), "style2"); } + @Test public void testSetWithExtraSpaces() { AbstractComponent component = getComponent(); component.setStyleName(" style1 style2 "); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java index 3a2150b700..76fe3c1681 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.abstractcomponentcontainer; +import org.junit.Test; + import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.HasComponents.ComponentAttachEvent; import com.vaadin.ui.HasComponents.ComponentAttachListener; @@ -10,11 +12,14 @@ import com.vaadin.ui.VerticalLayout; public class AbstractComponentContainerListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testComponentDetachListenerAddGetRemove() throws Exception { testListenerAddGetRemove(HorizontalLayout.class, ComponentDetachEvent.class, ComponentDetachListener.class); } + @Test public void testComponentAttachListenerAddGetRemove() throws Exception { testListenerAddGetRemove(VerticalLayout.class, ComponentAttachEvent.class, ComponentAttachListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java index 02aa6afe07..e428155ccd 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.server.component.abstractfield; -import junit.framework.TestCase; +import static org.junit.Assert.fail; import org.junit.Assert; +import org.junit.Test; import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.data.util.MethodProperty; @@ -14,12 +15,13 @@ import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; import com.vaadin.ui.TextField; -public class AbsFieldValueConversionErrorTest extends TestCase { +public class AbsFieldValueConversionErrorTest { Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com", 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town", Country.FINLAND)); + @Test public void testValidateConversionErrorParameters() { TextField tf = new TextField(); tf.setConverter(new StringToIntegerConverter()); @@ -37,6 +39,7 @@ public class AbsFieldValueConversionErrorTest extends TestCase { } + @Test public void testConvertToModelConversionErrorParameters() { TextField tf = new TextField(); tf.setConverter(new StringToIntegerConverter()); @@ -54,6 +57,7 @@ public class AbsFieldValueConversionErrorTest extends TestCase { } + @Test public void testNullConversionMessages() { TextField tf = new TextField(); tf.setConverter(new StringToIntegerConverter()); @@ -69,6 +73,7 @@ public class AbsFieldValueConversionErrorTest extends TestCase { } + @Test public void testDefaultConversionErrorMessage() { TextField tf = new TextField(); tf.setConverter(new StringToIntegerConverter()); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index 94ff10926f..3456e7c09e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.server.component.abstractfield; -import java.util.Locale; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.util.Locale; import org.junit.Assert; import org.junit.Test; @@ -21,7 +23,7 @@ import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; -public class AbsFieldValueConversionsTest extends TestCase { +public class AbsFieldValueConversionsTest { Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com", 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town", @@ -33,6 +35,7 @@ public class AbsFieldValueConversionsTest extends TestCase { */ private static final char FORMATTED_SPACE = 160; + @Test public void testWithoutConversion() { TextField tf = new TextField(); tf.setPropertyDataSource(new MethodProperty(paulaBean, @@ -45,6 +48,7 @@ public class AbsFieldValueConversionsTest extends TestCase { assertEquals("abc", paulaBean.getFirstName()); } + @Test public void testNonmodifiedBufferedFieldConversion() { VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("salary"); @@ -61,6 +65,7 @@ public class AbsFieldValueConversionsTest extends TestCase { } + @Test public void testModifiedBufferedFieldConversion() { VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("salary"); @@ -80,6 +85,7 @@ public class AbsFieldValueConversionsTest extends TestCase { assertEquals("123,123", tf.getValue()); } + @Test public void testStringIdentityConversion() { TextField tf = new TextField(); tf.setConverter(new Converter() { @@ -116,6 +122,7 @@ public class AbsFieldValueConversionsTest extends TestCase { assertEquals("abc", paulaBean.getFirstName()); } + @Test public void testIntegerStringConversion() { TextField tf = new TextField(); @@ -131,6 +138,7 @@ public class AbsFieldValueConversionsTest extends TestCase { assertEquals("42", tf.getValue()); } + @Test public void testChangeReadOnlyFieldLocale() { VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); @@ -147,6 +155,7 @@ public class AbsFieldValueConversionsTest extends TestCase { tf.getValue()); } + @Test public void testBooleanNullConversion() { CheckBox cb = new CheckBox(); cb.setConverter(new Converter() { @@ -219,6 +228,7 @@ public class AbsFieldValueConversionsTest extends TestCase { } + @Test public void testNumberDoubleConverterChange() { final VaadinSession a = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(a); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java index def3ceb643..d23d63e3e9 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.abstractfield; +import org.junit.Test; + import com.vaadin.data.Property.ReadOnlyStatusChangeEvent; import com.vaadin.data.Property.ReadOnlyStatusChangeListener; import com.vaadin.data.Property.ValueChangeEvent; @@ -8,12 +10,15 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.CheckBox; public class AbstractFieldListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(CheckBox.class, ReadOnlyStatusChangeEvent.class, ReadOnlyStatusChangeListener.class); } + @Test public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class, ValueChangeListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java index 68e198c37a..31158b1f09 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java @@ -1,9 +1,11 @@ package com.vaadin.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.data.util.MethodProperty; import com.vaadin.server.VaadinSession; @@ -14,7 +16,7 @@ import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; -public class DefaultConverterFactoryTest extends TestCase { +public class DefaultConverterFactoryTest { public static class FloatBean { float f1; @@ -80,6 +82,7 @@ public class DefaultConverterFactoryTest extends TestCase { paulaBean.setRent(rent); } + @Test public void testFloatConversion() { VaadinSession sess = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(sess); @@ -95,6 +98,7 @@ public class DefaultConverterFactoryTest extends TestCase { assertEquals(24f, tf.getPropertyDataSource().getValue()); } + @Test public void testLongConversion() { VaadinSession sess = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(sess); @@ -110,6 +114,7 @@ public class DefaultConverterFactoryTest extends TestCase { assertEquals(1982739187239L, tf.getPropertyDataSource().getValue()); } + @Test public void testDefaultNumberConversion() { VaadinSession app = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(app); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java index ee806cb5f7..cedc582b57 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.abstractselect; +import org.junit.Test; + import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Container.PropertySetChangeEvent; @@ -9,11 +11,14 @@ import com.vaadin.ui.ComboBox; public class AbstractSelectListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testItemSetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class, ItemSetChangeListener.class); } + @Test public void testPropertySetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(ComboBox.class, PropertySetChangeEvent.class, PropertySetChangeListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java similarity index 98% rename from server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java rename to server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java index 509e46c278..1b8b2f3bef 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java @@ -22,7 +22,7 @@ import com.vaadin.server.ThemeResource; import com.vaadin.tests.design.DeclarativeTestBase; import com.vaadin.ui.OptionGroup; -public class OptionGroupDeclarativeTests extends +public class OptionGroupDeclarativeTest extends DeclarativeTestBase { private OptionGroup og; diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTests.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java similarity index 95% rename from server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTests.java rename to server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java index c4a3d73652..9a20d2fd79 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTests.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import com.vaadin.ui.OptionGroup; -public class OptionGroupTests { +public class OptionGroupTest { private OptionGroup optionGroup; diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java index 0896b5d649..0641489e0e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.abstracttextfield; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -11,16 +13,20 @@ import com.vaadin.ui.TextField; public class AbstractTextFieldListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testTextChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(TextField.class, TextChangeEvent.class, TextChangeListener.class); } + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(TextField.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(TextField.class, BlurEvent.class, BlurListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java index 4478048b12..ad90883baa 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.button; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -10,16 +12,20 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; public class ButtonListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Button.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Button.class, BlurEvent.class, BlurListener.class); } + @Test public void testClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Button.class, ClickEvent.class, ClickListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java b/server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java index 8a066497cd..4bcd5c7192 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.server.component.calendar; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Date; import java.util.List; -import junit.framework.TestCase; - +import org.junit.Before; import org.junit.Test; import com.vaadin.data.Container.Indexed; @@ -33,11 +35,11 @@ import com.vaadin.ui.components.calendar.ContainerEventProvider; import com.vaadin.ui.components.calendar.event.BasicEvent; import com.vaadin.ui.components.calendar.event.CalendarEvent; -public class ContainerDataSourceTest extends TestCase { +public class ContainerDataSourceTest { private Calendar calendar; - @Override + @Before public void setUp() { calendar = new Calendar(); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java index f5467b2d18..4fcf1766fe 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java @@ -19,7 +19,8 @@ package com.vaadin.tests.server.component.datefield; import java.util.Date; import java.util.Locale; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; @@ -27,12 +28,12 @@ import com.vaadin.data.util.converter.Converter; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.ui.DateField; -public class DateFieldConverterTest extends TestCase { +public class DateFieldConverterTest { private Property date; private DateField datefield; - @Override + @Before public void setUp() { date = new ObjectProperty(0L); datefield = new DateField(); @@ -69,6 +70,7 @@ public class DateFieldConverterTest extends TestCase { /* * See #12193. */ + @Test public void testResolution() { datefield.setValue(new Date(110, 0, 1)); datefield.setResolution(Resolution.MINUTE); diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java index 6d774366a9..8885573bd8 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.datefield; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -8,11 +10,14 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.DateField; public class DateFieldListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(DateField.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(DateField.class, BlurEvent.class, BlurListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/ResolutionTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/ResolutionTest.java index ae72f9c743..a23c60b106 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/ResolutionTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/ResolutionTest.java @@ -2,13 +2,14 @@ package com.vaadin.tests.server.component.datefield; import java.util.ArrayList; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.tests.util.TestUtil; -public class ResolutionTest extends TestCase { +public class ResolutionTest { + @Test public void testResolutionHigherOrEqualToYear() { Iterable higherOrEqual = Resolution .getResolutionsHigherOrEqualTo(Resolution.YEAR); @@ -17,6 +18,7 @@ public class ResolutionTest extends TestCase { TestUtil.assertIterableEquals(expected, higherOrEqual); } + @Test public void testResolutionHigherOrEqualToDay() { Iterable higherOrEqual = Resolution .getResolutionsHigherOrEqualTo(Resolution.DAY); @@ -28,6 +30,7 @@ public class ResolutionTest extends TestCase { } + @Test public void testResolutionLowerThanDay() { Iterable higherOrEqual = Resolution .getResolutionsLowerThan(Resolution.DAY); @@ -39,6 +42,7 @@ public class ResolutionTest extends TestCase { } + @Test public void testResolutionLowerThanSecond() { Iterable higherOrEqual = Resolution .getResolutionsLowerThan(Resolution.SECOND); @@ -46,6 +50,7 @@ public class ResolutionTest extends TestCase { TestUtil.assertIterableEquals(expected, higherOrEqual); } + @Test public void testResolutionLowerThanYear() { Iterable higherOrEqual = Resolution .getResolutionsLowerThan(Resolution.YEAR); diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildren.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java similarity index 98% rename from server/src/test/java/com/vaadin/tests/server/component/grid/GridChildren.java rename to server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java index 7af1cfef69..65a4cfe564 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildren.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java @@ -26,7 +26,7 @@ import com.vaadin.ui.Grid.FooterCell; import com.vaadin.ui.Grid.HeaderCell; import com.vaadin.ui.Label; -public class GridChildren { +public class GridChildrenTest { @Test public void componentsInMergedHeader() { diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumns.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java similarity index 99% rename from server/src/test/java/com/vaadin/tests/server/component/grid/GridColumns.java rename to server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java index 83e9f21756..30db0e9fbe 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java @@ -50,7 +50,7 @@ import com.vaadin.ui.Grid.ColumnResizeEvent; import com.vaadin.ui.Grid.ColumnResizeListener; import com.vaadin.ui.TextField; -public class GridColumns { +public class GridColumnsTest { private Grid grid; diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelection.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java similarity index 99% rename from server/src/test/java/com/vaadin/tests/server/component/grid/GridSelection.java rename to server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java index dc641965ba..85f51c35fb 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelection.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java @@ -31,7 +31,7 @@ import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Grid.SelectionModel; -public class GridSelection { +public class GridSelectionTest { private static class MockSelectionChangeListener implements SelectionListener { diff --git a/server/src/test/java/com/vaadin/tests/server/component/label/LabelListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/label/LabelListenersTest.java index 4287d58d9c..51cf7bf1ff 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/label/LabelListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/label/LabelListenersTest.java @@ -7,6 +7,7 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import org.easymock.EasyMock; +import org.junit.Test; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeListener; @@ -15,11 +16,14 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Label.ValueChangeEvent; public class LabelListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Label.class, ValueChangeEvent.class, ValueChangeListener.class); } + @Test public void testValueChangeFiredWhenSettingValue() { Label underTest = new Label(); @@ -39,6 +43,7 @@ public class LabelListenersTest extends AbstractListenerMethodsTestBase { } + @Test public void testValueChangeFiredWhenSettingPropertyDataSource() { // setup Label underTest = new Label(); @@ -63,6 +68,7 @@ public class LabelListenersTest extends AbstractListenerMethodsTestBase { } + @Test public void testValueChangeNotFiredWhenNotSettingValue() { Label underTest = new Label(); // setup the mock listener @@ -75,6 +81,7 @@ public class LabelListenersTest extends AbstractListenerMethodsTestBase { verify(mockListener); } + @Test public void testNoValueChangeFiredWhenSettingPropertyDataSourceToNull() { Label underTest = new Label(); // setup the mock Listener diff --git a/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java b/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java index 68007bd870..105cf6660a 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java @@ -3,13 +3,15 @@ package com.vaadin.tests.server.component.menubar; import java.util.HashSet; import java.util.Set; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.Command; import com.vaadin.ui.MenuBar.MenuItem; -public class MenuBarIdsTest extends TestCase implements Command { +public class MenuBarIdsTest implements Command { private MenuItem lastSelectedItem; private MenuItem menuFile; @@ -25,7 +27,7 @@ public class MenuBarIdsTest extends TestCase implements Command { private MenuBar menuBar; - @Override + @Before public void setUp() { menuBar = new MenuBar(); menuFile = menuBar.addItem("File", this); @@ -51,6 +53,7 @@ public class MenuBarIdsTest extends TestCase implements Command { menuItems.add(menuFileExit); } + @Test public void testMenubarIdUniqueness() { // Ids within a menubar must be unique assertUniqueIds(menuBar); @@ -78,7 +81,7 @@ public class MenuBarIdsTest extends TestCase implements Command { private static void assertUniqueIds(Set ids, MenuItem item) { int id = item.getId(); System.out.println("Item " + item.getText() + ", id: " + id); - assertFalse(ids.contains(id)); + Assert.assertFalse(ids.contains(id)); ids.add(id); if (item.getChildren() != null) { for (MenuItem subItem : item.getChildren()) { @@ -89,7 +92,8 @@ public class MenuBarIdsTest extends TestCase implements Command { @Override public void menuSelected(MenuItem selectedItem) { - assertNull("lastSelectedItem was not cleared before selecting an item", + Assert.assertNull( + "lastSelectedItem was not cleared before selecting an item", lastSelectedItem); lastSelectedItem = selectedItem; diff --git a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java index c2dc175c75..2c2a8a81fb 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.optiongroup; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -8,11 +10,14 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.OptionGroup; public class OptionGroupListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(OptionGroup.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(OptionGroup.class, BlurEvent.class, BlurListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java index 3b3dfb94d8..b3bca12521 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java @@ -2,7 +2,7 @@ package com.vaadin.tests.server.component.orderedlayout; import java.util.Iterator; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Component; @@ -10,12 +10,14 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; -public class OrderedLayoutTest extends TestCase { +public class OrderedLayoutTest { + @Test public void testVLIteration() { testIndexing(new VerticalLayout(), 10); } + @Test public void testHLIteration() { testIndexing(new HorizontalLayout(), 12); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java index 9a2a5f1f50..1b0ff1caff 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.select; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -8,11 +10,14 @@ import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Select; public class SelectListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Select.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Select.class, BlurEvent.class, BlurListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/FooterTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/FooterTest.java index f9d373e864..d13a4a287e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/FooterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/FooterTest.java @@ -1,6 +1,12 @@ package com.vaadin.tests.server.component.table; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.Item; @@ -11,11 +17,12 @@ import com.vaadin.ui.Table; * Test case for testing the footer API * */ -public class FooterTest extends TestCase { +public class FooterTest { /** * Tests if setting the footer visibility works properly */ + @Test public void testFooterVisibility() { Table table = new Table("Test table", createContainer()); @@ -31,6 +38,7 @@ public class FooterTest extends TestCase { /** * Tests adding footers to the columns */ + @Test public void testAddingFooters() { Table table = new Table("Test table", createContainer()); @@ -54,6 +62,7 @@ public class FooterTest extends TestCase { /** * Test removing footers */ + @Test public void testRemovingFooters() { Table table = new Table("Test table", createContainer()); table.setColumnFooter("col1", "Footer1"); diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/MultipleSelectionTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/MultipleSelectionTest.java index ceb4c865d2..a7973b45f0 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/MultipleSelectionTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/MultipleSelectionTest.java @@ -1,20 +1,24 @@ package com.vaadin.tests.server.component.table; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.Set; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.util.IndexedContainer; import com.vaadin.shared.ui.MultiSelectMode; import com.vaadin.ui.Table; -public class MultipleSelectionTest extends TestCase { +public class MultipleSelectionTest { /** * Tests weather the multiple select mode is set when using Table.set */ + @Test @SuppressWarnings("unchecked") public void testSetMultipleItems() { Table table = new Table("", createTestContainer()); @@ -33,6 +37,7 @@ public class MultipleSelectionTest extends TestCase { * Tests setting the multiselect mode of the Table. The multiselect mode * affects how mouse selection is made in the table by the user. */ + @Test public void testSetMultiSelectMode() { Table table = new Table("", createTestContainer()); diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/TableListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/TableListenersTest.java index fce514954a..ac6fb171e3 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/TableListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/TableListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.table; +import org.junit.Test; + import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; @@ -14,26 +16,32 @@ import com.vaadin.ui.Table.HeaderClickEvent; import com.vaadin.ui.Table.HeaderClickListener; public class TableListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testColumnResizeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, ColumnResizeEvent.class, ColumnResizeListener.class); } + @Test public void testItemClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, ItemClickEvent.class, ItemClickListener.class); } + @Test public void testFooterClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, FooterClickEvent.class, FooterClickListener.class); } + @Test public void testHeaderClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, HeaderClickEvent.class, HeaderClickListener.class); } + @Test public void testColumnReorderListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, ColumnReorderEvent.class, ColumnReorderListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java index 7fd5bc67f6..0bcc71630e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java @@ -15,6 +15,10 @@ */ package com.vaadin.tests.server.component.table; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.lang.reflect.Field; import java.util.Collection; import java.util.HashMap; @@ -23,8 +27,7 @@ import java.util.Locale; import java.util.Map.Entry; import java.util.Set; -import junit.framework.TestCase; - +import org.junit.Before; import org.junit.Test; import com.vaadin.data.Container; @@ -34,12 +37,7 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.converter.Converter; import com.vaadin.ui.Table; -/** - * - * @since - * @author Vaadin Ltd - */ -public class TablePropertyValueConverterTest extends TestCase { +public class TablePropertyValueConverterTest { protected TestableTable table; protected Collection initialProperties; @@ -227,7 +225,7 @@ public class TablePropertyValueConverterTest extends TestCase { DerivedClass.class.isAssignableFrom(BaseClass.class)); } - @Override + @Before public void setUp() { table = new TestableTable("Test table", createContainer(new String[] { "col1", "col2", "col3" })); diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectable.java b/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java similarity index 98% rename from server/src/test/java/com/vaadin/tests/server/component/table/TableSelectable.java rename to server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java index 1af99a08eb..2ec8ccec81 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectable.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java @@ -27,7 +27,7 @@ import com.vaadin.ui.Table; * * @author Vaadin Ltd */ -public class TableSelectable { +public class TableSelectableTest { @Test public void setSelectable_explicitSelectable_tableIsSelectable() { diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/TableSerializationTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/TableSerializationTest.java index 3f3c52d6c0..22f2381980 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/table/TableSerializationTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/table/TableSerializationTest.java @@ -1,13 +1,13 @@ package com.vaadin.tests.server.component.table; -import junit.framework.TestCase; - import org.apache.commons.lang.SerializationUtils; +import org.junit.Test; import com.vaadin.ui.Table; -public class TableSerializationTest extends TestCase { +public class TableSerializationTest { + @Test public void testSerialization() { Table t = new Table(); byte[] ser = SerializationUtils.serialize(t); @@ -15,6 +15,7 @@ public class TableSerializationTest extends TestCase { } + @Test public void testSerializationWithRowHeaders() { Table t = new Table(); t.setRowHeaderMode(Table.ROW_HEADER_MODE_EXPLICIT); diff --git a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java index 83c45f94db..76cd1c7a39 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java @@ -1,25 +1,25 @@ package com.vaadin.tests.server.component.textfield; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.validator.RangeValidator; import com.vaadin.tests.data.converter.ConverterFactoryTest.ConvertTo42; import com.vaadin.ui.TextField; -public class TextFieldWithConverterAndValidatorTest extends TestCase { +public class TextFieldWithConverterAndValidatorTest { private TextField field; private ObjectProperty property; - @Override - protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() { field = new TextField(); field.setInvalidAllowed(false); } + @Test public void testConvert42AndValidator() { property = new ObjectProperty(123); field.setConverter(new ConvertTo42()); diff --git a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java index 8f2bec455b..68b9a2d2ce 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java @@ -1,8 +1,12 @@ package com.vaadin.tests.server.component.textfield; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Collections; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; @@ -11,7 +15,7 @@ import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertyFormatter; import com.vaadin.ui.TextField; -public class TextFieldWithPropertyFormatterTest extends TestCase { +public class TextFieldWithPropertyFormatterTest { private static final String INPUT_VALUE = "foo"; private static final String PARSED_VALUE = "BAR"; @@ -24,9 +28,8 @@ public class TextFieldWithPropertyFormatterTest extends TestCase { private int listenerCalled; private int repainted; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { field = new TextField() { @Override @@ -70,6 +73,7 @@ public class TextFieldWithPropertyFormatterTest extends TestCase { repainted = 0; } + @Test public void testWithServerApi() { checkInitialState(); @@ -93,6 +97,7 @@ public class TextFieldWithPropertyFormatterTest extends TestCase { assertEquals(FORMATTED_VALUE, field.getValue()); } + @Test public void testWithSimulatedClientSideChange() { checkInitialState(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java index b2a51aad8b..859d69d26e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.server.component.textfield; -import junit.framework.TestCase; +import static org.junit.Assert.fail; + +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Validator; import com.vaadin.data.Validator.InvalidValueException; @@ -10,14 +13,13 @@ import com.vaadin.data.validator.RegexpValidator; import com.vaadin.data.validator.StringLengthValidator; import com.vaadin.ui.TextField; -public class TextFieldWithValidatorTest extends TestCase { +public class TextFieldWithValidatorTest { private TextField field; private ObjectProperty property; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { field = new TextField(); field.setInvalidAllowed(false); @@ -25,6 +27,7 @@ public class TextFieldWithValidatorTest extends TestCase { field.setPropertyDataSource(property); } + @Test public void testMultipleValidators() { field.addValidator(new StringLengthValidator( "Length not between 1 and 3", 1, 3, false)); @@ -49,6 +52,7 @@ public class TextFieldWithValidatorTest extends TestCase { } } + @Test public void testRemoveValidator() { Validator validator1 = new StringLengthValidator( "Length not between 1 and 3", 1, 3, false); @@ -72,6 +76,7 @@ public class TextFieldWithValidatorTest extends TestCase { field.setValue("abcd"); } + @Test public void testRemoveAllValidators() { Validator validator1 = new StringLengthValidator( "Length not between 1 and 3", 1, 3, false); @@ -88,6 +93,7 @@ public class TextFieldWithValidatorTest extends TestCase { field.setValue("abcd"); } + @Test public void testEmailValidator() { field.addValidator(new EmailValidator("Invalid e-mail address")); @@ -144,6 +150,7 @@ public class TextFieldWithValidatorTest extends TestCase { } } + @Test public void testRegexpValidator() { field.addValidator(new RegexpValidator("pattern", true, "Validation failed")); diff --git a/server/src/test/java/com/vaadin/tests/server/component/tree/ListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/tree/ListenersTest.java index c327fe8c5f..359aa8d480 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tree/ListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tree/ListenersTest.java @@ -1,9 +1,12 @@ package com.vaadin.tests.server.component.tree; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.CollapseEvent; @@ -11,18 +14,18 @@ import com.vaadin.ui.Tree.CollapseListener; import com.vaadin.ui.Tree.ExpandEvent; import com.vaadin.ui.Tree.ExpandListener; -public class ListenersTest extends TestCase implements ExpandListener, - CollapseListener { +public class ListenersTest implements ExpandListener, CollapseListener { private int expandCalled; private int collapseCalled; private Object lastExpanded; private Object lastCollapsed; - @Override - protected void setUp() { + @Before + public void setUp() { expandCalled = 0; } + @Test public void testExpandListener() { Tree tree = createTree(10, 20, false); tree.addListener((ExpandListener) this); @@ -93,6 +96,7 @@ public class ListenersTest extends TestCase implements ExpandListener, return tree; } + @Test public void testCollapseListener() { Tree tree = createTree(7, 15, true); tree.addListener((CollapseListener) this); diff --git a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeListenersTest.java index 449f418596..ec10c4fe39 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.tree; +import org.junit.Test; + import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; @@ -10,16 +12,20 @@ import com.vaadin.ui.Tree.ExpandEvent; import com.vaadin.ui.Tree.ExpandListener; public class TreeListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testExpandListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Tree.class, ExpandEvent.class, ExpandListener.class); } + @Test public void testItemClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Tree.class, ItemClickEvent.class, ItemClickListener.class); } + @Test public void testCollapseListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Tree.class, CollapseEvent.class, CollapseListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java b/server/src/test/java/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java index a886b74f57..2a667bea72 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java @@ -1,10 +1,14 @@ package com.vaadin.tests.server.component.treetable; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; + +import org.junit.Test; import com.vaadin.ui.TreeTable; -public class EmptyTreeTableTest extends TestCase { +public class EmptyTreeTableTest { + + @Test public void testLastId() { TreeTable treeTable = new TreeTable(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java b/server/src/test/java/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java index 4a34094da1..9718d24f8c 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java @@ -1,11 +1,12 @@ package com.vaadin.tests.server.component.treetable; -import junit.framework.TestCase; +import org.junit.Test; import com.vaadin.ui.TreeTable; -public class TreeTableSetContainerNullTest extends TestCase { +public class TreeTableSetContainerNullTest { + @Test public void testNullContainer() { TreeTable treeTable = new TreeTable(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java b/server/src/test/java/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java index 470f04c15c..6ff6c1a71c 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java @@ -1,12 +1,13 @@ package com.vaadin.tests.server.component.ui; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; import java.util.Properties; -import junit.framework.TestCase; - import org.easymock.EasyMock; +import org.junit.Test; import com.vaadin.server.DefaultDeploymentConfiguration; import com.vaadin.server.DefaultUIProvider; @@ -18,7 +19,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.UI; -public class CustomUIClassLoaderTest extends TestCase { +public class CustomUIClassLoaderTest { /** * Stub root @@ -53,6 +54,7 @@ public class CustomUIClassLoaderTest extends TestCase { * @throws Exception * if thrown */ + @Test public void testWithDefaultClassLoader() throws Exception { VaadinSession application = createStubApplication(); application.setConfiguration(createConfigurationMock()); @@ -98,6 +100,7 @@ public class CustomUIClassLoaderTest extends TestCase { * @throws Exception * if thrown */ + @Test public void testWithClassLoader() throws Exception { LoggingClassLoader loggingClassLoader = new LoggingClassLoader(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadListenersTest.java index 13d4c6bfe6..f2bfaf9650 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.upload; +import org.junit.Test; + import com.vaadin.server.StreamVariable.StreamingProgressEvent; import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Upload; @@ -14,26 +16,32 @@ import com.vaadin.ui.Upload.SucceededEvent; import com.vaadin.ui.Upload.SucceededListener; public class UploadListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testProgressListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, StreamingProgressEvent.class, ProgressListener.class); } + @Test public void testSucceededListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, SucceededEvent.class, SucceededListener.class); } + @Test public void testStartedListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, StartedEvent.class, StartedListener.class); } + @Test public void testFailedListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, FailedEvent.class, FailedListener.class); } + @Test public void testFinishedListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, FinishedEvent.class, FinishedListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/component/window/WindowListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/window/WindowListenersTest.java index 87a1af301c..07bb0adadb 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/window/WindowListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/window/WindowListenersTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component.window; +import org.junit.Test; + import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; @@ -12,21 +14,26 @@ import com.vaadin.ui.Window.ResizeEvent; import com.vaadin.ui.Window.ResizeListener; public class WindowListenersTest extends AbstractListenerMethodsTestBase { + + @Test public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Window.class, FocusEvent.class, FocusListener.class); } + @Test public void testBlurListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Window.class, BlurEvent.class, BlurListener.class); } + @Test public void testResizeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Window.class, ResizeEvent.class, ResizeListener.class); } + @Test public void testCloseListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Window.class, CloseEvent.class, CloseListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java index f19821f92e..7bf0cb5c4e 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java @@ -1,19 +1,23 @@ package com.vaadin.tests.server.componentcontainer; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -public abstract class AbstractIndexedLayoutTestBase extends TestCase { +public abstract class AbstractIndexedLayoutTestBase { private Layout layout; protected abstract Layout createLayout(); - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { layout = createLayout(); } @@ -21,6 +25,7 @@ public abstract class AbstractIndexedLayoutTestBase extends TestCase { return layout; } + @Test public void testAddRemoveComponent() { Label c1 = new Label(); Label c2 = new Label(); @@ -46,6 +51,7 @@ public abstract class AbstractIndexedLayoutTestBase extends TestCase { protected abstract int getComponentIndex(Component c); + @Test public void testGetComponentIndex() { Label c1 = new Label(); Label c2 = new Label(); @@ -62,6 +68,7 @@ public abstract class AbstractIndexedLayoutTestBase extends TestCase { assertEquals(-1, getComponentIndex(c1)); } + @Test public void testGetComponent() { Label c1 = new Label(); Label c2 = new Label(); diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java index 91a302a274..c5bc4f39e5 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java @@ -2,7 +2,8 @@ package com.vaadin.tests.server.componentcontainer; import java.util.List; -import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.ComponentContainer; @@ -11,8 +12,9 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.components.colorpicker.ColorPickerPreview; -public class AddRemoveComponentTest extends TestCase { +public class AddRemoveComponentTest { + @Test public void testRemoveComponentFromWrongContainer() throws InstantiationException, IllegalAccessException { List> containerClasses = VaadinClasses @@ -35,8 +37,7 @@ public class AddRemoveComponentTest extends TestCase { hl.addComponent(label); componentContainer.removeComponent(label); - assertEquals( - "Parent no longer correct for " + componentContainer.getClass(), - hl, label.getParent()); + Assert.assertEquals("Parent no longer correct for " + + componentContainer.getClass(), hl, label.getParent()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java index f55798007f..29dfd08212 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java @@ -1,5 +1,9 @@ package com.vaadin.tests.server.componentcontainer; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + import java.util.Iterator; import java.util.NoSuchElementException; diff --git a/server/src/test/java/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java b/server/src/test/java/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java index 637947fc9b..d068051663 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java @@ -1,8 +1,7 @@ package com.vaadin.tests.server.components; -import junit.framework.TestCase; - import org.easymock.EasyMock; +import org.junit.Test; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; @@ -22,12 +21,12 @@ import com.vaadin.ui.AbstractField; * override {@link #setValue(AbstractField)} to set the field value via * changeVariables(). */ -public abstract class AbstractFieldValueChangeTestBase extends TestCase { +public abstract class AbstractFieldValueChangeTestBase { private AbstractField field; private ValueChangeListener listener; - protected void setUp(AbstractField field) throws Exception { + protected void setUp(AbstractField field) { this.field = field; listener = EasyMock.createStrictMock(ValueChangeListener.class); @@ -40,6 +39,7 @@ public abstract class AbstractFieldValueChangeTestBase extends TestCase { /** * Test that listeners are not called when they have been unregistered. */ + @Test public void testRemoveListener() { getField().setPropertyDataSource(new ObjectProperty("")); getField().setBuffered(false); @@ -75,6 +75,7 @@ public abstract class AbstractFieldValueChangeTestBase extends TestCase { * Field value change notifications closely mirror value changes of the data * source behind the field. */ + @Test public void testNonBuffered() { getField().setPropertyDataSource(new ObjectProperty("")); getField().setBuffered(false); diff --git a/server/src/test/java/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java b/server/src/test/java/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java index f3cc337657..8bc1eb87df 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java @@ -3,6 +3,8 @@ package com.vaadin.tests.server.components; import java.util.HashMap; import java.util.Map; +import org.junit.Before; + import com.vaadin.ui.AbstractField; import com.vaadin.ui.ComboBox; @@ -14,8 +16,9 @@ import com.vaadin.ui.ComboBox; */ public class ComboBoxValueChangeTest extends AbstractFieldValueChangeTestBase { - @Override - protected void setUp() throws Exception { + + @Before + public void setUp() { ComboBox combo = new ComboBox(); combo.addItem("myvalue"); super.setUp(combo); diff --git a/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java b/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java index d8b366ffbc..b13a379b05 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java +++ b/server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java @@ -1,8 +1,16 @@ package com.vaadin.tests.server.components; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.AbsoluteLayout.ComponentPosition; @@ -20,7 +28,7 @@ import com.vaadin.ui.HasComponents.ComponentDetachListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -public class ComponentAttachDetachListenerTest extends TestCase { +public class ComponentAttachDetachListenerTest { private AbstractOrderedLayout olayout; private GridLayout gridlayout; @@ -126,9 +134,8 @@ public class ComponentAttachDetachListenerTest extends TestCase { componentPosition = null; } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { olayout = new HorizontalLayout(); olayout.addComponentAttachListener(new MyAttachListener()); @@ -151,6 +158,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { customlayout.addComponentDetachListener(new MyDetachListener()); } + @Test public void testOrderedLayoutAttachListener() { // Reset state variables resetVariables(); @@ -175,6 +183,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertFalse(indexOfComponent == -1); } + @Test public void testOrderedLayoutDetachListener() { // Add a component to detach Component comp = new Label(); @@ -202,6 +211,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertEquals(-1, indexOfComponent); } + @Test public void testGridLayoutAttachListener() { // Reset state variables resetVariables(); @@ -226,6 +236,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertNotNull(componentArea); } + @Test public void testGridLayoutDetachListener() { // Add a component to detach Component comp = new Label(); @@ -253,6 +264,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertNull(componentArea); } + @Test public void testAbsoluteLayoutAttachListener() { // Reset state variables resetVariables(); @@ -277,6 +289,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertNotNull(componentPosition); } + @Test public void testAbsoluteLayoutDetachListener() { // Add a component to detach Component comp = new Label(); @@ -304,6 +317,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertNull(componentPosition); } + @Test public void testCSSLayoutAttachListener() { // Reset state variables resetVariables(); @@ -325,6 +339,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertTrue(foundInContainer); } + @Test public void testCSSLayoutDetachListener() { // Add a component to detach Component comp = new Label(); @@ -349,6 +364,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { assertFalse(foundInContainer); } + @Test public void testCustomLayoutAttachListener() { // Reset state variables resetVariables(); @@ -369,6 +385,7 @@ public class ComponentAttachDetachListenerTest extends TestCase { foundInContainer); } + @Test public void testCustomLayoutDetachListener() { // Add a component to detach Component comp = new Label(); diff --git a/server/src/test/java/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java b/server/src/test/java/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java index 3467d1d80c..2743301a72 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java +++ b/server/src/test/java/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java @@ -1,12 +1,17 @@ package com.vaadin.tests.server.components; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.junit.Test; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -public class GridLayoutLastRowRemovalTest extends TestCase { +public class GridLayoutLastRowRemovalTest { + @Test public void testRemovingLastRow() { GridLayout grid = new GridLayout(2, 1); grid.addComponent(new Label("Col1")); diff --git a/server/src/test/java/com/vaadin/tests/server/components/TextFieldValueChangeTest.java b/server/src/test/java/com/vaadin/tests/server/components/TextFieldValueChangeTest.java index cfceb6f7d7..3b34d17c99 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/TextFieldValueChangeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/components/TextFieldValueChangeTest.java @@ -5,6 +5,8 @@ import java.util.Map; import org.easymock.EasyMock; import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.ObjectProperty; @@ -20,8 +22,8 @@ import com.vaadin.ui.TextField; public class TextFieldValueChangeTest extends AbstractFieldValueChangeTestBase { - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { super.setUp(new TextField()); } @@ -29,6 +31,7 @@ public class TextFieldValueChangeTest extends * Case where the text field only uses its internal buffer, no external * property data source. */ + @Test public void testNoDataSource() { getField().setPropertyDataSource(null); @@ -49,6 +52,7 @@ public class TextFieldValueChangeTest extends * * TODO make test field type agnostic (eg. combobox) */ + @Test public void testValueChangeEventPropagationWithReadThrough() { ObjectProperty property = new ObjectProperty(""); getField().setPropertyDataSource(property); @@ -82,6 +86,7 @@ public class TextFieldValueChangeTest extends * * TODO make test field type agnostic (eg. combobox) */ + @Test public void testValueChangePropagationWithReadThroughOff() { final String initialValue = "initial"; ObjectProperty property = new ObjectProperty( diff --git a/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java b/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java index 26fe238342..ed22870b59 100644 --- a/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java +++ b/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java @@ -3,9 +3,9 @@ package com.vaadin.tests.server.components; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; - import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.Window; @@ -14,16 +14,17 @@ import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.Window.ResizeEvent; import com.vaadin.ui.Window.ResizeListener; -public class WindowTest extends TestCase { +public class WindowTest { private Window window; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { window = new Window(); new LegacyWindow().addWindow(window); } + @Test public void testCloseListener() { CloseListener cl = EasyMock.createMock(Window.CloseListener.class); @@ -50,6 +51,7 @@ public class WindowTest extends TestCase { } + @Test public void testResizeListener() { ResizeListener rl = EasyMock.createMock(Window.ResizeListener.class); diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java index bc067ddb88..ecd45251b5 100644 --- a/server/src/test/java/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java +++ b/server/src/test/java/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java @@ -16,14 +16,19 @@ package com.vaadin.tests.server.navigator; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.junit.Test; import com.vaadin.navigator.Navigator.ClassBasedViewProvider; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.ui.Label; -public class ClassBasedViewProviderTest extends TestCase { +public class ClassBasedViewProviderTest { public static class TestView extends Label implements View { public String parameters = null; @@ -39,26 +44,24 @@ public class ClassBasedViewProviderTest extends TestCase { } + @Test(expected = IllegalArgumentException.class) public void testCreateProviderWithNullName() throws Exception { - try { - new ClassBasedViewProvider(null, TestView.class); - fail("Should not be able to create view provider with null name"); - } catch (IllegalArgumentException e) { - } + new ClassBasedViewProvider(null, TestView.class); + fail("Should not be able to create view provider with null name"); } + @Test public void testCreateProviderWithEmptyStringName() throws Exception { new ClassBasedViewProvider("", TestView.class); } + @Test(expected = IllegalArgumentException.class) public void testCreateProviderNullViewClass() throws Exception { - try { - new ClassBasedViewProvider("test", null); - fail("Should not be able to create view provider with null view class"); - } catch (IllegalArgumentException e) { - } + new ClassBasedViewProvider("test", null); + fail("Should not be able to create view provider with null view class"); } + @Test public void testViewNameGetter() throws Exception { ClassBasedViewProvider provider1 = new ClassBasedViewProvider("", TestView.class); @@ -70,6 +73,7 @@ public class ClassBasedViewProviderTest extends TestCase { provider2.getViewName()); } + @Test public void testViewClassGetter() throws Exception { ClassBasedViewProvider provider = new ClassBasedViewProvider("test", TestView.class); @@ -77,6 +81,7 @@ public class ClassBasedViewProviderTest extends TestCase { provider.getViewClass()); } + @Test public void testGetViewNameForNullString() throws Exception { ClassBasedViewProvider provider = new ClassBasedViewProvider("test", TestView.class); @@ -84,6 +89,7 @@ public class ClassBasedViewProviderTest extends TestCase { provider.getViewName((String) null)); } + @Test public void testGetViewNameForEmptyString() throws Exception { ClassBasedViewProvider provider1 = new ClassBasedViewProvider("", TestView.class); @@ -98,6 +104,7 @@ public class ClassBasedViewProviderTest extends TestCase { provider2.getViewName("")); } + @Test public void testGetViewNameWithParameters() throws Exception { ClassBasedViewProvider provider = new ClassBasedViewProvider("test", TestView.class); @@ -111,6 +118,7 @@ public class ClassBasedViewProviderTest extends TestCase { "test", provider.getViewName("test/params/are/here")); } + @Test public void testGetView() throws Exception { ClassBasedViewProvider provider = new ClassBasedViewProvider("test", TestView.class); @@ -120,6 +128,7 @@ public class ClassBasedViewProviderTest extends TestCase { assertEquals("Incorrect view type", TestView.class, view.getClass()); } + @Test public void testGetViewIncorrectViewName() throws Exception { ClassBasedViewProvider provider = new ClassBasedViewProvider("test", TestView.class); diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java index 0de804fa0b..0eda1ed045 100644 --- a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -16,14 +16,19 @@ package com.vaadin.tests.server.navigator; -import java.util.LinkedList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.util.LinkedList; import org.easymock.EasyMock; import org.easymock.IArgumentMatcher; import org.easymock.IMocksControl; import org.junit.Assert; +import org.junit.Test; import com.vaadin.navigator.NavigationStateManager; import com.vaadin.navigator.Navigator; @@ -42,7 +47,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -public class NavigatorTest extends TestCase { +public class NavigatorTest { // TODO test internal parameters (and absence of them) // TODO test listeners blocking navigation, multiple listeners @@ -273,6 +278,7 @@ public class NavigatorTest extends TestCase { return new Navigator(createMockUI(), manager, display); } + @Test(expected = NullPointerException.class) public void testDestroy_unsetNavigatorInUIAndUriFragmentManager() { TestPage page = new TestPage(); UI ui = new TestUI(page); @@ -292,16 +298,14 @@ public class NavigatorTest extends TestCase { ui.getNavigator()); UriFragmentManager manager = (UriFragmentManager) navigator .getStateManager(); - try { - manager.uriFragmentChanged(EasyMock - .createMock(UriFragmentChangedEvent.class)); - Assert.assertTrue( - "Expected null pointer exception after call uriFragmentChanged " - + "for destroyed navigator", false); - } catch (NullPointerException e) { - } + + manager.uriFragmentChanged(EasyMock + .createMock(UriFragmentChangedEvent.class)); + Assert.fail("Expected null pointer exception after call uriFragmentChanged " + + "for destroyed navigator"); } + @Test public void testBasicNavigation() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -355,6 +359,7 @@ public class NavigatorTest extends TestCase { assertEquals("test1/params", navigator.getState()); } + @Test public void testMainView() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -400,6 +405,7 @@ public class NavigatorTest extends TestCase { navigator.navigateTo("test1/params"); } + @Test public void testListeners() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -450,6 +456,7 @@ public class NavigatorTest extends TestCase { } } + @Test public void testComponentContainerViewDisplay() { abstract class TestView implements Component, View { } @@ -478,6 +485,7 @@ public class NavigatorTest extends TestCase { assertEquals(1, container.getComponentCount()); } + @Test public void testBlockNavigation() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -557,6 +565,7 @@ public class NavigatorTest extends TestCase { } } + @Test public void testAddViewInstance() throws Exception { View view = new TestView(); @@ -568,6 +577,7 @@ public class NavigatorTest extends TestCase { view, navigator.getView("test")); } + @Test public void testAddViewInstanceSameName() throws Exception { View view1 = new TestView(); View view2 = new TestView2(); @@ -582,6 +592,7 @@ public class NavigatorTest extends TestCase { view2, navigator.getView("test")); } + @Test public void testAddViewClass() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -593,6 +604,7 @@ public class NavigatorTest extends TestCase { view.getClass()); } + @Test public void testAddViewClassSameName() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -604,6 +616,7 @@ public class NavigatorTest extends TestCase { TestView2.class, navigator.getView("test").getClass()); } + @Test public void testAddViewInstanceAndClassSameName() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -622,6 +635,7 @@ public class NavigatorTest extends TestCase { TestView.class, navigator.getView("test").getClass()); } + @Test public void testAddViewWithNullName() throws Exception { Navigator navigator = new TestNavigator(); @@ -637,26 +651,23 @@ public class NavigatorTest extends TestCase { } } + @Test(expected = IllegalArgumentException.class) public void testAddViewWithNullInstance() throws Exception { Navigator navigator = new TestNavigator(); - try { - navigator.addView("test", (View) null); - fail("addView() accepted null view instance"); - } catch (IllegalArgumentException e) { - } + navigator.addView("test", (View) null); + fail("addView() accepted null view instance"); } + @Test(expected = IllegalArgumentException.class) public void testAddViewWithNullClass() throws Exception { Navigator navigator = new TestNavigator(); - try { - navigator.addView("test", (Class) null); - fail("addView() accepted null view class"); - } catch (IllegalArgumentException e) { - } + navigator.addView("test", (Class) null); + fail("addView() accepted null view class"); } + @Test public void testRemoveViewInstance() throws Exception { View view = new TestView(); @@ -668,6 +679,7 @@ public class NavigatorTest extends TestCase { assertNull("View not removed", navigator.getView("test")); } + @Test public void testRemoveViewInstanceNothingElse() throws Exception { View view = new TestView(); View view2 = new TestView2(); @@ -681,6 +693,7 @@ public class NavigatorTest extends TestCase { assertEquals("Removed extra views", view2, navigator.getView("test2")); } + @Test public void testRemoveViewClass() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -690,6 +703,7 @@ public class NavigatorTest extends TestCase { assertNull("View not removed", navigator.getView("test")); } + @Test public void testRemoveViewClassNothingElse() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -701,6 +715,7 @@ public class NavigatorTest extends TestCase { navigator.getView("test2").getClass()); } + @Test public void testGetViewNestedNames() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -727,6 +742,7 @@ public class NavigatorTest extends TestCase { .getClass()); } + @Test public void testGetViewLongestPrefixOrder() throws Exception { TestNavigator navigator = new TestNavigator(); @@ -747,6 +763,7 @@ public class NavigatorTest extends TestCase { .getView("test").getClass()); } + @Test public void testNavigateToUnknownView() { TestNavigator navigator = new TestNavigator(); @@ -785,6 +802,7 @@ public class NavigatorTest extends TestCase { navigator.navigateTo("doesnotexist2"); } + @Test public void testShowViewEnterOrder() { IMocksControl control = EasyMock.createStrictControl(); @@ -805,6 +823,7 @@ public class NavigatorTest extends TestCase { navigator.navigateTo("view"); } + @Test(expected = IllegalArgumentException.class) public void testNullViewProvider() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -814,11 +833,8 @@ public class NavigatorTest extends TestCase { // create navigator to test Navigator navigator = createNavigator(manager, display); - try { - navigator.addProvider(null); - fail("Should not be allowed to add a null view provider"); - } catch (IllegalArgumentException e) { - // Expected - } + navigator.addProvider(null); + fail("Should not be allowed to add a null view provider"); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/validation/BeanValidationTest.java b/server/src/test/java/com/vaadin/tests/server/validation/BeanValidationTest.java index 6b7582525e..6ad6ac2d5f 100644 --- a/server/src/test/java/com/vaadin/tests/server/validation/BeanValidationTest.java +++ b/server/src/test/java/com/vaadin/tests/server/validation/BeanValidationTest.java @@ -85,6 +85,7 @@ public class BeanValidationTest { Assert.assertEquals(2, causes.length); } + @Test public void testBeanValidationNotAddedTwice() { // See ticket #11045 BeanFieldGroup fieldGroup = new BeanFieldGroup( @@ -100,8 +101,9 @@ public class BeanValidationTest { try { nameField.validate(); } catch (InvalidValueException e) { - // NOTE: causes are empty if only one validation fails - Assert.assertEquals(0, e.getCauses().length); + // The 1 cause is from BeanValidator, where it tells what failed + // 1 validation exception never gets wrapped. + Assert.assertEquals(1, e.getCauses().length); } // Create new, identical bean to cause duplicate validator unless #11045 @@ -115,9 +117,9 @@ public class BeanValidationTest { try { nameField.validate(); } catch (InvalidValueException e) { - // NOTE: if more than one validation fails, we get the number of - // failed validations - Assert.assertEquals(0, e.getCauses().length); + // The 1 cause is from BeanValidator, where it tells what failed + // 1 validation exception never gets wrapped. + Assert.assertEquals(1, e.getCauses().length); } } diff --git a/server/src/test/java/com/vaadin/tests/server/validation/RangeValidatorTest.java b/server/src/test/java/com/vaadin/tests/server/validation/RangeValidatorTest.java index e3320b8699..86c1083269 100644 --- a/server/src/test/java/com/vaadin/tests/server/validation/RangeValidatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/validation/RangeValidatorTest.java @@ -1,14 +1,18 @@ package com.vaadin.tests.server.validation; -import junit.framework.TestCase; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; import com.vaadin.data.validator.IntegerRangeValidator; -public class RangeValidatorTest extends TestCase { +public class RangeValidatorTest { // This test uses IntegerRangeValidator for simplicity. // IntegerRangeValidator contains no code so we really are testing // RangeValidator + @Test public void testMinValueNonInclusive() { IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10); iv.setMinValueIncluded(false); @@ -18,6 +22,7 @@ public class RangeValidatorTest extends TestCase { assertFalse(iv.isValid(-1)); } + @Test public void testMinMaxValuesInclusive() { IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10); assertTrue(iv.isValid(0)); @@ -27,6 +32,7 @@ public class RangeValidatorTest extends TestCase { assertFalse(iv.isValid(-1)); } + @Test public void testMaxValueNonInclusive() { IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10); iv.setMaxValueIncluded(false); @@ -37,6 +43,7 @@ public class RangeValidatorTest extends TestCase { assertFalse(iv.isValid(-1)); } + @Test public void testMinMaxValuesNonInclusive() { IntegerRangeValidator iv = new IntegerRangeValidator("Failed", 0, 10); iv.setMinValueIncluded(false); diff --git a/server/src/test/java/com/vaadin/tests/util/UniqueSerializableTest.java b/server/src/test/java/com/vaadin/tests/util/UniqueSerializableTest.java index abdc6c1a5c..287ed0338a 100644 --- a/server/src/test/java/com/vaadin/tests/util/UniqueSerializableTest.java +++ b/server/src/test/java/com/vaadin/tests/util/UniqueSerializableTest.java @@ -15,16 +15,19 @@ */ package com.vaadin.tests.util; -import java.io.Serializable; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.io.Serializable; import org.apache.commons.lang.SerializationUtils; +import org.junit.Test; import com.vaadin.ui.UniqueSerializable; -public class UniqueSerializableTest extends TestCase implements Serializable { +public class UniqueSerializableTest implements Serializable { + @Test public void testUniqueness() { UniqueSerializable o1 = new UniqueSerializable() { }; @@ -34,6 +37,7 @@ public class UniqueSerializableTest extends TestCase implements Serializable { assertFalse(o1.equals(o2)); } + @Test public void testSerialization() { UniqueSerializable o1 = new UniqueSerializable() { }; diff --git a/server/src/test/java/com/vaadin/ui/DateFieldTests.java b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java similarity index 97% rename from server/src/test/java/com/vaadin/ui/DateFieldTests.java rename to server/src/test/java/com/vaadin/ui/DateFieldTestCase.java index 6a75b4630c..5fee13f2cb 100644 --- a/server/src/test/java/com/vaadin/ui/DateFieldTests.java +++ b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java @@ -9,7 +9,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.nullValue; -public class DateFieldTests { +public class DateFieldTestCase { private DateField dateField; private Date date; -- 2.39.5