1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sourceforge.acelogger.interpolator.test;
16
17 import org.testng.annotations.DataProvider;
18 import org.testng.annotations.Test;
19
20 import net.sourceforge.acelogger.interpolator.JavaTextFormatInterpolator;
21 import net.sourceforge.acelogger.test.DataProviderHelper;
22
23 import static org.testng.Assert.assertEquals;
24
25
26
27
28
29
30
31
32 @Test
33 public class JavaTextFormatInterpolatorTest {
34
35 @DataProvider(name = "validPatternDataProvider")
36 public Object[][] validPatternDataProvider() {
37 return DataProviderHelper.loadData();
38 }
39
40 @Test(dataProvider = "validPatternDataProvider")
41 public void testValidPattern(String pattern, Object[] params, String expected) {
42 String got = JavaTextFormatInterpolator.getInstance().interpolate(pattern, params);
43 assertEquals(got, expected);
44 }
45
46 @DataProvider(name = "invalidPatternDataProvider")
47 public Object[][] invalidPatternDataProvider() {
48 return DataProviderHelper.loadData();
49 }
50
51 @Test(dataProvider = "invalidPatternDataProvider", expectedExceptions = { IllegalArgumentException.class })
52 public void testInvalidPattern(String pattern, Object[] params) {
53 JavaTextFormatInterpolator.getInstance().interpolate(pattern, params);
54 }
55
56 }