summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java49
1 files changed, 29 insertions, 20 deletions
diff --git a/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java b/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java
index a4c3732e1f..59c1ed133a 100644
--- a/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java
+++ b/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java
@@ -1,13 +1,14 @@
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.StringToEnumConverter;
-public class StringToEnumConverterTest extends TestCase {
+public class StringToEnumConverterTest {
public static enum FooEnum {
VALUE1, SOME_VALUE, FOO_BAR_BAZ, Bar, nonStandardCase, _HUGH;
@@ -17,56 +18,64 @@ public class StringToEnumConverterTest extends TestCase {
Converter<Enum, String> reverseConverter = new ReverseConverter<Enum, String>(
converter);
+ @Test
public void testEmptyStringConversion() {
- assertEquals(null, converter.convertToModel("", Enum.class, null));
+ Assert.assertEquals(null,
+ converter.convertToModel("", Enum.class, null));
}
+ @Test
public void testInvalidEnumClassConversion() {
try {
converter.convertToModel("Foo", Enum.class, null);
- fail("No exception thrown");
+ Assert.fail("No exception thrown");
} catch (ConversionException e) {
// OK
}
}
+ @Test
public void testNullConversion() {
- assertEquals(null, converter.convertToModel(null, Enum.class, null));
+ Assert.assertEquals(null,
+ converter.convertToModel(null, Enum.class, null));
}
+ @Test
public void testReverseNullConversion() {
- assertEquals(null,
+ Assert.assertEquals(null,
reverseConverter.convertToModel(null, String.class, null));
}
+ @Test
public void testValueConversion() {
- assertEquals(FooEnum.VALUE1,
+ Assert.assertEquals(FooEnum.VALUE1,
converter.convertToModel("Value1", FooEnum.class, null));
- assertEquals(FooEnum.SOME_VALUE,
+ Assert.assertEquals(FooEnum.SOME_VALUE,
converter.convertToModel("Some value", FooEnum.class, null));
- assertEquals(FooEnum.FOO_BAR_BAZ,
+ Assert.assertEquals(FooEnum.FOO_BAR_BAZ,
converter.convertToModel("Foo bar baz", FooEnum.class, null));
- assertEquals(FooEnum.Bar,
+ Assert.assertEquals(FooEnum.Bar,
converter.convertToModel("Bar", FooEnum.class, null));
- assertEquals(FooEnum.nonStandardCase, converter.convertToModel(
+ Assert.assertEquals(FooEnum.nonStandardCase, converter.convertToModel(
"Nonstandardcase", FooEnum.class, null));
- assertEquals(FooEnum._HUGH,
+ Assert.assertEquals(FooEnum._HUGH,
converter.convertToModel("_hugh", FooEnum.class, null));
}
+ @Test
public void testReverseValueConversion() {
- assertEquals("Value1", reverseConverter.convertToModel(FooEnum.VALUE1,
- String.class, null));
- assertEquals("Some value", reverseConverter.convertToModel(
+ Assert.assertEquals("Value1", reverseConverter.convertToModel(
+ FooEnum.VALUE1, String.class, null));
+ Assert.assertEquals("Some value", reverseConverter.convertToModel(
FooEnum.SOME_VALUE, String.class, null));
- assertEquals("Foo bar baz", reverseConverter.convertToModel(
+ Assert.assertEquals("Foo bar baz", reverseConverter.convertToModel(
FooEnum.FOO_BAR_BAZ, String.class, null));
- assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar,
+ Assert.assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar,
String.class, null));
- assertEquals("Nonstandardcase", reverseConverter.convertToModel(
+ Assert.assertEquals("Nonstandardcase", reverseConverter.convertToModel(
FooEnum.nonStandardCase, String.class, null));
- assertEquals("_hugh", reverseConverter.convertToModel(FooEnum._HUGH,
- String.class, null));
+ Assert.assertEquals("_hugh", reverseConverter.convertToModel(
+ FooEnum._HUGH, String.class, null));
}