Java Code Examples for org.springframework.beans.factory.NamedBean

The following examples show how to use org.springframework.beans.factory.NamedBean. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: ExposeBeanNameAdvisorsTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example 2
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example 3
@Test
public void testWithIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertTrue("Introduction was made", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();

	NamedBean nb = (NamedBean) proxy;
	assertEquals("Name returned correctly", beanName, nb.getBeanName());
}
 
Example 4
Source Project: spring-analysis-note   Source File: ExposeBeanNameAdvisorsTests.java    License: MIT License 5 votes vote down vote up
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}
 
Example 5
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}
 
Example 6
@Test
public void testNoIntroduction() {
	String beanName = "foo";
	TestBean target = new RequiresBeanNameBoundTestBean(beanName);
	ProxyFactory pf = new ProxyFactory(target);
	pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
	pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
	ITestBean proxy = (ITestBean) pf.getProxy();

	assertFalse("No introduction", proxy instanceof NamedBean);
	// Requires binding
	proxy.getAge();
}