use of org.mockitousage.IMethods in project mockito by mockito.
the class ReporterTest method can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists.
@Test(expected = MockitoException.class)
public void can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists() throws Exception {
Invocation dumb_invocation = new InvocationBuilder().toInvocation();
IMethods mock_with_bogus_default_answer = mock(IMethods.class, new Returns(false));
throw Reporter.delegatedMethodDoesNotExistOnDelegate(dumb_invocation.getMethod(), mock_with_bogus_default_answer, String.class);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class ClassPathLoaderTest method shouldReadConfigurationClassFromClassPath.
@Test
public void shouldReadConfigurationClassFromClassPath() {
ConfigurationAccess.getConfig().overrideDefaultAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
return "foo";
}
});
IMethods mock = mock(IMethods.class);
assertEquals("foo", mock.simpleMethod());
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationForAnnotationTest method should_verify_called_n_times_for_serialized_mock.
@Test
public void should_verify_called_n_times_for_serialized_mock() throws Exception {
List<?> value = Collections.emptyList();
when(imethodsMock.objectArgMethod(anyString())).thenReturn(value);
imethodsMock.objectArgMethod("");
// when
ByteArrayOutputStream serialized = serializeMock(imethodsMock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
verify(readObject, times(1)).objectArgMethod("");
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationForAnnotationTest method should_serialize_method_calls_using_any_string_matcher.
@Test
public void should_serialize_method_calls_using_any_string_matcher() throws Exception {
List<?> value = Collections.emptyList();
when(imethodsMock.objectArgMethod(anyString())).thenReturn(value);
// when
ByteArrayOutputStream serialized = serializeMock(imethodsMock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
assertEquals(value, readObject.objectArgMethod(""));
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationForAnnotationTest method should_verify_call_order_for_serialized_mock.
@Test
public void should_verify_call_order_for_serialized_mock() throws Exception {
imethodsMock.arrayReturningMethod();
imethodsMock2.arrayReturningMethod();
// when
ByteArrayOutputStream serialized = serializeMock(imethodsMock);
ByteArrayOutputStream serialized2 = serializeMock(imethodsMock2);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
IMethods readObject2 = deserializeMock(serialized2, IMethods.class);
InOrder inOrder = inOrder(readObject, readObject2);
inOrder.verify(readObject).arrayReturningMethod();
inOrder.verify(readObject2).arrayReturningMethod();
}
Aggregations