What I expect to see is the DataSet - annotated and loaded into the database being visible to the HibernateCursorItemReader. By this I am able to perform an Assert test before and after the batchJob has been executed.
In the enclosed code example is the data loaded by DbUnit visible to by managers before and after the job has been executed, - but not to the HibernateCursorItemReader. If I disable all Transactions, - the data is visible to the reader. It seems to me that the Job is not taking part in the transaction established by DbUnit/Unitils.
Geir
Code:
@DataSet
@Test(enabled = true)
public void testInvoiceMassCreditJob() throws Exception {
List<InvoiceBean> preJobExecution = invoicingManager.fetchInvoicesByPaymentAgreementId( 1);
runJob(BatchJob.INVOICE_MASSCREDIT_JOB, "initial.run.date(date)=2008/08/01,run.until.date(date)=2008/08/01,max.retries=8,"+"unik="+System.currentTimeMillis());
List<InvoiceBean> invoices = invoicingManager.fetchInvoicesByPaymentAgreementId( 1);
Assert.assertEquals( invoices.size(), 2);
for ( InvoiceBean invoice: invoices) {
if (InvoiceType.CREDIT_NOTE.equals( invoice.getInvoiceType())) {
Assert.assertEquals( invoice.getParentCrmInvoiceId(), "1-12345");
Assert.assertEquals( invoice.getAmount(), -125.50d);
} else if ( InvoiceType.INVOICE.equals( invoice.getInvoiceType())) {
Assert.assertEquals( invoice.getAmount(), 125.50d);
} else {
Assert.fail( "There should not be any invoices with type <> CREDIT_NOTE/INVOICE");
}
}
}