I am trying to mock the following JNA call using EasyMock
convInterface = (ConvInterface) Native.loadLibrary(libraryLocation,ConvInterface.class);
Using this test method
@Test
public void testLib() {
Capture<Class<?>> myClassCapture = EasyMock.newCapture();
PowerMock.mockStatic(Native.class);
EasyMock.expect(Native.loadLibrary(EasyMock.isA(String.class), EasyMock.capture(myClassCapture))).andReturn(mockConvInterface);
PowerMock.replay(Native.class);
ConvServiceImpl myLib = new ConvServiceImpl();
myLib.instantiateConvLibrary();
PowerMock.verify(Native.class);
}
I am getting the following error using version 4.3.0 of the JNA library
The method andReturn(capture#1-of ?) in the type IExpectationSetters<capture#1-of ?> is not applicable for the arguments (ConvInterface)
The same code is fine with version 4.2.0 of the JNA library
Here are the method signatures for the method I am trying to mock
Version 4.2.0
public static Object loadLibrary(String name, Class interfaceClass) {
Version 4.3
public static <T> T loadLibrary(String name, Class<T> interfaceClass) {
How do I go about mocking the return of a generic return type using EasyMock?
Thanks Damien