use of org.springframework.context.testfixture.SimpleMapScope in project spring-framework by spring-projects.
the class ComponentScanParserScopedProxyTests method testNoScopedProxy.
@Test
public void testNoScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyNoTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should not be a proxy
assertThat(AopUtils.isAopProxy(bean)).isFalse();
context.close();
}
use of org.springframework.context.testfixture.SimpleMapScope in project spring-framework by spring-projects.
the class ComponentScanParserScopedProxyTests method testTargetClassScopedProxy.
@Test
public void testTargetClassScopedProxy() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
// test serializability
assertThat(bean.foo(1)).isEqualTo("bar");
ScopedProxyTestBean deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(deserialized).isNotNull();
assertThat(deserialized.foo(1)).isEqualTo("bar");
context.close();
}
Aggregations