Closed GoogleCodeExporter closed 9 years ago
Hi Daniel,
I got it working with the following:
"An easymock mock with a java interface" should {
"work with a java method returning a genericized list" in {
val ls: java.util.List[Bar] = new java.util.ArrayList[Bar]
ls.add(new Bar(1))
val m = mock[Foo]
m.getBars.asInstanceOf[java.util.List[Bar]] returns ls
replay(m)
m.getBars.get(0).i must_== 1
}
}
and
public interface Foo {
public java.util.List<? extends Bar> getBars();
}
public class Bar {
public int i;
public Bar(int i) {
this.i = i;
}
}
Did you try to force the cast to List<Bar> like this, or is it not possible in
your
specific case?
Original comment by etorrebo...@gmail.com
on 22 Sep 2009 at 10:40
I'm embarrassed to admit that I didn't think to try that. At least to me, it
has
always seemed a little strange that mock frameworks stub methods by first
*calling*
that method and then asserting what the return value *should* have been. Just
way
too weird...
Thanks for the assist!
Original comment by djspie...@gmail.com
on 22 Sep 2009 at 2:49
Original issue reported on code.google.com by
djspie...@gmail.com
on 21 Sep 2009 at 10:37