example.scannable.ServiceInvocationCounter Java Examples
The following examples show how to use
example.scannable.ServiceInvocationCounter.
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: SimpleConfigTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = ctx.getBean("fooServiceImpl", FooService.class); ServiceInvocationCounter serviceInvocationCounter = ctx.getBean("serviceInvocationCounter", ServiceInvocationCounter.class); String value = fooService.foo(1); assertEquals("bar", value); Future<?> future = fooService.asyncFoo(1); assertTrue(future instanceof FutureTask); assertEquals("bar", future.get()); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #3
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 #4
Source File: SimpleScanTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = (FooService) ctx.getBean("fooServiceImpl"); ServiceInvocationCounter serviceInvocationCounter = (ServiceInvocationCounter) ctx.getBean("serviceInvocationCounter"); assertEquals(0, serviceInvocationCounter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, serviceInvocationCounter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #5
Source File: SimpleConfigTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = ctx.getBean("fooServiceImpl", FooService.class); ServiceInvocationCounter serviceInvocationCounter = ctx.getBean("serviceInvocationCounter", ServiceInvocationCounter.class); String value = fooService.foo(1); assertEquals("bar", value); Future<?> future = fooService.asyncFoo(1); assertTrue(future instanceof FutureTask); assertEquals("bar", future.get()); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #6
Source File: EnableAspectJAutoProxyTests.java From java-technology-stack with MIT License | 6 votes |
private void aspectIsApplied(ApplicationContext ctx) { FooService fooService = ctx.getBean(FooService.class); ServiceInvocationCounter counter = ctx.getBean(ServiceInvocationCounter.class); assertEquals(0, counter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, counter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, counter.getCount()); fooService.foo(1); assertEquals(3, counter.getCount()); }
Example #7
Source File: SimpleConfigTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = ctx.getBean("fooServiceImpl", FooService.class); ServiceInvocationCounter serviceInvocationCounter = ctx.getBean("serviceInvocationCounter", ServiceInvocationCounter.class); String value = fooService.foo(1); assertEquals("bar", value); Future<?> future = fooService.asyncFoo(1); assertTrue(future instanceof FutureTask); assertEquals("bar", future.get()); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #8
Source File: SimpleScanTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = (FooService) ctx.getBean("fooServiceImpl"); ServiceInvocationCounter serviceInvocationCounter = (ServiceInvocationCounter) ctx.getBean("serviceInvocationCounter"); assertEquals(0, serviceInvocationCounter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, serviceInvocationCounter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #9
Source File: EnableAspectJAutoProxyTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void aspectIsApplied(ApplicationContext ctx) { FooService fooService = ctx.getBean(FooService.class); ServiceInvocationCounter counter = ctx.getBean(ServiceInvocationCounter.class); assertEquals(0, counter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, counter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, counter.getCount()); fooService.foo(1); assertEquals(3, counter.getCount()); }
Example #10
Source File: SimpleScanTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = (FooService) ctx.getBean("fooServiceImpl"); ServiceInvocationCounter serviceInvocationCounter = (ServiceInvocationCounter) ctx.getBean("serviceInvocationCounter"); assertEquals(0, serviceInvocationCounter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, serviceInvocationCounter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, serviceInvocationCounter.getCount()); fooService.foo(1); assertEquals(3, serviceInvocationCounter.getCount()); }
Example #11
Source File: EnableAspectJAutoProxyTests.java From spring-analysis-note with MIT License | 6 votes |
private void aspectIsApplied(ApplicationContext ctx) { FooService fooService = ctx.getBean(FooService.class); ServiceInvocationCounter counter = ctx.getBean(ServiceInvocationCounter.class); assertEquals(0, counter.getCount()); assertTrue(fooService.isInitCalled()); assertEquals(1, counter.getCount()); String value = fooService.foo(1); assertEquals("bar", value); assertEquals(2, counter.getCount()); fooService.foo(1); assertEquals(3, counter.getCount()); }
Example #12
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 #13
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 #14
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testWithAspectAnnotationOnly() throws Exception { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Aspect.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(1, candidates.size()); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); }
Example #15
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 #16
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 #17
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)); }
Example #18
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 #19
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testWithAspectAnnotationOnly() throws Exception { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Aspect.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(1, candidates.size()); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); }
Example #20
Source File: ClassPathScanningCandidateComponentProviderTests.java From java-technology-stack with MIT License | 5 votes |
private void testExclude(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, StubFooDao.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(4, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #21
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 #22
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 #23
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 #24
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 #25
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testWithAspectAnnotationOnly() throws Exception { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); provider.addIncludeFilter(new AnnotationTypeFilter(Aspect.class)); Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertEquals(1, candidates.size()); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); }
Example #26
Source File: ClassPathScanningCandidateComponentProviderTests.java From spring-analysis-note with MIT License | 5 votes |
private void testExclude(ClassPathScanningCandidateComponentProvider provider, Class<? extends BeanDefinition> expectedBeanDefinitionType) { Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); assertTrue(containsBeanClass(candidates, FooServiceImpl.class)); assertTrue(containsBeanClass(candidates, StubFooDao.class)); assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class)); assertTrue(containsBeanClass(candidates, BarComponent.class)); assertEquals(4, candidates.size()); assertBeanDefinitionType(candidates, expectedBeanDefinitionType); }
Example #27
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 #28
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); }