springtestdbunit / spring-test-dbunit

Integration between the Spring testing framework and DBUnit
http://springtestdbunit.github.com/spring-test-dbunit/
Apache License 2.0
475 stars 238 forks source link

TestContext extracted to interface in Spring 4 #46

Closed erfranco closed 10 years ago

erfranco commented 10 years ago

Upgrading tests from Spring 3.2.6 (all worked well) to Spring 4.0.0, recently released, an error arises: java.lang.IncompatibleClassChangeError: Found interface org.springframework.test.context.TestContext, but class was expected at com.github.springtestdbunit.TestExecutionListenerChain.runChain(TestExecutionListenerChain.java:134) ~[spring-test-dbunit-1.0.1.jar:na]

This is due to the fact that the TestContext is now an interface, so the DefaultTestContext (or another implementation) should be fed to the chain

ndjordjevic commented 10 years ago

I have the same issue and if you upgrade spring-test-dbunit to use spring-test 4.0.0.RELEASE everything works well. The problem is that the projects with 3.x.x spring will not work with spring-test-dbunit which depends on spring 4 and vice versa ...

erfranco commented 10 years ago

Thanks for the advice, but how can you upgrade spring-test-dbunit? To say, do you recompile changing the spring-test-dbunit pom.xml?

philwebb commented 10 years ago

I have started a 1.1.0 version on master that targets Spring 4.0 whilst remaining compatible with Spring 3.2.

Could you try building the latest master and let me know if that works for you.

erfranco commented 10 years ago

All is ok. I have installed locally 1.1.0-SNAPSHOT, upgrading java.version property to 1.6, as Spring 4 requires, and adding ${java.version} to the compiler. Thanks for publishing in snapshot repository. Ermanno

erfranco commented 10 years ago

<target>${java.version}<target> (apologize html enities...)

ndjordjevic commented 10 years ago

I did the same and it worked. Some tests still fail, but mostly regarding the @Rule support, but since that feature will be dropped it doesn't matter. Also, 'mvn install' failed, in fact to be able to complete this I had to exclude all tests from the maven lifecycle. Also, I had to change the com.github.springtestdbunit.testutils.ExtendedTestContextManager class and replace this line: getTestContext().markApplicationContextDirty(); with getTestContext().markApplicationContextDirty(DirtiesContext.HierarchyMode.EXHAUSTIVE); ... to able to compile the code.

jason-patel-ensighten commented 10 years ago

Sorry if I'm a bit out of the loop here, I tried to line up this thread to the commit histories and maven artifact publish history, but thought i should ask just to make sure, has the 1.1.0 artifact been published and verified to continue to work with spring 3.2.x? I'm still seeing this issue when using spring 3.2.8, downgrading to 1.0.1 solves it for now, but I was hoping to leverage the query feature in the expected database annotation introduced in 1.1.0.

Great work by the way!

nowakp1 commented 10 years ago

I have the same issue at Spring 3.2.0. With version 1.0.1 it works fine but with version 1.1.1 I get the error about TestContext. I suggest to add small note about dependence between dbUnit version and Spring version at main documentation page.

rodsong commented 9 years ago

can use

spring-test-dbunit
        <version>1.1.0</version>