Browse Source

Add @Test annotations, rename test classes

Change-Id: Iac29db81c0c7ff425da73e7ae3d69eadabf5de77
tags/7.7.0.alpha1
Teemu Suo-Anttila 8 years ago
parent
commit
11a2b5263f
100 changed files with 1003 additions and 394 deletions
  1. 8
    5
      client/tests/src/com/vaadin/client/DateTimeServiceTest.java
  2. 10
    3
      client/tests/src/com/vaadin/client/LocatorUtilTest.java
  3. 41
    3
      client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java
  4. 1
    1
      server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java
  5. 7
    3
      server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java
  6. 6
    0
      server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java
  7. 30
    1
      server/src/test/java/com/vaadin/data/util/BeanContainerTest.java
  8. 45
    6
      server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java
  9. 17
    3
      server/src/test/java/com/vaadin/data/util/BeanItemTest.java
  10. 4
    0
      server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java
  11. 4
    0
      server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java
  12. 6
    7
      server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java
  13. 32
    0
      server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java
  14. 6
    0
      server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java
  15. 19
    0
      server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java
  16. 45
    54
      server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java
  17. 18
    11
      server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java
  18. 8
    3
      server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java
  19. 7
    3
      server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java
  20. 7
    3
      server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java
  21. 35
    7
      server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java
  22. 13
    0
      server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java
  23. 8
    0
      server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java
  24. 4
    0
      server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java
  25. 2
    0
      server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java
  26. 4
    0
      server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java
  27. 9
    0
      server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java
  28. 1
    1
      server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java
  29. 1
    1
      server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java
  30. 14
    16
      server/src/test/java/com/vaadin/server/JSONSerializerTest.java
  31. 12
    11
      server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java
  32. 1
    1
      server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java
  33. 1
    1
      server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java
  34. 1
    1
      server/src/test/java/com/vaadin/server/VaadinPortletTest.java
  35. 0
    3
      server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java
  36. 9
    5
      server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java
  37. 8
    4
      server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java
  38. 7
    4
      server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java
  39. 12
    6
      server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java
  40. 13
    6
      server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java
  41. 40
    22
      server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java
  42. 17
    11
      server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java
  43. 11
    5
      server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java
  44. 12
    5
      server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java
  45. 11
    5
      server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java
  46. 13
    6
      server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java
  47. 20
    11
      server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java
  48. 17
    11
      server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java
  49. 21
    16
      server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java
  50. 21
    16
      server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java
  51. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java
  52. 14
    6
      server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java
  53. 12
    5
      server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java
  54. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java
  55. 11
    6
      server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java
  56. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java
  57. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java
  58. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java
  59. 7
    2
      server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java
  60. 11
    2
      server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java
  61. 9
    2
      server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java
  62. 13
    2
      server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java
  63. 1
    1
      server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java
  64. 4
    0
      server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java
  65. 5
    0
      server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java
  66. 6
    2
      server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java
  67. 5
    2
      server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java
  68. 4
    4
      server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java
  69. 9
    2
      server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java
  70. 3
    2
      server/src/test/java/com/vaadin/tests/server/EventRouterTest.java
  71. 7
    2
      server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java
  72. 5
    0
      server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java
  73. 9
    2
      server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java
  74. 5
    2
      server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java
  75. 3
    3
      server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java
  76. 11
    2
      server/src/test/java/com/vaadin/tests/server/SerializationTest.java
  77. 10
    2
      server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java
  78. 11
    6
      server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java
  79. 2
    4
      server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
  80. 3
    3
      server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java
  81. 1
    1
      server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java
  82. 3
    2
      server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java
  83. 12
    6
      server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java
  84. 6
    5
      server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java
  85. 7
    5
      server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java
  86. 12
    2
      server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java
  87. 11
    2
      server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java
  88. 5
    0
      server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java
  89. 7
    2
      server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java
  90. 13
    3
      server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java
  91. 5
    0
      server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java
  92. 7
    2
      server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java
  93. 5
    0
      server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java
  94. 1
    1
      server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java
  95. 1
    1
      server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java
  96. 6
    0
      server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java
  97. 6
    0
      server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java
  98. 6
    4
      server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java
  99. 5
    3
      server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java
  100. 0
    0
      server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java

+ 8
- 5
client/tests/src/com/vaadin/client/DateTimeServiceTest.java View File

@@ -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);

}

+ 10
- 3
client/tests/src/com/vaadin/client/LocatorUtilTest.java View File

@@ -15,56 +15,63 @@
*/
package com.vaadin.client;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

import com.vaadin.client.componentlocator.LocatorUtil;

/*
* Test LocatorUtil.isUIElement() & isNotificaitonElement methods
*/
public class LocatorUtilTest extends TestCase {
public class LocatorUtilTest {

@Test
public void testIsUI1() {
boolean isUI = LocatorUtil.isUIElement("com.vaadin.ui.UI");
Assert.assertTrue(isUI);
}

@Test
public void testIsUI2() {
boolean isUI = LocatorUtil.isUIElement("/com.vaadin.ui.UI");
Assert.assertTrue(isUI);
}

@Test
public void testIsUI3() {
boolean isUI = LocatorUtil
.isUIElement("//com.vaadin.ui.UI[RandomString");
Assert.assertTrue(isUI);
}

@Test
public void testIsUI4() {
boolean isUI = LocatorUtil.isUIElement("//com.vaadin.ui.UI[0]");
Assert.assertTrue(isUI);
}

@Test
public void testIsNotification1() {
boolean isUI = LocatorUtil
.isNotificationElement("com.vaadin.ui.VNotification");
Assert.assertTrue(isUI);
}

@Test
public void testIsNotification2() {
boolean isUI = LocatorUtil
.isNotificationElement("com.vaadin.ui.Notification");
Assert.assertTrue(isUI);
}

@Test
public void testIsNotification3() {
boolean isUI = LocatorUtil
.isNotificationElement("/com.vaadin.ui.VNotification[");
Assert.assertTrue(isUI);
}

@Test
public void testIsNotification4() {
boolean isUI = LocatorUtil
.isNotificationElement("//com.vaadin.ui.VNotification[0]");

+ 41
- 3
client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java View 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);

}


server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTests.java → server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupTest.java View File

@@ -16,7 +16,7 @@ import com.vaadin.data.util.TransactionalPropertyWrapper;
import com.vaadin.ui.Field;
import com.vaadin.ui.TextField;

public class FieldGroupTests {
public class FieldGroupTest {

private FieldGroup sut;
private Field field;

+ 7
- 3
server/src/test/java/com/vaadin/data/util/AbstractContainerTestBase.java View 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.

+ 6
- 0
server/src/test/java/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java View 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;

+ 30
- 1
server/src/test/java/com/vaadin/data/util/BeanContainerTest.java View 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);

+ 45
- 6
server/src/test/java/com/vaadin/data/util/BeanItemContainerTest.java View 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);

+ 17
- 3
server/src/test/java/com/vaadin/data/util/BeanItemTest.java View 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());


+ 4
- 0
server/src/test/java/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java View 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()));

+ 4
- 0
server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java View 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()));

+ 6
- 7
server/src/test/java/com/vaadin/data/util/ContainerSortingTest.java View 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);

+ 32
- 0
server/src/test/java/com/vaadin/data/util/GeneratedPropertyContainerBasicTest.java View 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");

+ 6
- 0
server/src/test/java/com/vaadin/data/util/HierarchicalContainerOrderedWrapperTest.java View 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());
}

+ 19
- 0
server/src/test/java/com/vaadin/data/util/HierarchicalContainerTest.java View 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();


+ 45
- 54
server/src/test/java/com/vaadin/data/util/IndexedContainerTest.java View 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));
}

}

+ 18
- 11
server/src/test/java/com/vaadin/data/util/NestedMethodPropertyTest.java View 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");

+ 8
- 3
server/src/test/java/com/vaadin/data/util/ObjectPropertyTest.java View 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);

+ 7
- 3
server/src/test/java/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java View 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) {

+ 7
- 3
server/src/test/java/com/vaadin/data/util/PropertyDescriptorTest.java View 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>(

+ 35
- 7
server/src/test/java/com/vaadin/data/util/PropertySetItemTest.java View 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();

+ 13
- 0
server/src/test/java/com/vaadin/data/util/filter/AndOrFilterTest.java View 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"));

+ 8
- 0
server/src/test/java/com/vaadin/data/util/filter/CompareFilterTest.java View 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);

+ 4
- 0
server/src/test/java/com/vaadin/data/util/filter/IsNullFilterTest.java View 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");

+ 2
- 0
server/src/test/java/com/vaadin/data/util/filter/LikeFilterTest.java View 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");

+ 4
- 0
server/src/test/java/com/vaadin/data/util/filter/NotFilterTest.java View 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);

+ 9
- 0
server/src/test/java/com/vaadin/data/util/filter/SimpleStringFilterTest.java View 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());

+ 1
- 1
server/src/test/java/com/vaadin/data/util/sqlcontainer/AllTests.java View 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 {
}

server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTests.java → server/src/test/java/com/vaadin/data/util/sqlcontainer/TicketTest.java View File

@@ -26,7 +26,7 @@ import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

public class TicketTests {
public class TicketTest {

private JDBCConnectionPool connectionPool;


+ 14
- 16
server/src/test/java/com/vaadin/server/JSONSerializerTest.java View 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));

}


+ 12
- 11
server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java View 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

server/src/test/java/com/vaadin/server/VaadinPortletRequestTests.java → server/src/test/java/com/vaadin/server/VaadinPortletRequestTest.java View File

@@ -13,7 +13,7 @@ import static org.mockito.Matchers.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class VaadinPortletRequestTests {
public class VaadinPortletRequestTest {

private PortletRequest request;
private VaadinPortletRequest sut;

server/src/test/java/com/vaadin/server/VaadinPortletServiceTests.java → server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java View File

@@ -30,7 +30,7 @@ import org.mockito.Mockito;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.ui.UI;

public class VaadinPortletServiceTests {
public class VaadinPortletServiceTest {

private VaadinPortletService sut;
private VaadinPortletRequest request;

server/src/test/java/com/vaadin/server/VaadinPortletTests.java → server/src/test/java/com/vaadin/server/VaadinPortletTest.java View File

@@ -30,7 +30,7 @@ import com.vaadin.server.VaadinPortlet.VaadinGateInRequest;
import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
import com.vaadin.server.VaadinPortlet.VaadinWebSpherePortalRequest;

public class VaadinPortletTests {
public class VaadinPortletTest {

private VaadinPortlet sut;
private PortletRequest portletRequest;

+ 0
- 3
server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java View 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 {

+ 9
- 5
server/src/test/java/com/vaadin/tests/data/converter/ConverterFactoryTest.java View 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());
}
}

+ 8
- 4
server/src/test/java/com/vaadin/tests/data/converter/DateToLongConverterTest.java View 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));
}
}

+ 7
- 4
server/src/test/java/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java View 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));
}
}

+ 12
- 6
server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java View 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);
}
}

+ 13
- 6
server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java View 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);
}
}

+ 40
- 22
server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java View 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));
}

}

+ 17
- 11
server/src/test/java/com/vaadin/tests/data/converter/StringToByteConverterTest.java View 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);
}
}

+ 11
- 5
server/src/test/java/com/vaadin/tests/data/converter/StringToDateConverterTest.java View 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));
}
}

+ 12
- 5
server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java View 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);
}
}

+ 11
- 5
server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java View 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));
}
}

+ 13
- 6
server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java View 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));
}
}

+ 20
- 11
server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java View 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);

}
}

+ 17
- 11
server/src/test/java/com/vaadin/tests/data/converter/StringToShortConverterTest.java View 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);
}
}

+ 21
- 16
server/src/test/java/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java View 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)));
}
}

+ 21
- 16
server/src/test/java/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java View 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)));
}
}

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java View 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));

+ 14
- 6
server/src/test/java/com/vaadin/tests/data/validator/CompositeValidatorTest.java View 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";

+ 12
- 5
server/src/test/java/com/vaadin/tests/data/validator/DateRangeValidatorTest.java View 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);

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java View 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));

+ 11
- 6
server/src/test/java/com/vaadin/tests/data/validator/EmailValidatorTest.java View 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"));
}
}

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java View 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));

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java View 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));

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/LongRangeValidatorTest.java View 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));

+ 7
- 2
server/src/test/java/com/vaadin/tests/data/validator/NullValidatorTest.java View 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");

+ 11
- 2
server/src/test/java/com/vaadin/tests/data/validator/RegexpValidatorTest.java View 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"));

+ 9
- 2
server/src/test/java/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java View 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));

+ 13
- 2
server/src/test/java/com/vaadin/tests/data/validator/StringLengthValidatorTest.java View 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"));

server/src/test/java/com/vaadin/tests/design/InvalidTagNames.java → server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java View File

@@ -26,7 +26,7 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.Design;
import com.vaadin.ui.declarative.DesignException;

public class InvalidTagNames {
public class InvalidTagNamesTest {

@Test(expected = DesignException.class)
public void tagWithoutDash() {

+ 4
- 0
server/src/test/java/com/vaadin/tests/server/AbstractContainerListenersTest.java View 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);

+ 5
- 0
server/src/test/java/com/vaadin/tests/server/AbstractPropertyListenersTest.java View 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,

+ 6
- 2
server/src/test/java/com/vaadin/tests/server/AssertionsEnabledTest.java View File

@@ -16,9 +16,13 @@

package com.vaadin.tests.server;

import junit.framework.TestCase;
import static org.junit.Assert.assertTrue;

public class AssertionsEnabledTest extends TestCase {
import org.junit.Test;

public class AssertionsEnabledTest {

@Test
public void testAssertionsEnabled() {
boolean assertFailed = false;
try {

+ 5
- 2
server/src/test/java/com/vaadin/tests/server/AtmosphereVersionTest.java View 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());

+ 4
- 4
server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java View 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);
}
}

+ 9
- 2
server/src/test/java/com/vaadin/tests/server/ClientMethodSerializationTest.java View 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" };

+ 3
- 2
server/src/test/java/com/vaadin/tests/server/EventRouterTest.java View 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();


+ 7
- 2
server/src/test/java/com/vaadin/tests/server/FileTypeResolverTest.java View 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"));

+ 5
- 0
server/src/test/java/com/vaadin/tests/server/IndexedContainerListenersTest.java View 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);

+ 9
- 2
server/src/test/java/com/vaadin/tests/server/KeyMapperTest.java View 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();

+ 5
- 2
server/src/test/java/com/vaadin/tests/server/MimeTypesTest.java View 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",

+ 3
- 3
server/src/test/java/com/vaadin/tests/server/PropertyFormatterTest.java View 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 {


+ 11
- 2
server/src/test/java/com/vaadin/tests/server/SerializationTest.java View 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);


+ 10
- 2
server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java View 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");

+ 11
- 6
server/src/test/java/com/vaadin/tests/server/StreamVariableMappingTest.java View 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);

+ 2
- 4
server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java View 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,

+ 3
- 3
server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java View File

@@ -16,15 +16,14 @@

package com.vaadin.tests.server.component;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

import com.vaadin.server.Sizeable.Unit;
import com.vaadin.shared.ui.label.LabelState;
import com.vaadin.ui.Label;

public class ComponentSizeParseTest extends TestCase {
public class ComponentSizeParseTest {

private final class LabelWithPublicState extends Label {
@Override
@@ -33,6 +32,7 @@ public class ComponentSizeParseTest extends TestCase {
}
}

@Test
public void testAllTheUnit() {
testUnit("10.0px", 10, Unit.PIXELS);
testUnit("10.0pt", 10, Unit.POINTS);

server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValues.java → server/src/test/java/com/vaadin/tests/server/component/FieldDefaultValuesTest.java View File

@@ -25,7 +25,7 @@ import com.vaadin.tests.VaadinClasses;
import com.vaadin.ui.Field;
import com.vaadin.ui.Slider;

public class FieldDefaultValues {
public class FieldDefaultValuesTest {

@Test
public void testFieldsHaveDefaultValueAfterClear() throws Exception {

+ 3
- 2
server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java View 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()) {

+ 12
- 6
server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java View File

@@ -15,14 +15,18 @@
*/
package com.vaadin.tests.server.component;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import junit.framework.TestCase;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.DocumentType;
import org.jsoup.nodes.Element;
import org.junit.Before;
import org.junit.Test;

import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;
@@ -34,27 +38,29 @@ import com.vaadin.ui.declarative.DesignException;
* Test cases for checking that reading a design with no elements in the html
* body produces null as the root component.
*/
public class ReadEmptyDesignTest extends TestCase {
public class ReadEmptyDesignTest {
InputStream is;

@Override
protected void setUp() throws Exception {
super.setUp();
@Before
public void setUp() {
String html = createDesign().toString();
is = new ByteArrayInputStream(html.getBytes());
}

@Test
public void testReadComponent() {
Component root = Design.read(is);
assertNull("The root component should be null.", root);
}

@Test
public void testReadContext() {
DesignContext ctx = Design.read(is, null);
assertNotNull("The design context should not be null.", ctx);
assertNull("The root component should be null.", ctx.getRootComponent());
}

@Test
public void testReadContextWithRootParameter() {
try {
Component rootComponent = new VerticalLayout();

+ 6
- 5
server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java View 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);

+ 7
- 5
server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java View 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());
}
}

+ 12
- 2
server/src/test/java/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java View 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();

+ 11
- 2
server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java View 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 ");

+ 5
- 0
server/src/test/java/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java View 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);

+ 7
- 2
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java View 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());

+ 13
- 3
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java View 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);

+ 5
- 0
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java View 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);

+ 7
- 2
server/src/test/java/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java View 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);

+ 5
- 0
server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java View 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);

server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java → server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java View File

@@ -22,7 +22,7 @@ import com.vaadin.server.ThemeResource;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.OptionGroup;

public class OptionGroupDeclarativeTests extends
public class OptionGroupDeclarativeTest extends
DeclarativeTestBase<OptionGroup> {

private OptionGroup og;

server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTests.java → server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java View File

@@ -10,7 +10,7 @@ import org.junit.Test;

import com.vaadin.ui.OptionGroup;

public class OptionGroupTests {
public class OptionGroupTest {

private OptionGroup optionGroup;


+ 6
- 0
server/src/test/java/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java View 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);

+ 6
- 0
server/src/test/java/com/vaadin/tests/server/component/button/ButtonListenersTest.java View 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);

+ 6
- 4
server/src/test/java/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java View File

@@ -15,11 +15,13 @@
*/
package com.vaadin.tests.server.component.calendar;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.Date;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import com.vaadin.data.Container.Indexed;
@@ -33,11 +35,11 @@ import com.vaadin.ui.components.calendar.ContainerEventProvider;
import com.vaadin.ui.components.calendar.event.BasicEvent;
import com.vaadin.ui.components.calendar.event.CalendarEvent;

public class ContainerDataSourceTest extends TestCase {
public class ContainerDataSourceTest {

private Calendar calendar;

@Override
@Before
public void setUp() {
calendar = new Calendar();
}

+ 5
- 3
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java View 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);

+ 0
- 0
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save