org.springframework.tests.sample.beans.INestedTestBean Java Examples
The following examples show how to use
org.springframework.tests.sample.beans.INestedTestBean.
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: DelegatingIntroductionInterceptorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testDelegateReturnsThisIsMassagedToReturnProxy() { NestedTestBean target = new NestedTestBean(); String company = "Interface21"; target.setCompany(company); TestBean delegate = new TestBean() { @Override public ITestBean getSpouse() { return this; } }; ProxyFactory pf = new ProxyFactory(target); pf.addAdvice(new DelegatingIntroductionInterceptor(delegate)); INestedTestBean proxy = (INestedTestBean) pf.getProxy(); assertEquals(company, proxy.getCompany()); ITestBean introduction = (ITestBean) proxy; assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse()); assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse())); }
Example #2
Source File: AspectJAutoProxyCreatorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml"); StopWatch sw = new StopWatch(); sw.start("Prototype Creation"); for (int i = 0; i < 100000; i++) { INestedTestBean shouldNotBeWeaved = (INestedTestBean) ac.getBean("i21"); if (i < 10) { assertFalse(AopUtils.isAopProxy(shouldNotBeWeaved)); } } sw.stop(); // What's a reasonable expectation for _any_ server or developer machine load? // 3 seconds? assertStopWatchTimeLimit(sw, 6000); }
Example #3
Source File: DelegatingIntroductionInterceptorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testDelegateReturnsThisIsMassagedToReturnProxy() { NestedTestBean target = new NestedTestBean(); String company = "Interface21"; target.setCompany(company); TestBean delegate = new TestBean() { @Override public ITestBean getSpouse() { return this; } }; ProxyFactory pf = new ProxyFactory(target); pf.addAdvice(new DelegatingIntroductionInterceptor(delegate)); INestedTestBean proxy = (INestedTestBean) pf.getProxy(); assertEquals(company, proxy.getCompany()); ITestBean introduction = (ITestBean) proxy; assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse()); assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse())); }
Example #4
Source File: AspectJAutoProxyCreatorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml"); StopWatch sw = new StopWatch(); sw.start("Prototype Creation"); for (int i = 0; i < 100000; i++) { INestedTestBean shouldNotBeWeaved = (INestedTestBean) ac.getBean("i21"); if (i < 10) { assertFalse(AopUtils.isAopProxy(shouldNotBeWeaved)); } } sw.stop(); // What's a reasonable expectation for _any_ server or developer machine load? // 3 seconds? assertStopWatchTimeLimit(sw, 6000); }
Example #5
Source File: DelegatingIntroductionInterceptorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testDelegateReturnsThisIsMassagedToReturnProxy() { NestedTestBean target = new NestedTestBean(); String company = "Interface21"; target.setCompany(company); TestBean delegate = new TestBean() { @Override public ITestBean getSpouse() { return this; } }; ProxyFactory pf = new ProxyFactory(target); pf.addAdvice(new DelegatingIntroductionInterceptor(delegate)); INestedTestBean proxy = (INestedTestBean) pf.getProxy(); assertEquals(company, proxy.getCompany()); ITestBean introduction = (ITestBean) proxy; assertSame("Introduced method returning delegate returns proxy", introduction, introduction.getSpouse()); assertTrue("Introduced method returning delegate returns proxy", AopUtils.isAopProxy(introduction.getSpouse())); }
Example #6
Source File: AspectJAutoProxyCreatorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml"); StopWatch sw = new StopWatch(); sw.start("Prototype Creation"); for (int i = 0; i < 100000; i++) { INestedTestBean shouldNotBeWeaved = (INestedTestBean) ac.getBean("i21"); if (i < 10) { assertFalse(AopUtils.isAopProxy(shouldNotBeWeaved)); } } sw.stop(); // What's a reasonable expectation for _any_ server or developer machine load? // 3 seconds? assertStopWatchTimeLimit(sw, 6000); }
Example #7
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testResourceInjectionWithResolvableDependencyType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); bf.addBeanPostProcessor(bpp); RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class); abd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", abd); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("testBean4", tbd); bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() { @Override public Object getObject() throws BeansException { return new NestedTestBean(); } }); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("tb", "testBean4"); ppc.setProperties(props); ppc.postProcessBeanFactory(bf); ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); INestedTestBean tb = bean.getTestBean6(); assertNotNull(tb); ExtendedResourceInjectionBean anotherBean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); assertNotSame(anotherBean, bean); assertNotSame(anotherBean.getTestBean6(), tb); String[] depBeans = bf.getDependenciesForBean("annotatedBean"); assertEquals(1, depBeans.length); assertEquals("testBean4", depBeans[0]); }
Example #8
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@EJB public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #9
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Resource public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #10
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testResourceInjectionWithResolvableDependencyType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); bf.addBeanPostProcessor(bpp); RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class); abd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", abd); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("testBean4", tbd); bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() { @Override public Object getObject() throws BeansException { return new NestedTestBean(); } }); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("tb", "testBean4"); ppc.setProperties(props); ppc.postProcessBeanFactory(bf); ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); INestedTestBean tb = bean.getTestBean6(); assertNotNull(tb); ExtendedResourceInjectionBean anotherBean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); assertNotSame(anotherBean, bean); assertNotSame(anotherBean.getTestBean6(), tb); String[] depBeans = bf.getDependenciesForBean("annotatedBean"); assertEquals(1, depBeans.length); assertEquals("testBean4", depBeans[0]); }
Example #11
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 5 votes |
@EJB public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #12
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 5 votes |
@Resource public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #13
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testResourceInjectionWithResolvableDependencyType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); bf.addBeanPostProcessor(bpp); RootBeanDefinition abd = new RootBeanDefinition(ExtendedResourceInjectionBean.class); abd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("annotatedBean", abd); RootBeanDefinition tbd = new RootBeanDefinition(TestBean.class); tbd.setScope(BeanDefinition.SCOPE_PROTOTYPE); bf.registerBeanDefinition("testBean4", tbd); bf.registerResolvableDependency(BeanFactory.class, bf); bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() { @Override public Object getObject() throws BeansException { return new NestedTestBean(); } }); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("tb", "testBean4"); ppc.setProperties(props); ppc.postProcessBeanFactory(bf); ExtendedResourceInjectionBean bean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); INestedTestBean tb = bean.getTestBean6(); assertNotNull(tb); ExtendedResourceInjectionBean anotherBean = (ExtendedResourceInjectionBean) bf.getBean("annotatedBean"); assertNotSame(anotherBean, bean); assertNotSame(anotherBean.getTestBean6(), tb); String[] depBeans = bf.getDependenciesForBean("annotatedBean"); assertEquals(1, depBeans.length); assertEquals("testBean4", depBeans[0]); }
Example #14
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 5 votes |
@EJB public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #15
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 5 votes |
@Resource public void setTestBean6(INestedTestBean testBean6) { if (this.testBean6 != null) { throw new IllegalStateException("Already called"); } this.testBean6 = testBean6; }
Example #16
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 4 votes |
public INestedTestBean getTestBean5() { return testBean5; }
Example #17
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 4 votes |
public INestedTestBean getTestBean6() { return testBean6; }
Example #18
Source File: CommonAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 4 votes |
@Resource default void setTestBean7(INestedTestBean testBean7) { increaseCounter(); }
Example #19
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 4 votes |
@Resource default void setTestBean7(INestedTestBean testBean7) { increaseCounter(); }
Example #20
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 4 votes |
public INestedTestBean getTestBean6() { return testBean6; }
Example #21
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public INestedTestBean getTestBean5() { return testBean5; }
Example #22
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
public INestedTestBean getTestBean6() { return testBean6; }
Example #23
Source File: CommonAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Resource default void setTestBean7(INestedTestBean testBean7) { increaseCounter(); }
Example #24
Source File: CommonAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 4 votes |
public INestedTestBean getTestBean5() { return testBean5; }