From 4290ee20b506de430e40d2f985cac92369bb5c89 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sat, 29 Aug 2015 14:58:02 +0300 Subject: Convert test to JUnit 4 Change-Id: Ie01895d96e83f16d767f8cfcabde77ac78f50796 --- .../data/converter/StringToEnumConverterTest.java | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'server') 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 reverseConverter = new ReverseConverter( 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)); } -- cgit v1.2.3