package io.dropwizard.request.logging.old;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import io.dropwizard.configuration.YamlConfigurationFactory;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.logging.BootstrapLogging;
import io.dropwizard.logging.ConsoleAppenderFactory;
import io.dropwizard.logging.FileAppenderFactory;
import io.dropwizard.logging.SyslogAppenderFactory;
import io.dropwizard.validation.BaseValidator;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.util.TimeZone;

import static org.assertj.core.api.Assertions.assertThat;

public class LogbackClassicRequestLogFactoryTest {

    static {
        BootstrapLogging.bootstrap();
    }

    private LogbackClassicRequestLogFactory requestLog;

    @Before
    public void setUp() throws Exception {
        final ObjectMapper objectMapper = Jackson.newObjectMapper();
        objectMapper.getSubtypeResolver().registerSubtypes(ConsoleAppenderFactory.class, FileAppenderFactory.class,
            SyslogAppenderFactory.class);
        this.requestLog = new YamlConfigurationFactory<>(LogbackClassicRequestLogFactory.class,
            BaseValidator.newValidator(), objectMapper, "dw")
            .build(new File(Resources.getResource("yaml/logbackClassicRequestLog.yml").toURI()));
    }

    @Test
    public void testDeserialized() {
        assertThat(requestLog.getTimeZone()).isEqualTo(TimeZone.getTimeZone("Europe/Amsterdam"));
        assertThat(requestLog.getAppenders()).hasSize(3).extractingResultOf("getClass").contains(
            ConsoleAppenderFactory.class, FileAppenderFactory.class, SyslogAppenderFactory.class
        );
    }
}

@@ -181,32 +181,90 @@
 urationFactory;%0A
+import io.dropwizard.jackson.DiscoverableSubtypeResolver;%0A
 import io.dropwi
@@ -479,32 +479,88 @@
 ppenderFactory;%0A
+import io.dropwizard.request.logging.RequestLogFactory;%0A
 import io.dropwi
@@ -869,30 +869,16 @@
 private 
-LogbackClassic
 RequestL
@@ -1239,30 +1239,16 @@
 ctory%3C%3E(
-LogbackClassic
 RequestL
@@ -1478,16 +1478,129 @@
 zed() %7B%0A
+        LogbackClassicRequestLogFactory classicRequestLogFactory = (LogbackClassicRequestLogFactory) requestLog;%0A
         
@@ -1602,33 +1602,40 @@
      assertThat(
-r
+classicR
 equestLog.getTim
@@ -1623,24 +1623,31 @@
 icRequestLog
+Factory
 .getTimeZone
@@ -1722,17 +1722,24 @@
 ertThat(
-r
+classicR
 equestLo
@@ -1739,16 +1739,23 @@
 questLog
+Factory
 .getAppe
@@ -1928,11 +1928,220 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void isDiscoverable() throws Exception %7B%0A        assertThat(new DiscoverableSubtypeResolver().getDiscoveredSubtypes())%0A            .contains(LogbackClassicRequestLogFactory.class);%0A    %7D
 %0A%7D%0A

Fix the META-INF/services structure in `dropwizard-request-logging`