Skip to content

Commit d6a4981

Browse files
committed
Polishing
(cherry picked from commit 1e491f1)
1 parent 07db535 commit d6a4981

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

spring-context/src/main/java/org/springframework/scheduling/config/TriggerTask.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
1919
import org.springframework.scheduling.Trigger;
2020

2121
/**
22-
* {@link Task} implementation defining a {@code Runnable} to be executed according to a
23-
* given {@link Trigger}.
22+
* {@link Task} implementation defining a {@code Runnable} to be executed
23+
* according to a given {@link Trigger}.
2424
*
2525
* @author Chris Beams
2626
* @since 3.2
@@ -45,6 +45,7 @@ public TriggerTask(Runnable runnable, Trigger trigger) {
4545

4646

4747
public Trigger getTrigger() {
48-
return trigger;
48+
return this.trigger;
4949
}
50+
5051
}

src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020

2121
import org.junit.Before;
2222
import org.junit.Test;
23+
2324
import org.springframework.aop.support.AopUtils;
2425
import org.springframework.beans.factory.BeanCreationException;
2526
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -47,20 +48,22 @@
4748
* @author Chris Beams
4849
* @since 3.1
4950
*/
51+
@SuppressWarnings("resource")
5052
public class ScheduledAndTransactionalAnnotationIntegrationTests {
5153

5254
@Before
5355
public void setUp() {
5456
Assume.group(TestGroup.PERFORMANCE);
5557
}
5658

59+
5760
@Test
5861
public void failsWhenJdkProxyAndScheduledMethodNotPresentOnInterface() {
5962
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
6063
ctx.register(Config.class, JdkProxyTxConfig.class, RepoConfigA.class);
6164
try {
6265
ctx.refresh();
63-
fail("expected exception");
66+
fail("Should have thrown BeanCreationException");
6467
}
6568
catch (BeanCreationException ex) {
6669
assertTrue(ex.getRootCause().getMessage().startsWith("@Scheduled method 'scheduled' found"));
@@ -100,28 +103,36 @@ public void succeedsWhenJdkProxyAndScheduledMethodIsPresentOnInterface() throws
100103

101104
@Configuration
102105
@EnableTransactionManagement
103-
static class JdkProxyTxConfig { }
106+
static class JdkProxyTxConfig {
107+
}
108+
104109

105110
@Configuration
106111
@EnableTransactionManagement(proxyTargetClass=true)
107-
static class SubclassProxyTxConfig { }
112+
static class SubclassProxyTxConfig {
113+
}
114+
108115

109116
@Configuration
110117
static class RepoConfigA {
118+
111119
@Bean
112120
public MyRepository repository() {
113121
return new MyRepositoryImpl();
114122
}
115123
}
116124

125+
117126
@Configuration
118127
static class RepoConfigB {
128+
119129
@Bean
120130
public MyRepositoryWithScheduledMethod repository() {
121131
return new MyRepositoryWithScheduledMethodImpl();
122132
}
123133
}
124134

135+
125136
@Configuration
126137
@EnableScheduling
127138
static class Config {
@@ -138,15 +149,17 @@ public PlatformTransactionManager txManager() {
138149

139150
@Bean
140151
public PersistenceExceptionTranslator peTranslator() {
141-
PersistenceExceptionTranslator txlator = mock(PersistenceExceptionTranslator.class);
142-
return txlator;
152+
return mock(PersistenceExceptionTranslator.class);
143153
}
144154
}
145155

156+
146157
public interface MyRepository {
158+
147159
int getInvocationCount();
148160
}
149161

162+
150163
@Repository
151164
static class MyRepositoryImpl implements MyRepository {
152165

@@ -164,11 +177,15 @@ public int getInvocationCount() {
164177
}
165178
}
166179

180+
167181
public interface MyRepositoryWithScheduledMethod {
182+
168183
int getInvocationCount();
169-
public void scheduled();
184+
185+
void scheduled();
170186
}
171187

188+
172189
@Repository
173190
static class MyRepositoryWithScheduledMethodImpl implements MyRepositoryWithScheduledMethod {
174191

0 commit comments

Comments
 (0)