Skip to content

TestContext extracted to interface in Spring 4 #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erfranco opened this issue Dec 17, 2013 · 9 comments
Closed

TestContext extracted to interface in Spring 4 #46

erfranco opened this issue Dec 17, 2013 · 9 comments

Comments

@erfranco
Copy link

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
Copy link

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
Copy link
Author

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

@erfranco erfranco reopened this Dec 17, 2013
philwebb pushed a commit that referenced this issue Dec 17, 2013
Use reflection to access Spring's TestContext to protect against
IncompatibleClassChangeError caused by the fact that it changed from
a class to an interface between Spring 3.2 and 4.0

Issue: #46
@philwebb
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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

@ndjordjevic
Copy link

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
Copy link

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
Copy link

nowakp1 commented Mar 19, 2014

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
Copy link

rodsong commented Nov 20, 2014

can use

spring-test-dbunit
1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants