Problem with when and boolean

3,262 views
Skip to first unread message

Jackie G.

unread,
Nov 30, 2010, 10:51:41 AM11/30/10
to mockito
I have the following in my code...

Mockito.when(typedProperty.containsKey("requestedShipDate")).thenReturn(new
Boolean(true));

It gives me a compile error saying that the method is not valid for
arguments (boolean). I think I might have to use a primitive wrapper
of something but I am not sure how.

I am using the Java 1.4 version of Mockito 1.8

Thanks

Jackie

Brice Dutheil

unread,
Nov 30, 2010, 11:35:57 AM11/30/10
to moc...@googlegroups.com
Hello Jackie,

Unfortunately you cannot use Mockito with Java 1.4. The code base use features of Java 1.5.

As a side note in your line of code, you are using autoboxing, however this feature is not available in Java 1.4.

In similar situation you will have to wrap yourself primary types.
Mockito.when(new Boolean(typedProperty.containsKey("requestedShipDate"))).thenReturn(new Boolean(true));

However as I say, Mockito won't work with Java 1.4.

I think the old version of easymock might do the job in Java 1.4, but it's trickier to put in place.

Hope that helps,

-- 
Bryce



--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.


Jackie Gleason

unread,
Nov 30, 2010, 12:07:43 PM11/30/10
to moc...@googlegroups.com

Brice Dutheil

unread,
Nov 30, 2010, 2:20:37 PM11/30/10
to moc...@googlegroups.com
Ok I forgot about this one, this version is not officially supported by the team. As said in the wiki page, James Carr is the maintainer of this port.

Anyway the problems is the same : autoboxing is not supported in JDK prior version 5!

typedProperty.containsKey("requestedShipDate")

This method returns a native type.



-- 
Brice

Jackie Gleason

unread,
Nov 30, 2010, 2:39:13 PM11/30/10
to moc...@googlegroups.com
I see I will try this out after I get back to that environment.
Reply all
Reply to author
Forward
0 new messages