@@ -99,11 +99,7 @@ void withSimpleInterceptorAndNoTarget() {
9999
100100 @ Test
101101 void withPostProcessorForMethod () {
102- DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
103- bf .registerBeanDefinition ("bean" , new RootBeanDefinition (AnnotatedMethodBean .class ));
104- RetryAnnotationBeanPostProcessor bpp = new RetryAnnotationBeanPostProcessor ();
105- bpp .setBeanFactory (bf );
106- bf .addBeanPostProcessor (bpp );
102+ DefaultListableBeanFactory bf = createBeanFactoryFor (AnnotatedMethodBean .class );
107103 AnnotatedMethodBean proxy = bf .getBean (AnnotatedMethodBean .class );
108104 AnnotatedMethodBean target = (AnnotatedMethodBean ) AopProxyUtils .getSingletonTarget (proxy );
109105
@@ -113,11 +109,7 @@ void withPostProcessorForMethod() {
113109
114110 @ Test
115111 void withPostProcessorForMethodWithInterface () {
116- DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
117- bf .registerBeanDefinition ("bean" , new RootBeanDefinition (AnnotatedMethodBeanWithInterface .class ));
118- RetryAnnotationBeanPostProcessor bpp = new RetryAnnotationBeanPostProcessor ();
119- bpp .setBeanFactory (bf );
120- bf .addBeanPostProcessor (bpp );
112+ DefaultListableBeanFactory bf = createBeanFactoryFor (AnnotatedMethodBeanWithInterface .class );
121113 AnnotatedInterface proxy = bf .getBean (AnnotatedInterface .class );
122114 AnnotatedMethodBeanWithInterface target = (AnnotatedMethodBeanWithInterface ) AopProxyUtils .getSingletonTarget (proxy );
123115
@@ -179,11 +171,7 @@ void withPostProcessorForMethodWithInterfaceAndExposeInterfaces() {
179171
180172 @ Test
181173 void withPostProcessorForClass () {
182- DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
183- bf .registerBeanDefinition ("bean" , new RootBeanDefinition (AnnotatedClassBean .class ));
184- RetryAnnotationBeanPostProcessor bpp = new RetryAnnotationBeanPostProcessor ();
185- bpp .setBeanFactory (bf );
186- bf .addBeanPostProcessor (bpp );
174+ DefaultListableBeanFactory bf = createBeanFactoryFor (AnnotatedClassBean .class );
187175 AnnotatedClassBean proxy = bf .getBean (AnnotatedClassBean .class );
188176 AnnotatedClassBean target = (AnnotatedClassBean ) AopProxyUtils .getSingletonTarget (proxy );
189177
@@ -324,6 +312,16 @@ void withAsyncAnnotation() {
324312 }
325313
326314
315+ private static DefaultListableBeanFactory createBeanFactoryFor (Class <?> beanClass ) {
316+ DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
317+ bf .registerBeanDefinition ("bean" , new RootBeanDefinition (beanClass ));
318+ RetryAnnotationBeanPostProcessor bpp = new RetryAnnotationBeanPostProcessor ();
319+ bpp .setBeanFactory (bf );
320+ bf .addBeanPostProcessor (bpp );
321+ return bf ;
322+ }
323+
324+
327325 static class NonAnnotatedBean implements PlainInterface {
328326
329327 int counter = 0 ;
0 commit comments