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.location.information.test;
16  
17  import org.testng.annotations.DataProvider;
18  import org.testng.annotations.Test;
19  
20  import net.sourceforge.acelogger.location.LogEventLocation;
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 LogCallLocationTest {
34  
35  	@DataProvider(name = "classConstructorDataProvider")
36  	public Object[][] classConstructorDataProvider() {
37  		return DataProviderHelper.loadData();
38  	}
39  
40  	@Test(dataProvider = "classConstructorDataProvider")
41  	public void testClassConstructor(LogEventLocation location, String packageName,
42  			String className) {
43  		assertEquals(location.getPackageName(), packageName);
44  		assertEquals(location.getClassName(), className);
45  	}
46  
47  	@DataProvider(name = "qualifiedNameDataProvider")
48  	public Object[][] qualifiedNameDataProvider() {
49  		return DataProviderHelper.loadData();
50  	}
51  
52  	@Test(dataProvider = "qualifiedNameDataProvider")
53  	public void testGetQualifiedName(LogEventLocation location, String qualifiedName) {
54  		assertEquals(location.getFullQualifiedName(), qualifiedName);
55  	}
56  
57  	@DataProvider(name = "javadocNameDataProvider")
58  	public Object[][] javadocNameDataProvider() {
59  		return DataProviderHelper.loadData();
60  	}
61  
62  	@Test(dataProvider = "javadocNameDataProvider")
63  	public void testGetJavadocName(LogEventLocation location, String qualifiedName) {
64  		assertEquals(location.getJavadocLikeName(), qualifiedName);
65  	}
66  
67  	@Test
68  	public void testGetThreadName() {
69  		LogEventLocation location = new LogEventLocation(
70  				"net.sourceforge.acelogger.location.information.test", "LogCallLocationTest",
71  				"testGetThreadName");
72  		location.setThreadName("Main");
73  		assertEquals(location.getThreadName(), "Main");
74  		location.setThreadName(null);
75  		assertEquals(location.getThreadName(), "");
76  	}
77  
78  	@Test
79  	public void testGetPackageName() {
80  		LogEventLocation location = new LogEventLocation(
81  				"net.sourceforge.acelogger.location.information.test", "LogCallLocationTest",
82  				"testGetPackageName");
83  		assertEquals(location.getPackageName(),
84  				"net.sourceforge.acelogger.location.information.test");
85  		location.setPackageName(null);
86  		assertEquals(location.getPackageName(), "");
87  	}
88  
89  	@Test
90  	public void testGetClassName() {
91  		LogEventLocation location = new LogEventLocation(
92  				"net.sourceforge.acelogger.location.information.test", "LogCallLocationTest",
93  				"testGetClassName");
94  		assertEquals(location.getClassName(), "LogCallLocationTest");
95  		location.setClassName(null);
96  		assertEquals(location.getClassName(), "");
97  	}
98  
99  	@Test
100 	public void testGetMethodName() {
101 		LogEventLocation location = new LogEventLocation(
102 				"net.sourceforge.acelogger.location.information.test", "LogCallLocationTest",
103 				"testGetMethodName");
104 		assertEquals(location.getMethodName(), "testGetMethodName");
105 		location.setMethodName(null);
106 		assertEquals(location.getMethodName(), "");
107 	}
108 
109 	@Test
110 	public void testGetFileName() {
111 		LogEventLocation location = new LogEventLocation(
112 				"net.sourceforge.acelogger.location.information.test", "LogCallLocationTest",
113 				"testGetMethodName");
114 		location.setFileName("LogCallLocationTest.java");
115 		assertEquals(location.getFileName(), "LogCallLocationTest.java");
116 		location.setFileName(null);
117 		assertEquals(location.getFileName(), "");
118 	}
119 
120 }