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.formatter.test;
16  
17  import org.testng.annotations.BeforeMethod;
18  import org.testng.annotations.DataProvider;
19  import org.testng.annotations.Test;
20  
21  import net.sourceforge.acelogger.LogEvent;
22  import net.sourceforge.acelogger.formatter.BaseFormatter;
23  import net.sourceforge.acelogger.formatter.SimpleFormatter;
24  import net.sourceforge.acelogger.test.DataProviderHelper;
25  
26  import static org.testng.Assert.assertEquals;
27  
28  /**
29   * TODO: Create Doc.
30   * 
31   * @author Zardi (https://sourceforge.net/users/daniel_zardi)
32   * @version 1.0.0
33   * @since 1.0.0
34   */
35  @Test
36  public class SimpleFormatterTest {
37  
38  	private static final String PLATFORM_EOL = System.getProperty("line.separator");
39  
40  	private BaseFormatter formatter;
41  
42  	@BeforeMethod
43  	public void setUp() {
44  		formatter = null;
45  	}
46  
47  	@DataProvider(name = "formatLogCallDataProvider")
48  	public Object[][] formatLogCallDataProvider() {
49  		return DataProviderHelper.loadData();
50  	}
51  
52  	@Test(dataProvider = "formatLogCallDataProvider")
53  	public void testFormatLogCall(LogEvent call, String expectedMessage) {
54  		formatter = new SimpleFormatter("SimpleFormatter.testFormatLogCall");
55  		String message = formatter.formatLogCall(call);
56  		assertEquals(message, expectedMessage.replace("\n", PLATFORM_EOL) + PLATFORM_EOL);
57  	}
58  
59  	@Test
60  	public void testGetIdentifier() {
61  		formatter = new SimpleFormatter("SimpleFormatter.testGetIdentifier");
62  		assertEquals(formatter.getIdentifier(), "SimpleFormatter.testGetIdentifier");
63  	}
64  
65  	@Test
66  	public void testNullCall() {
67  		formatter = new SimpleFormatter("SimpleFormatter.testNullCall");
68  		String message = formatter.formatLogCall(null);
69  		assertEquals(message, "");
70  	}
71  
72  }