-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BATCH-1488: added common tests with Derby stored proc
- Loading branch information
trisberg
committed
Feb 1, 2010
1 parent
96e6286
commit c98a6f3
Showing
10 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...st/java/org/springframework/batch/item/database/StoredProcedureItemReaderCommonTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.springframework.batch.item.database; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
|
||
import org.hsqldb.Types; | ||
import org.junit.Test; | ||
import org.junit.internal.runners.JUnit4ClassRunner; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.batch.item.ExecutionContext; | ||
import org.springframework.batch.item.ItemReader; | ||
import org.springframework.batch.item.ReaderNotOpenException; | ||
import org.springframework.batch.item.sample.Foo; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
import org.springframework.jdbc.core.PreparedStatementSetter; | ||
import org.springframework.jdbc.core.SqlParameter; | ||
|
||
@RunWith(JUnit4ClassRunner.class) | ||
public class StoredProcedureItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { | ||
|
||
protected ItemReader<Foo> getItemReader() throws Exception { | ||
StoredProcedureItemReader<Foo> result = new StoredProcedureItemReader<Foo>(); | ||
result.setDataSource(getDataSource()); | ||
result.setProcedureName("read_foos"); | ||
result.setRowMapper(new FooRowMapper()); | ||
result.setVerifyCursorPosition(false); | ||
result.afterPropertiesSet(); | ||
return result; | ||
} | ||
|
||
protected void initializeContext() throws Exception { | ||
ctx = new ClassPathXmlApplicationContext("org/springframework/batch/item/database/stored-procedure-context.xml"); | ||
} | ||
|
||
@Test | ||
public void testRestartWithDriverSupportsAbsolute() throws Exception { | ||
testedAsStream().close(); | ||
tested = getItemReader(); | ||
((StoredProcedureItemReader<Foo>) tested).setDriverSupportsAbsolute(true); | ||
testedAsStream().open(executionContext); | ||
testedAsStream().close(); | ||
testedAsStream().open(executionContext); | ||
testRestart(); | ||
} | ||
|
||
protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception { | ||
StoredProcedureItemReader<Foo> reader = (StoredProcedureItemReader<Foo>) tested; | ||
reader.close(); | ||
reader.setDataSource(getDataSource()); | ||
reader.setProcedureName("read_some_foos"); | ||
reader.setParameters( | ||
new SqlParameter[] { | ||
new SqlParameter("from_id", Types.NUMERIC), | ||
new SqlParameter("to_id", Types.NUMERIC) | ||
}); | ||
reader.setPreparedStatementSetter( | ||
new PreparedStatementSetter() { | ||
public void setValues(PreparedStatement ps) | ||
throws SQLException { | ||
ps.setInt(1, 1000); | ||
ps.setInt(2, 1001); | ||
} | ||
}); | ||
reader.setRowMapper(new FooRowMapper()); | ||
reader.setVerifyCursorPosition(false); | ||
reader.afterPropertiesSet(); | ||
reader.open(new ExecutionContext()); | ||
} | ||
|
||
@Test(expected=ReaderNotOpenException.class) | ||
public void testReadBeforeOpen() throws Exception { | ||
testedAsStream().close(); | ||
tested = getItemReader(); | ||
tested.read(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ture/src/test/resources/org/springframework/batch/item/database/drop-foo-schema-derby.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
DROP PROCEDURE read_foos; | ||
DROP PROCEDURE read_some_foos; | ||
DROP TABLE T_FOOS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.