Search in sources :

Example 1 with ConsoleLogger

use of fr.xephi.authme.ConsoleLogger in project AuthMeReloaded by AuthMe.

the class ConsoleLoggerFactoryTest method shouldReturnSameInstanceForName.

@Test
public void shouldReturnSameInstanceForName() {
    // given / when
    ConsoleLogger logger1 = ConsoleLoggerFactory.get(String.class);
    ConsoleLogger logger2 = ConsoleLoggerFactory.get(Number.class);
    ConsoleLogger logger3 = ConsoleLoggerFactory.get(String.class);
    // then
    assertThat(ConsoleLoggerFactory.getTotalLoggers(), equalTo(2));
    assertThat(logger3, sameInstance(logger1));
    assertThat(logger2, not(sameInstance(logger1)));
}
Also used : ConsoleLogger(fr.xephi.authme.ConsoleLogger) Test(org.junit.Test)

Example 2 with ConsoleLogger

use of fr.xephi.authme.ConsoleLogger in project AuthMeReloaded by AuthMe.

the class ConsoleLoggerFactoryTest method shouldInitializeAccordingToSettings.

@Test
public void shouldInitializeAccordingToSettings() {
    // given
    Settings settings = mock(Settings.class);
    given(settings.getProperty(PluginSettings.LOG_LEVEL)).willReturn(LogLevel.FINE);
    given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(false);
    ConsoleLogger existingLogger = ConsoleLoggerFactory.get(String.class);
    // when
    ConsoleLoggerFactory.reloadSettings(settings);
    ConsoleLogger newLogger = ConsoleLoggerFactory.get(AuthMe.class);
    // then
    assertThat(existingLogger.getLogLevel(), equalTo(LogLevel.FINE));
    assertThat(newLogger.getLogLevel(), equalTo(LogLevel.FINE));
}
Also used : ConsoleLogger(fr.xephi.authme.ConsoleLogger) SecuritySettings(fr.xephi.authme.settings.properties.SecuritySettings) Settings(fr.xephi.authme.settings.Settings) PluginSettings(fr.xephi.authme.settings.properties.PluginSettings) Test(org.junit.Test)

Example 3 with ConsoleLogger

use of fr.xephi.authme.ConsoleLogger in project AuthMeReloaded by AuthMe.

the class ConsoleLoggerFactoryTest method shouldCreateLoggerWithProperNameAndDefaultLogLevel.

@Test
public void shouldCreateLoggerWithProperNameAndDefaultLogLevel() {
    // given / when
    ConsoleLogger logger = ConsoleLoggerFactory.get(AuthMe.class);
    // then
    assertThat(logger.getName(), equalTo("fr.xephi.authme.AuthMe"));
    assertThat(logger.getLogLevel(), equalTo(LogLevel.INFO));
    assertThat(getConsoleLoggerMap().keySet(), contains("fr.xephi.authme.AuthMe"));
}
Also used : ConsoleLogger(fr.xephi.authme.ConsoleLogger) Test(org.junit.Test)

Aggregations

ConsoleLogger (fr.xephi.authme.ConsoleLogger)3 Test (org.junit.Test)3 Settings (fr.xephi.authme.settings.Settings)1 PluginSettings (fr.xephi.authme.settings.properties.PluginSettings)1 SecuritySettings (fr.xephi.authme.settings.properties.SecuritySettings)1