Ejemplo n.º 1
0
 /**
  * Tests if the logger actually calls the writer. With the log level at default, it should be
  * called twice, both for the warning and the info.
  */
 @Test
 public void testWriteInfoLevelDefault() {
   Logger.setLogLevel(2);
   Logger.logInfo("WriteInfoLevel2");
   Logger.logWarning("WriteInfoLevel2");
   verify(print, times(2)).println(anyString());
 }
Ejemplo n.º 2
0
 /**
  * Tests if the logger actually calls the writer. With the log level at 1, it should only be
  * called once, when logging the warning.
  */
 @Test
 public void testWriteInfoLevel1() {
   Logger.setLogLevel(1);
   Logger.logInfo("WriteInfoLevel1");
   Logger.logWarning("WriteInfoLevel1");
   verify(print, times(1)).println("[WARNING]" + anyString());
 }
Ejemplo n.º 3
0
 /**
  * Tests if the logger actually calls the writer. It should not be called when the log level is 0.
  */
 @Test
 public void testWriteInfoLevel0() {
   Logger.setLogLevel(0);
   Logger.logInfo("WriteInfoLevel0");
   Logger.logWarning("WriteInfoLevel0");
   verify(print, never()).println();
 }
Ejemplo n.º 4
0
 /** Tests if all possible log settings are correctly passed on. Tests the default log level */
 @Test
 public void testSetLogLevelDefault() {
   Logger.setLogLevel(2);
   assertTrue(Logger.getLogInfo());
   assertTrue(Logger.getLogWarning());
 }
Ejemplo n.º 5
0
 /** Tests if all possible log settings are correctly passed on. Tests log level 1. */
 @Test
 public void testSetLogLevel1() {
   Logger.setLogLevel(1);
   assertFalse(Logger.getLogInfo());
   assertTrue(Logger.getLogWarning());
 }
Ejemplo n.º 6
0
 /**
  * Sets up the Logger with a mocked PrintWriter, to improve observability and to make sure it does
  * not actually write to the log.
  */
 @Before
 public void setUp() {
   Logger.setWriter(print);
 }