16
16
17
17
package org .springframework .scheduling .annotation ;
18
18
19
- import static org .easymock .EasyMock .createMock ;
20
- import static org .easymock .EasyMock .replay ;
21
- import static org .hamcrest .CoreMatchers .is ;
22
- import static org .hamcrest .Matchers .greaterThan ;
23
- import static org .junit .Assert .assertThat ;
24
- import static org .junit .Assert .assertTrue ;
25
- import static org .junit .Assert .fail ;
26
-
27
19
import java .util .concurrent .atomic .AtomicInteger ;
28
20
29
21
import org .junit .Test ;
22
+
30
23
import org .springframework .aop .support .AopUtils ;
31
24
import org .springframework .beans .factory .BeanCreationException ;
32
25
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
33
26
import org .springframework .context .annotation .Bean ;
34
27
import org .springframework .context .annotation .Configuration ;
35
28
import org .springframework .dao .annotation .PersistenceExceptionTranslationPostProcessor ;
36
29
import org .springframework .dao .support .PersistenceExceptionTranslator ;
37
- import org .springframework .scheduling .annotation .EnableScheduling ;
38
30
import org .springframework .stereotype .Repository ;
39
31
import org .springframework .transaction .CallCountingTransactionManager ;
40
32
import org .springframework .transaction .PlatformTransactionManager ;
41
33
import org .springframework .transaction .annotation .EnableTransactionManagement ;
42
34
import org .springframework .transaction .annotation .Transactional ;
43
35
36
+ import static org .easymock .EasyMock .*;
37
+ import static org .hamcrest .CoreMatchers .is ;
38
+ import static org .hamcrest .Matchers .*;
39
+ import static org .junit .Assert .*;
40
+
44
41
/**
45
42
* Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may
46
43
* not work well with beans that have already been proxied for other reasons such
@@ -58,7 +55,8 @@ public void failsWhenJdkProxyAndScheduledMethodNotPresentOnInterface() {
58
55
try {
59
56
ctx .refresh ();
60
57
fail ("expected exception" );
61
- } catch (BeanCreationException ex ) {
58
+ }
59
+ catch (BeanCreationException ex ) {
62
60
assertTrue (ex .getRootCause ().getMessage ().startsWith ("@Scheduled method 'scheduled' found" ));
63
61
}
64
62
}
@@ -69,7 +67,7 @@ public void succeedsWhenSubclassProxyAndScheduledMethodNotPresentOnInterface() t
69
67
ctx .register (Config .class , SubclassProxyTxConfig .class , RepoConfigA .class );
70
68
ctx .refresh ();
71
69
72
- Thread .sleep (50 ); // allow @Scheduled method to be called several times
70
+ Thread .sleep (100 ); // allow @Scheduled method to be called several times
73
71
74
72
MyRepository repository = ctx .getBean (MyRepository .class );
75
73
CallCountingTransactionManager txManager = ctx .getBean (CallCountingTransactionManager .class );
@@ -93,6 +91,7 @@ public void succeedsWhenJdkProxyAndScheduledMethodIsPresentOnInterface() throws
93
91
assertThat ("no transactions were committed" , txManager .commits , greaterThan (0 ));
94
92
}
95
93
94
+
96
95
@ Configuration
97
96
@ EnableTransactionManagement
98
97
static class JdkProxyTxConfig { }
@@ -179,5 +178,5 @@ public int getInvocationCount() {
179
178
return this .count .get ();
180
179
}
181
180
}
182
- }
183
181
182
+ }
0 commit comments