diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-10-04 12:52:32 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-10-04 12:52:32 -0400 |
commit | 3fd5777a58f59218e3229c9ea11d816ecc6ae367 (patch) | |
tree | 53f937505806e010d2bc3134fa5507d0ff78d32c /sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java | |
parent | b0bb30831a334ff30e3e6a13790bbc324db89de5 (diff) | |
parent | 8e24a47b69f940c31ac95451b4584b95de7c8670 (diff) | |
download | sangria-3fd5777a58f59218e3229c9ea11d816ecc6ae367.tar.xz |
Merge branch 'test'
Diffstat (limited to 'sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java')
-rw-r--r-- | sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java b/sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java index 69fabce..2895c7d 100644 --- a/sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java +++ b/sangria-lazy/src/test/java/com/tavianator/sangria/lazy/LazySingletonTest.java @@ -20,12 +20,14 @@ package com.tavianator.sangria.lazy; import javax.inject.Inject; import javax.inject.Provider; +import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.Stage; import org.junit.Test; +import static com.tavianator.sangria.test.SangriaMatchers.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -62,11 +64,6 @@ public class LazySingletonTest { test(Stage.PRODUCTION, new SangriaLazyModule()); } - @Test - public void testDuplicateModule() { - test(Stage.PRODUCTION, new SangriaLazyModule(), new SangriaLazyModule()); - } - private void test(Stage stage, Module... modules) { int before = Scoped.INSTANCES.get(); @@ -80,4 +77,18 @@ public class LazySingletonTest { assertThat(provider.get(), sameInstance(instance)); assertThat(Scoped.INSTANCES.get(), equalTo(before + 1)); } + + @Test + public void testBestPractices() { + Module module = new AbstractModule() { + @Override + protected void configure() { + install(new SangriaLazyModule()); + bind(Scoped.class); + } + }; + + assertThat(module, is(atomic())); + assertThat(module, followsBestPractices()); + } } |