• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Britton Smith
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic