Java Code Examples for org.springframework.tests.sample.beans.TestBean#absquatulate()

The following examples show how to use org.springframework.tests.sample.beans.TestBean#absquatulate() . 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: RegexpMethodPointcutAdvisorIntegrationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testMultiplePatterns() throws Throwable {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
	// This is a CGLIB proxy, so we can proxy it to the target class
	TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
	// Interceptor behind regexp advisor
	NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
	assertEquals(0, nop.getCount());

	int newAge = 12;
	// Not advised
	advised.exceptional(null);
	assertEquals(0, nop.getCount());

	// This is proxied
	advised.absquatulate();
	assertEquals(1, nop.getCount());
	advised.setAge(newAge);
	assertEquals(newAge, advised.getAge());
	// Only setter fired
	assertEquals(2, nop.getCount());
}
 
Example 2
Source File: RegexpMethodPointcutAdvisorIntegrationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testMultiplePatterns() throws Throwable {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
	// This is a CGLIB proxy, so we can proxy it to the target class
	TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
	// Interceptor behind regexp advisor
	NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
	assertEquals(0, nop.getCount());

	int newAge = 12;
	// Not advised
	advised.exceptional(null);
	assertEquals(0, nop.getCount());

	// This is proxied
	advised.absquatulate();
	assertEquals(1, nop.getCount());
	advised.setAge(newAge);
	assertEquals(newAge, advised.getAge());
	// Only setter fired
	assertEquals(2, nop.getCount());
}
 
Example 3
Source File: RegexpMethodPointcutAdvisorIntegrationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiplePatterns() throws Throwable {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
	// This is a CGLIB proxy, so we can proxy it to the target class
	TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
	// Interceptor behind regexp advisor
	NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
	assertEquals(0, nop.getCount());

	int newAge = 12;
	// Not advised
	advised.exceptional(null);
	assertEquals(0, nop.getCount());

	// This is proxied
	advised.absquatulate();
	assertEquals(1, nop.getCount());
	advised.setAge(newAge);
	assertEquals(newAge, advised.getAge());
	// Only setter fired
	assertEquals(2, nop.getCount());
}
 
Example 4
Source File: ConfigurationClassAspectIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void assertAdviceWasApplied(Class<?> configClass) {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
	ctx.registerBeanDefinition("config", new RootBeanDefinition(configClass));
	ctx.refresh();

	TestBean testBean = ctx.getBean("testBean", TestBean.class);
	assertThat(testBean.getName(), equalTo("name"));
	testBean.absquatulate();
	assertThat(testBean.getName(), equalTo("advisedName"));
}
 
Example 5
Source File: ConfigurationClassAspectIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void assertAdviceWasApplied(Class<?> configClass) {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
	ctx.registerBeanDefinition("config", new RootBeanDefinition(configClass));
	ctx.refresh();

	TestBean testBean = ctx.getBean("testBean", TestBean.class);
	assertThat(testBean.getName(), equalTo("name"));
	testBean.absquatulate();
	assertThat(testBean.getName(), equalTo("advisedName"));
}
 
Example 6
Source File: ConfigurationClassAspectIntegrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void assertAdviceWasApplied(Class<?> configClass) {
	DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
	new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
			new ClassPathResource("aspectj-autoproxy-config.xml", ConfigurationClassAspectIntegrationTests.class));
	GenericApplicationContext ctx = new GenericApplicationContext(factory);
	ctx.addBeanFactoryPostProcessor(new ConfigurationClassPostProcessor());
	ctx.registerBeanDefinition("config", new RootBeanDefinition(configClass));
	ctx.refresh();

	TestBean testBean = ctx.getBean("testBean", TestBean.class);
	assertThat(testBean.getName(), equalTo("name"));
	testBean.absquatulate();
	assertThat(testBean.getName(), equalTo("advisedName"));
}