32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
package io.gitlab.jfronny.commons.logging.test;
|
|
|
|
import io.gitlab.jfronny.commons.logging.HotSwappingDelegateLogger;
|
|
import io.gitlab.jfronny.commons.logging.Logger;
|
|
import io.gitlab.jfronny.commons.logging.NopLogger;
|
|
import io.gitlab.jfronny.commons.logging.StdoutLogger;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
|
|
|
public class LoggerTest {
|
|
@BeforeEach
|
|
void prepare() {
|
|
Logger.resetFactory();
|
|
}
|
|
|
|
@Test
|
|
void testFactory() {
|
|
assertEquals(StdoutLogger.class, assertInstanceOf(HotSwappingDelegateLogger.class, Logger.forName("Joe")).getDelegate().getClass());
|
|
}
|
|
|
|
@Test
|
|
void testRegisterFactory() {
|
|
HotSwappingDelegateLogger logger = assertInstanceOf(HotSwappingDelegateLogger.class, Logger.forName("Joe"));
|
|
assertEquals(StdoutLogger.class, logger.getDelegate().getClass());
|
|
Logger.registerFactory(s -> new NopLogger());
|
|
assertEquals(NopLogger.class, logger.getDelegate().getClass());
|
|
}
|
|
}
|