22
33import ch .qos .logback .classic .Level ;
44import ch .qos .logback .classic .Logger ;
5+
56import java .util .Properties ;
7+
68import static org .assertj .core .api .Assertions .assertThat ;
79import static org .assertj .core .api .Assertions .assertThatNoException ;
10+
811import org .slf4j .LoggerFactory ;
912import org .testng .annotations .BeforeClass ;
1013import org .testng .annotations .Test ;
1114
1215/**
1316 * Test class for {@link GlobalSettings}
17+ *
1418 * @author Edoardo Patti
1519 */
1620public class GlobalSettingsTest {
1721
18- private static final Object OBJECT = new Object ();
19-
20- @ BeforeClass
21- public void setUp () {
22- ((Logger ) LoggerFactory .getLogger (GlobalSettings .class )).setLevel (Level .DEBUG );
23- Properties props = new Properties (2 );
24- props .put ("test1" , OBJECT );
25- props .put (OBJECT , "test2" );
26- System .getProperties ().putAll (props );
27- }
28-
29- @ Test
30- public void testNonStringSystemProperties () {
31- assertThat (GlobalSettings .getProperty (OBJECT .toString ())).isNotNull ();
32- assertThat (GlobalSettings .getProperty ("test1" )).isNotNull ();
33- assertThatNoException ().isThrownBy (GlobalSettings ::log );
34- }
22+ @ BeforeClass
23+ public void setUp () {
24+ ((Logger ) LoggerFactory .getLogger (GlobalSettings .class )).setLevel (Level .DEBUG );
25+ Properties props = new Properties (2 );
26+ props .put ("test1" , 789 );
27+ props .put (345 , "test2" );
28+ System .getProperties ().putAll (props );
29+ }
30+
31+ @ Test
32+ public void testNonStringSystemProperties () {
33+ assertThat (GlobalSettings .getProperty ("345" )).isEqualTo ("test2" );
34+ assertThat (GlobalSettings .getProperty ("test1" )).isEqualTo ("789" );
35+ assertThatNoException ().isThrownBy (GlobalSettings ::log );
36+ }
3537
3638}
0 commit comments