example.scannable.NamedStubDao Java Examples
The following examples show how to use
example.scannable.NamedStubDao.
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: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("myNamedDao", new RootBeanDefinition(NamedStubDao.class)); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #3
Source File: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class); bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("myNamedDao", bd); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #4
Source File: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); try { scanner.scan("org.springframework.context.annotation2"); scanner.scan(BASE_PACKAGE); fail("Must have thrown IllegalStateException"); } catch (IllegalStateException expected) { assertTrue(expected.getMessage().contains("myNamedDao")); assertTrue(expected.getMessage().contains(NamedStubDao.class.getName())); assertTrue(expected.getMessage().contains(NamedStubDao2.class.getName())); } }
Example #5
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("myNamedDao", new RootBeanDefinition(NamedStubDao.class)); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #6
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class); bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("myNamedDao", bd); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #7
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); try { scanner.scan("org.springframework.context.annotation2"); scanner.scan(BASE_PACKAGE); fail("Must have thrown IllegalStateException"); } catch (IllegalStateException expected) { assertTrue(expected.getMessage().contains("myNamedDao")); assertTrue(expected.getMessage().contains(NamedStubDao.class.getName())); assertTrue(expected.getMessage().contains(NamedStubDao2.class.getName())); } }
Example #8
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 #9
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("myNamedDao", new RootBeanDefinition(NamedStubDao.class)); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(5, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #10
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class); bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); context.registerBeanDefinition("myNamedDao", bd); int initialBeanCount = context.getBeanDefinitionCount(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); int scannedBeanCount = scanner.scan(BASE_PACKAGE); assertEquals(5, scannedBeanCount); assertEquals(initialBeanCount + scannedBeanCount, context.getBeanDefinitionCount()); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); }
Example #11
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); try { scanner.scan("org.springframework.context.annotation2"); scanner.scan(BASE_PACKAGE); fail("Must have thrown IllegalStateException"); } catch (IllegalStateException expected) { assertTrue(expected.getMessage().contains("myNamedDao")); assertTrue(expected.getMessage().contains(NamedStubDao.class.getName())); assertTrue(expected.getMessage().contains(NamedStubDao2.class.getName())); } }
Example #12
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 #13
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 #14
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 #15
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)); }