customstub.java
来自「不管是测试驱动开发或者是其它的开发模式」· Java 代码 · 共 34 行
JAVA
34 行
/* Copyright (c) 2000-2004 jMock.org
*/
package org.jmock.core.stub;
import org.jmock.core.Stub;
/**
* A partial implementation of the Stub interface that makes it convenient to implement
* application-specific stubs with inline anonymous classes:
* <pre>
* final String name = "NAME";
* final StringBuffer buffer = new StringBuffer();
* <p/>
* mock.expect("describeTo", C.args(C.same(buffer))), new CustomStub("appends name to buffer") {
* public Object invoke( Invocation invocation ) throws Throwable {
* return buffer.append(name);
* }
* } );
* </pre>
*/
public abstract class CustomStub implements Stub
{
private String description;
public CustomStub( String description ) {
this.description = description;
}
public StringBuffer describeTo( StringBuffer buffer ) {
return buffer.append(description);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?