Java 类org.mockito.internal.invocation.realmethod.RealMethod 实例源码
项目:astor
文件:FilteredCGLIBProxyRealMethodTest.java
@Test
public void shouldRemoveMockitoInternalsFromStackTraceWhenRealMethodThrows() throws Throwable {
//given
FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(new RealMethod() {
public Object invoke(Object target, Object[] arguments) throws Throwable {
return new Foo().throwSomething();
}});
//when
try {
realMethod.invoke(null, null);
fail();
//then
} catch (Exception e) {
assertThat(e, hasMethodInStackTraceAt(0, "throwSomething"));
assertThat(e, hasMethodInStackTraceAt(1, "invoke"));
assertThat(e, hasMethodInStackTraceAt(2, "shouldRemoveMockitoInternalsFromStackTraceWhenRealMethodThrows"));
}
}
项目:astor
文件:FilteredCGLIBProxyRealMethodTest.java
@Test
public void shouldRemoveMockitoInternalsFromStackTraceWhenRealMethodThrows() throws Throwable {
//given
FilteredCGLIBProxyRealMethod realMethod = new FilteredCGLIBProxyRealMethod(new RealMethod() {
public Object invoke(Object target, Object[] arguments) throws Throwable {
return new Foo().throwSomething();
}});
//when
try {
realMethod.invoke(null, null);
fail();
//then
} catch (Exception e) {
assertThat(e, hasMethodInStackTraceAt(0, "throwSomething"));
assertThat(e, hasMethodInStackTraceAt(1, "invoke"));
assertThat(e, hasMethodInStackTraceAt(2, "shouldRemoveMockitoInternalsFromStackTraceWhenRealMethodThrows"));
}
}
项目:astor
文件:Invocation.java
public Invocation(Object mock, MockitoMethod mockitoMethod, Object[] args, int sequenceNumber, RealMethod realMethod) {
this.method = mockitoMethod;
this.mock = mock;
this.realMethod = realMethod;
this.arguments = expandVarArgs(mockitoMethod.isVarArgs(), args);
this.rawArguments = args;
this.sequenceNumber = sequenceNumber;
this.location = new Location();
}
项目:astor
文件:InvocationTest.java
@Test
public void shouldBeAbleToCallRealMethod() throws Throwable {
//when
Invocation invocation = invocationOf(Foo.class, "bark", new RealMethod() {
public Object invoke(Object target, Object[] arguments) throws Throwable {
return new Foo().bark();
}});
//then
assertEquals("woof", invocation.callRealMethod());
}
项目:astor
文件:InvocationImpl.java
public InvocationImpl(Object mock, MockitoMethod mockitoMethod, Object[] args, int sequenceNumber, RealMethod realMethod) {
this.method = mockitoMethod;
this.mock = mock;
this.realMethod = realMethod;
this.arguments = ArgumentsProcessor.expandVarArgs(mockitoMethod.isVarArgs(), args);
this.rawArguments = args;
this.sequenceNumber = sequenceNumber;
this.location = new LocationImpl();
}
项目:astor
文件:InvocationImplTest.java
@Test
public void shouldBeAbleToCallRealMethod() throws Throwable {
//when
Invocation invocation = invocationOf(Foo.class, "bark", new RealMethod() {
public Object invoke(Object target, Object[] arguments) throws Throwable {
return new Foo().bark();
}});
//then
assertEquals("woof", invocation.callRealMethod());
}
项目:astor
文件:TestBase.java
protected static Invocation invocationOf(Class<?> type, String methodName, RealMethod realMethod) throws NoSuchMethodException {
return new Invocation(new Object(), new SerializableMethod(type.getMethod(methodName,
new Class[0])), new Object[0], 1, realMethod);
}
项目:astor
文件:TestBase.java
protected static Invocation invocationOf(Class<?> type, String methodName, RealMethod realMethod) throws NoSuchMethodException {
return new InvocationImpl(new Object(), new SerializableMethod(type.getMethod(methodName,
new Class[0])), new Object[0], 1, realMethod);
}