This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes jmock class loader can not find the interface org.jmock.internal.CaptureControl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "jmock class loader can not find the interface org.jmock.internal.CaptureControl" Watch "jmock class loader can not find the interface org.jmock.internal.CaptureControl" New topic
Author

jmock class loader can not find the interface org.jmock.internal.CaptureControl

Britton Smith
Greenhorn

Joined: Dec 10, 2009
Posts: 1
jmock class loader can not find the interface org.jmock.internal.CaptureControl.

I am having a weird issue where a JMock-JUnit test works in eclipse but not in cygwin. I have verified the classpath should not be an issue since all of the jMock 2.5 classes are in my classpath, but I could be missing something.

the code:
<pre>
public class ReeherNextPageProcessingFilterMockTest extends ReeherMockTestCase {
public HttpSession mockSession;
public HttpServletRequest mockRequest;
public HttpServletResponse mockResponse;
public FilterChain filterChain;
public Users user;

@Override
public void setUp() throws Exception {
super.setUp();

user = null;
System.out.println("this.getClass().getClassLoader():" + this.getClass().getClassLoader());
Class clz = this.getClass().getClassLoader().loadClass("org.jmock.internal.CaptureControl");
System.out.println("clz:" + clz);

// this is how the Mock testing should be done! but doesn't work in Ant
mockSession = getMockery().mock(HttpSession.class);
mockRequest = getMockery().mock(HttpServletRequest.class);
mockResponse = getMockery().mock(HttpServletResponse.class);
filterChain = getMockery().mock(FilterChain.class);

getMockery().checking(new Expectations() {{
allowing(mockRequest).getSession();
will(returnValue(null));
//will(returnValue(mockSession));

// make sure this method is always executed
exactly(1).of(filterChain).doFilter(with(same(mockRequest)), with(same(mockResponse)));
}});
}

public void testDummy() {
}
}
</pre>

the error message:
<pre>
mockTest:
[junit] Running com.reeher.common.spring.ReeherNextPageProcessingFilterMockTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.531 sec
[junit] Testsuite: com.reeher.common.spring.ReeherNextPageProcessingFilterMockTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 1.531 sec

[junit] ------------- Standard Output ---------------
[junit] this.getClass().getClassLoader()rg.apache.tools.ant.loader.AntClassLoader2@18f51f
[junit] clz:interface org.jmock.internal.CaptureControl
[junit] ------------- ---------------- ---------------
[junit] Testcase: testDummy(com.reeher.common.spring.ReeherNextPageProcessingFilterMockTest): Caused an ERROR
[junit] interface org.jmock.internal.CaptureControl is not visible from class loader
[junit] java.lang.IllegalArgumentException: interface org.jmock.internal.CaptureControl is not visible from class loader
[junit] at java.lang.reflect.Proxy.getProxyClass(Unknown Source)
[junit] at java.lang.reflect.Proxy.newProxyInstance(Unknown Source)
[junit] at org.jmock.lib.JavaReflectionImposteriser.imposterise(JavaReflectionImposteriser.java:31)
[junit] at org.jmock.Mockery.mock(Mockery.java:139)
[junit] at com.reeher.common.spring.ReeherNextPageProcessingFilterMockTest.setUp(ReeherNextPageProcessingFilterMockTest.java:30)
</pre>

line 30 of ReeherNextPageProcessingFilterMockTest is "mockSession = getMockery().mock(HttpSession.class);"

any ideas? any help is appreciated. we do have various mock tests in our code base that execute correctly in both eclipse and cygwin.
 
 
subject: jmock class loader can not find the interface org.jmock.internal.CaptureControl
 
Similar Threads
JUnit and AbstractTestCase Problem
Running JUnit testcases with Maven
Juint task in Ant
Ant runs tests twice?
Ant 1.7 + Junit 4 problems