⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockstubmatcherscollection.java

📁 不管是测试驱动开发或者是其它的开发模式
💻 JAVA
字号:
/*  Copyright (c) 2000-2004 jMock.org
 */
package test.jmock.builder.testsupport;

import junit.framework.Assert;
import org.jmock.core.InvocationMatcher;
import org.jmock.core.Stub;
import org.jmock.core.StubMatchersCollection;
import org.jmock.expectation.ExpectationValue;
import org.jmock.util.Verifier;


public class MockStubMatchersCollection implements StubMatchersCollection
{
    public ExpectationValue addedMatcher = new ExpectationValue("added matcher");
    public ExpectationValue addedMatcherType = new ExpectationValue("added matcher type");

    public void addMatcher( InvocationMatcher matcher ) {
        addedMatcher.setActual(matcher);
        addedMatcherType.setActual(matcher.getClass());
    }

    public ExpectationValue setStubType = new ExpectationValue("set stub type");
    public ExpectationValue setStub = new ExpectationValue("set stub");
    public ExpectationValue setStubReturnValue = new ExpectationValue("set stub return value");

    public void setStub( Stub stub ) {
        setStub.setActual(stub);
        setStubType.setActual(stub.getClass());

        if (setStubReturnValue.hasExpectations()) {
            try {
                setStubReturnValue.setActual(stub.invoke(null));
            }
            catch (Throwable t) {
                Assert.fail("unexpected throw from stub: " + t);
            }
        }
    }

    public ExpectationValue setName = new ExpectationValue("setName name");

    public void setName( String name ) {
        setName.setActual(name);
    }

    public void verifyExpectations() {
        Verifier.verifyObject(this);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -