diff options
3 files changed, 15 insertions, 2 deletions
diff --git a/sangria-slf4j/pom.xml b/sangria-slf4j/pom.xml index c274a47..53cbfb7 100644 --- a/sangria-slf4j/pom.xml +++ b/sangria-slf4j/pom.xml @@ -39,6 +39,12 @@ </dependency> <dependency> + <groupId>com.tavianator.sangria</groupId> + <artifactId>sangria-test</artifactId> + <scope>test</scope> + </dependency> + + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/sangria-slf4j/src/main/java/com/tavianator/sangria/slf4j/Slf4jLoggerProvider.java b/sangria-slf4j/src/main/java/com/tavianator/sangria/slf4j/Slf4jLoggerProvider.java index 916f2b9..bcb7e8b 100644 --- a/sangria-slf4j/src/main/java/com/tavianator/sangria/slf4j/Slf4jLoggerProvider.java +++ b/sangria-slf4j/src/main/java/com/tavianator/sangria/slf4j/Slf4jLoggerProvider.java @@ -19,6 +19,7 @@ package com.tavianator.sangria.slf4j; import javax.inject.Singleton; +import com.google.inject.Inject; import com.google.inject.spi.InjectionPoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,10 @@ import com.tavianator.sangria.contextual.ContextSensitiveProvider; */ @Singleton class Slf4jLoggerProvider implements ContextSensitiveProvider<Logger> { + @Inject + Slf4jLoggerProvider() { + } + @Override public Logger getInContext(InjectionPoint injectionPoint) { return LoggerFactory.getLogger(injectionPoint.getDeclaringType().getRawType()); diff --git a/sangria-slf4j/src/test/java/com/tavianator/sangria/slf4j/SangriaSlf4jModuleTest.java b/sangria-slf4j/src/test/java/com/tavianator/sangria/slf4j/SangriaSlf4jModuleTest.java index d142bde..aaf72b2 100644 --- a/sangria-slf4j/src/test/java/com/tavianator/sangria/slf4j/SangriaSlf4jModuleTest.java +++ b/sangria-slf4j/src/test/java/com/tavianator/sangria/slf4j/SangriaSlf4jModuleTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; +import static com.tavianator.sangria.test.SangriaMatchers.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -75,7 +76,8 @@ public class SangriaSlf4jModuleTest { } @Test - public void testDeDuplication() { - Guice.createInjector(new SangriaSlf4jModule(), new SangriaSlf4jModule()); + public void testBestPractices() { + assertThat(new SangriaSlf4jModule(), is(atomic())); + assertThat(new SangriaSlf4jModule(), followsBestPractices()); } } |