springtestdbunit/spring-test-dbunit

@DatabaseSetup and @ExpectDatabase will ignore the column which is array type

Opened this issue · 2 comments

I use postgresql and define a table contains column which is defined the Array type.

Here is test method

    @Test
    @DatabaseSetup("/template/questionSubjectTemplate.xml")
    public void testFindQuestionSubject() {

    }

Here is my .xml template

<?xml version="1.0" encoding="utf-8" ?>
<dataset>
    <t_question_subject id="1" attributes="{'label1', 'label2'}" content="This is the content of a question." type="1"
                        filter="1" cuser_id="1"
                        cuser_name="Test User"
                        deleted="0" enabled="1"></t_question_subject>
</dataset>

Then i come across an error:

dataset.NoSuchColumnException: t_question_subject.ATTRIBUTES -  (Non-uppercase input column: attributes) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.

	at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)
	at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:89)
	at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:150)
	at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
	at com.github.springtestdbunit.DbUnitRunner.setupOrTeardown(DbUnitRunner.java:183)
	at com.github.springtestdbunit.DbUnitRunner.beforeTestMethod(DbUnitRunner.java:75)
	at com.github.springtestdbunit.DbUnitTestExecutionListener.beforeTestMethod(DbUnitTestExecutionListener.java:185)
	at com.github.springtestdbunit.TestExecutionListenerChain$3.call(TestExecutionListenerChain.java:94)
	at com.github.springtestdbunit.TestExecutionListenerChain.runChain(TestExecutionListenerChain.java:127)
	at com.github.springtestdbunit.TestExecutionListenerChain.forwards(TestExecutionListenerChain.java:116)
	at com.github.springtestdbunit.TestExecutionListenerChain.beforeTestMethod(TestExecutionListenerChain.java:92)
	at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

@ExpectDatabase has the same issue.

Have the same problem with @DatabaseSetup.

I experience the same issue, @ExpectedDatabase cannot handle a PostgreSql array of String and it ends up with the error message NoSuchColumnException.
Tested with dbunit-2.7.0.jar