1   /*
2    * This file is part of AceLogger.
3    * 
4    * AceLogger is free software: you can redistribute it and/or modify it under the terms of the GNU
5    * Lesser General Public License as published by the Free Software Foundation, either version 3 of
6    * the License, or (at your option) any later version.
7    * 
8    * AceLogger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
9    * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10   * Lesser General Public License for more details.
11   * 
12   * You should have received a copy of the GNU Lesser General Public License along with AceLogger.
13   * If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
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   * TODO: Create Doc.
27   * 
28   * @author Zardi (https://sourceforge.net/users/daniel_zardi)
29   * @version 1.0.0
30   * @since 1.0.0
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  }