diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/JdbcTestUtils.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/JdbcTestUtils.java index ecf99bf28..4662f2fec 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/JdbcTestUtils.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/JdbcTestUtils.java @@ -2,7 +2,7 @@ package org.springframework.batch.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.JdbcOperations; /** *

@@ -25,7 +25,7 @@ public final class JdbcTestUtils { * @param tableName table name to count rows in * @return the number of rows in the table */ - public static int countRowsInTable(JdbcTemplate jdbcTemplate, String tableName) { + public static int countRowsInTable(JdbcOperations jdbcTemplate, String tableName) { return jdbcTemplate.queryForInt("SELECT COUNT(0) FROM " + tableName); } @@ -35,7 +35,7 @@ public final class JdbcTestUtils { * @param tableNames the names of the tables from which to delete * @return the total number of rows deleted from all specified tables */ - public static int deleteFromTables(JdbcTemplate jdbcTemplate, String... tableNames) { + public static int deleteFromTables(JdbcOperations jdbcTemplate, String... tableNames) { int totalRowCount = 0; for (String tableName : tableNames) { int rowCount = jdbcTemplate.update("DELETE FROM " + tableName); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java index ea6c67fe6..dd9c11e6e 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/ColumnRangePartitioner.java @@ -7,19 +7,20 @@ import javax.sql.DataSource; import org.springframework.batch.core.partition.support.Partitioner; import org.springframework.batch.item.ExecutionContext; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; /** * Simple minded partitioner for a range of values of a column in a database * table. Works best if the values are uniformly distributed (e.g. * auto-generated primary key values). - * + * * @author Dave Syer - * + * */ public class ColumnRangePartitioner implements Partitioner { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; private String table; @@ -27,7 +28,7 @@ public class ColumnRangePartitioner implements Partitioner { /** * The name of the SQL table the data are in. - * + * * @param table the name of the table */ public void setTable(String table) { @@ -36,7 +37,7 @@ public class ColumnRangePartitioner implements Partitioner { /** * The name of the column to partition. - * + * * @param column the column name. */ public void setColumn(String column) { @@ -45,7 +46,7 @@ public class ColumnRangePartitioner implements Partitioner { /** * The data source for connecting to the database. - * + * * @param dataSource a {@link DataSource} */ public void setDataSource(DataSource dataSource) { @@ -57,7 +58,7 @@ public class ColumnRangePartitioner implements Partitioner { * are uniformly distributed. The execution context values will have keys * minValue and maxValue specifying the range of * values to consider in each partition. - * + * * @see Partitioner#partition(int) */ public Map partition(int gridSize) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java index cab9ab84c..e4012611b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.core.listener.StepListenerSupport; import org.springframework.batch.item.ItemReader; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.OptimisticLockingFailureException; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; @@ -31,7 +32,7 @@ import org.springframework.util.Assert; */ public class StagingItemListener extends StepListenerSupport implements InitializingBean { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java index 831145335..3bf84b234 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java @@ -5,26 +5,27 @@ import javax.sql.DataSource; import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.OptimisticLockingFailureException; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; /** * Marks the input row as 'processed'. (This change will rollback if there is * problem later) - * + * * @param item type - * + * * @see StagingItemReader * @see StagingItemWriter * @see ProcessIndicatorItemWrapper - * + * * @author Robert Kasanicky */ public class StagingItemProcessor implements ItemProcessor, T>, InitializingBean { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; - public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { + public void setJdbcTemplate(JdbcOperations jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java index b6532cf32..757033fbc 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,14 +34,15 @@ import org.springframework.batch.support.SerializationUtils; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.simple.ParameterizedRowMapper; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.simple.ParameterizedRowMapper; import org.springframework.util.Assert; /** * Thread-safe database {@link ItemReader} implementing the process indicator * pattern. - * + * * To achieve restartability use together with {@link StagingItemProcessor}. */ public class StagingItemReader implements ItemReader>, StepExecutionListener, @@ -57,7 +58,7 @@ public class StagingItemReader implements ItemReader keys; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDao.java index 14c5dd895..b406ed006 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDao.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,14 @@ package org.springframework.batch.sample.domain.football.internal; +import javax.sql.DataSource; + import org.springframework.batch.sample.domain.football.Player; import org.springframework.batch.sample.domain.football.PlayerDao; import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import javax.sql.DataSource; - /** * @author Lucas Ward * @@ -33,7 +34,7 @@ public class JdbcPlayerDao implements PlayerDao { "INSERT into PLAYERS (player_id, last_name, first_name, pos, year_of_birth, year_drafted)" + " values (:id, :lastName, :firstName, :position, :birthYear, :debutYear)"; - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + private NamedParameterJdbcOperations namedParameterJdbcTemplate; public void savePlayer(Player player) { namedParameterJdbcTemplate.update(INSERT_PLAYER, new BeanPropertySqlParameterSource(player)); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDao.java index 4c6fcfe03..f3ca7b1ad 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDao.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,14 @@ package org.springframework.batch.sample.domain.football.internal; import java.util.List; +import javax.sql.DataSource; + import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.football.PlayerSummary; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import javax.sql.DataSource; - public class JdbcPlayerSummaryDao implements ItemWriter { private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID, YEAR_NO, COMPLETES, ATTEMPTS, PASSING_YARDS, PASSING_TD, " @@ -32,7 +33,7 @@ public class JdbcPlayerSummaryDao implements ItemWriter { + "values(:id, :year, :completes, :attempts, :passingYards, :passingTd, " + ":interceptions, :rushes, :rushYards, :receptions, :receptionYards, :totalTd)"; - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + private NamedParameterJdbcOperations namedParameterJdbcTemplate; public void write(List summaries) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDao.java index a4840da77..efda0ab1b 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDao.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +21,20 @@ import javax.sql.DataSource; import org.springframework.batch.sample.domain.trade.CustomerDebit; import org.springframework.batch.sample.domain.trade.CustomerDebitDao; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; /** * Reduces customer's credit by the provided amount. - * + * * @author Robert Kasanicky */ public class JdbcCustomerDebitDao implements CustomerDebitDao { - + private static final String UPDATE_CREDIT = "UPDATE CUSTOMER SET credit= credit-? WHERE name=?"; - - private JdbcTemplate jdbcTemplate; + + private JdbcOperations jdbcTemplate; public void write(CustomerDebit customerDebit) { jdbcTemplate.update(UPDATE_CREDIT, customerDebit.getDebit(), customerDebit.getName()); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeDao.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeDao.java index baed1ce33..3b68f97b5 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeDao.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.sample.domain.trade.TradeDao; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; @@ -41,7 +42,7 @@ public class JdbcTradeDao implements TradeDao { /** * handles the processing of sql query */ - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; /** * database is not expected to be setup for autoincrement diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java index b4a164c0f..37f42a5c7 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CompositeItemWriterSampleFunctionalTests.java @@ -18,8 +18,9 @@ import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -35,7 +36,7 @@ public class CompositeItemWriterSampleFunctionalTests { + "Trade: [isin=UK21341EAH44,quantity=214,price=34.11,customer=customer4]" + "Trade: [isin=UK21341EAH45,quantity=215,price=35.11,customer=customer5]"; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java index c23d884c9..afea2890f 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/CustomerFilterJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,9 @@ import org.junit.runner.RunWith; import org.springframework.batch.core.JobExecution; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -48,7 +49,7 @@ public class CustomerFilterJobFunctionalTests { private List customers; private int activeRow = 0; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; private Map credits = new HashMap(); @Autowired @@ -135,9 +136,10 @@ public class CustomerFilterJobFunctionalTests { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { final int PRIME = 31; int result = 1; @@ -150,9 +152,10 @@ public class CustomerFilterJobFunctionalTests { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java index 4b3ade578..1bdd75935 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/FootballJobFunctionalTests.java @@ -8,6 +8,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -19,7 +20,7 @@ public class FootballJobFunctionalTests { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java index 448e3914a..2f1222935 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/HibernateFailureJobFunctionalTests.java @@ -20,9 +20,10 @@ import org.springframework.batch.sample.domain.trade.internal.HibernateCreditDao import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.UncategorizedSQLException; +import org.springframework.jdbc.core.JdbcOperations; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; -import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.orm.hibernate3.HibernateJdbcException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -34,7 +35,7 @@ import org.springframework.transaction.support.TransactionTemplate; /** * Test for HibernateJob - checks that customer credit has been updated to * expected value. - * + * * @author Dave Syer */ @RunWith(SpringJUnit4ClassRunner.class) @@ -45,17 +46,17 @@ public class HibernateFailureJobFunctionalTests { @Autowired private HibernateCreditDao writer; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; private PlatformTransactionManager transactionManager; private static final BigDecimal CREDIT_INCREASE = CustomerCreditIncreaseProcessor.FIXED_AMOUNT; - + private static String[] customers = { "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)", "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)", "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)", "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (4, 0, 'customer4', 100000)"}; - + private static String DELETE_CUSTOMERS = "DELETE FROM CUSTOMER"; private static final String ALL_CUSTOMERS = "select * from CUSTOMER order by ID"; @@ -81,9 +82,9 @@ public class HibernateFailureJobFunctionalTests { @Test public void testLaunchJob() throws Exception { - + validatePreConditions(); - + JobParameters params = new JobParametersBuilder().addString("key", "failureJob").toJobParameters(); writer.setFailOnFlush(2); @@ -101,9 +102,9 @@ public class HibernateFailureJobFunctionalTests { } int after = jdbcTemplate.queryForInt("SELECT COUNT(*) from CUSTOMER"); assertEquals(4, after); - + validatePostConditions(); - + } /** @@ -113,7 +114,7 @@ public class HibernateFailureJobFunctionalTests { protected void validatePreConditions() throws Exception { ensureState(); creditsBeforeUpdate = (List) new TransactionTemplate(transactionManager).execute(new TransactionCallback() { - public Object doInTransaction(TransactionStatus status) { + public Object doInTransaction(TransactionStatus status) { return jdbcTemplate.query(ALL_CUSTOMERS, new ParameterizedRowMapper() { public BigDecimal mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getBigDecimal(CREDIT_COLUMN); @@ -140,7 +141,7 @@ public class HibernateFailureJobFunctionalTests { }); } - + /** * Credit was increased by CREDIT_INCREASE */ @@ -161,13 +162,13 @@ public class HibernateFailureJobFunctionalTests { matches.add(rs.getBigDecimal(ID_COLUMN)); } } - + }); return null; } }); assertEquals((creditsBeforeUpdate.size() - 1), matches.size()); - assertFalse(matches.contains(new BigDecimal(2))); + assertFalse(matches.contains(new BigDecimal(2))); } } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java index a3e29fb64..d787b9491 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobStepFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,13 +26,14 @@ import org.springframework.batch.core.converter.DefaultJobParametersConverter; import org.springframework.batch.support.PropertiesConverter; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Sample using a step to launch a job. - * + * * @author Dave Syer */ @RunWith(SpringJUnit4ClassRunner.class) @@ -43,7 +44,7 @@ public class JobStepFunctionalTests { private JobLauncherTestUtils jobLauncherTestUtils; // auto-injected attributes - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { @@ -54,7 +55,7 @@ public class JobStepFunctionalTests { public void testJobLaunch() throws Exception { jdbcTemplate.update("DELETE FROM TRADE"); - + jobLauncherTestUtils.launchJob(new DefaultJobParametersConverter() .getJobParameters(PropertiesConverter .stringToProperties("run.id(long)=1,parameter=true,run.date=20070122,input.file=classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt"))); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java index 2f9372464..1d0cdfdfd 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/MailJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.batch.sample.domain.mail.internal.TestMailErrorHandle import org.springframework.batch.sample.domain.mail.internal.TestMailSender; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.mail.MailMessage; import org.springframework.mail.SimpleMailMessage; @@ -41,7 +42,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Dan Garrette * @author Dave Syer - * + * * @Since 2.1 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -66,7 +67,7 @@ public class MailJobFunctionalTests { private static final Object[] USER8 = new Object[] { 8, "Martin Van Buren", email }; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private JobLauncherTestUtils jobLauncherTestUtils; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java index 1e493f239..039fea8da 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/ParallelJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/parallelJob.xml", @@ -39,7 +40,7 @@ public class ParallelJobFunctionalTests { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java index bab144228..47b4557b2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/RestartFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.core.converter.DefaultJobParametersConverter; import org.springframework.batch.support.PropertiesConverter; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -35,7 +36,7 @@ import org.springframework.test.context.transaction.BeforeTransaction; /** * Simple restart scenario. - * + * * @author Robert Kasanicky * @author Dave Syer */ @@ -48,7 +49,7 @@ public class RestartFunctionalTests { private JobLauncherTestUtils jobLauncherTestUtils; // auto-injected attributes - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { @@ -66,7 +67,7 @@ public class RestartFunctionalTests { * finish successfully, because it continues execution where the previous * run stopped (module throws exception after fixed number of processed * records). - * + * * @throws Exception */ @Test diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java index aa03772c4..dfdc17135 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/SkipSampleFunctionalTests.java @@ -24,18 +24,19 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteExcep import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.sample.common.SkipCheckingListener; import org.springframework.batch.sample.domain.trade.internal.TradeWriter; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.batch.support.JdbcTestUtils; /** * Error is encountered during writing - transaction is rolled back and the * error item is skipped on second attempt to process the chunk. - * + * * @author Robert Kasanicky * @author Dan Garrette */ @@ -43,7 +44,7 @@ import org.springframework.batch.support.JdbcTestUtils; @ContextConfiguration(locations = { "/skipSample-job-launcher-context.xml" }) public class SkipSampleFunctionalTests { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private JobExplorer jobExplorer; @@ -172,7 +173,7 @@ public class SkipSampleFunctionalTests { // to output // System.err.println(jdbcTemplate.queryForList("SELECT * FROM TRADE")); assertEquals(5, jdbcTemplate.queryForInt("SELECT COUNT(*) from TRADE where VERSION=?", 1)); - + // 1 record skipped in processing second step assertEquals(1, SkipCheckingListener.getProcessSkips()); @@ -217,7 +218,7 @@ public class SkipSampleFunctionalTests { /** * Launch the entire job, including all steps, in order. - * + * * @return JobExecution, so that the test may validate the exit status */ public long launchJobWithIncrementer() { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java index e44a5d112..354d924c8 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/TradeJobFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,9 @@ import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -48,12 +49,12 @@ public class TradeJobFunctionalTests { private static final String GET_TRADES = "select ISIN, QUANTITY, PRICE, CUSTOMER, ID, VERSION from TRADE order by ISIN"; private static final String GET_CUSTOMERS = "select NAME, CREDIT from CUSTOMER order by NAME"; - + private List customers; private List trades; private int activeRow = 0; - - private JdbcTemplate jdbcTemplate; + + private JdbcOperations jdbcTemplate; private Map credits = new HashMap(); @Autowired @@ -63,7 +64,7 @@ public class TradeJobFunctionalTests { public void setDataSource(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } - + @Before public void onSetUp() throws Exception { jdbcTemplate.update("delete from TRADE"); @@ -72,7 +73,7 @@ public class TradeJobFunctionalTests { credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue()); } } - + @After public void tearDown() throws Exception { jdbcTemplate.update("delete from TRADE"); @@ -80,9 +81,9 @@ public class TradeJobFunctionalTests { @Test public void testLaunchJob() throws Exception { - + jobLauncherTestUtils.launchJob(); - + customers = Arrays.asList(new Customer("customer1", (credits.get("customer1") - 98.34)), new Customer("customer2", (credits.get("customer2") - 18.12 - 12.78)), new Customer("customer3", (credits.get("customer3") - 109.25)), @@ -93,48 +94,48 @@ public class TradeJobFunctionalTests { new Trade("UK21341EAH47", 245, new BigDecimal("12.78"), "customer2"), new Trade("UK21341EAH48", 108, new BigDecimal("109.25"), "customer3"), new Trade("UK21341EAH49", 854, new BigDecimal("123.39"), "customer4")); - + // check content of the trade table jdbcTemplate.query(GET_TRADES, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { Trade trade = trades.get(activeRow++); - + assertTrue(trade.getIsin().equals(rs.getString(1))); assertTrue(trade.getQuantity() == rs.getLong(2)); assertTrue(trade.getPrice().equals(rs.getBigDecimal(3))); assertTrue(trade.getCustomer().equals(rs.getString(4))); } }); - + assertEquals(activeRow, trades.size()); - + // check content of the customer table activeRow = 0; jdbcTemplate.query(GET_CUSTOMERS, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { Customer customer = customers.get(activeRow++); - + assertEquals(customer.getName(),rs.getString(1)); assertEquals(customer.getCredit(), rs.getDouble(2), .01); } }); - + assertEquals(customers.size(), activeRow); - + // check content of the output file } private static class Customer { private String name; private double credit; - + public Customer(String name, double credit) { this.name = name; this.credit = credit; } - + /** * @return the credit */ @@ -178,9 +179,9 @@ public class TradeJobFunctionalTests { return false; return true; } - - + + } - - + + } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java index 3e3af1550..762014af1 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java @@ -11,6 +11,7 @@ import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; @@ -22,7 +23,7 @@ public class ErrorLogTasklet implements Tasklet, StepExecutionListener { protected final Log logger = LogFactory.getLog(getClass()); - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; private String jobName; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java index 17e55c89a..11097c01a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemReaderTests.java @@ -14,6 +14,7 @@ import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -30,7 +31,7 @@ import org.springframework.transaction.support.TransactionTemplate; @ContextConfiguration() public class StagingItemReaderTests { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private PlatformTransactionManager transactionManager; @@ -73,9 +74,9 @@ public class StagingItemReaderTests { assertEquals(StagingItemWriter.NEW, before); ProcessIndicatorItemWrapper wrapper = reader.read(); - String item = wrapper.getItem(); + String item = wrapper.getItem(); assertEquals("FOO", item); - + StagingItemProcessor updater = new StagingItemProcessor(); updater.setJdbcTemplate(jdbcTemplate); updater.process(wrapper); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java index 7f3dcad2a..f67f2402b 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/StagingItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -38,7 +39,7 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration public class StagingItemWriterTests { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private StagingItemWriter writer; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java index e048302c8..de6a8020d 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcGameDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,15 +28,16 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.football.Game; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.ParameterizedRowMapper; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.simple.ParameterizedRowMapper; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; /** * @author Lucas Ward - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/data-source-context.xml"}) @@ -46,7 +47,7 @@ public class JdbcGameDaoIntegrationTests { private Game game = new Game(); - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java index c2905b620..2730acdee 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.football.Player; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; @@ -40,21 +41,21 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/data-source-context.xml"}) public class JdbcPlayerDaoIntegrationTests { - + private JdbcPlayerDao playerDao; private Player player; private static final String GET_PLAYER = "SELECT * from PLAYERS"; - - private JdbcTemplate jdbcTemplate; + + private JdbcOperations jdbcTemplate; @Autowired public void init(DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); playerDao = new JdbcPlayerDao(); - playerDao.setDataSource(dataSource); + playerDao.setDataSource(dataSource); player = new Player(); player.setId("AKFJDL00"); @@ -63,7 +64,7 @@ public class JdbcPlayerDaoIntegrationTests { player.setPosition("QB"); player.setBirthYear(1975); player.setDebutYear(1998); - + } @@ -76,7 +77,7 @@ public class JdbcPlayerDaoIntegrationTests { @Transactional @Test public void testSavePlayer(){ - + playerDao.savePlayer(player); jdbcTemplate.query(GET_PLAYER, new RowCallbackHandler(){ @@ -88,8 +89,8 @@ public class JdbcPlayerDaoIntegrationTests { assertEquals(rs.getString("POS"), "QB"); assertEquals(rs.getInt("YEAR_OF_BIRTH"), 1975); assertEquals(rs.getInt("YEAR_DRAFTED"), 1998); - } + } }); } - + } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java index f590d3375..04ca13dff 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/football/internal/JdbcPlayerSummaryDaoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.football.PlayerSummary; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -33,7 +34,7 @@ import org.springframework.transaction.annotation.Transactional; /** * @author Lucas Ward - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/data-source-context.xml" }) @@ -43,7 +44,7 @@ public class JdbcPlayerSummaryDaoIntegrationTests { private PlayerSummary summary; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired public void init(DataSource dataSource) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java index 9b963ae8b..992e2fc36 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/ItemTrackingTradeItemWriter.java @@ -8,6 +8,7 @@ import javax.sql.DataSource; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.sample.domain.trade.Trade; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; public class ItemTrackingTradeItemWriter implements ItemWriter { @@ -16,7 +17,7 @@ public class ItemTrackingTradeItemWriter implements ItemWriter { private String writeFailureISIN; - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java index a7164e2c0..794e496b4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.trade.CustomerDebit; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; @@ -37,7 +38,7 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration() public class JdbcCustomerDebitDaoTests { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; @Autowired private JdbcCustomerDebitDao writer; @@ -50,7 +51,7 @@ public class JdbcCustomerDebitDaoTests { @Transactional @Test public void testWrite() { - //insert customer credit + //insert customer credit jdbcTemplate.execute("INSERT INTO CUSTOMER VALUES (99, 0, 'testName', 100)"); //create customer debit diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java index 98b7bfeb4..d1ce736cc 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/internal/JdbcTradeWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,9 @@ import org.junit.runner.RunWith; import org.springframework.batch.sample.domain.trade.Trade; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -39,7 +40,7 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration(locations = {"/data-source-context.xml"}) public class JdbcTradeWriterTests { - private JdbcTemplate jdbcTemplate; + private JdbcOperations jdbcTemplate; private JdbcTradeDao writer; @@ -65,7 +66,7 @@ public class JdbcTradeWriterTests { trade.setIsin("5647238492"); trade.setPrice(new BigDecimal(Double.toString(99.69))); trade.setQuantity(5); - + writer.writeTrade(trade); jdbcTemplate.query("SELECT * FROM TRADE WHERE ISIN = '5647238492'", new RowCallbackHandler() { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java index a6442cc7b..8b0d7cef3 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/TwoJobInstancesPagingFunctionalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -50,9 +51,9 @@ public class TwoJobInstancesPagingFunctionalTests { @Autowired private Job job; - - private JdbcTemplate jdbcTemplate; - + + private JdbcOperations jdbcTemplate; + @Autowired public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource);