I have a class with a forwarding method foo:
void foo( Concrete c, String s ) { c.bar( s ); }
I want to check if it really footranslates. Unfortunately, for me it Concreteis a class in a third-party library and represents a specific type, not an interface. So I have to use ClassImposteriserin JMock for mock Concrete, so in my test case I do this:
@Test
public final void testFoo() {
Mockery context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
final Concrete c = context.mock(Concrete.class);
final String s = "xxx" ;
context.checking(new Expectations() {{
oneOf (c).bar(s);
}});
new ClassUnderTest.foo( c, s );
context.assertIsSatisfied();
}
Unfortunately, it Concrete.barin turn calls a method that throws. This method is final, so I cannot override it. Also, even if I comment out a line new ClassUnderTest.foo( c, s );, an exception occurs when JMock sets exceptions, and not when it is called foo.
, , ClassUnderTest.foo Concrete.bar?
Edit:
, .
, , , "" Concrete.