Reputation: 41
I am really new to Spring JDBC. I have 3 JUnit Tests which have no shared data (no before/after methods required as they have their own data in their own data files)
Each of these tests call a stored procedure inside a package. If I run the tests individually they all pass but running all three, one fails: (if i change the order of the tests in the class the failing one changes)
The call to the stored proc uses Spring JDBC:
SimpleJdbcCall callProcedure = new SimpleJdbcCall(jdbcTemplate)
.withCatalogName("ADMIN.CALCULATE")
.withProcedureName("GET_TOTALS")
.useInParameterNames("account_no", "request_list")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("account_no", Types.INTEGER),
new SqlParameter("request_list", OracleTypes.ARRAY, "ADMIN.CALC_REQUEST_TAB"),
new SqlOutParameter("response_list", OracleTypes.ARRAY, "ADMIN.CALC_RESPONSE_TAB"));
callProcedure.compile();
Map<String, Object> inputParams = new HashMap<String, Object>();
// set StructDescriptor and ArrayDescriptor
genericTypeDTO.setStructDescriptorName("ADMIN.T_CALC_REQUEST_TYPE");
genericTypeDTO.setArrayDescriptorName("ADMIN.CALC_REQUEST_TAB");
inputParams.put("account_no", accountNo);
inputParams.put("clawback_list", genericTypeDTO);
Map<String, Object> outData = (Map<String, Object>) callProcedure.execute(inputParams);
Below is the exception that is thrown when hitting callProcedure.execute(inputParams) for one of the tests:
Caused by: org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call ADMIN.CALCULATE.GET_TOTALS(?, ?, ?)}]; nested exception is java.sql.SQLException: ORA-06533: Subscript beyond count ORA-06512: at "ADMIN.CALCULATE", line 2160 ORA-06512: at line 1
Any advice would be appreciated.
Upvotes: 1
Views: 2941
Reputation: 4184
I think that you need to take a look at the mocking frameworks. It looks like your unit-tests are related to each other. Unit-tests actually must be unrelated, and you can achieve this by using the mocks.
Upvotes: 0