I am trying to use DBUnit to run integration tests, however I am finding myself unable to insert the primary key columns, which obviously will not work with foreign keys referencing the primary key later on in the file.
For example, I have the following DDL:
CREATE TABLE attributes(
attribute_id UUID NOT NULL DEFAULT uuid_generate_v4(),
attribute VARCHAR(64) NOT NULL,
description TEXT NOT NULL,
PRIMARY KEY(attribute_id)
);
And the DBUnit setup XML looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<attributes attribute_id="233bc966-4fcd-4b46-88e6-3e07090f322d" attribute="Empathy" description="Empathy Description" />
</dataset>
When I attempt to run the test, I get the failure:
org.dbunit.dataset.NoSuchColumnException: attributes.ATTRIBUTE_ID - (Non-uppercase input column: attribute_id) in ColumnNameToIndexes cache map. Note that the
ap's column names are NOT case sensitive.
Here is the test being run:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@DbUnitConfiguration(dataSetLoader = TestConfiguration.FlatXmlDataLoaderProxy.class)
@ContextConfiguration(classes = {ApplicationConfiguration.class, TestConfiguration.class})
@TestExecutionListeners({
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class,
TransactionalTestExecutionListener.class,
DbUnitTestExecutionListener.class
})
public class ApplicationAssessmentJobTest {
@Autowired
private ApplicationAssessmentJob applicationAssessmentJob;
@Test
@DatabaseSetup("/dbunit/ApplicationAssessmentJobTestSetup.xml")
@DatabaseTearDown("dbunit/ApplicationAssessmentJobTestTearDown.xml")
public void testJob() {
ApplicationAssessmentJobModel model = new ApplicationAssessmentJobModel();
model.setApplicationId(UUID.fromString("41fa1d51-c1ee-482b-80a7-a6eefda64436"));
applicationAssessmentJob.receiveMessage(model);
}
}
This error shown does not appear to be directly related to the underlying issue. If I remove the attribute_id
column from the XML, the record is inserted.