Java Code Examples for example.scannable.FooService#foo()
The following examples show how to use
example.scannable.FooService#foo() .
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: 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 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: 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 4
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 5
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 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: 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 8
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 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: 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) { } }