Skip to content

Commit dca9b77

Browse files
committed
Fix incorrect reference to SimpleJdbcTemplate in reference documentation
Resolves #4197
1 parent 499ec2b commit dca9b77

File tree

3 files changed

+102
-103
lines changed

3 files changed

+102
-103
lines changed

spring-batch-docs/asciidoc/testing.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@ public class SkipSampleFunctionalTests {
103103
@Autowired
104104
private JobLauncherTestUtils jobLauncherTestUtils;
105105
106-
private SimpleJdbcTemplate simpleJdbcTemplate;
106+
private JdbcTemplate jdbcTemplate;
107107
108108
@Autowired
109109
public void setDataSource(DataSource dataSource) {
110-
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
110+
this.jdbcTemplate = new JdbcTemplate(dataSource);
111111
}
112112
113113
@Test
114114
public void testJob() throws Exception {
115-
simpleJdbcTemplate.update("delete from CUSTOMER");
115+
this.jdbcTemplate.update("delete from CUSTOMER");
116116
for (int i = 1; i <= 10; i++) {
117-
simpleJdbcTemplate.update("insert into CUSTOMER values (?, 0, ?, 100000)",
117+
this.jdbcTemplate.update("insert into CUSTOMER values (?, 0, ?, 100000)",
118118
i, "customer" + i);
119119
}
120120
@@ -140,18 +140,18 @@ public class SkipSampleFunctionalTests {
140140
@Autowired
141141
private JobLauncherTestUtils jobLauncherTestUtils;
142142
143-
private SimpleJdbcTemplate simpleJdbcTemplate;
143+
private JdbcTemplate jdbcTemplate;
144144
145145
@Autowired
146146
public void setDataSource(DataSource dataSource) {
147-
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
147+
this.jdbcTemplate = new JdbcTemplate(dataSource);
148148
}
149149
150150
@Test
151151
public void testJob() throws Exception {
152-
simpleJdbcTemplate.update("delete from CUSTOMER");
152+
this.jdbcTemplate.update("delete from CUSTOMER");
153153
for (int i = 1; i <= 10; i++) {
154-
simpleJdbcTemplate.update("insert into CUSTOMER values (?, 0, ?, 100000)",
154+
this.jdbcTemplate.update("insert into CUSTOMER values (?, 0, ?, 100000)",
155155
i, "customer" + i);
156156
}
157157

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void setJdbcTemplate(NamedParameterJdbcOperations namedParameterJdbcTempl
135135
}
136136

137137
/**
138-
* Check mandatory properties - there must be a SimpleJdbcTemplate and an SQL statement plus a
138+
* Check mandatory properties - there must be a NamedParameterJdbcOperations and an SQL statement plus a
139139
* parameter source.
140140
*/
141141
@Override
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,93 @@
1-
package org.springframework.batch.integration.chunk;
2-
3-
import static org.junit.Assert.assertEquals;
4-
5-
import java.util.Collections;
6-
7-
import org.junit.Before;
8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
10-
import org.springframework.batch.core.BatchStatus;
11-
import org.springframework.batch.core.Job;
12-
import org.springframework.batch.core.JobExecution;
13-
import org.springframework.batch.core.JobParameter;
14-
import org.springframework.batch.core.JobParameters;
15-
import org.springframework.batch.core.JobParametersBuilder;
16-
import org.springframework.batch.core.StepExecution;
17-
import org.springframework.batch.core.launch.JobLauncher;
18-
import org.springframework.beans.factory.annotation.Autowired;
19-
import org.springframework.messaging.Message;
20-
import org.springframework.messaging.PollableChannel;
21-
import org.springframework.test.annotation.DirtiesContext;
22-
import org.springframework.test.context.ContextConfiguration;
23-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
24-
25-
@ContextConfiguration
26-
@RunWith(SpringJUnit4ClassRunner.class)
27-
public class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
28-
29-
@Autowired
30-
private JobLauncher jobLauncher;
31-
32-
@Autowired
33-
private Job job;
34-
35-
@Autowired
36-
private PollableChannel replies;
37-
38-
@Before
39-
public void drain() {
40-
Message<?> message = replies.receive(100L);
41-
while (message!=null) {
42-
message = replies.receive(100L);
43-
}
44-
}
45-
46-
@Test
47-
@DirtiesContext
48-
public void testFailedStep() throws Exception {
49-
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
50-
new JobParameter("unsupported"))));
51-
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
52-
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
53-
assertEquals(9, stepExecution.getReadCount());
54-
// In principle the write count could be more than 2 and less than 9...
55-
assertEquals(7, stepExecution.getWriteCount());
56-
}
57-
58-
@Test
59-
@DirtiesContext
60-
public void testFailedStepOnError() throws Exception {
61-
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
62-
new JobParameter("error"))));
63-
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
64-
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
65-
assertEquals(9, stepExecution.getReadCount());
66-
// In principle the write count could be more than 2 and less than 9...
67-
assertEquals(7, stepExecution.getWriteCount());
68-
}
69-
70-
@Test
71-
@DirtiesContext
72-
public void testSunnyDayFaultTolerant() throws Exception {
73-
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
74-
new JobParameter("3"))));
75-
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
76-
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
77-
assertEquals(9, stepExecution.getReadCount());
78-
assertEquals(9, stepExecution.getWriteCount());
79-
}
80-
81-
@Test
82-
@DirtiesContext
83-
public void testSkipsInWriter() throws Exception {
84-
JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder().addString("item.three", "fail")
85-
.addLong("run.id", 1L).toJobParameters());
86-
// System.err.println(new SimpleJdbcTemplate(dataSource).queryForList("SELECT * FROM INT_MESSAGE_GROUP"));
87-
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
88-
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
89-
assertEquals(9, stepExecution.getReadCount());
90-
assertEquals(7, stepExecution.getWriteCount());
91-
// The whole chunk gets skipped...
92-
assertEquals(2, stepExecution.getWriteSkipCount());
93-
}
94-
}
1+
package org.springframework.batch.integration.chunk;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import java.util.Collections;
6+
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
import org.springframework.batch.core.BatchStatus;
11+
import org.springframework.batch.core.Job;
12+
import org.springframework.batch.core.JobExecution;
13+
import org.springframework.batch.core.JobParameter;
14+
import org.springframework.batch.core.JobParameters;
15+
import org.springframework.batch.core.JobParametersBuilder;
16+
import org.springframework.batch.core.StepExecution;
17+
import org.springframework.batch.core.launch.JobLauncher;
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.messaging.Message;
20+
import org.springframework.messaging.PollableChannel;
21+
import org.springframework.test.annotation.DirtiesContext;
22+
import org.springframework.test.context.ContextConfiguration;
23+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
24+
25+
@ContextConfiguration
26+
@RunWith(SpringJUnit4ClassRunner.class)
27+
public class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
28+
29+
@Autowired
30+
private JobLauncher jobLauncher;
31+
32+
@Autowired
33+
private Job job;
34+
35+
@Autowired
36+
private PollableChannel replies;
37+
38+
@Before
39+
public void drain() {
40+
Message<?> message = replies.receive(100L);
41+
while (message!=null) {
42+
message = replies.receive(100L);
43+
}
44+
}
45+
46+
@Test
47+
@DirtiesContext
48+
public void testFailedStep() throws Exception {
49+
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
50+
new JobParameter("unsupported"))));
51+
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
52+
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
53+
assertEquals(9, stepExecution.getReadCount());
54+
// In principle the write count could be more than 2 and less than 9...
55+
assertEquals(7, stepExecution.getWriteCount());
56+
}
57+
58+
@Test
59+
@DirtiesContext
60+
public void testFailedStepOnError() throws Exception {
61+
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
62+
new JobParameter("error"))));
63+
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
64+
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
65+
assertEquals(9, stepExecution.getReadCount());
66+
// In principle the write count could be more than 2 and less than 9...
67+
assertEquals(7, stepExecution.getWriteCount());
68+
}
69+
70+
@Test
71+
@DirtiesContext
72+
public void testSunnyDayFaultTolerant() throws Exception {
73+
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
74+
new JobParameter("3"))));
75+
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
76+
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
77+
assertEquals(9, stepExecution.getReadCount());
78+
assertEquals(9, stepExecution.getWriteCount());
79+
}
80+
81+
@Test
82+
@DirtiesContext
83+
public void testSkipsInWriter() throws Exception {
84+
JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder().addString("item.three", "fail")
85+
.addLong("run.id", 1L).toJobParameters());
86+
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
87+
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
88+
assertEquals(9, stepExecution.getReadCount());
89+
assertEquals(7, stepExecution.getWriteCount());
90+
// The whole chunk gets skipped...
91+
assertEquals(2, stepExecution.getWriteSkipCount());
92+
}
93+
}

0 commit comments

Comments
 (0)