I have an issue with JMOCK 2.6 and JUINT4 when mocking ByteBuffer
@RunWith(JUnit4.class)
public class Test {
@Rule
public JUnitRuleMockery context = new JUnitRuleMockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
@Before
public void setUp() throws Exception {
}
@org.junit.Test
public void testMockByteBuffer() {
final java.nio.ByteBuffer byteBufferMock = context.mock(java.nio.ByteBuffer.class);
byteBufferMock.remaining();
}
}
I expected the test to fail, but it passes.
Just realized I can't mock final methods. java.nio.ByteBuffer.remaining() declared as final.
from: http://jmock.org/mocking-classes.html
If you want to mock final classes or final methods, the JDave library includes an unfinalizer >Instrumentation agent that can unfinalise classes before they are loaded by the JVM. They can then be >mocked by the ClassImposteriser.