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();
EasyMock cannot mock the toString() method. This is why I was having the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With