Add bean name filters to GuiceModule
This commit is contained in:
@@ -45,6 +45,18 @@ public class GuiceModuleAnnotationTests {
|
||||
assertNotNull(injector.getBinding(Service.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includesNames() throws Exception {
|
||||
Injector injector = createInjector(TestConfig.class, MetadataIncludeNamesConfig.class);
|
||||
assertNotNull(injector.getBinding(Service.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includesPatterns() throws Exception {
|
||||
Injector injector = createInjector(TestConfig.class, MetadataIncludePatternsConfig.class);
|
||||
assertNotNull(injector.getBinding(Service.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludes() throws Exception {
|
||||
Injector injector = createInjector(TestConfig.class, MetadataExcludesConfig.class);
|
||||
@@ -85,11 +97,26 @@ public class GuiceModuleAnnotationTests {
|
||||
protected static class MetadataExcludesConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@GuiceModule(excludePatterns=".*")
|
||||
protected static class MetadataExcludesNameConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@GuiceModule(includeFilters=@Filter(type=FilterType.ASSIGNABLE_TYPE, value=Service.class))
|
||||
protected static class MetadataIncludesConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@GuiceModule(includeNames="*service") // Bean name filter
|
||||
protected static class MetadataIncludeNamesConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@GuiceModule(includePatterns=".*service") // Bean name filter
|
||||
protected static class MetadataIncludePatternsConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@GuiceModule(includeFilters=@Filter(type=FilterType.ASSIGNABLE_TYPE, value=Foo.class))
|
||||
protected static class MetadataMoreIncludesConfig {
|
||||
|
||||
Reference in New Issue
Block a user