I am using spring-test-dbunit and I get a warning in my Unit tests with this message:
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/context.xml"})
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class,
DbUnitTestExecutionListener.class })
public class TestDB {
@Autowired
private ICourseService courseService;
@Test
@DatabaseSetup("sampleData.xml")
public void testFind() throws Exception {
List<Course> courseList = this.courseService.getAllCourses();
assertEquals(1, courseList.size());
assertEquals("A001", courseList.get(0).getCourseNumber());
}
}
Warning:
1093 [main] WARN org.dbunit.dataset.AbstractTableMetaData - Potential problem found: The configured data type factory 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'MySQL' (e.g. some datatypes may not be supported properly). In rare cases you might see this message because the list of supported database products is incomplete (list=[derby]). If so please request a java-class update via the forums.If you are using your own IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override getValidDbProducts() to specify the supported database products.
The problem can be solved when I use DBunit without spring-test-dbunit as follow:
Connection jdbcConnection = DriverManager.getConnection( "jdbc:mysql://localhost/test", "root", "root");
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
connection.getConfig().setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, new MySqlMetadataHandler());
I don't know how to solve this problem in spring-test-dbunit. Please help.