I have wrote a test class for Dao using DbUnit and dataset
Here is my class :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:config/appContext-test.xml" })
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, DBUnitTestExecutionListener.class })
@DBUnitConfiguration(locations = { "testdata/mso_data.xml" })
public class TestMsoJobsDao{
@Resource
private MsoJobsDao msoJobsDao;
@Test
public void testSaveMsoDataIntoTempTable() throws Exception{
List<Object[]> msoHeadendList = new ArrayList<Object[]>();
Timestamp timestamp1 = Timestamp.valueOf("2015-07-01 08:49:50");
Object[] obj1 = {"TEST_MSO_SERVICE_ID_3","America/Detroit","SL","1",timestamp1,"1",timestamp1};
msoList.add(obj1);
msoJobsDao.saveMsoDataIntoTempTable(msoList);
}
}
and data set is :
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<mso_temp id="1" mso_service_id="TEST_MSO_SERVICE_ID_3"
timezone="America/Detroit" customer_group="RC" created_by="1"
created_date="2015-10-05 06:31:59" updated_by="1"
updated_date="2015-10-05 06:31:59"/>
</dataset>
When i am running my test case i am getting org.dbunit.dataset.NoSuchTableException: mso_temp
My problem is i don't need any entity as i am connecting to other database and saving the data from there to the temp table in our application database using PreparedStatement.If i create entity class the test case runs fine.
Is there any way through which DBUnit will consider the table for which entity class is not there.