Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easymock incompatible return value type error

I'm trying to create a EasyMock for this particular piece of code, such that innerfValue is of type IJavaValue, which is a subclass of IJavaObject. I've tried conventional methods of dealing with this by mocking innerfValue and then just assuming aJavaValue points to innerfValue and mocking the sendmessage method as if it were a method of innerfValue, but its hasen't been working and by the time I get to the end it gives me a incompatible return value type when I do (symbolvalue in this case is a mock object that I made to return after the sendmessage method was called on my mock innerfValue object, not the saem as the symbolValue in the other piece of code):

EasyMock.expect(((IJavaObject)symbolValue).toString()).andReturn("aValue");

Here is the piece of code

IJavaObject aJavaValue = (IJavaObject)innerfValue.getValue();
IJavaObject symbolValue = (IJavaObject) ((IJavaObject)aJavaValue).sendMessage(
    "toString", "()Ljava/lang/String;", null, thread, false);
value = symbolValue.toString();
like image 389
KWJ2104 Avatar asked Feb 20 '23 16:02

KWJ2104


1 Answers

EasyMock cannot mock the toString() method. This is why I was having the issue.

like image 176
KWJ2104 Avatar answered Feb 22 '23 08:02

KWJ2104