Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 2.0 (2.2 plugin)
-
Fix Version/s: None
-
Component/s: classloading
-
Labels:None
-
Environment:Windows, Cygwin
-
Complexity:Intermediate
Description
This is a repeat of the comment in SUREFIRE-286
I am having a problem with surefire classloading.
I had to hack the ServiceMix class:
org.apache.servicemix.http.processors.ConsumerProcessor.
I saved the hacked version as the same class name and the same package. This class does compile to target/classes. The ServiceMix jar that contains this class is included in my classpath after the target/classes directory (seen with -X)
When running mvn test, I get a test failure for the Test class that tries to create a ConsumerProcessor. We are expecting it to create "our" version of ConsumerProcessor, but it instead creates the ServiceMix version.
I have tried all the available usage options from the surefire plugin documentation to no avail. Through debug in Eclipse, I see through a watch expression (getClass().getClassLoader()) is always the IsolatedClassLoader, no matter what options we set.
This test passes in Eclipse, so I am pretty sure it is a classloading issue with the surefire plugin.
Thanks for your help in advance.
Issue Links
- duplicates
-
SUREFIRE-61
Incorrect classpath ordering
-
Adding a test case to prove this problem.
First unzip the cheese.zip into your local repo. It contains a jar file at cheese/org/cheeseburgertest-1.0.jar
cheeseburgertest-1.0.jar contains a class "test/TestClass" that has a method String sayCheese() which returns "CheeseBurger!".
Unizip the cheesetest.zip anywhere and run "mvn install". cheesetest is a simple project that contains a duplicate "test/TestClass" whose sayCheese method returns "Cheese!".
When it runs the test "test/TestClassTest", it asserts that sayCheese returns "Cheese!". But as you will see, the test fails and the surefire report shows "CheeseBurger!" was returned instead.
If you do an eclipse:eclipse and run the test in Eclipse, the test will pass as expected..