diff --git a/src/test/java/org/springframework/guice/JustInTimeBindingTests.java b/src/test/java/org/springframework/guice/JustInTimeBindingTests.java index 8d4b3fa..cb81347 100644 --- a/src/test/java/org/springframework/guice/JustInTimeBindingTests.java +++ b/src/test/java/org/springframework/guice/JustInTimeBindingTests.java @@ -1,61 +1,64 @@ package org.springframework.guice; +import javax.inject.Inject; + import org.junit.After; import org.junit.Test; + import org.springframework.beans.factory.UnsatisfiedDependencyException; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.guice.annotation.EnableGuiceModules; -import javax.inject.Inject; - import static org.junit.Assert.assertNotNull; public class JustInTimeBindingTests { - @After - public void tearDown() { - System.clearProperty("spring.guice.autowireJIT"); - } + @After + public void tearDown() { + System.clearProperty("spring.guice.autowireJIT"); + } - @Test - public void springWithJustInTimeBinding() { - System.setProperty("spring.guice.autowireJIT", "true"); - assertNotNull(springGetFoo()); - } + @Test + public void springWithJustInTimeBinding() { + System.setProperty("spring.guice.autowireJIT", "true"); + assertNotNull(springGetFoo()); + } - @Test(expected = UnsatisfiedDependencyException.class) - public void springWithoutJustInTimeBinding() { - System.setProperty("spring.guice.autowireJIT", "false"); - springGetFoo(); - } + @Test(expected = UnsatisfiedDependencyException.class) + public void springWithoutJustInTimeBinding() { + System.setProperty("spring.guice.autowireJIT", "false"); + springGetFoo(); + } - private Foo springGetFoo() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ModulesConfig.class); - context.getDefaultListableBeanFactory().registerBeanDefinition(Foo.class.getSimpleName(), new RootBeanDefinition(Foo.class)); - return context.getBean(Foo.class); - } + @SuppressWarnings("resource") + private Foo springGetFoo() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + ModulesConfig.class); + context.getDefaultListableBeanFactory().registerBeanDefinition( + Foo.class.getSimpleName(), new RootBeanDefinition(Foo.class)); + return context.getBean(Foo.class); + } - @Configuration - @EnableGuiceModules - static class ModulesConfig { + @Configuration + @EnableGuiceModules + static class ModulesConfig { - } + } + public static class Service { + } - public static class Service { - } + public static class Foo { - public static class Foo { + Service service; - Service service; + @Inject + public Foo(Service service) { + this.service = service; + } - @Inject - public Foo(Service service) { - this.service = service; - } - - } + } } diff --git a/src/test/java/org/springframework/guice/SuperClassTests.java b/src/test/java/org/springframework/guice/SuperClassTests.java index fdfa2c4..762431c 100644 --- a/src/test/java/org/springframework/guice/SuperClassTests.java +++ b/src/test/java/org/springframework/guice/SuperClassTests.java @@ -5,6 +5,7 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.TypeLiteral; import org.junit.Test; + import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -19,382 +20,427 @@ import static org.junit.Assert.assertTrue; public class SuperClassTests { + @Test + public void testSpringInterface() { + baseTestSpringInterface(ModulesConfig.class); + } + + @Test + public void testImportSpringInterface() { + baseTestSpringInterface(ImportConfig.class); + } + + @Test + public void testComponentScanSpringInterface() { + baseTestSpringInterface(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestSpringInterface(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + assertTrue(context.getBean(IParent.class) instanceof IGrandChildImpl); + assertTrue(context.getBean(IChild.class) instanceof IGrandChildImpl); + assertTrue(context.getBean(IGrandChild.class) instanceof IGrandChildImpl); + } + + @Test + public void testGuiceInterface() { + baseTestGuiceInterface(ModulesConfig.class); + } + + @Test + public void testImportGuiceInterface() { + baseTestGuiceInterface(ImportConfig.class); + } + + @Test + public void testComponentScanGuiceInterface() { + baseTestGuiceInterface(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestGuiceInterface(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + Injector injector = context.getBean(Injector.class); + assertTrue(injector.getInstance(IParent.class) instanceof IGrandChildImpl); + assertTrue(injector.getInstance(IChild.class) instanceof IGrandChildImpl); + assertTrue(injector.getInstance(IGrandChild.class) instanceof IGrandChildImpl); + } + + @Test + public void testSpringInterfaceWithType() { + baseTestSpringInterfaceWithType(ModulesConfig.class); + } + + @Test + public void testImportSpringInterfaceWithType() { + baseTestSpringInterfaceWithType(ImportConfig.class); + } + + @Test + public void testComponentScanSpringInterfaceWithType() { + baseTestSpringInterfaceWithType(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestSpringInterfaceWithType(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + + String[] allParentBeanNames = context.getBeanNamesForType(IParentWithType.class); + assertEquals(2, allParentBeanNames.length); + + String[] stringParentBeanNames = context.getBeanNamesForType( + ResolvableType.forClassWithGenerics(IParentWithType.class, String.class)); + assertEquals(1, stringParentBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(stringParentBeanNames[0]))); + + String[] integerParentBeanNames = context.getBeanNamesForType(ResolvableType + .forClassWithGenerics(IParentWithType.class, Integer.class)); + assertEquals(1, integerParentBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(integerParentBeanNames[0]))); + + String[] allChildBeanNames = context.getBeanNamesForType(IChildWithType.class); + assertEquals(2, allChildBeanNames.length); + + String[] stringChildBeanNames = context.getBeanNamesForType( + ResolvableType.forClassWithGenerics(IChildWithType.class, String.class)); + assertEquals(1, stringChildBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(stringChildBeanNames[0]))); + + String[] integerChildBeanNames = context.getBeanNamesForType( + ResolvableType.forClassWithGenerics(IChildWithType.class, Integer.class)); + assertEquals(1, integerChildBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(integerChildBeanNames[0]))); + + String[] allGrandChildBeanNames = context + .getBeanNamesForType(IGrandChildWithType.class); + assertEquals(2, allGrandChildBeanNames.length); + + String[] stringGrandChildBeanNames = context.getBeanNamesForType(ResolvableType + .forClassWithGenerics(IGrandChildWithType.class, String.class)); + assertEquals(1, stringGrandChildBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(stringGrandChildBeanNames[0]))); + + String[] integerGrandChildBeanNames = context.getBeanNamesForType(ResolvableType + .forClassWithGenerics(IGrandChildWithType.class, Integer.class)); + assertEquals(1, integerGrandChildBeanNames.length); + assertTrue(new TypeLiteral>() { + }.getRawType().isInstance(context.getBean(integerGrandChildBeanNames[0]))); + + } + + @Test + public void testGuiceInterfaceWithType() { + baseTestGuiceInterfaceWithType(ModulesConfig.class); + } + + @Test + public void testImportGuiceInterfaceWithType() { + baseTestGuiceInterfaceWithType(ImportConfig.class); + } + + @Test + public void testComponentScanGuiceInterfaceWithType() { + baseTestGuiceInterfaceWithType(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestGuiceInterfaceWithType(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + Injector injector = context.getBean(Injector.class); + IParentWithType iParentString = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iParentString instanceof IGrandChildString); + IParentWithType iParentInteger = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iParentInteger instanceof IGrandChildInteger); + + IChildWithType iChildString = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iChildString instanceof IGrandChildString); + IChildWithType iChildInteger = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iChildInteger instanceof IGrandChildInteger); + + IGrandChildWithType iGrandChildString = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iGrandChildString instanceof IGrandChildString); + IGrandChildWithType iGrandChildInteger = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iGrandChildInteger instanceof IGrandChildInteger); + } + + @SuppressWarnings("resource") + @Test + public void testSpringClass() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + ModulesConfig.class); + IFoo iFoo = context.getBean(IFoo.class); + assertTrue(iFoo instanceof Foo); + assertTrue(iFoo instanceof SubFoo); + + Foo foo = context.getBean(Foo.class); + assertTrue(foo instanceof SubFoo); + } + + @Test + public void testGuiceClass() { + baseTestGuiceClass(ModulesConfig.class); + } + + @Test + public void testImportGuiceClass() { + baseTestGuiceClass(ImportConfig.class); + } + + @Test + public void testComponentScanGuiceClass() { + baseTestGuiceClass(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestGuiceClass(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + Injector injector = context.getBean(Injector.class); + IFoo iFoo = injector.getInstance(IFoo.class); + assertTrue(iFoo instanceof Foo); + assertTrue(iFoo instanceof SubFoo); + + Foo foo = injector.getInstance(Foo.class); + assertTrue(foo instanceof SubFoo); + } + + @Test + public void testSpringClassWithType() { + baseTestSpringClassWithType(ModulesConfig.class); + } + + @Test + public void testImportSpringClassWithType() { + baseTestSpringClassWithType(ImportConfig.class); + } + + @Test + public void testComponentScanSpringClassWithType() { + baseTestSpringClassWithType(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestSpringClassWithType(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + String[] stringBeanNames = context.getBeanNamesForType( + ResolvableType.forClassWithGenerics(IFooWithType.class, String.class)); + assertEquals(1, stringBeanNames.length); + assertTrue(context.getBean(stringBeanNames[0]) instanceof StringFoo); + assertTrue(context.getBean(stringBeanNames[0]) instanceof SubStringFoo); + + stringBeanNames = context.getBeanNamesForType(StringFoo.class); + assertEquals(1, stringBeanNames.length); + assertTrue(context.getBean(stringBeanNames[0]) instanceof StringFoo); + assertTrue(context.getBean(stringBeanNames[0]) instanceof SubStringFoo); + + String[] integerBeanNames = context.getBeanNamesForType( + ResolvableType.forClassWithGenerics(IFooWithType.class, Integer.class)); + assertEquals(1, integerBeanNames.length); + assertTrue(context.getBean(integerBeanNames[0]) instanceof IntegerFoo); + assertTrue(context.getBean(integerBeanNames[0]) instanceof SubIntegerFoo); + + integerBeanNames = context.getBeanNamesForType(IntegerFoo.class); + assertEquals(1, integerBeanNames.length); + assertTrue(context.getBean(integerBeanNames[0]) instanceof IntegerFoo); + assertTrue(context.getBean(integerBeanNames[0]) instanceof SubIntegerFoo); + } + + @Test + public void testGuiceClassWithType() { + baseTestGuiceClassWithType(ModulesConfig.class); + } + + @Test + public void testImportGuiceClassWithType() { + baseTestGuiceClassWithType(ImportConfig.class); + } + + @Test + public void testComponentScanGuiceClassWithType() { + baseTestGuiceClassWithType(ComponentScanConfig.class); + } + + @SuppressWarnings("resource") + private void baseTestGuiceClassWithType(Class configClass) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + configClass); + Injector injector = context.getBean(Injector.class); + + IFooWithType iFooWithTypeString = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iFooWithTypeString instanceof StringFoo); + assertTrue(iFooWithTypeString instanceof SubStringFoo); + + StringFoo stringFoo = injector.getInstance(StringFoo.class); + assertTrue(stringFoo instanceof SubStringFoo); + + IFooWithType iFooWithTypeInteger = injector + .getInstance(Key.get(new TypeLiteral>() { + })); + assertTrue(iFooWithTypeInteger instanceof IntegerFoo); + assertTrue(iFooWithTypeInteger instanceof SubIntegerFoo); + + IntegerFoo integerFoo = injector.getInstance(IntegerFoo.class); + assertTrue(integerFoo instanceof SubIntegerFoo); + } + + static class DisableJITConfig { + @Bean + public AbstractModule disableJITModule() { + return new AbstractModule() { + @Override + protected void configure() { + binder().requireExplicitBindings(); + } + }; + } + } - @Test - public void testSpringInterface() { - baseTestSpringInterface(ModulesConfig.class); - } - - @Test - public void testImportSpringInterface() { - baseTestSpringInterface(ImportConfig.class); - } - - @Test - public void testComponentScanSpringInterface() { - baseTestSpringInterface(ComponentScanConfig.class); - } - - private void baseTestSpringInterface(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - assertTrue(context.getBean(IParent.class) instanceof IGrandChildImpl); - assertTrue(context.getBean(IChild.class) instanceof IGrandChildImpl); - assertTrue(context.getBean(IGrandChild.class) instanceof IGrandChildImpl); - } - - @Test - public void testGuiceInterface() { - baseTestGuiceInterface(ModulesConfig.class); - } - - @Test - public void testImportGuiceInterface() { - baseTestGuiceInterface(ImportConfig.class); - } - - @Test - public void testComponentScanGuiceInterface() { - baseTestGuiceInterface(ComponentScanConfig.class); - } - - private void baseTestGuiceInterface(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - Injector injector = context.getBean(Injector.class); - assertTrue(injector.getInstance(IParent.class) instanceof IGrandChildImpl); - assertTrue(injector.getInstance(IChild.class) instanceof IGrandChildImpl); - assertTrue(injector.getInstance(IGrandChild.class) instanceof IGrandChildImpl); - } - - @Test - public void testSpringInterfaceWithType() { - baseTestSpringInterfaceWithType(ModulesConfig.class); - } - - @Test - public void testImportSpringInterfaceWithType() { - baseTestSpringInterfaceWithType(ImportConfig.class); - } - - @Test - public void testComponentScanSpringInterfaceWithType() { - baseTestSpringInterfaceWithType(ComponentScanConfig.class); - } - - private void baseTestSpringInterfaceWithType(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - - String[] allParentBeanNames = context.getBeanNamesForType(IParentWithType.class); - assertEquals(2, allParentBeanNames.length); - - String[] stringParentBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IParentWithType.class, String.class)); - assertEquals(1, stringParentBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(stringParentBeanNames[0]))); - - String[] integerParentBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IParentWithType.class, Integer.class)); - assertEquals(1, integerParentBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(integerParentBeanNames[0]))); - - String[] allChildBeanNames = context.getBeanNamesForType(IChildWithType.class); - assertEquals(2, allChildBeanNames.length); - - String[] stringChildBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IChildWithType.class, String.class)); - assertEquals(1, stringChildBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(stringChildBeanNames[0]))); - - String[] integerChildBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IChildWithType.class, Integer.class)); - assertEquals(1, integerChildBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(integerChildBeanNames[0]))); - - String[] allGrandChildBeanNames = context.getBeanNamesForType(IGrandChildWithType.class); - assertEquals(2, allGrandChildBeanNames.length); - - String[] stringGrandChildBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IGrandChildWithType.class, String.class)); - assertEquals(1, stringGrandChildBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(stringGrandChildBeanNames[0]))); - - String[] integerGrandChildBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IGrandChildWithType.class, Integer.class)); - assertEquals(1, integerGrandChildBeanNames.length); - assertTrue(new TypeLiteral>() {}.getRawType().isInstance(context.getBean(integerGrandChildBeanNames[0]))); - - } - - @Test - public void testGuiceInterfaceWithType() { - baseTestGuiceInterfaceWithType(ModulesConfig.class); - } - - @Test - public void testImportGuiceInterfaceWithType() { - baseTestGuiceInterfaceWithType(ImportConfig.class); - } - - @Test - public void testComponentScanGuiceInterfaceWithType() { - baseTestGuiceInterfaceWithType(ComponentScanConfig.class); - } - - private void baseTestGuiceInterfaceWithType(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - Injector injector = context.getBean(Injector.class); - IParentWithType iParentString = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iParentString instanceof IGrandChildString); - IParentWithType iParentInteger = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iParentInteger instanceof IGrandChildInteger); - - IChildWithType iChildString = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iChildString instanceof IGrandChildString); - IChildWithType iChildInteger = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iChildInteger instanceof IGrandChildInteger); - - IGrandChildWithType iGrandChildString = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iGrandChildString instanceof IGrandChildString); - IGrandChildWithType iGrandChildInteger = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iGrandChildInteger instanceof IGrandChildInteger); - } - - @Test - public void testSpringClass() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ModulesConfig.class); - IFoo iFoo = context.getBean(IFoo.class); - assertTrue(iFoo instanceof Foo); - assertTrue(iFoo instanceof SubFoo); - - Foo foo = context.getBean(Foo.class); - assertTrue(foo instanceof SubFoo); - } - - @Test - public void testGuiceClass() { - baseTestGuiceClass(ModulesConfig.class); - } - - @Test - public void testImportGuiceClass() { - baseTestGuiceClass(ImportConfig.class); - } - - @Test - public void testComponentScanGuiceClass() { - baseTestGuiceClass(ComponentScanConfig.class); - } - - private void baseTestGuiceClass(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - Injector injector = context.getBean(Injector.class); - IFoo iFoo = injector.getInstance(IFoo.class); - assertTrue(iFoo instanceof Foo); - assertTrue(iFoo instanceof SubFoo); - - Foo foo = injector.getInstance(Foo.class); - assertTrue(foo instanceof SubFoo); - } - - @Test - public void testSpringClassWithType() { - baseTestSpringClassWithType(ModulesConfig.class); - } - - @Test - public void testImportSpringClassWithType() { - baseTestSpringClassWithType(ImportConfig.class); - } - - @Test - public void testComponentScanSpringClassWithType() { - baseTestSpringClassWithType(ComponentScanConfig.class); - } - - private void baseTestSpringClassWithType(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - String[] stringBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IFooWithType.class, String.class)); - assertEquals(1, stringBeanNames.length); - assertTrue(context.getBean(stringBeanNames[0]) instanceof StringFoo); - assertTrue(context.getBean(stringBeanNames[0]) instanceof SubStringFoo); - - stringBeanNames = context.getBeanNamesForType(StringFoo.class); - assertEquals(1, stringBeanNames.length); - assertTrue(context.getBean(stringBeanNames[0]) instanceof StringFoo); - assertTrue(context.getBean(stringBeanNames[0]) instanceof SubStringFoo); - - String[] integerBeanNames = context.getBeanNamesForType(ResolvableType.forClassWithGenerics(IFooWithType.class, Integer.class)); - assertEquals(1, integerBeanNames.length); - assertTrue(context.getBean(integerBeanNames[0]) instanceof IntegerFoo); - assertTrue(context.getBean(integerBeanNames[0]) instanceof SubIntegerFoo); - - integerBeanNames = context.getBeanNamesForType(IntegerFoo.class); - assertEquals(1, integerBeanNames.length); - assertTrue(context.getBean(integerBeanNames[0]) instanceof IntegerFoo); - assertTrue(context.getBean(integerBeanNames[0]) instanceof SubIntegerFoo); - } - - @Test - public void testGuiceClassWithType() { - baseTestGuiceClassWithType(ModulesConfig.class); - } - - @Test - public void testImportGuiceClassWithType() { - baseTestGuiceClassWithType(ImportConfig.class); - } - - @Test - public void testComponentScanGuiceClassWithType() { - baseTestGuiceClassWithType(ComponentScanConfig.class); - } - - private void baseTestGuiceClassWithType(Class configClass) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configClass); - Injector injector = context.getBean(Injector.class); - - IFooWithType iFooWithTypeString = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iFooWithTypeString instanceof StringFoo); - assertTrue(iFooWithTypeString instanceof SubStringFoo); - - StringFoo stringFoo = injector.getInstance(StringFoo.class); - assertTrue(stringFoo instanceof SubStringFoo); - - IFooWithType iFooWithTypeInteger = injector.getInstance(Key.get(new TypeLiteral>(){})); - assertTrue(iFooWithTypeInteger instanceof IntegerFoo); - assertTrue(iFooWithTypeInteger instanceof SubIntegerFoo); - - IntegerFoo integerFoo = injector.getInstance(IntegerFoo.class); - assertTrue(integerFoo instanceof SubIntegerFoo); - } + @Configuration + @EnableGuiceModules + static class ModulesConfig extends DisableJITConfig { - static class DisableJITConfig { - @Bean - public AbstractModule disableJITModule() { - return new AbstractModule() { - @Override - protected void configure() { - binder().requireExplicitBindings(); - } - }; - } - } + @Bean + public IGrandChild iGrandChild() { + return new IGrandChildImpl(); + } - @Configuration - @EnableGuiceModules - static class ModulesConfig extends DisableJITConfig { + @Bean + public IGrandChildWithType iChildString() { + return new IGrandChildString(); + } - @Bean - public IGrandChild iGrandChild() { - return new IGrandChildImpl(); - } + @Bean + public IGrandChildWithType iChildInteger() { + return new IGrandChildInteger(); + } - @Bean - public IGrandChildWithType iChildString() { - return new IGrandChildString(); - } + @Bean + public SubFoo subFoo() { + return new SubFoo(); + } - @Bean - public IGrandChildWithType iChildInteger() { - return new IGrandChildInteger(); - } + @Bean + public SubStringFoo stringFoo() { + return new SubStringFoo(); + } - @Bean - public SubFoo subFoo() { - return new SubFoo(); - } + @Bean + SubIntegerFoo integerFoo() { + return new SubIntegerFoo(); + } - @Bean - public SubStringFoo stringFoo() { - return new SubStringFoo(); - } + } - @Bean SubIntegerFoo integerFoo() { - return new SubIntegerFoo(); - } + @Configuration + @EnableGuiceModules + @Import({ IGrandChildImpl.class, IGrandChildString.class, IGrandChildInteger.class, + SubFoo.class, SubStringFoo.class, SubIntegerFoo.class }) + static class ImportConfig extends DisableJITConfig { + } + @Configuration + @EnableGuiceModules + @ComponentScan(basePackageClasses = ComponentScanConfig.class, resourcePattern = "**/SuperClassTests**.class", excludeFilters = { + @ComponentScan.Filter(Configuration.class) }) + static class ComponentScanConfig extends DisableJITConfig { + } - } + public interface IParent { + } - @Configuration - @EnableGuiceModules - @Import({IGrandChildImpl.class, IGrandChildString.class, IGrandChildInteger.class, SubFoo.class, SubStringFoo.class, SubIntegerFoo.class}) - static class ImportConfig extends DisableJITConfig { - } + public interface IChild extends IParent { - @Configuration - @EnableGuiceModules - @ComponentScan(basePackageClasses = ComponentScanConfig.class, resourcePattern = "**/SuperClassTests**.class", - excludeFilters = {@ComponentScan.Filter(Configuration.class)}) - static class ComponentScanConfig extends DisableJITConfig { - } + } - public interface IParent { - } + public interface IGrandChild extends IChild { - public interface IChild extends IParent { + } - } + @Component + public static class IGrandChildImpl implements IGrandChild { - public interface IGrandChild extends IChild { + } - } + public interface IParentWithType { - @Component - public static class IGrandChildImpl implements IGrandChild { + } - } + public interface IChildWithType extends IParentWithType { - public interface IParentWithType { + } - } + public interface IGrandChildWithType extends IChildWithType { - public interface IChildWithType extends IParentWithType { + } - } + @Component + public static class IGrandChildString implements IGrandChildWithType { - public interface IGrandChildWithType extends IChildWithType { + } - } + @Component + public static class IGrandChildInteger implements IGrandChildWithType { - @Component - public static class IGrandChildString implements IGrandChildWithType { + } - } + public interface IFoo { - @Component - public static class IGrandChildInteger implements IGrandChildWithType { + } - } + public static class Foo implements IFoo { + } + @Component + public static class SubFoo extends Foo { - public interface IFoo { + } - } + public interface IFooWithType { - public static class Foo implements IFoo { + } - } + public static class StringFoo implements IFooWithType { - @Component - public static class SubFoo extends Foo { + } - } + @Component + public static class SubStringFoo extends StringFoo { - public interface IFooWithType { + } - } + public static class IntegerFoo implements IFooWithType { - public static class StringFoo implements IFooWithType { + } - } + @Component + public static class SubIntegerFoo extends IntegerFoo { - @Component - public static class SubStringFoo extends StringFoo { - - } - - public static class IntegerFoo implements IFooWithType { - - } - - @Component - public static class SubIntegerFoo extends IntegerFoo { - - } + } }