]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add @Test annotations, rename test classes
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 17 Mar 2016 09:37:12 +0000 (11:37 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 17 Mar 2016 12:33:34 +0000 (14:33 +0200)
Change-Id: Iac29db81c0c7ff425da73e7ae3d69eadabf5de77

154 files changed:
client/tests/src/com/vaadin/client/DateTimeServiceTest.java
client/tests/src/com/vaadin/client/LocatorUtilTest.java
client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java [deleted file]
server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java
server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java
server/src/test/java/com/vaadin/data/util/BeanContainerTest.java
server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java
server/src/test/java/com/vaadin/data/util/BeanItemTest.java
server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java
server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java
server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java
server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java
server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java
server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java
server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java
server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java
server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java
server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java
server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java
server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java
server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java
server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java
server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java
server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java
server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java
server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java
server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java
server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java [deleted file]
server/src/test/java/com/vaadin/server/JSONSerializerTest.java
server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java
server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java [deleted file]
server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java [deleted file]
server/src/test/java/com/vaadin/server/VaadinPortletTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/server/VaadinPortletTests.java [deleted file]
server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java
server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java
server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java
server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java
server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java
server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java
server/src/test/java/com/vaadin/tests/design/InvalidTagNames.java [deleted file]
server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java
server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java
server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java
server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java
server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java
server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java
server/src/test/java/com/vaadin/tests/server/EventRouterTest.java
server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java
server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java
server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java
server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java
server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java
server/src/test/java/com/vaadin/tests/server/SerializationTest.java
server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java
server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java
server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java
server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValues.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java
server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java
server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java
server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java
server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTests.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/datefield/ResolutionTest.java
server/src/test/java/com/vaadin/tests/server/component/grid/GridChildren.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/grid/GridColumns.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/grid/GridSelection.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/label/LabelListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java
server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java
server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/table/FooterTest.java
server/src/test/java/com/vaadin/tests/server/component/table/MultipleSelectionTest.java
server/src/test/java/com/vaadin/tests/server/component/table/TableListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java
server/src/test/java/com/vaadin/tests/server/component/table/TableSelectable.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/table/TableSerializationTest.java
server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java
server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java
server/src/test/java/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java
server/src/test/java/com/vaadin/tests/server/component/tree/ListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/tree/TreeListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java
server/src/test/java/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java
server/src/test/java/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java
server/src/test/java/com/vaadin/tests/server/component/upload/UploadListenersTest.java
server/src/test/java/com/vaadin/tests/server/component/window/WindowListenersTest.java
server/src/test/java/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java
server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java
server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java
server/src/test/java/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java
server/src/test/java/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java
server/src/test/java/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
server/src/test/java/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java
server/src/test/java/com/vaadin/tests/server/components/TextFieldValueChangeTest.java
server/src/test/java/com/vaadin/tests/server/components/WindowTest.java
server/src/test/java/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java
server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
server/src/test/java/com/vaadin/tests/server/validation/BeanValidationTest.java
server/src/test/java/com/vaadin/tests/server/validation/RangeValidatorTest.java
server/src/test/java/com/vaadin/tests/util/UniqueSerializableTest.java
server/src/test/java/com/vaadin/ui/DateFieldTestCase.java [new file with mode: 0644]
server/src/test/java/com/vaadin/ui/DateFieldTests.java [deleted file]

index f9351d1cc0dca7bfba3186f18149e8067fd77bf5..e5e6cbd7dbeac87bf12b5151159ea3008174dce7 100755 (executable)
@@ -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);
 
         }
index 15536ac6fc73909697b6b4ee23bfc40bed046ea6..971688e1c556e6f9661929fc58050ac155edcceb 100644 (file)
  */
 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]");
index 24bf9b655820af68cece17748ef95c465e9c1590..5522b8e2bcda555c18b60567f73f524aa02c60e8 100644 (file)
@@ -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/FieldGroupTest.java b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java
new file mode 100644 (file)
index 0000000..f8e4d1c
--- /dev/null
@@ -0,0 +1,95 @@
+package com.vaadin.data.fieldgroup;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.Transactional;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.TransactionalPropertyWrapper;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.TextField;
+
+public class FieldGroupTest {
+
+    private FieldGroup sut;
+    private Field field;
+
+    @Before
+    public void setup() {
+        sut = new FieldGroup();
+        field = mock(Field.class);
+    }
+
+    @Test
+    public void fieldIsBound() {
+        sut.bind(field, "foobar");
+
+        assertThat(sut.getField("foobar"), is(field));
+    }
+
+    @Test(expected = FieldGroup.BindException.class)
+    public void cannotBindToAlreadyBoundProperty() {
+        sut.bind(field, "foobar");
+        sut.bind(mock(Field.class), "foobar");
+    }
+
+    @Test(expected = FieldGroup.BindException.class)
+    public void cannotBindNullField() {
+        sut.bind(null, "foobar");
+    }
+
+    public void canUnbindWithoutItem() {
+        sut.bind(field, "foobar");
+
+        sut.unbind(field);
+        assertThat(sut.getField("foobar"), is(nullValue()));
+    }
+
+    @Test
+    public void wrapInTransactionalProperty_provideCustomImpl_customTransactionalWrapperIsUsed() {
+        Bean bean = new Bean();
+        FieldGroup group = new FieldGroup() {
+            @Override
+            protected <T> Transactional<T> wrapInTransactionalProperty(
+                    Property<T> itemProperty) {
+                return new TransactionalPropertyImpl(itemProperty);
+            }
+        };
+        group.setItemDataSource(new BeanItem<Bean>(bean));
+        TextField field = new TextField();
+        group.bind(field, "name");
+
+        Property propertyDataSource = field.getPropertyDataSource();
+        Assert.assertTrue("Custom implementation of transactional property "
+                + "has not been used",
+                propertyDataSource instanceof TransactionalPropertyImpl);
+    }
+
+    public static class TransactionalPropertyImpl<T> extends
+            TransactionalPropertyWrapper<T> {
+
+        public TransactionalPropertyImpl(Property<T> wrappedProperty) {
+            super(wrappedProperty);
+        }
+
+    }
+
+    public static class Bean {
+        private String name;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+}
diff --git a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java
deleted file mode 100644 (file)
index dce9f65..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.vaadin.data.fieldgroup;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.Transactional;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.TransactionalPropertyWrapper;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.TextField;
-
-public class FieldGroupTests {
-
-    private FieldGroup sut;
-    private Field field;
-
-    @Before
-    public void setup() {
-        sut = new FieldGroup();
-        field = mock(Field.class);
-    }
-
-    @Test
-    public void fieldIsBound() {
-        sut.bind(field, "foobar");
-
-        assertThat(sut.getField("foobar"), is(field));
-    }
-
-    @Test(expected = FieldGroup.BindException.class)
-    public void cannotBindToAlreadyBoundProperty() {
-        sut.bind(field, "foobar");
-        sut.bind(mock(Field.class), "foobar");
-    }
-
-    @Test(expected = FieldGroup.BindException.class)
-    public void cannotBindNullField() {
-        sut.bind(null, "foobar");
-    }
-
-    public void canUnbindWithoutItem() {
-        sut.bind(field, "foobar");
-
-        sut.unbind(field);
-        assertThat(sut.getField("foobar"), is(nullValue()));
-    }
-
-    @Test
-    public void wrapInTransactionalProperty_provideCustomImpl_customTransactionalWrapperIsUsed() {
-        Bean bean = new Bean();
-        FieldGroup group = new FieldGroup() {
-            @Override
-            protected <T> Transactional<T> wrapInTransactionalProperty(
-                    Property<T> itemProperty) {
-                return new TransactionalPropertyImpl(itemProperty);
-            }
-        };
-        group.setItemDataSource(new BeanItem<Bean>(bean));
-        TextField field = new TextField();
-        group.bind(field, "name");
-
-        Property propertyDataSource = field.getPropertyDataSource();
-        Assert.assertTrue("Custom implementation of transactional property "
-                + "has not been used",
-                propertyDataSource instanceof TransactionalPropertyImpl);
-    }
-
-    public static class TransactionalPropertyImpl<T> extends
-            TransactionalPropertyWrapper<T> {
-
-        public TransactionalPropertyImpl(Property<T> wrappedProperty) {
-            super(wrappedProperty);
-        }
-
-    }
-
-    public static class Bean {
-        private String name;
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-    }
-}
index 52acc5ab76719225224ddc16e4d739470eee8826..c70cf9844902910d4a2a8ea7be57d013e0fcd09f 100644 (file)
@@ -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.
index 9cede77162a8fa59d0e4b240f93cb09f2572f947..7a07c553f7dea0964c79b4af7e1c62ef1ef489de 100644 (file)
@@ -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;
index 3d755f439704f79ee3e79bb51e31ba27986de758..d990f3d1235d0ed1b21ff688e3ce771a34591606 100644 (file)
@@ -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<String, ClassName>(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<String, ClassName> 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<String, ClassName> 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<String, String> container = new BeanContainer<String, String>(
                 String.class);
@@ -175,6 +190,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
 
     // TODO test Container.Indexed interface operation - testContainerIndexed()?
 
+    @Test
     public void testAddItemAt() {
         BeanContainer<String, String> container = new BeanContainer<String, String>(
                 String.class);
@@ -198,6 +214,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals("id4", container.getIdByIndex(3));
     }
 
+    @Test
     public void testUnsupportedMethods() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -255,6 +272,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, container.size());
     }
 
+    @Test
     public void testRemoveContainerProperty() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -271,6 +289,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         Assert.assertNull(container.getItem("John").getItemProperty("name"));
     }
 
+    @Test
     public void testAddNullBeans() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -282,6 +301,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(0, container.size());
     }
 
+    @Test
     public void testAddNullId() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -295,6 +315,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(0, container.size());
     }
 
+    @Test
     public void testEmptyContainer() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -307,6 +328,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         // could test more about empty container
     }
 
+    @Test
     public void testAddBeanWithoutResolver() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -340,6 +362,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(0, container.size());
     }
 
+    @Test
     public void testAddAllWithNullItemId() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -372,6 +395,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(3, container.size());
     }
 
+    @Test
     public void testAddBeanWithNullResolver() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -400,6 +424,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(0, container.size());
     }
 
+    @Test
     public void testAddBeanWithResolver() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -422,6 +447,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(5, container.size());
     }
 
+    @Test
     public void testAddNullBeansWithResolver() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -434,6 +460,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(0, container.size());
     }
 
+    @Test
     public void testAddBeanWithPropertyResolver() {
         BeanContainer<String, Person> container = new BeanContainer<String, Person>(
                 Person.class);
@@ -456,6 +483,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(5, container.size());
     }
 
+    @Test
     public void testAddNestedContainerProperty() {
         BeanContainer<String, NestedMethodPropertyTest.Person> container = new BeanContainer<String, NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
@@ -470,6 +498,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase {
                         .getValue());
     }
 
+    @Test
     public void testNestedContainerPropertyWithNullBean() {
         BeanContainer<String, NestedMethodPropertyTest.Person> container = new BeanContainer<String, NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
index 3c30b41d39c5d41dd40f425b7c70b284b5798436..0298e57dcc8a8de3e1d8792f5785e79d00e54eac 100644 (file)
@@ -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>(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<ClassName> 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<ClassName> 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<String> container = new BeanItemContainer<String>(
                 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<ClassName> classNames = new ArrayList<ClassName>();
         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<ClassName>((Collection<ClassName>) null);
@@ -230,6 +248,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         }
     }
 
+    @Test
     public void testItemSetChangeListeners() {
         BeanItemContainer<ClassName> container = getContainer();
         ItemSetChangeCounter counter = new ItemSetChangeCounter();
@@ -328,6 +347,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
 
     }
 
+    @Test
     public void testItemSetChangeListenersFiltering() {
         BeanItemContainer<ClassName> container = getContainer();
         ItemSetChangeCounter counter = new ItemSetChangeCounter();
@@ -496,6 +516,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         counter.assertNone();
     }
 
+    @Test
     public void testAddRemoveWhileFiltering() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -573,6 +594,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(michael, container.lastItemId());
     }
 
+    @Test
     public void testRefilterOnPropertyModification() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -608,6 +630,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(3, container.size());
     }
 
+    @Test
     public void testAddAll() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -637,6 +660,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(michael, container.nextItemId(jack));
     }
 
+    @Test
     public void testUnsupportedMethods() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -673,6 +697,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, container.size());
     }
 
+    @Test
     public void testRemoveContainerProperty() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -689,6 +714,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         Assert.assertNull(container.getItem(john).getItemProperty("name"));
     }
 
+    @Test
     public void testAddNullBean() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -703,6 +729,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, container.size());
     }
 
+    @Test
     public void testBeanIdResolver() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 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<Object>((Class<Object>) null);
-        } catch (IllegalArgumentException e) {
-            // should get exception
-        }
+        new BeanItemContainer<Object>((Class<Object>) null);
     }
 
+    @Test
     public void testAddNestedContainerProperty() {
         BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
@@ -734,6 +759,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
                         .getValue());
     }
 
+    @Test
     public void testNestedContainerPropertyWithNullBean() {
         BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
@@ -748,6 +774,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
                 .getValue());
     }
 
+    @Test
     public void testItemAddedEvent() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -761,6 +788,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         EasyMock.verify(addListener);
     }
 
+    @Test
     public void testItemAddedEvent_AddedItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -774,6 +802,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(bean, capturedEvent.getValue().getFirstItemId());
     }
 
+    @Test
     public void testItemAddedEvent_addItemAt_IndexOfAddedItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -788,6 +817,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, capturedEvent.getValue().getFirstIndex());
     }
 
+    @Test
     public void testItemAddedEvent_addItemAfter_IndexOfAddedItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -802,6 +832,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, capturedEvent.getValue().getFirstIndex());
     }
 
+    @Test
     public void testItemAddedEvent_amountOfAddedItems() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -816,6 +847,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(2, capturedEvent.getValue().getAddedItemsCount());
     }
 
+    @Test
     public void testItemAddedEvent_someItemsAreFiltered_amountOfAddedItemsIsReducedByAmountOfFilteredItems() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -831,6 +863,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, capturedEvent.getValue().getAddedItemsCount());
     }
 
+    @Test
     public void testItemAddedEvent_someItemsAreFiltered_addedItemIsTheFirstVisibleItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -846,6 +879,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(bean, capturedEvent.getValue().getFirstItemId());
     }
 
+    @Test
     public void testItemRemovedEvent() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -861,6 +895,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         EasyMock.verify(removeListener);
     }
 
+    @Test
     public void testItemRemovedEvent_RemovedItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -875,6 +910,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(bean, capturedEvent.getValue().getFirstItemId());
     }
 
+    @Test
     public void testItemRemovedEvent_indexOfRemovedItem() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -890,6 +926,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         assertEquals(1, capturedEvent.getValue().getFirstIndex());
     }
 
+    @Test
     public void testItemRemovedEvent_amountOfRemovedItems() {
         BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                 Person.class);
@@ -926,6 +963,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
         return listener;
     }
 
+    @Test
     public void testAddNestedContainerBeanBeforeData() {
         BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
@@ -947,6 +985,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase {
 
     }
 
+    @Test
     public void testAddNestedContainerBeanAfterData() {
         BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
                 NestedMethodPropertyTest.Person.class);
index 89c56b1779b838638b2663cf3c364392a834b49e..e78d518a257a3ece9b259a0b47d60d1935a0274e 100644 (file)
@@ -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<MySuperClass> item = new BeanItem<MySuperClass>(
                 new MySuperClass());
@@ -172,6 +172,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertTrue(itemPropertyIds.contains("superPublic"));
     }
 
+    @Test
     public void testGetSuperClassProperties() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1"));
 
@@ -185,6 +186,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertTrue(itemPropertyIds.contains("name2"));
     }
 
+    @Test
     public void testOverridingProperties() {
         BeanItem<MyClass2> item = new BeanItem<MyClass2>(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<String> ids = new ArrayList<String>();
         ids.add("name");
@@ -253,6 +258,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertFalse(it.hasNext());
     }
 
+    @Test
     public void testPropertyExplicitOrder2() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(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<String> ids = new ArrayList<String>();
         ids.add("name3");
@@ -279,6 +286,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertFalse(it.hasNext());
     }
 
+    @Test
     public void testRemoveProperty() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1"));
 
@@ -290,6 +298,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertFalse(itemPropertyIds.contains("name2"));
     }
 
+    @Test
     public void testRemoveSuperProperty() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1"));
 
@@ -301,6 +310,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertFalse(itemPropertyIds.contains("superPrivate"));
     }
 
+    @Test
     public void testPropertyTypes() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1"));
 
@@ -314,6 +324,7 @@ public class BeanItemTest extends TestCase {
                 .getType()));
     }
 
+    @Test
     public void testPropertyReadOnly() {
         BeanItem<MyClass> item = new BeanItem<MyClass>(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<String, VaadinPropertyDescriptor<MyClass>> propertyDescriptors = new LinkedHashMap<String, VaadinPropertyDescriptor<MyClass>>();
         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<BeanItemTest.MyClass> pd = new MethodPropertyDescriptor<BeanItemTest.MyClass>(
                 "myname", MyClass.class,
@@ -359,6 +372,7 @@ public class BeanItemTest extends TestCase {
         Assert.assertEquals(null, item.getItemProperty("myname"));
     }
 
+    @Test
     public void testOverridenGenericMethods() {
         BeanItem<SubClass> item = new BeanItem<SubClass>(new SubClass());
 
index 8e554d50302e330e00f71cbf0b06c35bbea5f81d..a6fec6670bb40cd3a798654f63b27892135da69d 100644 (file)
@@ -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()));
index 422e9756f882be900de0b58c6ad520943d1b22ad..7e720071beea97cfaad67c69d593b05f0d3838a2 100644 (file)
@@ -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()));
index dd713dd7b07185b114868662d318cda997c71e0d..dced4b4e7211e82c6559999216729d455350243a 100644 (file)
@@ -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);
index 90ec893f4d915fc5ef55e24b807add8ae00d9747..5f7f965c69f961a44e87908a6c3e0e2ec52d8ea1 100644 (file)
@@ -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");
index 7ecf59c309ffabd57e976e598c5e873f8f7fc5c2..8c7970e554234813945133d02508f0d4e4e8c327 100644 (file)
@@ -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());
     }
index 0b71b3dff96af03963a6dc76b74050ae2ac69ba8..280c46efcc476962d9b650dcb668addc13f1c94c 100644 (file)
@@ -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();
 
index 5828ac88cc84c2a8e7aa95d0a07479bac63af39e..27632846deaab73f0feb5e5c91d8939d6eaea7ef 100644 (file)
@@ -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<Object> 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<Object> 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<Object> 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<Object> 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<Object> itemIds = ic.getItemIds(1, 2);
+        List<Object> 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));
     }
-
 }
index 6535ba1870ba2e7c90507bc3ccc0e23b421df450..79ce425bae8cbf374199f71af2ee4d170d1fce7f 100644 (file)
@@ -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<String> nameProperty = new NestedMethodProperty<String>(
                 vaadin, "name");
@@ -147,6 +144,7 @@ public class NestedMethodPropertyTest extends TestCase {
         Assert.assertEquals("Vaadin", nameProperty.getValue());
     }
 
+    @Test
     public void testSingleLevelNestedObjectProperty() {
         NestedMethodProperty<Person> managerProperty = new NestedMethodProperty<Person>(
                 vaadin, "manager");
@@ -155,6 +153,7 @@ public class NestedMethodPropertyTest extends TestCase {
         Assert.assertEquals(joonas, managerProperty.getValue());
     }
 
+    @Test
     public void testMultiLevelNestedProperty() {
         NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
                 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<Object>(vaadin, "");
@@ -207,6 +207,7 @@ public class NestedMethodPropertyTest extends TestCase {
         }
     }
 
+    @Test
     public void testInvalidPropertyName() {
         try {
             new NestedMethodProperty<Object>(vaadin, ".");
@@ -234,6 +235,7 @@ public class NestedMethodPropertyTest extends TestCase {
         }
     }
 
+    @Test
     public void testInvalidNestedPropertyName() {
         try {
             new NestedMethodProperty<Object>(vaadin, "member");
@@ -257,6 +259,7 @@ public class NestedMethodPropertyTest extends TestCase {
         }
     }
 
+    @Test
     public void testNullNestedProperty() {
         NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
                 vaadin, "manager.name");
@@ -276,6 +279,7 @@ public class NestedMethodPropertyTest extends TestCase {
 
     }
 
+    @Test
     public void testMultiLevelNestedPropertySetValue() {
         NestedMethodProperty<String> managerNameProperty = new NestedMethodProperty<String>(
                 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<String> streetProperty = new NestedMethodProperty<String>(
                 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<String> streetProperty = new NestedMethodProperty<String>(
                 vaadin, "manager.address.street");
index 99ca58ba42e88f934d858a661bbbfe71ddca4a73..e0307034cf06b123558805f3a659908acff64134 100644 (file)
@@ -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<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>(
                 super1, TestSuperClass.class);
@@ -46,6 +46,7 @@ public class ObjectPropertyTest extends TestCase {
         Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
     }
 
+    @Test
     public void testSetValueObjectSuper() {
         ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
                 super1, TestSuperClass.class);
@@ -55,6 +56,7 @@ public class ObjectPropertyTest extends TestCase {
         Assert.assertEquals("super2", prop.getValue().getName());
     }
 
+    @Test
     public void testSetValueObjectSub() {
         ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
                 sub1, TestSubClass.class);
@@ -64,6 +66,7 @@ public class ObjectPropertyTest extends TestCase {
         Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
     }
 
+    @Test
     public void testSetValueStringSuper() {
         ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
                 super1, TestSuperClass.class);
@@ -73,6 +76,7 @@ public class ObjectPropertyTest extends TestCase {
         Assert.assertEquals("super2", prop.getValue().getName());
     }
 
+    @Test
     public void testSetValueStringSub() {
         ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
                 sub1, TestSubClass.class);
@@ -82,6 +86,7 @@ public class ObjectPropertyTest extends TestCase {
         Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
     }
 
+    @Test
     public void testMixedGenerics() {
         ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
                 sub1);
index 042f260be83811c6975c4c5e88907359f73d369b..fdfc2199b6bd85f6c936e0c0a279429ec3a4d30d 100644 (file)
@@ -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<Long> times = new ArrayList<Long>();
         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<Long> times = new ArrayList<Long>();
         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<Long> times = new ArrayList<Long>();
@@ -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<Long> times = new ArrayList<Long>();
@@ -81,6 +84,7 @@ public class PerformanceTestIndexedContainerTest extends TestCase {
                 ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD);
     }
 
+    @Test
     public void testAddItemsConstructorPerformance() {
         Collection<Object> items = new ArrayList<Object>(50000);
         for (int i = 0; i < ITEMS; ++i) {
index 9d662b2599619694be87c977ae87fd100b579173..86f3968116cd676bb8c445a710092ced720eb7d9 100644 (file)
@@ -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<Person> pd = new NestedPropertyDescriptor<Person>(
@@ -55,6 +57,7 @@ public class PropertyDescriptorTest extends TestCase {
         Assert.assertEquals("John", property.getValue());
     }
 
+    @Test
     public void testNestedPropertyDescriptorSerialization() throws Exception {
         NestedPropertyDescriptor<Person> pd = new NestedPropertyDescriptor<Person>(
                 "address.street", Person.class);
@@ -69,6 +72,7 @@ public class PropertyDescriptorTest extends TestCase {
         Assert.assertNull(property.getValue());
     }
 
+    @Test
     public void testMethodPropertyDescriptorWithPrimitivePropertyType()
             throws Exception {
         MethodPropertyDescriptor<Person> pd = new MethodPropertyDescriptor<Person>(
index ff83db4437f0fec683205af63116fc7fad6bf80f..b957cb7f20592f41446e0104b01008cfac4ce97a 100644 (file)
@@ -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<String>(VALUE1, String.class);
         prop2 = new ObjectProperty<String>(VALUE2, String.class);
         prop3 = new ObjectProperty<String>(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();
index 1f42f4e93516b39d59e61c883159f6b55d2338b4..21ce68544551e32509f14101f4de231a06270938 100644 (file)
@@ -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<Integer>(1);
     protected Item item2 = new BeanItem<Integer>(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"));
index fc5ffb9b560c51cf0cb389f83b8a98138cd91bd0..116d70e188c95033c8863f6afc77262ab116baac 100644 (file)
@@ -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<Compare> {
         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<Compare> {
         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<Compare> {
         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<Compare> {
         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<Compare> {
 
     }
 
+    @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<Compare> {
         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<Compare> {
         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);
index 953bf3cd653db03a3aae3296ef9a78cc119ae449..7a2ab3af7e7eb093d02eb97969dbf97837868573 100644 (file)
@@ -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<IsNull> {
 
+    @Test
     public void testIsNull() {
         Item item1 = new PropertysetItem();
         item1.addItemProperty("a", new ObjectProperty<String>(null,
@@ -30,6 +32,7 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> {
         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<IsNull> {
         Assert.assertTrue(filterB.appliesToProperty("b"));
     }
 
+    @Test
     public void testIsNullEqualsHashCode() {
         Filter filter1 = new IsNull("a");
         Filter filter1b = new IsNull("a");
index 9ba5168ac9f16e93a5e5432c2030c31cecf01876..d43650101de228e7f1bfa1c1bfdeaa451968509e 100644 (file)
@@ -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<Like> {
     protected Item item2 = new PropertysetItem();
     protected Item item3 = new PropertysetItem();
 
+    @Test
     public void testLikeWithNulls() {
 
         Like filter = new Like("value", "a");
index 310b749ce2a5fed1f722404a8956de5de5941d5c..e797b484f82c87a38798bc45515350c8750bee31 100644 (file)
@@ -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<Not> {
     protected Item item1 = new BeanItem<Integer>(1);
     protected Item item2 = new BeanItem<Integer>(2);
 
+    @Test
     public void testNot() {
         Filter origFilter = new SameItemFilter(item1);
         Filter filter = new Not(origFilter);
@@ -21,6 +23,7 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> {
         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<Not> {
         Assert.assertTrue(filterB.appliesToProperty("b"));
     }
 
+    @Test
     public void testNotEqualsHashCode() {
         Filter origFilter = new SameItemFilter(item1);
         Filter filter1 = new Not(origFilter);
index fcaff6f2c3aae8f799750425d684cb927bee217d..e085c934c968386ecb0a65172bba6bf4cb16d692 100644 (file)
@@ -1,6 +1,7 @@
 package com.vaadin.data.util.filter;
 
 import org.junit.Assert;
+import org.junit.Test;
 
 public class SimpleStringFilterTest extends
         AbstractFilterTestBase<SimpleStringFilter> {
@@ -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<String, String> item = createTestItem();
         item.addItemProperty("other1", new NullProperty());
index d2c7ad85ed7d73aacc57782f70176d0c57a04df9..9c3f6c0eaa78cc8fd11d5f141c34efe5ad9508fd 100644 (file)
@@ -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/TicketTest.java b/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java
new file mode 100644 (file)
index 0000000..2030096
--- /dev/null
@@ -0,0 +1,198 @@
+package com.vaadin.data.util.sqlcontainer;
+
+import java.math.BigDecimal;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.filter.Compare.Equal;
+import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.FreeformQuery;
+import com.vaadin.data.util.sqlcontainer.query.FreeformStatementDelegate;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+import com.vaadin.data.util.sqlcontainer.query.ValidatingSimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
+import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class TicketTest {
+
+    private JDBCConnectionPool connectionPool;
+
+    @Before
+    public void setUp() throws SQLException {
+        connectionPool = new ValidatingSimpleJDBCConnectionPool(
+                SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL,
+                SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2);
+        DataGenerator.addPeopleToDatabase(connectionPool);
+    }
+
+    @Test
+    public void ticket5867_throwsIllegalState_transactionAlreadyActive()
+            throws SQLException {
+        SQLContainer container = new SQLContainer(new FreeformQuery(
+                "SELECT * FROM people", Arrays.asList("ID"), connectionPool));
+        Table table = new Table();
+        Window w = new Window();
+        w.setContent(table);
+        table.setContainerDataSource(container);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void ticket6136_freeform_ageIs18() throws SQLException {
+        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
+                Arrays.asList("ID"), connectionPool);
+        FreeformStatementDelegate delegate = EasyMock
+                .createMock(FreeformStatementDelegate.class);
+        final ArrayList<Filter> filters = new ArrayList<Filter>();
+        delegate.setFilters(null);
+        EasyMock.expectLastCall().anyTimes();
+        delegate.setOrderBy(EasyMock.isA(List.class));
+        EasyMock.expectLastCall().anyTimes();
+        delegate.setOrderBy(null);
+        EasyMock.expectLastCall().anyTimes();
+        delegate.setFilters(EasyMock.isA(List.class));
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            @Override
+            public Object answer() throws Throwable {
+                List<Filter> orders = (List<Filter>) EasyMock
+                        .getCurrentArguments()[0];
+                filters.clear();
+                filters.addAll(orders);
+                return null;
+            }
+        }).anyTimes();
+        EasyMock.expect(
+                delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt()))
+                .andAnswer(new IAnswer<StatementHelper>() {
+                    @Override
+                    public StatementHelper answer() throws Throwable {
+                        Object[] args = EasyMock.getCurrentArguments();
+                        int offset = (Integer) (args[0]);
+                        int limit = (Integer) (args[1]);
+                        return FreeformQueryUtil.getQueryWithFilters(filters,
+                                offset, limit);
+                    }
+                }).anyTimes();
+        EasyMock.expect(delegate.getCountStatement())
+                .andAnswer(new IAnswer<StatementHelper>() {
+                    @Override
+                    public StatementHelper answer() throws Throwable {
+                        StatementHelper sh = new StatementHelper();
+                        StringBuffer query = new StringBuffer(
+                                "SELECT COUNT(*) FROM people");
+                        if (!filters.isEmpty()) {
+                            query.append(QueryBuilder.getWhereStringForFilters(
+                                    filters, sh));
+                        }
+                        sh.setQueryString(query.toString());
+                        return sh;
+                    }
+                }).anyTimes();
+
+        EasyMock.replay(delegate);
+        query.setDelegate(delegate);
+        SQLContainer container = new SQLContainer(query);
+        // Ville, Kalle, Pelle, Börje
+        Assert.assertEquals(4, container.size());
+        Assert.assertEquals("Börje",
+                container.getContainerProperty(container.lastItemId(), "NAME")
+                        .getValue());
+
+        container.addContainerFilter(new Equal("AGE", 18));
+        // Pelle
+        Assert.assertEquals(1, container.size());
+        Assert.assertEquals("Pelle",
+                container.getContainerProperty(container.firstItemId(), "NAME")
+                        .getValue());
+        if (SQLTestsConstants.db == DB.ORACLE) {
+            Assert.assertEquals(new BigDecimal(18), container
+                    .getContainerProperty(container.firstItemId(), "AGE")
+                    .getValue());
+        } else {
+            Assert.assertEquals(
+                    18,
+                    container.getContainerProperty(container.firstItemId(),
+                            "AGE").getValue());
+        }
+
+        EasyMock.verify(delegate);
+    }
+
+    @Test
+    public void ticket6136_table_ageIs18() throws SQLException {
+        TableQuery query = new TableQuery("people", connectionPool,
+                SQLTestsConstants.sqlGen);
+        SQLContainer container = new SQLContainer(query);
+        // Ville, Kalle, Pelle, Börje
+        Assert.assertEquals(4, container.size());
+
+        container.addContainerFilter(new Equal("AGE", 18));
+
+        // Pelle
+        Assert.assertEquals(1, container.size());
+        Assert.assertEquals("Pelle",
+                container.getContainerProperty(container.firstItemId(), "NAME")
+                        .getValue());
+        if (SQLTestsConstants.db == DB.ORACLE) {
+            Assert.assertEquals(new BigDecimal(18), container
+                    .getContainerProperty(container.firstItemId(), "AGE")
+                    .getValue());
+        } else {
+            Assert.assertEquals(
+                    18,
+                    container.getContainerProperty(container.firstItemId(),
+                            "AGE").getValue());
+        }
+    }
+
+    @Test
+    public void ticket7434_getItem_Modified_Changed_Unchanged()
+            throws SQLException {
+        SQLContainer container = new SQLContainer(new TableQuery("people",
+                connectionPool, SQLTestsConstants.sqlGen));
+
+        Object id = container.firstItemId();
+        Item item = container.getItem(id);
+        String name = (String) item.getItemProperty("NAME").getValue();
+
+        // set a different name
+        item.getItemProperty("NAME").setValue("otherName");
+        Assert.assertEquals("otherName", item.getItemProperty("NAME")
+                .getValue());
+
+        // access the item and reset the name to its old value
+        Item item2 = container.getItem(id);
+        item2.getItemProperty("NAME").setValue(name);
+        Assert.assertEquals(name, item2.getItemProperty("NAME").getValue());
+
+        Item item3 = container.getItem(id);
+        String name3 = (String) item3.getItemProperty("NAME").getValue();
+
+        Assert.assertEquals(name, name3);
+    }
+
+    @Test
+    public void ticket10032_empty_set_metadata_correctly_handled()
+            throws SQLException {
+        // If problem exists will break when method getPropertyIds()
+        // is called in constructor SQLContainer(QueryDelegate delegate).
+        SQLContainer container = new SQLContainer(new FreeformQuery(
+                "SELECT * FROM people WHERE name='does_not_exist'",
+                Arrays.asList("ID"), connectionPool));
+        Assert.assertTrue("Got items while expected empty set",
+                container.size() == 0);
+    }
+}
diff --git a/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java b/server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java
deleted file mode 100644 (file)
index e180e3f..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-package com.vaadin.data.util.sqlcontainer;
-
-import java.math.BigDecimal;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.Container.Filter;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.filter.Compare.Equal;
-import com.vaadin.data.util.sqlcontainer.SQLTestsConstants.DB;
-import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.FreeformQuery;
-import com.vaadin.data.util.sqlcontainer.query.FreeformStatementDelegate;
-import com.vaadin.data.util.sqlcontainer.query.TableQuery;
-import com.vaadin.data.util.sqlcontainer.query.ValidatingSimpleJDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
-import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-public class TicketTests {
-
-    private JDBCConnectionPool connectionPool;
-
-    @Before
-    public void setUp() throws SQLException {
-        connectionPool = new ValidatingSimpleJDBCConnectionPool(
-                SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL,
-                SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2);
-        DataGenerator.addPeopleToDatabase(connectionPool);
-    }
-
-    @Test
-    public void ticket5867_throwsIllegalState_transactionAlreadyActive()
-            throws SQLException {
-        SQLContainer container = new SQLContainer(new FreeformQuery(
-                "SELECT * FROM people", Arrays.asList("ID"), connectionPool));
-        Table table = new Table();
-        Window w = new Window();
-        w.setContent(table);
-        table.setContainerDataSource(container);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void ticket6136_freeform_ageIs18() throws SQLException {
-        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
-                Arrays.asList("ID"), connectionPool);
-        FreeformStatementDelegate delegate = EasyMock
-                .createMock(FreeformStatementDelegate.class);
-        final ArrayList<Filter> filters = new ArrayList<Filter>();
-        delegate.setFilters(null);
-        EasyMock.expectLastCall().anyTimes();
-        delegate.setOrderBy(EasyMock.isA(List.class));
-        EasyMock.expectLastCall().anyTimes();
-        delegate.setOrderBy(null);
-        EasyMock.expectLastCall().anyTimes();
-        delegate.setFilters(EasyMock.isA(List.class));
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                List<Filter> orders = (List<Filter>) EasyMock
-                        .getCurrentArguments()[0];
-                filters.clear();
-                filters.addAll(orders);
-                return null;
-            }
-        }).anyTimes();
-        EasyMock.expect(
-                delegate.getQueryStatement(EasyMock.anyInt(), EasyMock.anyInt()))
-                .andAnswer(new IAnswer<StatementHelper>() {
-                    @Override
-                    public StatementHelper answer() throws Throwable {
-                        Object[] args = EasyMock.getCurrentArguments();
-                        int offset = (Integer) (args[0]);
-                        int limit = (Integer) (args[1]);
-                        return FreeformQueryUtil.getQueryWithFilters(filters,
-                                offset, limit);
-                    }
-                }).anyTimes();
-        EasyMock.expect(delegate.getCountStatement())
-                .andAnswer(new IAnswer<StatementHelper>() {
-                    @Override
-                    public StatementHelper answer() throws Throwable {
-                        StatementHelper sh = new StatementHelper();
-                        StringBuffer query = new StringBuffer(
-                                "SELECT COUNT(*) FROM people");
-                        if (!filters.isEmpty()) {
-                            query.append(QueryBuilder.getWhereStringForFilters(
-                                    filters, sh));
-                        }
-                        sh.setQueryString(query.toString());
-                        return sh;
-                    }
-                }).anyTimes();
-
-        EasyMock.replay(delegate);
-        query.setDelegate(delegate);
-        SQLContainer container = new SQLContainer(query);
-        // Ville, Kalle, Pelle, Börje
-        Assert.assertEquals(4, container.size());
-        Assert.assertEquals("Börje",
-                container.getContainerProperty(container.lastItemId(), "NAME")
-                        .getValue());
-
-        container.addContainerFilter(new Equal("AGE", 18));
-        // Pelle
-        Assert.assertEquals(1, container.size());
-        Assert.assertEquals("Pelle",
-                container.getContainerProperty(container.firstItemId(), "NAME")
-                        .getValue());
-        if (SQLTestsConstants.db == DB.ORACLE) {
-            Assert.assertEquals(new BigDecimal(18), container
-                    .getContainerProperty(container.firstItemId(), "AGE")
-                    .getValue());
-        } else {
-            Assert.assertEquals(
-                    18,
-                    container.getContainerProperty(container.firstItemId(),
-                            "AGE").getValue());
-        }
-
-        EasyMock.verify(delegate);
-    }
-
-    @Test
-    public void ticket6136_table_ageIs18() throws SQLException {
-        TableQuery query = new TableQuery("people", connectionPool,
-                SQLTestsConstants.sqlGen);
-        SQLContainer container = new SQLContainer(query);
-        // Ville, Kalle, Pelle, Börje
-        Assert.assertEquals(4, container.size());
-
-        container.addContainerFilter(new Equal("AGE", 18));
-
-        // Pelle
-        Assert.assertEquals(1, container.size());
-        Assert.assertEquals("Pelle",
-                container.getContainerProperty(container.firstItemId(), "NAME")
-                        .getValue());
-        if (SQLTestsConstants.db == DB.ORACLE) {
-            Assert.assertEquals(new BigDecimal(18), container
-                    .getContainerProperty(container.firstItemId(), "AGE")
-                    .getValue());
-        } else {
-            Assert.assertEquals(
-                    18,
-                    container.getContainerProperty(container.firstItemId(),
-                            "AGE").getValue());
-        }
-    }
-
-    @Test
-    public void ticket7434_getItem_Modified_Changed_Unchanged()
-            throws SQLException {
-        SQLContainer container = new SQLContainer(new TableQuery("people",
-                connectionPool, SQLTestsConstants.sqlGen));
-
-        Object id = container.firstItemId();
-        Item item = container.getItem(id);
-        String name = (String) item.getItemProperty("NAME").getValue();
-
-        // set a different name
-        item.getItemProperty("NAME").setValue("otherName");
-        Assert.assertEquals("otherName", item.getItemProperty("NAME")
-                .getValue());
-
-        // access the item and reset the name to its old value
-        Item item2 = container.getItem(id);
-        item2.getItemProperty("NAME").setValue(name);
-        Assert.assertEquals(name, item2.getItemProperty("NAME").getValue());
-
-        Item item3 = container.getItem(id);
-        String name3 = (String) item3.getItemProperty("NAME").getValue();
-
-        Assert.assertEquals(name, name3);
-    }
-
-    @Test
-    public void ticket10032_empty_set_metadata_correctly_handled()
-            throws SQLException {
-        // If problem exists will break when method getPropertyIds()
-        // is called in constructor SQLContainer(QueryDelegate delegate).
-        SQLContainer container = new SQLContainer(new FreeformQuery(
-                "SELECT * FROM people WHERE name='does_not_exist'",
-                Arrays.asList("ID"), connectionPool));
-        Assert.assertTrue("Got items while expected empty set",
-                container.size() == 0);
-    }
-}
index 6c5744556432d92f9e2ab0df1b2dd5ffe0795c3a..bb0be0987014e8c135f77ce8dba54351501b9b68 100644 (file)
@@ -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<String, AbstractSplitPanelState> stringToStateMap;
     HashMap<AbstractSplitPanelState, String> 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));
 
     }
 
index 3f940ae0a762114b522f82f45a236e9663b8b47a..aba29bf9a5024c57fccca8e71538e03a98d54d96 100644 (file)
@@ -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/VaadinPortletRequestTest.java b/server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java
new file mode 100644 (file)
index 0000000..2d15826
--- /dev/null
@@ -0,0 +1,53 @@
+package com.vaadin.server;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class VaadinPortletRequestTest {
+
+    private PortletRequest request;
+    private VaadinPortletRequest sut;
+    private VaadinPortletService service;
+    private PortletPreferences preferences;
+
+    @Before
+    public void setup() {
+        request = mock(PortletRequest.class);
+        service = mock(VaadinPortletService.class);
+
+        sut = new VaadinPortletRequest(request, service);
+
+        preferences = mock(PortletPreferences.class);
+        when(request.getPreferences()).thenReturn(preferences);
+    }
+
+    @Test
+    public void portletPreferenceIsFetched() {
+        when(preferences.getValue(eq("foo"), anyString())).thenReturn("bar");
+
+        String value = sut.getPortletPreference("foo");
+
+        assertThat(value, is("bar"));
+    }
+
+    @Test
+    public void defaultValueForPortletPreferenceIsNull() {
+        when(preferences.getValue(anyString(), isNull(String.class)))
+                .thenReturn(null);
+
+        String value = sut.getPortletPreference("foo");
+
+        assertNull(value);
+    }
+
+}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java
deleted file mode 100644 (file)
index bf2b809..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.vaadin.server;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class VaadinPortletRequestTests {
-
-    private PortletRequest request;
-    private VaadinPortletRequest sut;
-    private VaadinPortletService service;
-    private PortletPreferences preferences;
-
-    @Before
-    public void setup() {
-        request = mock(PortletRequest.class);
-        service = mock(VaadinPortletService.class);
-
-        sut = new VaadinPortletRequest(request, service);
-
-        preferences = mock(PortletPreferences.class);
-        when(request.getPreferences()).thenReturn(preferences);
-    }
-
-    @Test
-    public void portletPreferenceIsFetched() {
-        when(preferences.getValue(eq("foo"), anyString())).thenReturn("bar");
-
-        String value = sut.getPortletPreference("foo");
-
-        assertThat(value, is("bar"));
-    }
-
-    @Test
-    public void defaultValueForPortletPreferenceIsNull() {
-        when(preferences.getValue(anyString(), isNull(String.class)))
-                .thenReturn(null);
-
-        String value = sut.getPortletPreference("foo");
-
-        assertNull(value);
-    }
-
-}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java
new file mode 100644 (file)
index 0000000..d8c66e3
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.server;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.vaadin.shared.ui.ui.UIConstants;
+import com.vaadin.ui.UI;
+
+public class VaadinPortletServiceTest {
+
+    private VaadinPortletService sut;
+    private VaadinPortletRequest request;
+    private DeploymentConfiguration conf;
+
+    @Before
+    public void setup() throws ServiceException {
+        VaadinPortlet portlet = mock(VaadinPortlet.class);
+        conf = mock(DeploymentConfiguration.class);
+
+        sut = new VaadinPortletService(portlet, conf);
+
+        request = mock(VaadinPortletRequest.class);
+    }
+
+    private void mockFileLocationProperty(String location) {
+        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH,
+                location);
+    }
+
+    private void mockPortalProperty(String name, String value) {
+        when(request.getPortalProperty(name)).thenReturn(value);
+    }
+
+    private void mockFileLocationPreference(String location) {
+        when(
+                request.getPortletPreference(Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH))
+                .thenReturn(location);
+    }
+
+    private void mockLocationDeploymentConfiguration(String location) {
+        when(
+                conf.getApplicationOrSystemProperty(
+                        Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, null))
+                .thenReturn(location);
+    }
+
+    private String getStaticFileLocation() {
+        return sut.getStaticFileLocation(request);
+    }
+
+    private String getTheme() {
+        return sut.getConfiguredTheme(request);
+    }
+
+    private void mockThemeProperty(String theme) {
+        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_THEME, theme);
+    }
+
+    private void mockWidgetsetProperty(String widgetset) {
+        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET,
+                widgetset);
+    }
+
+    private void mockWidgetsetConfiguration(String widgetset) {
+        when(conf.getWidgetset(null)).thenReturn(widgetset);
+    }
+
+    @Test
+    public void preferencesOverrideDeploymentConfiguration() {
+        mockFileLocationPreference("prefs");
+        mockLocationDeploymentConfiguration("conf");
+
+        String location = getStaticFileLocation();
+
+        assertThat(location, is("prefs"));
+    }
+
+    @Test
+    public void deploymentConfigurationOverridesProperties() {
+        mockFileLocationPreference(null);
+        mockLocationDeploymentConfiguration("conf");
+        mockFileLocationProperty("props");
+
+        String location = getStaticFileLocation();
+
+        assertThat(location, is("conf"));
+    }
+
+    @Test
+    public void defaultFileLocationIsSet() {
+        mockFileLocationPreference(null);
+        mockLocationDeploymentConfiguration(null);
+        mockFileLocationProperty(null);
+
+        String location = getStaticFileLocation();
+
+        assertThat(location, is("/html"));
+    }
+
+    @Test
+    public void trailingSlashesAreTrimmedFromStaticFileLocation() {
+        mockFileLocationPreference("/content////");
+
+        String staticFileLocation = getStaticFileLocation();
+
+        assertThat(staticFileLocation, is("/content"));
+    }
+
+    @Test
+    public void themeCanBeOverridden() {
+        mockThemeProperty("foobar");
+
+        String theme = getTheme();
+
+        assertThat(theme, is("foobar"));
+    }
+
+    @Test
+    public void defaultThemeIsSet() {
+        mockThemeProperty(null);
+
+        String theme = getTheme();
+
+        assertThat(theme, is(Constants.DEFAULT_THEME_NAME));
+    }
+
+    private String getWidgetset() {
+        return sut.getConfiguredWidgetset(request);
+    }
+
+    @Test
+    public void defaultWidgetsetIsSet() {
+        mockWidgetsetProperty(null);
+        mockWidgetsetConfiguration(null);
+
+        String widgetset = getWidgetset();
+
+        assertThat(widgetset, is(Constants.DEFAULT_WIDGETSET));
+    }
+
+    @Test
+    public void configurationWidgetsetOverridesProperty() {
+        mockWidgetsetProperty("foo");
+        mockWidgetsetConfiguration("bar");
+
+        String widgetset = getWidgetset();
+
+        assertThat(widgetset, is("bar"));
+    }
+
+    @Test
+    public void oldDefaultWidgetsetIsMappedToDefaultWidgetset() {
+        mockWidgetsetConfiguration(null);
+        mockWidgetsetProperty("com.vaadin.portal.gwt.PortalDefaultWidgetSet");
+
+        String widgetset = getWidgetset();
+
+        assertThat(widgetset, is(Constants.DEFAULT_WIDGETSET));
+    }
+
+    @Test
+    public void oldDefaultWidgetSetIsNotMappedToDefaultWidgetset() {
+        mockWidgetsetConfiguration("com.vaadin.portal.gwt.PortalDefaultWidgetSet");
+        mockWidgetsetProperty(null);
+
+        String widgetset = getWidgetset();
+
+        assertThat(widgetset,
+                is("com.vaadin.portal.gwt.PortalDefaultWidgetSet"));
+    }
+
+    @Test
+    public void findUIDoesntThrowNPE() {
+        try {
+            ReentrantLock mockLock = Mockito.mock(ReentrantLock.class);
+            when(mockLock.isHeldByCurrentThread()).thenReturn(true);
+
+            WrappedSession emptyWrappedSession = Mockito
+                    .mock(WrappedPortletSession.class);
+            when(emptyWrappedSession.getAttribute("null.lock")).thenReturn(
+                    mockLock);
+            VaadinRequest requestWithUIIDSet = Mockito
+                    .mock(VaadinRequest.class);
+            when(requestWithUIIDSet.getParameter(UIConstants.UI_ID_PARAMETER))
+                    .thenReturn("1");
+            when(requestWithUIIDSet.getWrappedSession()).thenReturn(
+                    emptyWrappedSession);
+
+            UI ui = sut.findUI(requestWithUIIDSet);
+            Assert.assertNull("Unset session did not return null", ui);
+        } catch (NullPointerException e) {
+            Assert.fail("findUI threw a NullPointerException");
+        }
+    }
+}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java
deleted file mode 100644 (file)
index 38f3b85..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.server;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import com.vaadin.shared.ui.ui.UIConstants;
-import com.vaadin.ui.UI;
-
-public class VaadinPortletServiceTests {
-
-    private VaadinPortletService sut;
-    private VaadinPortletRequest request;
-    private DeploymentConfiguration conf;
-
-    @Before
-    public void setup() throws ServiceException {
-        VaadinPortlet portlet = mock(VaadinPortlet.class);
-        conf = mock(DeploymentConfiguration.class);
-
-        sut = new VaadinPortletService(portlet, conf);
-
-        request = mock(VaadinPortletRequest.class);
-    }
-
-    private void mockFileLocationProperty(String location) {
-        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH,
-                location);
-    }
-
-    private void mockPortalProperty(String name, String value) {
-        when(request.getPortalProperty(name)).thenReturn(value);
-    }
-
-    private void mockFileLocationPreference(String location) {
-        when(
-                request.getPortletPreference(Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH))
-                .thenReturn(location);
-    }
-
-    private void mockLocationDeploymentConfiguration(String location) {
-        when(
-                conf.getApplicationOrSystemProperty(
-                        Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, null))
-                .thenReturn(location);
-    }
-
-    private String getStaticFileLocation() {
-        return sut.getStaticFileLocation(request);
-    }
-
-    private String getTheme() {
-        return sut.getConfiguredTheme(request);
-    }
-
-    private void mockThemeProperty(String theme) {
-        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_THEME, theme);
-    }
-
-    private void mockWidgetsetProperty(String widgetset) {
-        mockPortalProperty(Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET,
-                widgetset);
-    }
-
-    private void mockWidgetsetConfiguration(String widgetset) {
-        when(conf.getWidgetset(null)).thenReturn(widgetset);
-    }
-
-    @Test
-    public void preferencesOverrideDeploymentConfiguration() {
-        mockFileLocationPreference("prefs");
-        mockLocationDeploymentConfiguration("conf");
-
-        String location = getStaticFileLocation();
-
-        assertThat(location, is("prefs"));
-    }
-
-    @Test
-    public void deploymentConfigurationOverridesProperties() {
-        mockFileLocationPreference(null);
-        mockLocationDeploymentConfiguration("conf");
-        mockFileLocationProperty("props");
-
-        String location = getStaticFileLocation();
-
-        assertThat(location, is("conf"));
-    }
-
-    @Test
-    public void defaultFileLocationIsSet() {
-        mockFileLocationPreference(null);
-        mockLocationDeploymentConfiguration(null);
-        mockFileLocationProperty(null);
-
-        String location = getStaticFileLocation();
-
-        assertThat(location, is("/html"));
-    }
-
-    @Test
-    public void trailingSlashesAreTrimmedFromStaticFileLocation() {
-        mockFileLocationPreference("/content////");
-
-        String staticFileLocation = getStaticFileLocation();
-
-        assertThat(staticFileLocation, is("/content"));
-    }
-
-    @Test
-    public void themeCanBeOverridden() {
-        mockThemeProperty("foobar");
-
-        String theme = getTheme();
-
-        assertThat(theme, is("foobar"));
-    }
-
-    @Test
-    public void defaultThemeIsSet() {
-        mockThemeProperty(null);
-
-        String theme = getTheme();
-
-        assertThat(theme, is(Constants.DEFAULT_THEME_NAME));
-    }
-
-    private String getWidgetset() {
-        return sut.getConfiguredWidgetset(request);
-    }
-
-    @Test
-    public void defaultWidgetsetIsSet() {
-        mockWidgetsetProperty(null);
-        mockWidgetsetConfiguration(null);
-
-        String widgetset = getWidgetset();
-
-        assertThat(widgetset, is(Constants.DEFAULT_WIDGETSET));
-    }
-
-    @Test
-    public void configurationWidgetsetOverridesProperty() {
-        mockWidgetsetProperty("foo");
-        mockWidgetsetConfiguration("bar");
-
-        String widgetset = getWidgetset();
-
-        assertThat(widgetset, is("bar"));
-    }
-
-    @Test
-    public void oldDefaultWidgetsetIsMappedToDefaultWidgetset() {
-        mockWidgetsetConfiguration(null);
-        mockWidgetsetProperty("com.vaadin.portal.gwt.PortalDefaultWidgetSet");
-
-        String widgetset = getWidgetset();
-
-        assertThat(widgetset, is(Constants.DEFAULT_WIDGETSET));
-    }
-
-    @Test
-    public void oldDefaultWidgetSetIsNotMappedToDefaultWidgetset() {
-        mockWidgetsetConfiguration("com.vaadin.portal.gwt.PortalDefaultWidgetSet");
-        mockWidgetsetProperty(null);
-
-        String widgetset = getWidgetset();
-
-        assertThat(widgetset,
-                is("com.vaadin.portal.gwt.PortalDefaultWidgetSet"));
-    }
-
-    @Test
-    public void findUIDoesntThrowNPE() {
-        try {
-            ReentrantLock mockLock = Mockito.mock(ReentrantLock.class);
-            when(mockLock.isHeldByCurrentThread()).thenReturn(true);
-
-            WrappedSession emptyWrappedSession = Mockito
-                    .mock(WrappedPortletSession.class);
-            when(emptyWrappedSession.getAttribute("null.lock")).thenReturn(
-                    mockLock);
-            VaadinRequest requestWithUIIDSet = Mockito
-                    .mock(VaadinRequest.class);
-            when(requestWithUIIDSet.getParameter(UIConstants.UI_ID_PARAMETER))
-                    .thenReturn("1");
-            when(requestWithUIIDSet.getWrappedSession()).thenReturn(
-                    emptyWrappedSession);
-
-            UI ui = sut.findUI(requestWithUIIDSet);
-            Assert.assertNull("Unset session did not return null", ui);
-        } catch (NullPointerException e) {
-            Assert.fail("findUI threw a NullPointerException");
-        }
-    }
-}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletTest.java b/server/src/test/java/com/vaadin/server/VaadinPortletTest.java
new file mode 100644 (file)
index 0000000..4e74f91
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.server;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.server.VaadinPortlet.VaadinGateInRequest;
+import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
+import com.vaadin.server.VaadinPortlet.VaadinWebSpherePortalRequest;
+
+public class VaadinPortletTest {
+
+    private VaadinPortlet sut;
+    private PortletRequest portletRequest;
+    private PortalContext portalContext;
+
+    @Before
+    public void setup() {
+        sut = new VaadinPortlet();
+
+        portletRequest = mock(PortletRequest.class);
+        portalContext = mock(PortalContext.class);
+
+        when(portletRequest.getPortalContext()).thenReturn(portalContext);
+    }
+
+    private void mockPortalInfo(String name) {
+        when(portalContext.getPortalInfo()).thenReturn(name);
+    }
+
+    private VaadinPortletRequest createRequest() {
+        VaadinPortletRequest request = sut.createVaadinRequest(portletRequest);
+        return request;
+    }
+
+    @Test
+    public void gateInRequestIsCreated() {
+        mockPortalInfo("gatein");
+
+        VaadinPortletRequest request = createRequest();
+
+        assertThat(request, instanceOf(VaadinGateInRequest.class));
+    }
+
+    @Test
+    public void liferayRequestIsCreated() {
+        mockPortalInfo("liferay");
+
+        VaadinPortletRequest request = createRequest();
+
+        assertThat(request, instanceOf(VaadinLiferayRequest.class));
+    }
+
+    @Test
+    public void webspherePortalRequestIsCreated() {
+        mockPortalInfo("websphere portal");
+
+        VaadinPortletRequest request = createRequest();
+
+        assertThat(request, instanceOf(VaadinWebSpherePortalRequest.class));
+    }
+
+    @Test
+    public void defaultPortletRequestIsCreated() {
+        mockPortalInfo("foobar");
+
+        VaadinPortletRequest request = createRequest();
+
+        assertThat(request, instanceOf(VaadinPortletRequest.class));
+    }
+
+}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletTests.java b/server/src/test/java/com/vaadin/server/VaadinPortletTests.java
deleted file mode 100644 (file)
index f92aa0d..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.server;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import javax.portlet.PortalContext;
-import javax.portlet.PortletRequest;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.server.VaadinPortlet.VaadinGateInRequest;
-import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
-import com.vaadin.server.VaadinPortlet.VaadinWebSpherePortalRequest;
-
-public class VaadinPortletTests {
-
-    private VaadinPortlet sut;
-    private PortletRequest portletRequest;
-    private PortalContext portalContext;
-
-    @Before
-    public void setup() {
-        sut = new VaadinPortlet();
-
-        portletRequest = mock(PortletRequest.class);
-        portalContext = mock(PortalContext.class);
-
-        when(portletRequest.getPortalContext()).thenReturn(portalContext);
-    }
-
-    private void mockPortalInfo(String name) {
-        when(portalContext.getPortalInfo()).thenReturn(name);
-    }
-
-    private VaadinPortletRequest createRequest() {
-        VaadinPortletRequest request = sut.createVaadinRequest(portletRequest);
-        return request;
-    }
-
-    @Test
-    public void gateInRequestIsCreated() {
-        mockPortalInfo("gatein");
-
-        VaadinPortletRequest request = createRequest();
-
-        assertThat(request, instanceOf(VaadinGateInRequest.class));
-    }
-
-    @Test
-    public void liferayRequestIsCreated() {
-        mockPortalInfo("liferay");
-
-        VaadinPortletRequest request = createRequest();
-
-        assertThat(request, instanceOf(VaadinLiferayRequest.class));
-    }
-
-    @Test
-    public void webspherePortalRequestIsCreated() {
-        mockPortalInfo("websphere portal");
-
-        VaadinPortletRequest request = createRequest();
-
-        assertThat(request, instanceOf(VaadinWebSpherePortalRequest.class));
-    }
-
-    @Test
-    public void defaultPortletRequestIsCreated() {
-        mockPortalInfo("foobar");
-
-        VaadinPortletRequest request = createRequest();
-
-        assertThat(request, instanceOf(VaadinPortletRequest.class));
-    }
-
-}
index f9e12ce75f4433856868b77e187f0d50c2026387..a1a833e8af6661b7bf51d8f1b387e000c6c5034c 100644 (file)
@@ -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 {
index a61c0c9986d1a7cee4b23dd9bb0ee3e1047233f4..766c2309a0ab166ba65c4259ff20114a21e550cc 100644 (file)
@@ -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<String, Integer> {
 
@@ -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());
     }
 }
index d767430cc101c77deea95d6d21c80c0c78e17961..2dbdaceb3bf41847492eac89d8008c2000c95656 100644 (file)
@@ -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));
     }
 }
index 46dca6d13e426036595da3f5a68edbe3089ba22e..dd71609d02288c1e8ac13aae46b47953ea344f9e 100644 (file)
@@ -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));
     }
 }
index 06d407c9f427ea30a446f2ff29c80ed719969c3d..48ebebdaff0384f1765ec7cd14ef88307146ef13 100644 (file)
@@ -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);
     }
 }
index 057017790d22eedc29aad63006f39afc81b526aa..312595746dc0ac355ed4186f44447e673690e0af 100644 (file)
@@ -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);
     }
 }
index 6e81af97a3f27ccbfdd7b7f150b56226d706ea7a..16bb5b1a640a1f54658a070fd966179ec88ebc01 100644 (file)
@@ -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));
     }
-
 }
index 3859d03cc35944fdd47e491e61d48645e6a4d9fb..2de72093d816dd8b5cc7aaaa968f184ed39f0a7a 100644 (file)
@@ -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<Byte, String> reverseConverter = new ReverseConverter<Byte, String>(
             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);
     }
 }
index 16008d89c26ffe78ae431a61f01a0bdba62f6c7a..8bac8b535baf8cd23f71e384c4a6d8768cb2e737 100644 (file)
@@ -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));
     }
 }
index 7054587009f9e671392deca5b32b1a1ac6b62241..1c983d48f65794b4f22d18036d5438a3d09e29d2 100644 (file)
@@ -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);
     }
 }
index 86319e641c783e4af6307240f53d32abd314f970..b99ce313b429fdf93577930b7ef929ea963d69ec 100644 (file)
@@ -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));
     }
 }
index 0076f2c9d1d9205e1a549db3755c4c77c6dfc3eb..56826b77c088005cfcc78b58856fb4bf2a4b734c 100644 (file)
@@ -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));
     }
 }
index 989dbcbbf546995fe6424fe07d20b223fd8c22e3..9ea0cea63ca16842fe1adf61eb7edd1070bb49d9 100644 (file)
@@ -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<Long, String> reverseConverter = new ReverseConverter<Long, String>(
             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);
 
     }
 }
index ab255bce80d2b970cafffe6f1d62224ec9f70d39..3faa65c863675e56f461cf10082e1ea14ff5a391 100644 (file)
@@ -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<Short, String> reverseConverter = new ReverseConverter<Short, String>(
             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);
     }
 }
index 36f120151bbf96100e2251449dcf41779967bc62..abffae9c9e909c194ae977b7e1ebe159b077a304 100644 (file)
@@ -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)));
     }
 }
index 92fabbb02a6e8f6f4ade4b7929393a09019cdf3f..5f15a63f59674a405654fd424133360fd4c4c463 100644 (file)
@@ -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)));
     }
 }
index 03f35fe1bb6a689d5af17d961021b37695b574a1..203c7847e922fcd109504a989cc381fba3755b9f 100644 (file)
@@ -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));
index 8199419b670c8773f538c8b8f5268ba0e54b06ab..12b84e129da2408d5e0981a6ea31e0e8c44672e0 100644 (file)
@@ -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";
index 7bb3e20160ef6ffc2eeaf3360f1ffedae14a412f..4beea35905f8640e15874b2bdf02f8104787ad58 100644 (file)
@@ -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);
index b096937bd24be7508f8fd905e25b30a2b659dd54..81fb9b0ac6d898e1d91411d67993c2a9c9978da3 100644 (file)
@@ -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));
index 19fe9e6580cacdf5783aaf8f35fd48155e1290a2..97d304d7df33aa1d3d4fa4330df6ffeb3804186a 100644 (file)
@@ -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"));
     }
 }
index c5a07be43fc8e5849ad0956c0ab7f0849b080588..db4b73fd1bb12b223496bbe0ef4c0aed75b4ec2b 100644 (file)
@@ -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));
index 5e64d0107ea083b9ad52519187dec931377c35f9..8a572cb3275e349b770b1215269a16a5d3741154 100644 (file)
@@ -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));
index 440e9c3fd2823a7fcc71f22473affe5e0efc4c6f..436e3224a4d5014d1abe31325fb253d1a789aaaf 100644 (file)
@@ -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));
index 1e08ea7e2c480c5fd1550b4b39d16f9837da9124..336df617d14d50bf9e03b57fc55c73e58faa83d7 100644 (file)
@@ -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");
index 2a62d230598d7cd1c8edd9bbd9381f91100e826b..7776d8929301cd87e7c30f86f436679aa4d8732d 100644 (file)
@@ -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"));
index 69d22eb91ebbc634dbba8c5780cf93d8508d18b2..d3534ebe9780bac01522510c602e6986e03c89d6 100644 (file)
@@ -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));
index 5f12367f09473b55414dfd310e8239fc2522c9ac..de925f479f31217b7ea203dcdb7cf307d0ccdae3 100644 (file)
@@ -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/InvalidTagNames.java
deleted file mode 100644 (file)
index 9f405f4..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.design;
-
-import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.declarative.Design;
-import com.vaadin.ui.declarative.DesignException;
-
-public class InvalidTagNames {
-
-    @Test(expected = DesignException.class)
-    public void tagWithoutDash() {
-        readDesign("<vbutton>foo</vbutton>");
-    }
-
-    @Test
-    public void emptyTag() {
-        // JSoup parses empty tags into text nodes
-        Component c = readDesign("<>foo</>");
-        Assert.assertNull(c);
-    }
-
-    @Test(expected = DesignException.class)
-    public void onlyPrefix() {
-        readDesign("<vaadin->foo</vaadin->");
-    }
-
-    @Test
-    public void onlyClass() {
-        // JSoup will refuse to parse tags starting with - and convert them into
-        // text nodes instead
-        Component c = readDesign("<-v>foo</-v>");
-        Assert.assertNull(c);
-    }
-
-    @Test(expected = DesignException.class)
-    public void unknownClass() {
-        readDesign("<vaadin-unknownbutton>foo</vaadin-unknownbutton>");
-    }
-
-    @Test(expected = DesignException.class)
-    public void unknownTag() {
-        readDesign("<x-button></x-button>");
-    }
-
-    // @Test(expected = DesignException.class)
-    // This is a side effect of not actively checking for invalid input. Will be
-    // parsed currently as <vaadin-button> (this should not be considered API)
-    public void tagEndsInDash() {
-        Component c = readDesign("<vaadin-button-></vaadin-button->");
-        Assert.assertTrue(c.getClass() == Button.class);
-    }
-
-    // @Test(expected = DesignException.class)
-    // This is a side effect of not actively checking for invalid input. Will be
-    // parsed currently as <vaadin-button> (this should not be considered API)
-    public void tagEndsInTwoDashes() {
-        Component c = readDesign("<vaadin-button--></vaadin-button-->");
-        Assert.assertTrue(c.getClass() == Button.class);
-    }
-
-    // @Test(expected = DesignException.class)
-    // This is a side effect of not actively checking for invalid input. Will be
-    // parsed currently as <vaadin-button> (this should not be considered API)
-    public void tagWithTwoDashes() {
-        Component c = readDesign("<vaadin--button></vaadin--button>");
-        Assert.assertTrue(c.getClass() == Button.class);
-    }
-
-    @Test(expected = DesignException.class)
-    public void specialCharacters() {
-        readDesign("<vaadin-button-&!#></vaadin-button-&!#>");
-    }
-
-    private Component readDesign(String string) {
-        try {
-            return Design.read(new ByteArrayInputStream(string
-                    .getBytes("UTF-8")));
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e);
-        }
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java
new file mode 100644 (file)
index 0000000..1b5bfcc
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.design;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.declarative.DesignException;
+
+public class InvalidTagNamesTest {
+
+    @Test(expected = DesignException.class)
+    public void tagWithoutDash() {
+        readDesign("<vbutton>foo</vbutton>");
+    }
+
+    @Test
+    public void emptyTag() {
+        // JSoup parses empty tags into text nodes
+        Component c = readDesign("<>foo</>");
+        Assert.assertNull(c);
+    }
+
+    @Test(expected = DesignException.class)
+    public void onlyPrefix() {
+        readDesign("<vaadin->foo</vaadin->");
+    }
+
+    @Test
+    public void onlyClass() {
+        // JSoup will refuse to parse tags starting with - and convert them into
+        // text nodes instead
+        Component c = readDesign("<-v>foo</-v>");
+        Assert.assertNull(c);
+    }
+
+    @Test(expected = DesignException.class)
+    public void unknownClass() {
+        readDesign("<vaadin-unknownbutton>foo</vaadin-unknownbutton>");
+    }
+
+    @Test(expected = DesignException.class)
+    public void unknownTag() {
+        readDesign("<x-button></x-button>");
+    }
+
+    // @Test(expected = DesignException.class)
+    // This is a side effect of not actively checking for invalid input. Will be
+    // parsed currently as <vaadin-button> (this should not be considered API)
+    public void tagEndsInDash() {
+        Component c = readDesign("<vaadin-button-></vaadin-button->");
+        Assert.assertTrue(c.getClass() == Button.class);
+    }
+
+    // @Test(expected = DesignException.class)
+    // This is a side effect of not actively checking for invalid input. Will be
+    // parsed currently as <vaadin-button> (this should not be considered API)
+    public void tagEndsInTwoDashes() {
+        Component c = readDesign("<vaadin-button--></vaadin-button-->");
+        Assert.assertTrue(c.getClass() == Button.class);
+    }
+
+    // @Test(expected = DesignException.class)
+    // This is a side effect of not actively checking for invalid input. Will be
+    // parsed currently as <vaadin-button> (this should not be considered API)
+    public void tagWithTwoDashes() {
+        Component c = readDesign("<vaadin--button></vaadin--button>");
+        Assert.assertTrue(c.getClass() == Button.class);
+    }
+
+    @Test(expected = DesignException.class)
+    public void specialCharacters() {
+        readDesign("<vaadin-button-&!#></vaadin-button-&!#>");
+    }
+
+    private Component readDesign(String string) {
+        try {
+            return Design.read(new ByteArrayInputStream(string
+                    .getBytes("UTF-8")));
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
index 91036c03ed2c4bbb38681efd80a2dbde02d06075..cb7b91226e2fc0e9b8442d7ea6e1214207c0f14e 100644 (file)
@@ -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);
index fd38b52a3787a27397843aede33e969f22e10015..71a84eea6eeb408cfcfa903426820d74796a0d48 100644 (file)
@@ -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<String>(""));
     }
 
+    @Test
     public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
         testListenerAddGetRemove(AbstractProperty.class,
                 ReadOnlyStatusChangeEvent.class,
index 087a7fb0f535bda488c9b1e31caf3063b93aeac7..f09db0ea9907e52d515a1da4356d379ab1db92d3 100644 (file)
 
 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 {
index 90a0283cda4802b458698165f745e8a46168116f..ef5420229ac43bb954a666d11c90a4bb5af480ad 100644 (file)
@@ -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());
index c22e289bc4dc2e82b8235c13ed2caece84146fc3..2aef09fa2ab80cb1fcfe49de9d8b7ca4b2543c58 100644 (file)
@@ -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<String> 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);
         }
     }
index 1ec19724d81e4c57954b396c1dbd4eba931d85b1..33f6e1f90a85c1597cc95d496908bb7b7fa26cc9 100644 (file)
@@ -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" };
index 67f39d301dc5285eee12f057f6ca88e115171563..e7d8749c858b0ff6639a984bbb78e3d3093a213d 100644 (file)
@@ -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();
 
index 3c68e86afa9a820866023aaca9d905030750b7a7..a8af915cdc9edc847d92031f3cf296270fb45e4a 100644 (file)
@@ -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"));
index 594f5627dd0d869f218c2d50544c08c4e44f64c0..bc2c5e3558bc271a09b1ad376e0c9a4db0b049d4 100644 (file)
@@ -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);
index d632e65c9fe198efa68579412ec07762226a2db5..7ca3c61a557fbd8e8993055e7d4614beeba767f9 100644 (file)
@@ -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<Object> mapper = new KeyMapper<Object>();
         Object o1 = new Object();
@@ -40,6 +45,7 @@ public class KeyMapperTest extends TestCase {
 
     }
 
+    @Test
     public void testRemoveAll() {
         KeyMapper<Object> mapper = new KeyMapper<Object>();
         Object o1 = new Object();
@@ -57,6 +63,7 @@ public class KeyMapperTest extends TestCase {
 
     }
 
+    @Test
     public void testRemove() {
         KeyMapper<Object> mapper = new KeyMapper<Object>();
         Object o1 = new Object();
index 36007fae17e80e9ecc7ebf6444cb1028b0820bb3..825c8b22ad7649a29bf129eecbd7b512748fdf5f 100644 (file)
@@ -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",
index 6563556a4eef020bf96e8f0617207c6b63d11068..14da1171c6898233ef52a43fbfeb409e6a6e854b 100644 (file)
@@ -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 {
 
index 4de30e579e3a4011dc5c45aabde42c4cd82ad7fd..349a2c525e9afb35620ea260d18d34cc4d08ac77 100644 (file)
@@ -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<Object>(new Data(),
                 "dummyGetter");
         serializeAndDeserialize(mp);
     }
 
+    @Test
     public void testMethodPropertyGetterAndSetter() throws Exception {
         MethodProperty<?> mp = new MethodProperty<Object>(new Data(),
                 "dummyGetterAndSetter");
         serializeAndDeserialize(mp);
     }
 
+    @Test
     public void testMethodPropertyInt() throws Exception {
         MethodProperty<?> mp = new MethodProperty<Object>(new Data(),
                 "dummyInt");
         serializeAndDeserialize(mp);
     }
 
+    @Test
     public void testVaadinSession() throws Exception {
         VaadinSession session = new VaadinSession(null);
 
index 04e621d5d206569248195f332c7cdf046babe407..70a18d1fa6f7de93dfbe1ebaf822fb52e1f124d1 100644 (file)
@@ -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");
index b430c7cf8481b2078d43de0477b1d81844acfd4c..f93d6095c15e1933d0c399cd289933d0c5598510 100644 (file)
@@ -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);
index 4e8f987def090b5d39e3a39b77a002650b8b8708..24201ce51dd8707d976015b416dff322aa4fc1f2 100644 (file)
@@ -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,
index 2083d1f473ecf830d336f9f71e1a060d434d7f4c..335963ec1b638b1a373f9c057bcd3db41a868e72 100644 (file)
 
 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/FieldDefaultValues.java
deleted file mode 100644 (file)
index 16bbd70..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.tests.VaadinClasses;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Slider;
-
-public class FieldDefaultValues {
-
-    @Test
-    public void testFieldsHaveDefaultValueAfterClear() throws Exception {
-        for (Field<?> field : createFields()) {
-            Object originalValue = field.getValue();
-
-            field.clear();
-
-            Object clearedValue = field.getValue();
-
-            Assert.assertEquals("Expected to get default value after clearing "
-                    + field.getClass().getName(), originalValue, clearedValue);
-        }
-    }
-
-    @Test
-    public void testFieldsAreEmptyAfterClear() throws Exception {
-        for (Field<?> field : createFields()) {
-            field.clear();
-
-            if (field instanceof Slider) {
-                Assert.assertFalse(
-                        "Slider should not be empty even after being cleared",
-                        field.isEmpty());
-
-            } else {
-                Assert.assertTrue(field.getClass().getName()
-                        + " should be empty after being cleared",
-                        field.isEmpty());
-            }
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static List<Field<?>> createFields() throws InstantiationException,
-            IllegalAccessException {
-        List<Field<?>> fieldInstances = new ArrayList<Field<?>>();
-
-        for (Class<? extends Field> fieldType : VaadinClasses.getFields()) {
-            fieldInstances.add(fieldType.newInstance());
-        }
-        return fieldInstances;
-    }
-
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java b/server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java
new file mode 100644 (file)
index 0000000..32f5ef8
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Slider;
+
+public class FieldDefaultValuesTest {
+
+    @Test
+    public void testFieldsHaveDefaultValueAfterClear() throws Exception {
+        for (Field<?> field : createFields()) {
+            Object originalValue = field.getValue();
+
+            field.clear();
+
+            Object clearedValue = field.getValue();
+
+            Assert.assertEquals("Expected to get default value after clearing "
+                    + field.getClass().getName(), originalValue, clearedValue);
+        }
+    }
+
+    @Test
+    public void testFieldsAreEmptyAfterClear() throws Exception {
+        for (Field<?> field : createFields()) {
+            field.clear();
+
+            if (field instanceof Slider) {
+                Assert.assertFalse(
+                        "Slider should not be empty even after being cleared",
+                        field.isEmpty());
+
+            } else {
+                Assert.assertTrue(field.getClass().getName()
+                        + " should be empty after being cleared",
+                        field.isEmpty());
+            }
+        }
+    }
+
+    @SuppressWarnings("rawtypes")
+    private static List<Field<?>> createFields() throws InstantiationException,
+            IllegalAccessException {
+        List<Field<?>> fieldInstances = new ArrayList<Field<?>>();
+
+        for (Class<? extends Field> fieldType : VaadinClasses.getFields()) {
+            fieldInstances.add(fieldType.newInstance());
+        }
+        return fieldInstances;
+    }
+
+}
index ad80007882217ab86ffb7df1cccabf76e9ea85d0..6dd451ac2a156bcde13aa2e1c1bfc8f6268f42a4 100644 (file)
@@ -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<Class<?>> tested = new HashSet<Class<?>>();
@@ -20,6 +20,7 @@ public class FinalMethodTest extends TestCase {
     // }
     // }
 
+    @Test
     public void testThatComponentsHaveNoFinalMethods() {
         HashSet<Class<?>> tested = new HashSet<Class<?>>();
         for (Class<? extends Component> c : VaadinClasses.getComponents()) {
index 5cf3b9700e3ee1cd851095b812a801ecc0e62848..146c633789932cd5189b8d8ff96f655a90cef13b 100644 (file)
  */
 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();
index da4d8a92d4afcb31ebb1300be38762628892b2cf..2ae845716dd29dea55e9b258578e748d96c0252a 100644 (file)
@@ -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<String> excludedMethods = new HashSet<String>();
 
-    @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<? extends Component> c : VaadinClasses.getComponents()) {
             Component newInstance = construct(c);
index a535de2b24b87d151c7e1bc8144f905ed86b651f..85d25aec792ee9fcbdb5753434b609f04ca861ef 100644 (file)
@@ -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
index eac7ff4d8abf4bf39aa939701d52241b247153f7..20a85edea5025879ec72ff7b7195dbd5036023c8 100644 (file)
@@ -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();
index 18eb79aadc194c0cee2506919e0a771ae1278b3d..77c2fef7e88c1eccf92f54d7f41232b1fe917a63 100644 (file)
@@ -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 ");
index 3a2150b700a5393c92aaefe1d1404217cb46723b..76fe3c16813d2c25fa145c11a24f3dc55ce30c56 100644 (file)
@@ -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);
index 02aa6afe07956061218284bf7ba6b78f5dbd3cf8..e428155ccd57aa5d0eb26a2bd9dda1865eaf4145 100644 (file)
@@ -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());
index 94ff10926f75697a4cb60e05c1475724e39e20da..3456e7c09ee4086e9b7362e5d4d4854434e147c8 100644 (file)
@@ -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<String>(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<String, String>() {
@@ -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<Boolean, Boolean>() {
@@ -219,6 +228,7 @@ public class AbsFieldValueConversionsTest extends TestCase {
 
     }
 
+    @Test
     public void testNumberDoubleConverterChange() {
         final VaadinSession a = new AlwaysLockedVaadinSession(null);
         VaadinSession.setCurrent(a);
index def3ceb64334586c319c16c5dcf49dd98e0eddef..d23d63e3e9bd7906990402912b4e721f1008fcbb 100644 (file)
@@ -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);
index 68e198c37a7cbe878460e7647033e395ebedbb30..31158b1f09f6aadc8862fb4f0b4024fc1f609336 100644 (file)
@@ -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);
index ee806cb5f759e076ab8fa20c823db30f06f5e6ed..cedc582b57b3cf5c8a96850112a40726c565d959 100644 (file)
@@ -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/OptionGroupDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java
new file mode 100644 (file)
index 0000000..1b8b2f3
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.abstractselect;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.server.ThemeResource;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.OptionGroup;
+
+public class OptionGroupDeclarativeTest extends
+        DeclarativeTestBase<OptionGroup> {
+
+    private OptionGroup og;
+
+    @Before
+    public void init() {
+        og = new OptionGroup();
+    }
+
+    @Test
+    public void testBasicSyntax() {
+
+        String expected = "<vaadin-option-group />";
+        testReadWrite(expected);
+
+    }
+
+    @Test
+    public void testOptionSyntax() {
+
+        og.addItems("foo", "bar", "baz", "bang");
+
+        //@formatter:off
+        String expected = 
+                "<vaadin-option-group>"
+                + "<option>foo</option>"
+                + "<option>bar</option>"
+                + "<option>baz</option>"
+                + "<option>bang</option>"
+                + "</vaadin-option-group>";
+        //@formatter:on
+
+        testReadWrite(expected);
+
+    }
+
+    @Test
+    public void testDisabledOptionSyntax() {
+
+        og.addItems("foo", "bar", "baz", "bang");
+        og.setItemEnabled("baz", false);
+
+        //@formatter:off
+        String expected = 
+                "<vaadin-option-group>"
+                + "<option>foo</option>"
+                + "<option>bar</option>"
+                + "<option disabled>baz</option>"
+                + "<option>bang</option>"
+                + "</vaadin-option-group>";
+        //@formatter:on
+
+        testReadWrite(expected);
+
+    }
+
+    @Test
+    public void testIconSyntax() {
+
+        og.addItems("foo", "bar", "baz", "bang");
+        og.setItemIcon("bar", new ThemeResource("foobar.png"));
+
+        //@formatter:off
+        String expected = 
+                "<vaadin-option-group>"
+                + "<option>foo</option>"
+                + "<option icon='theme://foobar.png'>bar</option>"
+                + "<option>baz</option>"
+                + "<option>bang</option>"
+                + "</vaadin-option-group>";
+        //@formatter:on
+
+        testReadWrite(expected);
+
+    }
+
+    @Test
+    public void testHTMLCaption() {
+
+        og.addItems("foo", "bar", "baz", "bang");
+
+        og.setHtmlContentAllowed(true);
+
+        og.setItemCaption("foo", "<b>True</b>");
+        og.setItemCaption("bar", "<font color='red'>False</font>");
+
+        //@formatter:off
+        String expected = 
+                "<vaadin-option-group html-content-allowed>"
+                + "<option item-id=\"foo\"><b>True</b></option>"
+                + "<option item-id=\"bar\"><font color='red'>False</font></option>"
+                + "<option>baz</option>"
+                + "<option>bang</option>"
+                + "</vaadin-option-group>";
+        //@formatter:on
+
+        testReadWrite(expected);
+    }
+
+    @Test
+    public void testPlaintextCaption() {
+
+        og.addItems("foo", "bar", "baz", "bang");
+
+        og.setItemCaption("foo", "<b>True</b>");
+        og.setItemCaption("bar", "<font color=\"red\">False</font>");
+
+        //@formatter:off
+        String expected =
+                "<vaadin-option-group>"
+                + "<option item-id=\"foo\">&lt;b&gt;True&lt;/b&gt;</option>"
+                + "<option item-id=\"bar\">&lt;font color=\"red\"&gt;False&lt;/font&gt;</option>"
+                + "<option>baz</option>"
+                + "<option>bang</option>"
+                + "</vaadin-option-group>";
+        //@formatter:on
+
+        testReadWrite(expected);
+    }
+
+    private void testReadWrite(String design) {
+        testWrite(design, og, true);
+        testRead(design, og);
+    }
+
+    @Override
+    public OptionGroup testRead(String design, OptionGroup expected) {
+
+        OptionGroup read = super.testRead(design, expected);
+        testWrite(design, read, true);
+
+        return read;
+    }
+
+}
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/OptionGroupDeclarativeTests.java
deleted file mode 100644 (file)
index 509e46c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.abstractselect;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.server.ThemeResource;
-import com.vaadin.tests.design.DeclarativeTestBase;
-import com.vaadin.ui.OptionGroup;
-
-public class OptionGroupDeclarativeTests extends
-        DeclarativeTestBase<OptionGroup> {
-
-    private OptionGroup og;
-
-    @Before
-    public void init() {
-        og = new OptionGroup();
-    }
-
-    @Test
-    public void testBasicSyntax() {
-
-        String expected = "<vaadin-option-group />";
-        testReadWrite(expected);
-
-    }
-
-    @Test
-    public void testOptionSyntax() {
-
-        og.addItems("foo", "bar", "baz", "bang");
-
-        //@formatter:off
-        String expected = 
-                "<vaadin-option-group>"
-                + "<option>foo</option>"
-                + "<option>bar</option>"
-                + "<option>baz</option>"
-                + "<option>bang</option>"
-                + "</vaadin-option-group>";
-        //@formatter:on
-
-        testReadWrite(expected);
-
-    }
-
-    @Test
-    public void testDisabledOptionSyntax() {
-
-        og.addItems("foo", "bar", "baz", "bang");
-        og.setItemEnabled("baz", false);
-
-        //@formatter:off
-        String expected = 
-                "<vaadin-option-group>"
-                + "<option>foo</option>"
-                + "<option>bar</option>"
-                + "<option disabled>baz</option>"
-                + "<option>bang</option>"
-                + "</vaadin-option-group>";
-        //@formatter:on
-
-        testReadWrite(expected);
-
-    }
-
-    @Test
-    public void testIconSyntax() {
-
-        og.addItems("foo", "bar", "baz", "bang");
-        og.setItemIcon("bar", new ThemeResource("foobar.png"));
-
-        //@formatter:off
-        String expected = 
-                "<vaadin-option-group>"
-                + "<option>foo</option>"
-                + "<option icon='theme://foobar.png'>bar</option>"
-                + "<option>baz</option>"
-                + "<option>bang</option>"
-                + "</vaadin-option-group>";
-        //@formatter:on
-
-        testReadWrite(expected);
-
-    }
-
-    @Test
-    public void testHTMLCaption() {
-
-        og.addItems("foo", "bar", "baz", "bang");
-
-        og.setHtmlContentAllowed(true);
-
-        og.setItemCaption("foo", "<b>True</b>");
-        og.setItemCaption("bar", "<font color='red'>False</font>");
-
-        //@formatter:off
-        String expected = 
-                "<vaadin-option-group html-content-allowed>"
-                + "<option item-id=\"foo\"><b>True</b></option>"
-                + "<option item-id=\"bar\"><font color='red'>False</font></option>"
-                + "<option>baz</option>"
-                + "<option>bang</option>"
-                + "</vaadin-option-group>";
-        //@formatter:on
-
-        testReadWrite(expected);
-    }
-
-    @Test
-    public void testPlaintextCaption() {
-
-        og.addItems("foo", "bar", "baz", "bang");
-
-        og.setItemCaption("foo", "<b>True</b>");
-        og.setItemCaption("bar", "<font color=\"red\">False</font>");
-
-        //@formatter:off
-        String expected =
-                "<vaadin-option-group>"
-                + "<option item-id=\"foo\">&lt;b&gt;True&lt;/b&gt;</option>"
-                + "<option item-id=\"bar\">&lt;font color=\"red\"&gt;False&lt;/font&gt;</option>"
-                + "<option>baz</option>"
-                + "<option>bang</option>"
-                + "</vaadin-option-group>";
-        //@formatter:on
-
-        testReadWrite(expected);
-    }
-
-    private void testReadWrite(String design) {
-        testWrite(design, og, true);
-        testRead(design, og);
-    }
-
-    @Override
-    public OptionGroup testRead(String design, OptionGroup expected) {
-
-        OptionGroup read = super.testRead(design, expected);
-        testWrite(design, read, true);
-
-        return read;
-    }
-
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java
new file mode 100644 (file)
index 0000000..9a20d2f
--- /dev/null
@@ -0,0 +1,32 @@
+package com.vaadin.tests.server.component.abstractselect;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.ui.OptionGroup;
+
+public class OptionGroupTest {
+
+    private OptionGroup optionGroup;
+
+    @Before
+    public void setup() {
+        optionGroup = new OptionGroup();
+    }
+
+    @Test
+    public void itemsAreAdded() {
+        optionGroup.addItems("foo", "bar");
+
+        Collection<?> itemIds = optionGroup.getItemIds();
+
+        assertEquals(2, itemIds.size());
+        assertTrue(itemIds.contains("foo"));
+        assertTrue(itemIds.contains("bar"));
+    }
+}
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/OptionGroupTests.java
deleted file mode 100644 (file)
index c4a3d73..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.vaadin.tests.server.component.abstractselect;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.ui.OptionGroup;
-
-public class OptionGroupTests {
-
-    private OptionGroup optionGroup;
-
-    @Before
-    public void setup() {
-        optionGroup = new OptionGroup();
-    }
-
-    @Test
-    public void itemsAreAdded() {
-        optionGroup.addItems("foo", "bar");
-
-        Collection<?> itemIds = optionGroup.getItemIds();
-
-        assertEquals(2, itemIds.size());
-        assertTrue(itemIds.contains("foo"));
-        assertTrue(itemIds.contains("bar"));
-    }
-}
index 0896b5d649f56f101c291f1717adca4208587b91..0641489e0e38f07fe3b458caa7e699f29fceb241 100644 (file)
@@ -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);
index 4478048b12d643f75a6111e6e790ba91ac31b5df..ad90883baa2999c8a32f02be302d06d995c51a61 100644 (file)
@@ -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);
index 8a066497cddf3451a3db65989893455a02106690..4bcd5c7192adc82762ec48d04c4f6b27ddf0a2d5 100644 (file)
  */
 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();
     }
index f5467b2d188da7de80e4a04e08aed163759bb889..4fcf1766fef542ac75f8f33b063f7980a3553354 100644 (file)
@@ -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<Long> date;
     private DateField datefield;
 
-    @Override
+    @Before
     public void setUp() {
         date = new ObjectProperty<Long>(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);
index 6d774366a98f59cd47c24c3b7520d7e3b502665e..8885573bd86477301f0a45bb8791761f2948ea4f 100644 (file)
@@ -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);
index ae72f9c7430d5db939af761fdd8b5ead0298d72f..a23c60b106e49e1f737c6942f304ba444afcde4e 100644 (file)
@@ -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<Resolution> higherOrEqual = Resolution
                 .getResolutionsHigherOrEqualTo(Resolution.YEAR);
@@ -17,6 +18,7 @@ public class ResolutionTest extends TestCase {
         TestUtil.assertIterableEquals(expected, higherOrEqual);
     }
 
+    @Test
     public void testResolutionHigherOrEqualToDay() {
         Iterable<Resolution> higherOrEqual = Resolution
                 .getResolutionsHigherOrEqualTo(Resolution.DAY);
@@ -28,6 +30,7 @@ public class ResolutionTest extends TestCase {
 
     }
 
+    @Test
     public void testResolutionLowerThanDay() {
         Iterable<Resolution> higherOrEqual = Resolution
                 .getResolutionsLowerThan(Resolution.DAY);
@@ -39,6 +42,7 @@ public class ResolutionTest extends TestCase {
 
     }
 
+    @Test
     public void testResolutionLowerThanSecond() {
         Iterable<Resolution> higherOrEqual = Resolution
                 .getResolutionsLowerThan(Resolution.SECOND);
@@ -46,6 +50,7 @@ public class ResolutionTest extends TestCase {
         TestUtil.assertIterableEquals(expected, higherOrEqual);
     }
 
+    @Test
     public void testResolutionLowerThanYear() {
         Iterable<Resolution> 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/GridChildren.java
deleted file mode 100644 (file)
index 7af1cfe..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.grid;
-
-import java.util.Iterator;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.FooterCell;
-import com.vaadin.ui.Grid.HeaderCell;
-import com.vaadin.ui.Label;
-
-public class GridChildren {
-
-    @Test
-    public void componentsInMergedHeader() {
-        Grid grid = new Grid();
-        grid.addColumn("foo");
-        grid.addColumn("bar");
-        grid.addColumn("baz");
-        HeaderCell merged = grid.getDefaultHeaderRow()
-                .join("foo", "bar", "baz");
-        Label label = new Label();
-        merged.setComponent(label);
-        Iterator<Component> i = grid.iterator();
-        Assert.assertEquals(label, i.next());
-        Assert.assertFalse(i.hasNext());
-    }
-
-    @Test
-    public void componentsInMergedFooter() {
-        Grid grid = new Grid();
-        grid.addColumn("foo");
-        grid.addColumn("bar");
-        grid.addColumn("baz");
-        FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");
-        Label label = new Label();
-        merged.setComponent(label);
-        Iterator<Component> i = grid.iterator();
-        Assert.assertEquals(label, i.next());
-        Assert.assertFalse(i.hasNext());
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java
new file mode 100644 (file)
index 0000000..65a4cfe
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.grid;
+
+import java.util.Iterator;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.FooterCell;
+import com.vaadin.ui.Grid.HeaderCell;
+import com.vaadin.ui.Label;
+
+public class GridChildrenTest {
+
+    @Test
+    public void componentsInMergedHeader() {
+        Grid grid = new Grid();
+        grid.addColumn("foo");
+        grid.addColumn("bar");
+        grid.addColumn("baz");
+        HeaderCell merged = grid.getDefaultHeaderRow()
+                .join("foo", "bar", "baz");
+        Label label = new Label();
+        merged.setComponent(label);
+        Iterator<Component> i = grid.iterator();
+        Assert.assertEquals(label, i.next());
+        Assert.assertFalse(i.hasNext());
+    }
+
+    @Test
+    public void componentsInMergedFooter() {
+        Grid grid = new Grid();
+        grid.addColumn("foo");
+        grid.addColumn("bar");
+        grid.addColumn("baz");
+        FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz");
+        Label label = new Label();
+        merged.setComponent(label);
+        Iterator<Component> i = grid.iterator();
+        Assert.assertEquals(label, i.next());
+        Assert.assertFalse(i.hasNext());
+    }
+}
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/GridColumns.java
deleted file mode 100644 (file)
index 83e9f21..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.grid;
-
-import static org.easymock.EasyMock.and;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.isA;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-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 static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.server.KeyMapper;
-import com.vaadin.shared.ui.grid.GridColumnState;
-import com.vaadin.shared.ui.grid.GridState;
-import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.Column;
-import com.vaadin.ui.Grid.ColumnResizeEvent;
-import com.vaadin.ui.Grid.ColumnResizeListener;
-import com.vaadin.ui.TextField;
-
-public class GridColumns {
-
-    private Grid grid;
-
-    private GridState state;
-
-    private Method getStateMethod;
-
-    private Field columnIdGeneratorField;
-
-    private KeyMapper<Object> columnIdMapper;
-
-    @Before
-    @SuppressWarnings("unchecked")
-    public void setup() throws Exception {
-        IndexedContainer ds = new IndexedContainer();
-        for (int c = 0; c < 10; c++) {
-            ds.addContainerProperty("column" + c, String.class, "");
-        }
-        ds.addContainerProperty("noSort", Object.class, null);
-        grid = new Grid(ds);
-
-        getStateMethod = Grid.class.getDeclaredMethod("getState");
-        getStateMethod.setAccessible(true);
-
-        state = (GridState) getStateMethod.invoke(grid);
-
-        columnIdGeneratorField = Grid.class.getDeclaredField("columnKeys");
-        columnIdGeneratorField.setAccessible(true);
-
-        columnIdMapper = (KeyMapper<Object>) columnIdGeneratorField.get(grid);
-    }
-
-    @Test
-    public void testColumnGeneration() throws Exception {
-
-        for (Object propertyId : grid.getContainerDataSource()
-                .getContainerPropertyIds()) {
-
-            // All property ids should get a column
-            Column column = grid.getColumn(propertyId);
-            assertNotNull(column);
-
-            // Humanized property id should be the column header by default
-            assertEquals(
-                    SharedUtil.camelCaseToHumanFriendly(propertyId.toString()),
-                    grid.getDefaultHeaderRow().getCell(propertyId).getText());
-        }
-    }
-
-    @Test
-    public void testModifyingColumnProperties() throws Exception {
-
-        // Modify first column
-        Column column = grid.getColumn("column1");
-        assertNotNull(column);
-
-        column.setHeaderCaption("CustomHeader");
-        assertEquals("CustomHeader", column.getHeaderCaption());
-        assertEquals(column.getHeaderCaption(), grid.getDefaultHeaderRow()
-                .getCell("column1").getText());
-
-        column.setWidth(100);
-        assertEquals(100, column.getWidth(), 0.49d);
-        assertEquals(column.getWidth(), getColumnState("column1").width, 0.49d);
-
-        try {
-            column.setWidth(-1);
-            fail("Setting width to -1 should throw exception");
-        } catch (IllegalArgumentException iae) {
-            // expected
-        }
-
-        assertEquals(100, column.getWidth(), 0.49d);
-        assertEquals(100, getColumnState("column1").width, 0.49d);
-    }
-
-    @Test
-    public void testRemovingColumnByRemovingPropertyFromContainer()
-            throws Exception {
-
-        Column column = grid.getColumn("column1");
-        assertNotNull(column);
-
-        // Remove column
-        grid.getContainerDataSource().removeContainerProperty("column1");
-
-        try {
-            column.setHeaderCaption("asd");
-
-            fail("Succeeded in modifying a detached column");
-        } catch (IllegalStateException ise) {
-            // Detached state should throw exception
-        }
-
-        try {
-            column.setWidth(123);
-            fail("Succeeded in modifying a detached column");
-        } catch (IllegalStateException ise) {
-            // Detached state should throw exception
-        }
-
-        assertNull(grid.getColumn("column1"));
-        assertNull(getColumnState("column1"));
-    }
-
-    @Test
-    public void testAddingColumnByAddingPropertyToContainer() throws Exception {
-        grid.getContainerDataSource().addContainerProperty("columnX",
-                String.class, "");
-        Column column = grid.getColumn("columnX");
-        assertNotNull(column);
-    }
-
-    @Test
-    public void testHeaderVisiblility() throws Exception {
-
-        assertTrue(grid.isHeaderVisible());
-        assertTrue(state.header.visible);
-
-        grid.setHeaderVisible(false);
-        assertFalse(grid.isHeaderVisible());
-        assertFalse(state.header.visible);
-
-        grid.setHeaderVisible(true);
-        assertTrue(grid.isHeaderVisible());
-        assertTrue(state.header.visible);
-    }
-
-    @Test
-    public void testFooterVisibility() throws Exception {
-
-        assertTrue(grid.isFooterVisible());
-        assertTrue(state.footer.visible);
-
-        grid.setFooterVisible(false);
-        assertFalse(grid.isFooterVisible());
-        assertFalse(state.footer.visible);
-
-        grid.setFooterVisible(true);
-        assertTrue(grid.isFooterVisible());
-        assertTrue(state.footer.visible);
-    }
-
-    @Test
-    public void testSetFrozenColumnCount() {
-        assertEquals("Grid should not start with a frozen column", 0,
-                grid.getFrozenColumnCount());
-        grid.setFrozenColumnCount(2);
-        assertEquals("Freezing two columns should freeze two columns", 2,
-                grid.getFrozenColumnCount());
-    }
-
-    @Test
-    public void testSetFrozenColumnCountThroughColumn() {
-        assertEquals("Grid should not start with a frozen column", 0,
-                grid.getFrozenColumnCount());
-        grid.getColumns().get(2).setLastFrozenColumn();
-        assertEquals(
-                "Setting the third column as last frozen should freeze three columns",
-                3, grid.getFrozenColumnCount());
-    }
-
-    @Test
-    public void testFrozenColumnRemoveColumn() {
-        assertEquals("Grid should not start with a frozen column", 0,
-                grid.getFrozenColumnCount());
-
-        int containerSize = grid.getContainerDataSource()
-                .getContainerPropertyIds().size();
-        grid.setFrozenColumnCount(containerSize);
-
-        Object propertyId = grid.getContainerDataSource()
-                .getContainerPropertyIds().iterator().next();
-
-        grid.getContainerDataSource().removeContainerProperty(propertyId);
-        assertEquals(
-                "Frozen column count should update when removing last row",
-                containerSize - 1, grid.getFrozenColumnCount());
-    }
-
-    @Test
-    public void testReorderColumns() {
-        Set<?> containerProperties = new LinkedHashSet<Object>(grid
-                .getContainerDataSource().getContainerPropertyIds());
-        Object[] properties = new Object[] { "column3", "column2", "column6" };
-        grid.setColumnOrder(properties);
-
-        int i = 0;
-        // Test sorted columns are first in order
-        for (Object property : properties) {
-            containerProperties.remove(property);
-            assertEquals(columnIdMapper.key(property),
-                    state.columnOrder.get(i++));
-        }
-
-        // Test remaining columns are in original order
-        for (Object property : containerProperties) {
-            assertEquals(columnIdMapper.key(property),
-                    state.columnOrder.get(i++));
-        }
-
-        try {
-            grid.setColumnOrder("foo", "bar", "baz");
-            fail("Grid allowed sorting with non-existent properties");
-        } catch (IllegalArgumentException e) {
-            // All ok
-        }
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testRemoveColumnThatDoesNotExist() {
-        grid.removeColumn("banana phone");
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testSetNonSortableColumnSortable() {
-        Column noSortColumn = grid.getColumn("noSort");
-        assertFalse("Object property column should not be sortable.",
-                noSortColumn.isSortable());
-        noSortColumn.setSortable(true);
-    }
-
-    @Test
-    public void testColumnsEditableByDefault() {
-        for (Column c : grid.getColumns()) {
-            assertTrue(c + " should be editable", c.isEditable());
-        }
-    }
-
-    @Test
-    public void testPropertyAndColumnEditorFieldsMatch() {
-        Column column1 = grid.getColumn("column1");
-        column1.setEditorField(new TextField());
-        assertSame(column1.getEditorField(), grid.getColumn("column1")
-                .getEditorField());
-
-        Column column2 = grid.getColumn("column2");
-        column2.setEditorField(new TextField());
-        assertSame(column2.getEditorField(), column2.getEditorField());
-    }
-
-    @Test
-    public void testUneditableColumnHasNoField() {
-        Column col = grid.getColumn("column1");
-
-        col.setEditable(false);
-
-        assertFalse("Column should be uneditable", col.isEditable());
-        assertNull("Uneditable column should not be auto-assigned a Field",
-                col.getEditorField());
-    }
-
-    private GridColumnState getColumnState(Object propertyId) {
-        String columnId = columnIdMapper.key(propertyId);
-        for (GridColumnState columnState : state.columns) {
-            if (columnState.id.equals(columnId)) {
-                return columnState;
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void testAddAndRemoveSortableColumn() {
-        boolean sortable = grid.getColumn("column1").isSortable();
-        grid.removeColumn("column1");
-        grid.addColumn("column1");
-        assertEquals("Column sortability changed when re-adding", sortable,
-                grid.getColumn("column1").isSortable());
-    }
-
-    @Test
-    public void testSetColumns() {
-        grid.setColumns("column7", "column0", "column9");
-        Iterator<Column> it = grid.getColumns().iterator();
-        assertEquals(it.next().getPropertyId(), "column7");
-        assertEquals(it.next().getPropertyId(), "column0");
-        assertEquals(it.next().getPropertyId(), "column9");
-        assertFalse(it.hasNext());
-    }
-
-    @Test
-    public void testAddingColumnsWithSetColumns() {
-        Grid g = new Grid();
-        g.setColumns("c1", "c2", "c3");
-        Iterator<Column> it = g.getColumns().iterator();
-        assertEquals(it.next().getPropertyId(), "c1");
-        assertEquals(it.next().getPropertyId(), "c2");
-        assertEquals(it.next().getPropertyId(), "c3");
-        assertFalse(it.hasNext());
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testAddingColumnsWithSetColumnsNonDefaultContainer() {
-        grid.setColumns("column1", "column2", "column50");
-    }
-
-    @Test
-    public void testDefaultColumnHidingToggleCaption() {
-        Column firstColumn = grid.getColumns().get(0);
-        firstColumn.setHeaderCaption("headerCaption");
-        assertEquals(null, firstColumn.getHidingToggleCaption());
-    }
-
-    @Test
-    public void testOverriddenColumnHidingToggleCaption() {
-        Column firstColumn = grid.getColumns().get(0);
-        firstColumn.setHidingToggleCaption("hidingToggleCaption");
-        firstColumn.setHeaderCaption("headerCaption");
-        assertEquals("hidingToggleCaption",
-                firstColumn.getHidingToggleCaption());
-    }
-
-    @Test
-    public void testColumnSetWidthFiresResizeEvent() {
-        final Column firstColumn = grid.getColumns().get(0);
-
-        // prepare a listener mock that captures the argument
-        ColumnResizeListener mock = EasyMock
-                .createMock(ColumnResizeListener.class);
-        Capture<ColumnResizeEvent> capturedEvent = new Capture<ColumnResizeEvent>();
-        mock.columnResize(and(capture(capturedEvent),
-                isA(ColumnResizeEvent.class)));
-        EasyMock.expectLastCall().once();
-
-        // Tell it to wait for the call
-        EasyMock.replay(mock);
-
-        // Cause a resize event
-        grid.addColumnResizeListener(mock);
-        firstColumn.setWidth(firstColumn.getWidth() + 10);
-
-        // Verify the method was called
-        EasyMock.verify(mock);
-
-        // Asserts on the captured event
-        ColumnResizeEvent event = capturedEvent.getValue();
-        assertEquals("Event column was not first column.", firstColumn,
-                event.getColumn());
-        assertFalse("Event should not be userOriginated",
-                event.isUserOriginated());
-    }
-
-       @Test
-    public void textHeaderCaptionIsReturned() {
-        Column firstColumn = grid.getColumns().get(0);
-
-        firstColumn.setHeaderCaption("text");
-
-        assertThat(firstColumn.getHeaderCaption(), is("text"));
-    }
-
-    @Test
-    public void defaultCaptionIsReturnedForHtml() {
-        Column firstColumn = grid.getColumns().get(0);
-
-        grid.getDefaultHeaderRow().getCell("column0").setHtml("<b>html</b>");
-
-        assertThat(firstColumn.getHeaderCaption(), is("Column0"));
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridColumnsTest.java
new file mode 100644 (file)
index 0000000..30db0e9
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.grid;
+
+import static org.easymock.EasyMock.and;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.isA;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+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 static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.server.KeyMapper;
+import com.vaadin.shared.ui.grid.GridColumnState;
+import com.vaadin.shared.ui.grid.GridState;
+import com.vaadin.shared.util.SharedUtil;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.Grid.ColumnResizeEvent;
+import com.vaadin.ui.Grid.ColumnResizeListener;
+import com.vaadin.ui.TextField;
+
+public class GridColumnsTest {
+
+    private Grid grid;
+
+    private GridState state;
+
+    private Method getStateMethod;
+
+    private Field columnIdGeneratorField;
+
+    private KeyMapper<Object> columnIdMapper;
+
+    @Before
+    @SuppressWarnings("unchecked")
+    public void setup() throws Exception {
+        IndexedContainer ds = new IndexedContainer();
+        for (int c = 0; c < 10; c++) {
+            ds.addContainerProperty("column" + c, String.class, "");
+        }
+        ds.addContainerProperty("noSort", Object.class, null);
+        grid = new Grid(ds);
+
+        getStateMethod = Grid.class.getDeclaredMethod("getState");
+        getStateMethod.setAccessible(true);
+
+        state = (GridState) getStateMethod.invoke(grid);
+
+        columnIdGeneratorField = Grid.class.getDeclaredField("columnKeys");
+        columnIdGeneratorField.setAccessible(true);
+
+        columnIdMapper = (KeyMapper<Object>) columnIdGeneratorField.get(grid);
+    }
+
+    @Test
+    public void testColumnGeneration() throws Exception {
+
+        for (Object propertyId : grid.getContainerDataSource()
+                .getContainerPropertyIds()) {
+
+            // All property ids should get a column
+            Column column = grid.getColumn(propertyId);
+            assertNotNull(column);
+
+            // Humanized property id should be the column header by default
+            assertEquals(
+                    SharedUtil.camelCaseToHumanFriendly(propertyId.toString()),
+                    grid.getDefaultHeaderRow().getCell(propertyId).getText());
+        }
+    }
+
+    @Test
+    public void testModifyingColumnProperties() throws Exception {
+
+        // Modify first column
+        Column column = grid.getColumn("column1");
+        assertNotNull(column);
+
+        column.setHeaderCaption("CustomHeader");
+        assertEquals("CustomHeader", column.getHeaderCaption());
+        assertEquals(column.getHeaderCaption(), grid.getDefaultHeaderRow()
+                .getCell("column1").getText());
+
+        column.setWidth(100);
+        assertEquals(100, column.getWidth(), 0.49d);
+        assertEquals(column.getWidth(), getColumnState("column1").width, 0.49d);
+
+        try {
+            column.setWidth(-1);
+            fail("Setting width to -1 should throw exception");
+        } catch (IllegalArgumentException iae) {
+            // expected
+        }
+
+        assertEquals(100, column.getWidth(), 0.49d);
+        assertEquals(100, getColumnState("column1").width, 0.49d);
+    }
+
+    @Test
+    public void testRemovingColumnByRemovingPropertyFromContainer()
+            throws Exception {
+
+        Column column = grid.getColumn("column1");
+        assertNotNull(column);
+
+        // Remove column
+        grid.getContainerDataSource().removeContainerProperty("column1");
+
+        try {
+            column.setHeaderCaption("asd");
+
+            fail("Succeeded in modifying a detached column");
+        } catch (IllegalStateException ise) {
+            // Detached state should throw exception
+        }
+
+        try {
+            column.setWidth(123);
+            fail("Succeeded in modifying a detached column");
+        } catch (IllegalStateException ise) {
+            // Detached state should throw exception
+        }
+
+        assertNull(grid.getColumn("column1"));
+        assertNull(getColumnState("column1"));
+    }
+
+    @Test
+    public void testAddingColumnByAddingPropertyToContainer() throws Exception {
+        grid.getContainerDataSource().addContainerProperty("columnX",
+                String.class, "");
+        Column column = grid.getColumn("columnX");
+        assertNotNull(column);
+    }
+
+    @Test
+    public void testHeaderVisiblility() throws Exception {
+
+        assertTrue(grid.isHeaderVisible());
+        assertTrue(state.header.visible);
+
+        grid.setHeaderVisible(false);
+        assertFalse(grid.isHeaderVisible());
+        assertFalse(state.header.visible);
+
+        grid.setHeaderVisible(true);
+        assertTrue(grid.isHeaderVisible());
+        assertTrue(state.header.visible);
+    }
+
+    @Test
+    public void testFooterVisibility() throws Exception {
+
+        assertTrue(grid.isFooterVisible());
+        assertTrue(state.footer.visible);
+
+        grid.setFooterVisible(false);
+        assertFalse(grid.isFooterVisible());
+        assertFalse(state.footer.visible);
+
+        grid.setFooterVisible(true);
+        assertTrue(grid.isFooterVisible());
+        assertTrue(state.footer.visible);
+    }
+
+    @Test
+    public void testSetFrozenColumnCount() {
+        assertEquals("Grid should not start with a frozen column", 0,
+                grid.getFrozenColumnCount());
+        grid.setFrozenColumnCount(2);
+        assertEquals("Freezing two columns should freeze two columns", 2,
+                grid.getFrozenColumnCount());
+    }
+
+    @Test
+    public void testSetFrozenColumnCountThroughColumn() {
+        assertEquals("Grid should not start with a frozen column", 0,
+                grid.getFrozenColumnCount());
+        grid.getColumns().get(2).setLastFrozenColumn();
+        assertEquals(
+                "Setting the third column as last frozen should freeze three columns",
+                3, grid.getFrozenColumnCount());
+    }
+
+    @Test
+    public void testFrozenColumnRemoveColumn() {
+        assertEquals("Grid should not start with a frozen column", 0,
+                grid.getFrozenColumnCount());
+
+        int containerSize = grid.getContainerDataSource()
+                .getContainerPropertyIds().size();
+        grid.setFrozenColumnCount(containerSize);
+
+        Object propertyId = grid.getContainerDataSource()
+                .getContainerPropertyIds().iterator().next();
+
+        grid.getContainerDataSource().removeContainerProperty(propertyId);
+        assertEquals(
+                "Frozen column count should update when removing last row",
+                containerSize - 1, grid.getFrozenColumnCount());
+    }
+
+    @Test
+    public void testReorderColumns() {
+        Set<?> containerProperties = new LinkedHashSet<Object>(grid
+                .getContainerDataSource().getContainerPropertyIds());
+        Object[] properties = new Object[] { "column3", "column2", "column6" };
+        grid.setColumnOrder(properties);
+
+        int i = 0;
+        // Test sorted columns are first in order
+        for (Object property : properties) {
+            containerProperties.remove(property);
+            assertEquals(columnIdMapper.key(property),
+                    state.columnOrder.get(i++));
+        }
+
+        // Test remaining columns are in original order
+        for (Object property : containerProperties) {
+            assertEquals(columnIdMapper.key(property),
+                    state.columnOrder.get(i++));
+        }
+
+        try {
+            grid.setColumnOrder("foo", "bar", "baz");
+            fail("Grid allowed sorting with non-existent properties");
+        } catch (IllegalArgumentException e) {
+            // All ok
+        }
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testRemoveColumnThatDoesNotExist() {
+        grid.removeColumn("banana phone");
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testSetNonSortableColumnSortable() {
+        Column noSortColumn = grid.getColumn("noSort");
+        assertFalse("Object property column should not be sortable.",
+                noSortColumn.isSortable());
+        noSortColumn.setSortable(true);
+    }
+
+    @Test
+    public void testColumnsEditableByDefault() {
+        for (Column c : grid.getColumns()) {
+            assertTrue(c + " should be editable", c.isEditable());
+        }
+    }
+
+    @Test
+    public void testPropertyAndColumnEditorFieldsMatch() {
+        Column column1 = grid.getColumn("column1");
+        column1.setEditorField(new TextField());
+        assertSame(column1.getEditorField(), grid.getColumn("column1")
+                .getEditorField());
+
+        Column column2 = grid.getColumn("column2");
+        column2.setEditorField(new TextField());
+        assertSame(column2.getEditorField(), column2.getEditorField());
+    }
+
+    @Test
+    public void testUneditableColumnHasNoField() {
+        Column col = grid.getColumn("column1");
+
+        col.setEditable(false);
+
+        assertFalse("Column should be uneditable", col.isEditable());
+        assertNull("Uneditable column should not be auto-assigned a Field",
+                col.getEditorField());
+    }
+
+    private GridColumnState getColumnState(Object propertyId) {
+        String columnId = columnIdMapper.key(propertyId);
+        for (GridColumnState columnState : state.columns) {
+            if (columnState.id.equals(columnId)) {
+                return columnState;
+            }
+        }
+        return null;
+    }
+
+    @Test
+    public void testAddAndRemoveSortableColumn() {
+        boolean sortable = grid.getColumn("column1").isSortable();
+        grid.removeColumn("column1");
+        grid.addColumn("column1");
+        assertEquals("Column sortability changed when re-adding", sortable,
+                grid.getColumn("column1").isSortable());
+    }
+
+    @Test
+    public void testSetColumns() {
+        grid.setColumns("column7", "column0", "column9");
+        Iterator<Column> it = grid.getColumns().iterator();
+        assertEquals(it.next().getPropertyId(), "column7");
+        assertEquals(it.next().getPropertyId(), "column0");
+        assertEquals(it.next().getPropertyId(), "column9");
+        assertFalse(it.hasNext());
+    }
+
+    @Test
+    public void testAddingColumnsWithSetColumns() {
+        Grid g = new Grid();
+        g.setColumns("c1", "c2", "c3");
+        Iterator<Column> it = g.getColumns().iterator();
+        assertEquals(it.next().getPropertyId(), "c1");
+        assertEquals(it.next().getPropertyId(), "c2");
+        assertEquals(it.next().getPropertyId(), "c3");
+        assertFalse(it.hasNext());
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAddingColumnsWithSetColumnsNonDefaultContainer() {
+        grid.setColumns("column1", "column2", "column50");
+    }
+
+    @Test
+    public void testDefaultColumnHidingToggleCaption() {
+        Column firstColumn = grid.getColumns().get(0);
+        firstColumn.setHeaderCaption("headerCaption");
+        assertEquals(null, firstColumn.getHidingToggleCaption());
+    }
+
+    @Test
+    public void testOverriddenColumnHidingToggleCaption() {
+        Column firstColumn = grid.getColumns().get(0);
+        firstColumn.setHidingToggleCaption("hidingToggleCaption");
+        firstColumn.setHeaderCaption("headerCaption");
+        assertEquals("hidingToggleCaption",
+                firstColumn.getHidingToggleCaption());
+    }
+
+    @Test
+    public void testColumnSetWidthFiresResizeEvent() {
+        final Column firstColumn = grid.getColumns().get(0);
+
+        // prepare a listener mock that captures the argument
+        ColumnResizeListener mock = EasyMock
+                .createMock(ColumnResizeListener.class);
+        Capture<ColumnResizeEvent> capturedEvent = new Capture<ColumnResizeEvent>();
+        mock.columnResize(and(capture(capturedEvent),
+                isA(ColumnResizeEvent.class)));
+        EasyMock.expectLastCall().once();
+
+        // Tell it to wait for the call
+        EasyMock.replay(mock);
+
+        // Cause a resize event
+        grid.addColumnResizeListener(mock);
+        firstColumn.setWidth(firstColumn.getWidth() + 10);
+
+        // Verify the method was called
+        EasyMock.verify(mock);
+
+        // Asserts on the captured event
+        ColumnResizeEvent event = capturedEvent.getValue();
+        assertEquals("Event column was not first column.", firstColumn,
+                event.getColumn());
+        assertFalse("Event should not be userOriginated",
+                event.isUserOriginated());
+    }
+
+       @Test
+    public void textHeaderCaptionIsReturned() {
+        Column firstColumn = grid.getColumns().get(0);
+
+        firstColumn.setHeaderCaption("text");
+
+        assertThat(firstColumn.getHeaderCaption(), is("text"));
+    }
+
+    @Test
+    public void defaultCaptionIsReturnedForHtml() {
+        Column firstColumn = grid.getColumns().get(0);
+
+        grid.getDefaultHeaderRow().getCell("column0").setHtml("<b>html</b>");
+
+        assertThat(firstColumn.getHeaderCaption(), is("Column0"));
+    }
+}
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/GridSelection.java
deleted file mode 100644 (file)
index dc64196..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.grid;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.event.SelectionEvent;
-import com.vaadin.event.SelectionEvent.SelectionListener;
-import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.SelectionMode;
-import com.vaadin.ui.Grid.SelectionModel;
-
-public class GridSelection {
-
-    private static class MockSelectionChangeListener implements
-            SelectionListener {
-        private SelectionEvent event;
-
-        @Override
-        public void select(final SelectionEvent event) {
-            this.event = event;
-        }
-
-        public Collection<?> getAdded() {
-            return event.getAdded();
-        }
-
-        public Collection<?> getRemoved() {
-            return event.getRemoved();
-        }
-
-        public void clearEvent() {
-            /*
-             * This method is not strictly needed as the event will simply be
-             * overridden, but it's good practice, and makes the code more
-             * obvious.
-             */
-            event = null;
-        }
-
-        public boolean eventHasHappened() {
-            return event != null;
-        }
-    }
-
-    private Grid grid;
-    private MockSelectionChangeListener mockListener;
-
-    private final Object itemId1Present = "itemId1Present";
-    private final Object itemId2Present = "itemId2Present";
-
-    private final Object itemId1NotPresent = "itemId1NotPresent";
-    private final Object itemId2NotPresent = "itemId2NotPresent";
-
-    @Before
-    public void setup() {
-        final IndexedContainer container = new IndexedContainer();
-        container.addItem(itemId1Present);
-        container.addItem(itemId2Present);
-        for (int i = 2; i < 10; i++) {
-            container.addItem(new Object());
-        }
-
-        assertEquals("init size", 10, container.size());
-        assertTrue("itemId1Present", container.containsId(itemId1Present));
-        assertTrue("itemId2Present", container.containsId(itemId2Present));
-        assertFalse("itemId1NotPresent",
-                container.containsId(itemId1NotPresent));
-        assertFalse("itemId2NotPresent",
-                container.containsId(itemId2NotPresent));
-
-        grid = new Grid(container);
-
-        mockListener = new MockSelectionChangeListener();
-        grid.addSelectionListener(mockListener);
-
-        assertFalse("eventHasHappened", mockListener.eventHasHappened());
-    }
-
-    @Test
-    public void defaultSelectionModeIsSingle() {
-        assertTrue(grid.getSelectionModel() instanceof SelectionModel.Single);
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void getSelectedRowThrowsExceptionMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        grid.getSelectedRow();
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void getSelectedRowThrowsExceptionNone() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.getSelectedRow();
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void selectThrowsExceptionNone() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.select(itemId1Present);
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void deselectRowThrowsExceptionNone() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.deselect(itemId1Present);
-    }
-
-    @Test
-    public void selectionModeMapsToMulti() {
-        assertTrue(grid.setSelectionMode(SelectionMode.MULTI) instanceof SelectionModel.Multi);
-    }
-
-    @Test
-    public void selectionModeMapsToSingle() {
-        assertTrue(grid.setSelectionMode(SelectionMode.SINGLE) instanceof SelectionModel.Single);
-    }
-
-    @Test
-    public void selectionModeMapsToNone() {
-        assertTrue(grid.setSelectionMode(SelectionMode.NONE) instanceof SelectionModel.None);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void selectionModeNullThrowsException() {
-        grid.setSelectionMode(null);
-    }
-
-    @Test
-    public void noSelectModel_isSelected() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        assertFalse("itemId1Present", grid.isSelected(itemId1Present));
-        assertFalse("itemId1NotPresent", grid.isSelected(itemId1NotPresent));
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void noSelectModel_getSelectedRow() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        grid.getSelectedRow();
-    }
-
-    @Test
-    public void noSelectModel_getSelectedRows() {
-        grid.setSelectionMode(SelectionMode.NONE);
-        assertTrue(grid.getSelectedRows().isEmpty());
-    }
-
-    @Test
-    public void selectionCallsListenerMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        selectionCallsListener();
-    }
-
-    @Test
-    public void selectionCallsListenerSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        selectionCallsListener();
-    }
-
-    private void selectionCallsListener() {
-        grid.select(itemId1Present);
-        assertEquals("added size", 1, mockListener.getAdded().size());
-        assertEquals("added item", itemId1Present, mockListener.getAdded()
-                .iterator().next());
-        assertEquals("removed size", 0, mockListener.getRemoved().size());
-    }
-
-    @Test
-    public void deselectionCallsListenerMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        deselectionCallsListener();
-    }
-
-    @Test
-    public void deselectionCallsListenerSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        deselectionCallsListener();
-    }
-
-    private void deselectionCallsListener() {
-        grid.select(itemId1Present);
-        mockListener.clearEvent();
-
-        grid.deselect(itemId1Present);
-        assertEquals("removed size", 1, mockListener.getRemoved().size());
-        assertEquals("removed item", itemId1Present, mockListener.getRemoved()
-                .iterator().next());
-        assertEquals("removed size", 0, mockListener.getAdded().size());
-    }
-
-    @Test
-    public void deselectPresentButNotSelectedItemIdShouldntFireListenerMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        deselectPresentButNotSelectedItemIdShouldntFireListener();
-    }
-
-    @Test
-    public void deselectPresentButNotSelectedItemIdShouldntFireListenerSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        deselectPresentButNotSelectedItemIdShouldntFireListener();
-    }
-
-    private void deselectPresentButNotSelectedItemIdShouldntFireListener() {
-        grid.deselect(itemId1Present);
-        assertFalse(mockListener.eventHasHappened());
-    }
-
-    @Test
-    public void deselectNotPresentItemIdShouldNotThrowExceptionMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        grid.deselect(itemId1NotPresent);
-    }
-
-    @Test
-    public void deselectNotPresentItemIdShouldNotThrowExceptionSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        grid.deselect(itemId1NotPresent);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void selectNotPresentItemIdShouldThrowExceptionMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        grid.select(itemId1NotPresent);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void selectNotPresentItemIdShouldThrowExceptionSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        grid.select(itemId1NotPresent);
-    }
-
-    @Test
-    public void selectAllMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        final SelectionModel.Multi select = (SelectionModel.Multi) grid
-                .getSelectionModel();
-        select.selectAll();
-        assertEquals("added size", 10, mockListener.getAdded().size());
-        assertEquals("removed size", 0, mockListener.getRemoved().size());
-        assertTrue("itemId1Present",
-                mockListener.getAdded().contains(itemId1Present));
-        assertTrue("itemId2Present",
-                mockListener.getAdded().contains(itemId2Present));
-    }
-
-    @Test
-    public void deselectAllMulti() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        final SelectionModel.Multi select = (SelectionModel.Multi) grid
-                .getSelectionModel();
-        select.selectAll();
-        mockListener.clearEvent();
-
-        select.deselectAll();
-        assertEquals("removed size", 10, mockListener.getRemoved().size());
-        assertEquals("added size", 0, mockListener.getAdded().size());
-        assertTrue("itemId1Present",
-                mockListener.getRemoved().contains(itemId1Present));
-        assertTrue("itemId2Present",
-                mockListener.getRemoved().contains(itemId2Present));
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-    }
-
-    @Test
-    public void gridDeselectAllMultiAllSelected() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        final SelectionModel.Multi select = (SelectionModel.Multi) grid
-                .getSelectionModel();
-        select.selectAll();
-        mockListener.clearEvent();
-
-        assertTrue(grid.deselectAll());
-        assertEquals("removed size", 10, mockListener.getRemoved().size());
-        assertEquals("added size", 0, mockListener.getAdded().size());
-        assertTrue("itemId1Present",
-                mockListener.getRemoved().contains(itemId1Present));
-        assertTrue("itemId2Present",
-                mockListener.getRemoved().contains(itemId2Present));
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-
-    }
-
-    @Test
-    public void gridDeselectAllMultiOneSelected() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-        final SelectionModel.Multi select = (SelectionModel.Multi) grid
-                .getSelectionModel();
-        select.select(itemId2Present);
-        mockListener.clearEvent();
-
-        assertTrue(grid.deselectAll());
-        assertEquals("removed size", 1, mockListener.getRemoved().size());
-        assertEquals("added size", 0, mockListener.getAdded().size());
-        assertFalse("itemId1Present",
-                mockListener.getRemoved().contains(itemId1Present));
-        assertTrue("itemId2Present",
-                mockListener.getRemoved().contains(itemId2Present));
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-
-    }
-
-    @Test
-    public void gridDeselectAllSingleNoneSelected() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        assertFalse(grid.deselectAll());
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-    }
-
-    @Test
-    public void gridDeselectAllSingleOneSelected() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        final SelectionModel.Single select = (SelectionModel.Single) grid
-                .getSelectionModel();
-        select.select(itemId2Present);
-        mockListener.clearEvent();
-
-        assertTrue(grid.deselectAll());
-        assertEquals("removed size", 1, mockListener.getRemoved().size());
-        assertEquals("added size", 0, mockListener.getAdded().size());
-        assertFalse("itemId1Present",
-                mockListener.getRemoved().contains(itemId1Present));
-        assertTrue("itemId2Present",
-                mockListener.getRemoved().contains(itemId2Present));
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-
-    }
-
-    @Test
-    public void gridDeselectAllMultiNoneSelected() {
-        grid.setSelectionMode(SelectionMode.MULTI);
-
-        assertFalse(grid.deselectAll());
-        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
-
-    }
-
-    @Test
-    public void reselectionDeselectsPreviousSingle() {
-        grid.setSelectionMode(SelectionMode.SINGLE);
-        grid.select(itemId1Present);
-        mockListener.clearEvent();
-
-        grid.select(itemId2Present);
-        assertEquals("added size", 1, mockListener.getAdded().size());
-        assertEquals("removed size", 1, mockListener.getRemoved().size());
-        assertEquals("added item", itemId2Present, mockListener.getAdded()
-                .iterator().next());
-        assertEquals("removed item", itemId1Present, mockListener.getRemoved()
-                .iterator().next());
-        assertEquals("selectedRows is correct", itemId2Present,
-                grid.getSelectedRow());
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridSelectionTest.java
new file mode 100644 (file)
index 0000000..85f51c3
--- /dev/null
@@ -0,0 +1,374 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.grid;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.SelectionEvent;
+import com.vaadin.event.SelectionEvent.SelectionListener;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.Grid.SelectionModel;
+
+public class GridSelectionTest {
+
+    private static class MockSelectionChangeListener implements
+            SelectionListener {
+        private SelectionEvent event;
+
+        @Override
+        public void select(final SelectionEvent event) {
+            this.event = event;
+        }
+
+        public Collection<?> getAdded() {
+            return event.getAdded();
+        }
+
+        public Collection<?> getRemoved() {
+            return event.getRemoved();
+        }
+
+        public void clearEvent() {
+            /*
+             * This method is not strictly needed as the event will simply be
+             * overridden, but it's good practice, and makes the code more
+             * obvious.
+             */
+            event = null;
+        }
+
+        public boolean eventHasHappened() {
+            return event != null;
+        }
+    }
+
+    private Grid grid;
+    private MockSelectionChangeListener mockListener;
+
+    private final Object itemId1Present = "itemId1Present";
+    private final Object itemId2Present = "itemId2Present";
+
+    private final Object itemId1NotPresent = "itemId1NotPresent";
+    private final Object itemId2NotPresent = "itemId2NotPresent";
+
+    @Before
+    public void setup() {
+        final IndexedContainer container = new IndexedContainer();
+        container.addItem(itemId1Present);
+        container.addItem(itemId2Present);
+        for (int i = 2; i < 10; i++) {
+            container.addItem(new Object());
+        }
+
+        assertEquals("init size", 10, container.size());
+        assertTrue("itemId1Present", container.containsId(itemId1Present));
+        assertTrue("itemId2Present", container.containsId(itemId2Present));
+        assertFalse("itemId1NotPresent",
+                container.containsId(itemId1NotPresent));
+        assertFalse("itemId2NotPresent",
+                container.containsId(itemId2NotPresent));
+
+        grid = new Grid(container);
+
+        mockListener = new MockSelectionChangeListener();
+        grid.addSelectionListener(mockListener);
+
+        assertFalse("eventHasHappened", mockListener.eventHasHappened());
+    }
+
+    @Test
+    public void defaultSelectionModeIsSingle() {
+        assertTrue(grid.getSelectionModel() instanceof SelectionModel.Single);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void getSelectedRowThrowsExceptionMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        grid.getSelectedRow();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void getSelectedRowThrowsExceptionNone() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        grid.getSelectedRow();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void selectThrowsExceptionNone() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        grid.select(itemId1Present);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void deselectRowThrowsExceptionNone() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        grid.deselect(itemId1Present);
+    }
+
+    @Test
+    public void selectionModeMapsToMulti() {
+        assertTrue(grid.setSelectionMode(SelectionMode.MULTI) instanceof SelectionModel.Multi);
+    }
+
+    @Test
+    public void selectionModeMapsToSingle() {
+        assertTrue(grid.setSelectionMode(SelectionMode.SINGLE) instanceof SelectionModel.Single);
+    }
+
+    @Test
+    public void selectionModeMapsToNone() {
+        assertTrue(grid.setSelectionMode(SelectionMode.NONE) instanceof SelectionModel.None);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void selectionModeNullThrowsException() {
+        grid.setSelectionMode(null);
+    }
+
+    @Test
+    public void noSelectModel_isSelected() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        assertFalse("itemId1Present", grid.isSelected(itemId1Present));
+        assertFalse("itemId1NotPresent", grid.isSelected(itemId1NotPresent));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void noSelectModel_getSelectedRow() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        grid.getSelectedRow();
+    }
+
+    @Test
+    public void noSelectModel_getSelectedRows() {
+        grid.setSelectionMode(SelectionMode.NONE);
+        assertTrue(grid.getSelectedRows().isEmpty());
+    }
+
+    @Test
+    public void selectionCallsListenerMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        selectionCallsListener();
+    }
+
+    @Test
+    public void selectionCallsListenerSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        selectionCallsListener();
+    }
+
+    private void selectionCallsListener() {
+        grid.select(itemId1Present);
+        assertEquals("added size", 1, mockListener.getAdded().size());
+        assertEquals("added item", itemId1Present, mockListener.getAdded()
+                .iterator().next());
+        assertEquals("removed size", 0, mockListener.getRemoved().size());
+    }
+
+    @Test
+    public void deselectionCallsListenerMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        deselectionCallsListener();
+    }
+
+    @Test
+    public void deselectionCallsListenerSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        deselectionCallsListener();
+    }
+
+    private void deselectionCallsListener() {
+        grid.select(itemId1Present);
+        mockListener.clearEvent();
+
+        grid.deselect(itemId1Present);
+        assertEquals("removed size", 1, mockListener.getRemoved().size());
+        assertEquals("removed item", itemId1Present, mockListener.getRemoved()
+                .iterator().next());
+        assertEquals("removed size", 0, mockListener.getAdded().size());
+    }
+
+    @Test
+    public void deselectPresentButNotSelectedItemIdShouldntFireListenerMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        deselectPresentButNotSelectedItemIdShouldntFireListener();
+    }
+
+    @Test
+    public void deselectPresentButNotSelectedItemIdShouldntFireListenerSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        deselectPresentButNotSelectedItemIdShouldntFireListener();
+    }
+
+    private void deselectPresentButNotSelectedItemIdShouldntFireListener() {
+        grid.deselect(itemId1Present);
+        assertFalse(mockListener.eventHasHappened());
+    }
+
+    @Test
+    public void deselectNotPresentItemIdShouldNotThrowExceptionMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        grid.deselect(itemId1NotPresent);
+    }
+
+    @Test
+    public void deselectNotPresentItemIdShouldNotThrowExceptionSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        grid.deselect(itemId1NotPresent);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void selectNotPresentItemIdShouldThrowExceptionMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        grid.select(itemId1NotPresent);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void selectNotPresentItemIdShouldThrowExceptionSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        grid.select(itemId1NotPresent);
+    }
+
+    @Test
+    public void selectAllMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        final SelectionModel.Multi select = (SelectionModel.Multi) grid
+                .getSelectionModel();
+        select.selectAll();
+        assertEquals("added size", 10, mockListener.getAdded().size());
+        assertEquals("removed size", 0, mockListener.getRemoved().size());
+        assertTrue("itemId1Present",
+                mockListener.getAdded().contains(itemId1Present));
+        assertTrue("itemId2Present",
+                mockListener.getAdded().contains(itemId2Present));
+    }
+
+    @Test
+    public void deselectAllMulti() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        final SelectionModel.Multi select = (SelectionModel.Multi) grid
+                .getSelectionModel();
+        select.selectAll();
+        mockListener.clearEvent();
+
+        select.deselectAll();
+        assertEquals("removed size", 10, mockListener.getRemoved().size());
+        assertEquals("added size", 0, mockListener.getAdded().size());
+        assertTrue("itemId1Present",
+                mockListener.getRemoved().contains(itemId1Present));
+        assertTrue("itemId2Present",
+                mockListener.getRemoved().contains(itemId2Present));
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+    }
+
+    @Test
+    public void gridDeselectAllMultiAllSelected() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        final SelectionModel.Multi select = (SelectionModel.Multi) grid
+                .getSelectionModel();
+        select.selectAll();
+        mockListener.clearEvent();
+
+        assertTrue(grid.deselectAll());
+        assertEquals("removed size", 10, mockListener.getRemoved().size());
+        assertEquals("added size", 0, mockListener.getAdded().size());
+        assertTrue("itemId1Present",
+                mockListener.getRemoved().contains(itemId1Present));
+        assertTrue("itemId2Present",
+                mockListener.getRemoved().contains(itemId2Present));
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+
+    }
+
+    @Test
+    public void gridDeselectAllMultiOneSelected() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+        final SelectionModel.Multi select = (SelectionModel.Multi) grid
+                .getSelectionModel();
+        select.select(itemId2Present);
+        mockListener.clearEvent();
+
+        assertTrue(grid.deselectAll());
+        assertEquals("removed size", 1, mockListener.getRemoved().size());
+        assertEquals("added size", 0, mockListener.getAdded().size());
+        assertFalse("itemId1Present",
+                mockListener.getRemoved().contains(itemId1Present));
+        assertTrue("itemId2Present",
+                mockListener.getRemoved().contains(itemId2Present));
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+
+    }
+
+    @Test
+    public void gridDeselectAllSingleNoneSelected() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        assertFalse(grid.deselectAll());
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+    }
+
+    @Test
+    public void gridDeselectAllSingleOneSelected() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        final SelectionModel.Single select = (SelectionModel.Single) grid
+                .getSelectionModel();
+        select.select(itemId2Present);
+        mockListener.clearEvent();
+
+        assertTrue(grid.deselectAll());
+        assertEquals("removed size", 1, mockListener.getRemoved().size());
+        assertEquals("added size", 0, mockListener.getAdded().size());
+        assertFalse("itemId1Present",
+                mockListener.getRemoved().contains(itemId1Present));
+        assertTrue("itemId2Present",
+                mockListener.getRemoved().contains(itemId2Present));
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+
+    }
+
+    @Test
+    public void gridDeselectAllMultiNoneSelected() {
+        grid.setSelectionMode(SelectionMode.MULTI);
+
+        assertFalse(grid.deselectAll());
+        assertTrue("selectedRows is empty", grid.getSelectedRows().isEmpty());
+
+    }
+
+    @Test
+    public void reselectionDeselectsPreviousSingle() {
+        grid.setSelectionMode(SelectionMode.SINGLE);
+        grid.select(itemId1Present);
+        mockListener.clearEvent();
+
+        grid.select(itemId2Present);
+        assertEquals("added size", 1, mockListener.getAdded().size());
+        assertEquals("removed size", 1, mockListener.getRemoved().size());
+        assertEquals("added item", itemId2Present, mockListener.getAdded()
+                .iterator().next());
+        assertEquals("removed item", itemId1Present, mockListener.getRemoved()
+                .iterator().next());
+        assertEquals("selectedRows is correct", itemId2Present,
+                grid.getSelectedRow());
+    }
+}
index 4287d58d9c5ac160a7dcaab0890d472f42e4a515..51cf7bf1ffae737ab8c3ecd833e6320955c3797e 100644 (file)
@@ -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
index 68007bd870a68a6fc54291ea23c9dda39aee5f40..105cf6660aee75ae130bcc70b58eb8a52b4f34cc 100644 (file)
@@ -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<Object> 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;
index c2dc175c75861aa4fbefd3e7b198d5997ccb352f..2c2a8a81fb312f23f3a84e0b96fb8e696a116cc0 100644 (file)
@@ -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);
index 3b3dfb94d8aec723834edaf408515213179adf2a..b3bca125214a7838f11b4ec5185b16766e9124be 100644 (file)
@@ -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);
     }
index 9a2a5f1f5076cd2d5c21ad48c27127bdcb3def02..1b0ff1caffaabf16375bffd40ab7642e384eda1e 100644 (file)
@@ -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);
index f9d373e86402af7cc0111b806ac8a67f57e3ddad..d13a4a287ee447c0273cb2e89441fc842bb84ca7 100644 (file)
@@ -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");
index ceb4c865d23c996b8cf49798d35688c683e7bba3..a7973b45f043fe74f1ad29a6463b73e40f6a75fe 100644 (file)
@@ -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());
 
index fce514954a7a7671f70e62adb7115d52dc6d226f..ac6fb171e31f37f9265112a75a5e3cb207c95339 100644 (file)
@@ -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);
index 7fd5bc67f6fbfdb5bd81d8f5b7e1c9c5a4ecf584..0bcc71630ece6f44afae2892550f0bd1fad84c39 100644 (file)
  */
 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/TableSelectable.java
deleted file mode 100644 (file)
index 1af99a0..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.server.component.table;
-
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.ui.Table;
-
-/**
- * Tests for 'selectable' property of {@link Table} class.
- * 
- * @author Vaadin Ltd
- */
-public class TableSelectable {
-
-    @Test
-    public void setSelectable_explicitSelectable_tableIsSelectable() {
-        Table table = new Table();
-        table.setSelectable(true);
-
-        Assert.assertTrue(table.isSelectable());
-    }
-
-    @Test
-    public void addValueChangeListener_explicitSelectable_tableIsSelectable() {
-        TestTable table = new TestTable();
-        table.addValueChangeListener(EasyMock
-                .createMock(ValueChangeListener.class));
-
-        Assert.assertTrue(table.isSelectable());
-        Assert.assertTrue(table.markAsDirtyCalled);
-    }
-
-    @Test
-    public void tableIsNotSelectableByDefult() {
-        Table table = new Table();
-
-        Assert.assertFalse(table.isSelectable());
-    }
-
-    @Test
-    public void setSelectable_explicitNotSelectable_tableIsNotSelectable() {
-        Table table = new Table();
-        table.setSelectable(false);
-        table.addValueChangeListener(EasyMock
-                .createMock(ValueChangeListener.class));
-
-        Assert.assertFalse(table.isSelectable());
-    }
-
-    private static final class TestTable extends Table {
-        @Override
-        public void markAsDirty() {
-            markAsDirtyCalled = true;
-        }
-
-        private boolean markAsDirtyCalled;
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java b/server/src/test/java/com/vaadin/tests/server/component/table/TableSelectableTest.java
new file mode 100644 (file)
index 0000000..2ec8cce
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.server.component.table;
+
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.ui.Table;
+
+/**
+ * Tests for 'selectable' property of {@link Table} class.
+ * 
+ * @author Vaadin Ltd
+ */
+public class TableSelectableTest {
+
+    @Test
+    public void setSelectable_explicitSelectable_tableIsSelectable() {
+        Table table = new Table();
+        table.setSelectable(true);
+
+        Assert.assertTrue(table.isSelectable());
+    }
+
+    @Test
+    public void addValueChangeListener_explicitSelectable_tableIsSelectable() {
+        TestTable table = new TestTable();
+        table.addValueChangeListener(EasyMock
+                .createMock(ValueChangeListener.class));
+
+        Assert.assertTrue(table.isSelectable());
+        Assert.assertTrue(table.markAsDirtyCalled);
+    }
+
+    @Test
+    public void tableIsNotSelectableByDefult() {
+        Table table = new Table();
+
+        Assert.assertFalse(table.isSelectable());
+    }
+
+    @Test
+    public void setSelectable_explicitNotSelectable_tableIsNotSelectable() {
+        Table table = new Table();
+        table.setSelectable(false);
+        table.addValueChangeListener(EasyMock
+                .createMock(ValueChangeListener.class));
+
+        Assert.assertFalse(table.isSelectable());
+    }
+
+    private static final class TestTable extends Table {
+        @Override
+        public void markAsDirty() {
+            markAsDirtyCalled = true;
+        }
+
+        private boolean markAsDirtyCalled;
+    }
+}
index 3f3c52d6c02f525dc3235490120499d5f3a9c40f..22f2381980d7a42ad0429b2429c4bc3008f8f50c 100644 (file)
@@ -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);
index 83c45f94dbbf714cf556038936f17c3c4cca6545..76cd1c7a39444ae024ab482d303c5fd5d9122214 100644 (file)
@@ -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<Integer> 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<Integer>(123);
         field.setConverter(new ConvertTo42());
index 8f2bec455b507c1a1d5eb1fcc361257ab355dd41..68b9a2d2cef7c13a87f6eb0d88fefbe318acbf1f 100644 (file)
@@ -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();
 
index b2a51aad8be1e59703d1fe3198b36c410d324d50..859d69d26e559906c63b22e2d4216c380bffd798 100644 (file)
@@ -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<String> 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"));
index c327fe8c5f75219920637cdb9ea14cd75fae80df..359aa8d480e257360dc723a1c6819f84ebeaa6cb 100644 (file)
@@ -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);
index 449f418596fa0b8ec01d86694d43aa14ed729fd0..ec10c4fe39aa746ebdc47a948a0833ea5b3d9e2f 100644 (file)
@@ -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);
index a886b74f57752402672ab386563ce73bb1110424..2a667bea72227fca185a29a52db77d61a80f20e4 100644 (file)
@@ -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();
 
index 4a34094da1896b2cb141eef5a04e9729763fa0fb..9718d24f8ca5fcbb5d9fc67a8dbc4c3955025018 100644 (file)
@@ -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();
 
index 470f04c15cb079df6b48be245120b792ae21c7a8..6ff6c1a71c2b451536ded5575b626c95a598dfd2 100644 (file)
@@ -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();
 
index 13d4c6bfe612ed889f19e95bde454dc83eeb1754..f2bfaf9650cc89d0c9456d26e090c3a0614f5c62 100644 (file)
@@ -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);
index 87a1af301c7325a1b025c26d785b2ad2dc84e71d..07bb0adadb72bf0b0654a28757adcc4fc565d772 100644 (file)
@@ -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);
index f19821f92e173dcff998a2b2c85e4f930c63e604..7bf0cb5c4e6b5ee482785afc87cdacf01656ab9c 100644 (file)
@@ -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();
index 91a302a274925577381a1be590735141a592d13e..c5bc4f39e5cd9531f594184e47ea413acfaf02cf 100644 (file)
@@ -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<Class<? extends ComponentContainer>> 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());
     }
 }
index f55798007f3c2a7503d4f49ea2f098be61d05de3..29dfd08212065f68510527ce12211a4a633321d7 100644 (file)
@@ -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;
 
index 637947fc9b347e56bf2001fb81dccd99725e87b7..d0680516638a1aa9b95751aef92335cac691b34a 100644 (file)
@@ -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
  * <code>changeVariables()</code>.
  */
-public abstract class AbstractFieldValueChangeTestBase<T> extends TestCase {
+public abstract class AbstractFieldValueChangeTestBase<T> {
 
     private AbstractField<T> field;
     private ValueChangeListener listener;
 
-    protected void setUp(AbstractField<T> field) throws Exception {
+    protected void setUp(AbstractField<T> field) {
         this.field = field;
         listener = EasyMock.createStrictMock(ValueChangeListener.class);
 
@@ -40,6 +39,7 @@ public abstract class AbstractFieldValueChangeTestBase<T> extends TestCase {
     /**
      * Test that listeners are not called when they have been unregistered.
      */
+    @Test
     public void testRemoveListener() {
         getField().setPropertyDataSource(new ObjectProperty<String>(""));
         getField().setBuffered(false);
@@ -75,6 +75,7 @@ public abstract class AbstractFieldValueChangeTestBase<T> 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<String>(""));
         getField().setBuffered(false);
index f3cc337657bb07bcfc5579190eb767ca438207bf..8bc1eb87df1afde952118760a754539a6cbc455f 100644 (file)
@@ -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<Object> {
-    @Override
-    protected void setUp() throws Exception {
+
+    @Before
+    public void setUp() {
         ComboBox combo = new ComboBox();
         combo.addItem("myvalue");
         super.setUp(combo);
index d8b366ffbc9e5922abb7bb74af9c6418f93dfd83..b13a379b055a112660e1a33872c1cddb4c304c84 100644 (file)
@@ -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();
index 3467d1d80c2728b51346b90fc6afc05058488e20..2743301a72520bb8883eeb1f6dcaae327083796d 100644 (file)
@@ -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"));
index cfceb6f7d7dd1aa2b94edfaf19fe09a6fb74c69c..3b34d17c9978d3cc20b0c58350892df9aefd7a22 100644 (file)
@@ -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<String> {
 
-    @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<String> property = new ObjectProperty<String>("");
         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<String> property = new ObjectProperty<String>(
index 26fe2383426124637054a9ba5595b77558bdb310..ed22870b59977a9c9c83b0714716581c41f1f938 100644 (file)
@@ -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);
 
index bc067ddb884575c1666653c19d9fa70d65e0a112..ecd45251b5709affb3eeea570a590702e1dce177 100644 (file)
 
 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);
index 0de804fa0b5442d65db5a0405ffa84fc4ff59a8a..0eda1ed0453f9fdebb0ce224275ecd58354e3bde 100644 (file)
 
 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<View>) null);
-            fail("addView() accepted null view class");
-        } catch (IllegalArgumentException e) {
-        }
+        navigator.addView("test", (Class<View>) 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");
+
     }
 }
index 6b7582525e78cc2fbd05a47ebc6ef85b86382e94..6ad6ac2d5f0fed617917995084c7dd1eea0ec22d 100644 (file)
@@ -85,6 +85,7 @@ public class BeanValidationTest {
         Assert.assertEquals(2, causes.length);
     }
 
+    @Test
     public void testBeanValidationNotAddedTwice() {
         // See ticket #11045
         BeanFieldGroup<BeanToValidate> fieldGroup = new BeanFieldGroup<BeanToValidate>(
@@ -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);
         }
 
     }
index e3320b8699475c70179526b1e31efbad18ef15d6..86c108326900607fca3a55e2059b095f3bd001c3 100644 (file)
@@ -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);
index abdc6c1a5c0d55f4526bf150c0822e2c7a166265..287ed0338a87ed6a6a19fbeb281037e3a4b11055 100644 (file)
  */
 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/DateFieldTestCase.java b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java
new file mode 100644 (file)
index 0000000..5fee13f
--- /dev/null
@@ -0,0 +1,56 @@
+package com.vaadin.ui;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Date;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.nullValue;
+
+public class DateFieldTestCase {
+
+    private DateField dateField;
+    private Date date;
+
+    @Before
+    public void setup() {
+        dateField = new DateField();
+        date = new Date();
+    }
+
+    @Test
+    public void rangeStartIsSetToNull() {
+        dateField.setRangeStart(null);
+
+        assertThat(dateField.getRangeStart(), is(nullValue()));
+    }
+
+    @Test
+    public void rangeStartIsImmutable() {
+        long expectedTime = date.getTime();
+
+        dateField.setRangeStart(date);
+        date.setTime(expectedTime + 1);
+
+        assertThat(dateField.getRangeStart().getTime(), is(expectedTime));
+    }
+
+    @Test
+    public void rangeEndIsSetToNull() {
+        dateField.setRangeEnd(null);
+
+        assertThat(dateField.getRangeEnd(), is(nullValue()));
+    }
+
+    @Test
+    public void rangeEndIsImmutable() {
+        long expectedTime = date.getTime();
+
+        dateField.setRangeEnd(date);
+        date.setTime(expectedTime + 1);
+
+        assertThat(dateField.getRangeEnd().getTime(), is(expectedTime));
+    }
+}
diff --git a/server/src/test/java/com/vaadin/ui/DateFieldTests.java b/server/src/test/java/com/vaadin/ui/DateFieldTests.java
deleted file mode 100644 (file)
index 6a75b46..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.vaadin.ui;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Date;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.nullValue;
-
-public class DateFieldTests {
-
-    private DateField dateField;
-    private Date date;
-
-    @Before
-    public void setup() {
-        dateField = new DateField();
-        date = new Date();
-    }
-
-    @Test
-    public void rangeStartIsSetToNull() {
-        dateField.setRangeStart(null);
-
-        assertThat(dateField.getRangeStart(), is(nullValue()));
-    }
-
-    @Test
-    public void rangeStartIsImmutable() {
-        long expectedTime = date.getTime();
-
-        dateField.setRangeStart(date);
-        date.setTime(expectedTime + 1);
-
-        assertThat(dateField.getRangeStart().getTime(), is(expectedTime));
-    }
-
-    @Test
-    public void rangeEndIsSetToNull() {
-        dateField.setRangeEnd(null);
-
-        assertThat(dateField.getRangeEnd(), is(nullValue()));
-    }
-
-    @Test
-    public void rangeEndIsImmutable() {
-        long expectedTime = date.getTime();
-
-        dateField.setRangeEnd(date);
-        date.setTime(expectedTime + 1);
-
-        assertThat(dateField.getRangeEnd().getTime(), is(expectedTime));
-    }
-}