example.scannable.FooService Java Examples
The following examples show how to use
example.scannable.FooService.
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: ComponentScanAnnotationIntegrationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void withScopedProxy() throws IOException, ClassNotFoundException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ComponentScanWithScopedProxy.class); ctx.getBeanFactory().registerScope("myScope", new SimpleMapScope()); ctx.refresh(); // should cast to the interface FooService bean = (FooService) ctx.getBean("scopedProxyTestBean"); // should be dynamic proxy assertThat(AopUtils.isJdkDynamicProxy(bean), is(true)); // test serializability assertThat(bean.foo(1), equalTo("bar")); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertThat(deserialized, notNullValue()); assertThat(deserialized.foo(1), equalTo("bar")); }
Example #2
Source File: ComponentScanAnnotationIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void withScopedProxy() throws IOException, ClassNotFoundException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ComponentScanWithScopedProxy.class); ctx.getBeanFactory().registerScope("myScope", new SimpleMapScope()); ctx.refresh(); // should cast to the interface FooService bean = (FooService) ctx.getBean("scopedProxyTestBean"); // should be dynamic proxy assertThat(AopUtils.isJdkDynamicProxy(bean), is(true)); // test serializability assertThat(bean.foo(1), equalTo("bar")); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertThat(deserialized, notNullValue()); assertThat(deserialized.foo(1), equalTo("bar")); }
Example #3
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 #4
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 #5
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(11, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #6
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.setIncludeAnnotationConfig(false); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertFalse(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertFalse(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); }
Example #7
Source File: ClassPathBeanDefinitionScannerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testMultipleCustomExcludeFiltersAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(10, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertFalse(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #8
Source File: ComponentScanParserScopedProxyTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testInterfacesScopedProxy() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyInterfacesTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); // should cast to the interface FooService bean = (FooService) context.getBean("scopedProxyTestBean"); // should be dynamic proxy assertTrue(AopUtils.isJdkDynamicProxy(bean)); // test serializability assertEquals("bar", bean.foo(1)); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertNotNull(deserialized); assertEquals("bar", deserialized.foo(1)); context.close(); }
Example #9
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 #10
Source File: ComponentScanAnnotationIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void withScopedProxy() throws IOException, ClassNotFoundException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ComponentScanWithScopedProxy.class); ctx.getBeanFactory().registerScope("myScope", new SimpleMapScope()); ctx.refresh(); // should cast to the interface FooService bean = (FooService) ctx.getBean("scopedProxyTestBean"); // should be dynamic proxy assertThat(AopUtils.isJdkDynamicProxy(bean), is(true)); // test serializability assertThat(bean.foo(1), equalTo("bar")); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertThat(deserialized, notNullValue()); assertThat(deserialized.foo(1), equalTo("bar")); }
Example #11
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 #12
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 #13
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(11, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #14
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.setIncludeAnnotationConfig(false); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(5, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertFalse(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertFalse(context.containsBean(AnnotationConfigUtils.REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertFalse(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); }
Example #15
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testMultipleCustomExcludeFiltersAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(10, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertFalse(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #16
Source File: ClassPathBeanDefinitionScannerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testBeanNotAutowiredWithAnnotationConfigDisabled() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); scanner.setBeanNameGenerator(new TestBeanNameGenerator()); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, beanCount); context.refresh(); FooService fooService = (FooService) context.getBean("fooService"); assertFalse(fooService.isInitCalled()); try { fooService.foo(123); fail("NullPointerException expected; fooDao must not have been set"); } catch (NullPointerException expected) { } }
Example #17
Source File: ComponentScanParserScopedProxyTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testInterfacesScopedProxy() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyInterfacesTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); // should cast to the interface FooService bean = (FooService) context.getBean("scopedProxyTestBean"); // should be dynamic proxy assertTrue(AopUtils.isJdkDynamicProxy(bean)); // test serializability assertEquals("bar", bean.foo(1)); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertNotNull(deserialized); assertEquals("bar", deserialized.foo(1)); context.close(); }
Example #18
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 #19
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 #20
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 #21
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 #22
Source File: ComponentScanParserScopedProxyTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testInterfacesScopedProxy() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyInterfacesTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); // should cast to the interface FooService bean = (FooService) context.getBean("scopedProxyTestBean"); // should be dynamic proxy assertTrue(AopUtils.isJdkDynamicProxy(bean)); // test serializability assertEquals("bar", bean.foo(1)); FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean); assertNotNull(deserialized); assertEquals("bar", deserialized.foo(1)); context.close(); }
Example #23
Source File: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(11, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #24
Source File: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.setIncludeAnnotationConfig(false); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(6, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertTrue(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertFalse(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertFalse(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); }
Example #25
Source File: ClassPathBeanDefinitionScannerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testMultipleCustomExcludeFiltersAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class)); int beanCount = scanner.scan(BASE_PACKAGE); assertEquals(10, beanCount); assertFalse(context.containsBean("fooServiceImpl")); assertFalse(context.containsBean("serviceInvocationCounter")); assertTrue(context.containsBean("stubFooDao")); assertTrue(context.containsBean("myNamedComponent")); assertTrue(context.containsBean("myNamedDao")); assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_PROCESSOR_BEAN_NAME)); assertTrue(context.containsBean(AnnotationConfigUtils.EVENT_LISTENER_FACTORY_BEAN_NAME)); }
Example #26
Source File: EnableAspectJAutoProxyTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void withCglibProxy() { ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithCglibProxy.class); aspectIsApplied(ctx); assertThat(AopUtils.isCglibProxy(ctx.getBean(FooService.class)), is(true)); }
Example #27
Source File: ComponentScanAnnotationIntegrationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void withScopedProxyThroughAspectJPattern() throws IOException, ClassNotFoundException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ComponentScanWithScopedProxyThroughAspectJPattern.class); ctx.getBeanFactory().registerScope("myScope", new SimpleMapScope()); ctx.refresh(); // should cast to the interface FooService bean = (FooService) ctx.getBean("scopedProxyTestBean"); // should be dynamic proxy assertThat(AopUtils.isJdkDynamicProxy(bean), is(true)); }
Example #28
Source File: EnableAspectJAutoProxyTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void withExposedProxy() { ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithExposedProxy.class); aspectIsApplied(ctx); assertThat(AopUtils.isJdkDynamicProxy(ctx.getBean(FooService.class)), is(true)); }
Example #29
Source File: EnableAspectJAutoProxyTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void withJdkProxy() { ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithJdkProxy.class); aspectIsApplied(ctx); assertThat(AopUtils.isJdkDynamicProxy(ctx.getBean(FooService.class)), is(true)); }
Example #30
Source File: EnableAspectJAutoProxyTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void withCglibProxy() { ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithCglibProxy.class); aspectIsApplied(ctx); assertThat(AopUtils.isCglibProxy(ctx.getBean(FooService.class)), is(true)); }