junit 4.7 向けリファクタリング
@@ -19,7 +19,9 @@ | ||
19 | 19 | |
20 | 20 | import jp.sf.orangesignal.csv.entity.Price; |
21 | 21 | |
22 | +import org.junit.Rule; | |
22 | 23 | import org.junit.Test; |
24 | +import org.junit.rules.ExpectedException; | |
23 | 25 | |
24 | 26 | /** |
25 | 27 | * {@link CsvBeanSaver} クラスの単体テストです。 |
@@ -28,8 +30,13 @@ | ||
28 | 30 | */ |
29 | 31 | public class CsvBeanSaverTest { |
30 | 32 | |
31 | - @Test(expected = IllegalArgumentException.class) | |
33 | + @Rule | |
34 | + public ExpectedException exception = ExpectedException.none(); | |
35 | + | |
36 | + @Test | |
32 | 37 | public void testCsvBeanSaverIllegalArgumentException() { |
38 | + exception.expect(IllegalArgumentException.class); | |
39 | + exception.expectMessage("CsvConfig must not be null"); | |
33 | 40 | new CsvBeanSaver<Price>(null, null, Price.class); |
34 | 41 | } |
35 | 42 |
@@ -34,7 +34,9 @@ | ||
34 | 34 | import jp.sf.orangesignal.csv.filters.SimpleCsvNamedValueFilter; |
35 | 35 | |
36 | 36 | import org.junit.BeforeClass; |
37 | +import org.junit.Rule; | |
37 | 38 | import org.junit.Test; |
39 | +import org.junit.rules.ExpectedException; | |
38 | 40 | |
39 | 41 | /** |
40 | 42 | * {@link CsvEntityManager} クラスの単体テストです。 |
@@ -45,6 +47,9 @@ | ||
45 | 47 | |
46 | 48 | private static CsvConfig cfg; |
47 | 49 | |
50 | + @Rule | |
51 | + public ExpectedException exception = ExpectedException.none(); | |
52 | + | |
48 | 53 | @BeforeClass |
49 | 54 | public static void setUpBeforeClass() throws Exception { |
50 | 55 | cfg = new CsvConfig(','); |
@@ -61,8 +66,10 @@ | ||
61 | 66 | new CsvEntityManager(cfg); |
62 | 67 | } |
63 | 68 | |
64 | - @Test(expected = IllegalArgumentException.class) | |
69 | + @Test | |
65 | 70 | public void testCsvEntityManagerIllegalArgumentException() { |
71 | + exception.expect(IllegalArgumentException.class); | |
72 | + exception.expectMessage("CsvConfig must not be null"); | |
66 | 73 | new CsvEntityManager(null); |
67 | 74 | } |
68 | 75 |
@@ -71,8 +78,10 @@ | ||
71 | 78 | new CsvEntityManager().config(cfg); |
72 | 79 | } |
73 | 80 | |
74 | - @Test(expected = IllegalArgumentException.class) | |
81 | + @Test | |
75 | 82 | public void testConfigIllegalArgumentException() { |
83 | + exception.expect(IllegalArgumentException.class); | |
84 | + exception.expectMessage("CsvConfig must not be null"); | |
76 | 85 | new CsvEntityManager().config(null); |
77 | 86 | } |
78 | 87 |
@@ -35,7 +35,9 @@ | ||
35 | 35 | import jp.sf.orangesignal.csv.model.SampleBean; |
36 | 36 | |
37 | 37 | import org.junit.BeforeClass; |
38 | +import org.junit.Rule; | |
38 | 39 | import org.junit.Test; |
40 | +import org.junit.rules.ExpectedException; | |
39 | 41 | |
40 | 42 | /** |
41 | 43 | * {@link CsvColumnNameMappingBeanManager} クラスの単体テストです。 |
@@ -46,6 +48,9 @@ | ||
46 | 48 | |
47 | 49 | private static CsvConfig cfg; |
48 | 50 | |
51 | + @Rule | |
52 | + public ExpectedException exception = ExpectedException.none(); | |
53 | + | |
49 | 54 | @BeforeClass |
50 | 55 | public static void setUpBeforeClass() throws Exception { |
51 | 56 | cfg = new CsvConfig(','); |
@@ -62,8 +67,10 @@ | ||
62 | 67 | new CsvColumnNameMappingBeanManager(cfg); |
63 | 68 | } |
64 | 69 | |
65 | - @Test(expected = IllegalArgumentException.class) | |
70 | + @Test | |
66 | 71 | public void testCsvColumnNameMappingBeanManagerIllegalArgumentException() { |
72 | + exception.expect(IllegalArgumentException.class); | |
73 | + exception.expectMessage("CsvConfig must not be null"); | |
67 | 74 | new CsvColumnNameMappingBeanManager(null); |
68 | 75 | } |
69 | 76 |
@@ -72,8 +79,10 @@ | ||
72 | 79 | new CsvColumnNameMappingBeanManager().config(cfg); |
73 | 80 | } |
74 | 81 | |
75 | - @Test(expected = IllegalArgumentException.class) | |
82 | + @Test | |
76 | 83 | public void testConfigIllegalArgumentException() { |
84 | + exception.expect(IllegalArgumentException.class); | |
85 | + exception.expectMessage("CsvConfig must not be null"); | |
77 | 86 | new CsvColumnNameMappingBeanManager().config(null); |
78 | 87 | } |
79 | 88 |
@@ -19,7 +19,9 @@ | ||
19 | 19 | |
20 | 20 | import jp.sf.orangesignal.csv.entity.Price; |
21 | 21 | |
22 | +import org.junit.Rule; | |
22 | 23 | import org.junit.Test; |
24 | +import org.junit.rules.ExpectedException; | |
23 | 25 | |
24 | 26 | /** |
25 | 27 | * {@link CsvBeanLoader} クラスの単体テストです。 |
@@ -28,8 +30,13 @@ | ||
28 | 30 | */ |
29 | 31 | public class CsvBeanLoaderTest { |
30 | 32 | |
31 | - @Test(expected = IllegalArgumentException.class) | |
33 | + @Rule | |
34 | + public ExpectedException exception = ExpectedException.none(); | |
35 | + | |
36 | + @Test | |
32 | 37 | public void testCsvBeanLoaderIllegalArgumentException() { |
38 | + exception.expect(IllegalArgumentException.class); | |
39 | + exception.expectMessage("CsvConfig must not be null"); | |
33 | 40 | new CsvBeanLoader<Price>(null, Price.class); |
34 | 41 | } |
35 | 42 |
@@ -35,7 +35,9 @@ | ||
35 | 35 | import jp.sf.orangesignal.csv.model.SampleBean; |
36 | 36 | |
37 | 37 | import org.junit.Before; |
38 | +import org.junit.Rule; | |
38 | 39 | import org.junit.Test; |
40 | +import org.junit.rules.ExpectedException; | |
39 | 41 | |
40 | 42 | /** |
41 | 43 | * {@link CsvColumnPositionMappingBeanManager} クラスの単体テストです。 |
@@ -46,6 +48,9 @@ | ||
46 | 48 | |
47 | 49 | private CsvConfig cfg; |
48 | 50 | |
51 | + @Rule | |
52 | + public ExpectedException exception = ExpectedException.none(); | |
53 | + | |
49 | 54 | @Before |
50 | 55 | public void setUp() throws Exception { |
51 | 56 | cfg = new CsvConfig(','); |
@@ -62,8 +67,10 @@ | ||
62 | 67 | new CsvColumnPositionMappingBeanManager(cfg); |
63 | 68 | } |
64 | 69 | |
65 | - @Test(expected = IllegalArgumentException.class) | |
70 | + @Test | |
66 | 71 | public void testCsvColumnPositionMappingBeanManagerIllegalArgumentException() { |
72 | + exception.expect(IllegalArgumentException.class); | |
73 | + exception.expectMessage("CsvConfig must not be null"); | |
67 | 74 | new CsvColumnPositionMappingBeanManager(null); |
68 | 75 | } |
69 | 76 |
@@ -72,8 +79,10 @@ | ||
72 | 79 | new CsvColumnPositionMappingBeanManager().config(cfg); |
73 | 80 | } |
74 | 81 | |
75 | - @Test(expected = IllegalArgumentException.class) | |
82 | + @Test | |
76 | 83 | public void testConfigIllegalArgumentException() { |
84 | + exception.expect(IllegalArgumentException.class); | |
85 | + exception.expectMessage("CsvConfig must not be null"); | |
77 | 86 | new CsvColumnPositionMappingBeanManager().config(null); |
78 | 87 | } |
79 | 88 |
@@ -35,7 +35,9 @@ | ||
35 | 35 | import jp.sf.orangesignal.csv.model.SampleBean; |
36 | 36 | |
37 | 37 | import org.junit.BeforeClass; |
38 | +import org.junit.Rule; | |
38 | 39 | import org.junit.Test; |
40 | +import org.junit.rules.ExpectedException; | |
39 | 41 | |
40 | 42 | /** |
41 | 43 | * {@link CsvBeanManager} クラスの単体テストです。 |
@@ -46,6 +48,9 @@ | ||
46 | 48 | |
47 | 49 | private static CsvConfig cfg; |
48 | 50 | |
51 | + @Rule | |
52 | + public ExpectedException exception = ExpectedException.none(); | |
53 | + | |
49 | 54 | @BeforeClass |
50 | 55 | public static void setUpBeforeClass() throws Exception { |
51 | 56 | cfg = new CsvConfig(','); |
@@ -62,8 +67,10 @@ | ||
62 | 67 | new CsvBeanManager(cfg); |
63 | 68 | } |
64 | 69 | |
65 | - @Test(expected = IllegalArgumentException.class) | |
70 | + @Test | |
66 | 71 | public void testCsvBeanManagerIllegalArgumentException() { |
72 | + exception.expect(IllegalArgumentException.class); | |
73 | + exception.expectMessage("CsvConfig must not be null"); | |
67 | 74 | new CsvBeanManager(null); |
68 | 75 | } |
69 | 76 |
@@ -72,8 +79,10 @@ | ||
72 | 79 | new CsvBeanManager().config(cfg); |
73 | 80 | } |
74 | 81 | |
75 | - @Test(expected = IllegalArgumentException.class) | |
82 | + @Test | |
76 | 83 | public void testConfigIllegalArgumentException() { |
84 | + exception.expect(IllegalArgumentException.class); | |
85 | + exception.expectMessage("CsvConfig must not be null"); | |
77 | 86 | new CsvBeanManager().config(null); |
78 | 87 | } |
79 | 88 |