example.scannable.NamedComponent Java Examples
The following examples show how to use
example.scannable.NamedComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 7 votes |
@Test public void testWithComponentAnnotationOnly() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Service.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(3, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); assertFalse(containsBeanClass(candidates, StubFooDao.class)); assertFalse(containsBeanClass(candidates, NamedStubDao.class)); }
Example #2
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testWithComponentAnnotationOnly() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Service.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(3, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); assertFalse(containsBeanClass(candidates, StubFooDao.class)); assertFalse(containsBeanClass(candidates, NamedStubDao.class)); }
Example #3
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
private void testDefault(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, DefaultNamedComponent.class)); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, StubFooDao.class)); assertTrue(containsBeanClass(candidates, NamedStubDao.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(7, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #4
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
private void testCustomSupportedIncludeAndExcludeFilter(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Service.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(3, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #5
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testWithMultipleMatchingFilters() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(7, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); }
Example #6
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testExcludeTakesPrecedence() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); provider.addExcludeFilter(new AssignableTypeFilter(FooService.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(6, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); }
Example #7
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
private void testDefault(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, DefaultNamedComponent.class)); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, StubFooDao.class)); assertTrue(containsBeanClass(candidates, NamedStubDao.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(7, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #8
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
private void testCustomSupportedIncludeAndExcludeFilter(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Service.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(3, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #9
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testWithMultipleMatchingFilters() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(7, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); }
Example #10
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testExcludeTakesPrecedence() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); provider.addExcludeFilter(new AssignableTypeFilter(FooService.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(6, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); }
Example #11
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testWithDefaults() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(6, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, StubFooDao.class)); assertTrue(containsBeanClass(candidates, NamedStubDao.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); }
Example #12
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testWithComponentAnnotationOnly() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Service.class)); provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(2, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); assertFalse(containsBeanClass(candidates, StubFooDao.class)); assertFalse(containsBeanClass(candidates, NamedStubDao.class)); }
Example #13
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testWithMultipleMatchingFilters() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(6, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); }
Example #14
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testExcludeTakesPrecedence() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Component.class)); provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class)); provider.addExcludeFilter(new AssignableTypeFilter(FooService.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(5, candidates.size()); assertTrue(containsBeanClass(candidates, NamedComponent.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertFalse(containsBeanClass(candidates, FooServiceImpl.class)); }