本文整理汇总了Java中org.mockito.listeners.MethodInvocationReport类的典型用法代码示例。如果您正苦于以下问题:Java MethodInvocationReport类的具体用法?Java MethodInvocationReport怎么用?Java MethodInvocationReport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodInvocationReport类属于org.mockito.listeners包,在下文中一共展示了MethodInvocationReport类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: should_call_all_listener_when_mock_throws_exception
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Test
public void should_call_all_listener_when_mock_throws_exception() throws Exception {
// given
InvocationListener listener1 = mock(InvocationListener.class, "listener1");
InvocationListener listener2 = mock(InvocationListener.class, "listener2");
Foo foo = mock(Foo.class, withSettings().invocationListeners(listener1, listener2));
doThrow(new OvenNotWorking()).when(foo).doSomething("cook");
// when
try {
foo.doSomething("cook");
fail("Exception expected.");
} catch (OvenNotWorking actualException) {
// then
InOrder orderedVerify = inOrder(listener1, listener2);
orderedVerify.verify(listener1).reportInvocation(any(MethodInvocationReport.class));
orderedVerify.verify(listener2).reportInvocation(any(MethodInvocationReport.class));
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:InvocationListenerCallbackTest.java
示例2: defaultStackLogsNothing
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Test
public void defaultStackLogsNothing() {
OffHeapStoredObjectAddressStack stack = new OffHeapStoredObjectAddressStack();
Logger lw = mock(Logger.class, withSettings().invocationListeners(new InvocationListener() {
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
fail("Unexpected invocation");
}
}));
stack.logSizes(lw, "should not be used");
}
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:OffHeapStoredObjectAddressStackJUnitTest.java
示例3: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
if(! active){
return;
}
DescribedInvocation di = methodInvocationReport.getInvocation();
MethodDescriptor md = null;
if(di instanceof InvocationOnMock){
InvocationOnMock impl = (InvocationOnMock) di;
Method method = impl.getMethod();
md = new MethodDescriptor(method, retvalType);
} else {
//hopefully it should never happen
md = getMethodDescriptor_old(di);
}
if(md.getMethodName().equals("finalize")){
//ignore it, otherwise if we mock it, we ll end up in a lot of side effects... :(
return;
}
if(onlyMockAbstractMethods() && !md.getGenericMethod().isAbstract()) {
return;
}
synchronized (map){
MethodDescriptor current = map.get(md.getID());
if(current == null){
current = md;
}
current.increaseCounter();
map.put(md.getID(),current);
}
}
开发者ID:EvoSuite,项目名称:evosuite,代码行数:38,代码来源:EvoInvocationListener.java
示例4: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
printHeader();
printStubInfo(methodInvocationReport);
printInvocation(methodInvocationReport.getInvocation());
printReturnedValueOrThrowable(methodInvocationReport);
printFooter();
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:VerboseMockInvocationLogger.java
示例5: printReturnedValueOrThrowable
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
private void printReturnedValueOrThrowable(MethodInvocationReport methodInvocationReport) {
if (methodInvocationReport.threwException()) {
String message = methodInvocationReport.getThrowable().getMessage() == null ? "" : " with message " + methodInvocationReport.getThrowable().getMessage();
printlnIndented("has thrown: " + methodInvocationReport.getThrowable().getClass() + message);
} else {
String type = (methodInvocationReport.getReturnedValue() == null) ? "" : " (" + methodInvocationReport.getReturnedValue().getClass().getName() + ")";
printlnIndented("has returned: \"" + methodInvocationReport.getReturnedValue() + "\"" + type);
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:VerboseMockInvocationLogger.java
示例6: listener
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Test
public void listener() throws Exception {
InvocationListener invocationListener = mock(InvocationListener.class);
List mockedList = mock(List.class, withSettings().invocationListeners(invocationListener));
reset(mockedList);
mockedList.clear();
verify(invocationListener).reportInvocation(any(MethodInvocationReport.class));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:ListenersLostOnResetMockTest.java
示例7: should_report_listener_exception
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Test
public void should_report_listener_exception() throws Throwable {
willThrow(new NullPointerException()).given(customListener).reportInvocation(any(MethodInvocationReport.class));
try {
notifier.handle(invocation);
fail();
} catch (MockitoException me) {
assertThat(me.getMessage())
.contains("invocation listener")
.contains("CustomListener")
.contains("threw an exception")
.contains("NullPointerException");
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:16,代码来源:InvocationNotifierHandlerTest.java
示例8: shouldThrowMockitoExceptionWhenInvocationHandlerThrowsAnything
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Test(expected = MockitoException.class)
public void shouldThrowMockitoExceptionWhenInvocationHandlerThrowsAnything() throws Throwable {
// given
InvocationListener throwingListener = mock(InvocationListener.class);
doThrow(new Throwable()).when(throwingListener).reportInvocation(any(MethodInvocationReport.class));
MockHandlerImpl<?> handler = createCorrectlyStubbedHandler(throwingListener);
// when
handler.handle(invocation);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:MockHandlerImplTest.java
示例9: async
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
public static MockSettings async(MockSettings settings) {
return settings.invocationListeners(new InvocationListener() {
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
DescribedInvocation invocation = methodInvocationReport.getInvocation();
if (invocation instanceof InvocationOnMock) {
Object mock = ((InvocationOnMock) invocation).getMock();
synchronized (mock) {
mock.notifyAll();
}
}
}
});
}
开发者ID:yngui,项目名称:mockito-async,代码行数:16,代码来源:Await.java
示例10: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
}
开发者ID:pchudzik,项目名称:springmock,代码行数:4,代码来源:InvocationListenersTest.java
示例11: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
@Override
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
System.out.println("" +
"Calling method " + methodInvocationReport.getInvocation().toString() +
" and result is " + methodInvocationReport.getReturnedValue());
}
开发者ID:pchudzik,项目名称:springmock,代码行数:7,代码来源:MockitoSamplesApplicationTests.java
示例12: printStubInfo
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
private void printStubInfo(MethodInvocationReport methodInvocationReport) {
if (methodInvocationReport.getLocationOfStubbing() != null) {
printlnIndented("stubbed: " + methodInvocationReport.getLocationOfStubbing());
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:6,代码来源:VerboseMockInvocationLogger.java
示例13: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
public void reportInvocation(MethodInvocationReport mcr) {
this.invocation = mcr.getInvocation();
this.returnValue = mcr.getReturnedValue();
this.locationOfStubbing = mcr.getLocationOfStubbing();
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:6,代码来源:InvocationListenerCallbackTest.java
示例14: reportInvocation
import org.mockito.listeners.MethodInvocationReport; //导入依赖的package包/类
public void reportInvocation(MethodInvocationReport methodInvocationReport) {
// nop
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:4,代码来源:InvocationNotifierHandlerTest.java
注:本文中的org.mockito.listeners.MethodInvocationReport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论