Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Expectation


    public Expectation stubs(String methodName) {
        return expects(methodName).zeroOrMoreTimes();
    }

    public Expectation expects(String methodName) {
        Expectation expects = new Expectation(this, methodName);
        expectations.add(expects);
        return expects.once();
    }
View Full Code Here


        }
    }

    public Expectation lookup(String id) {
        for (Iterator i = expectations.iterator(); i.hasNext();) {
            Expectation expectation = (Expectation) i.next();
            if (expectation.id().equals(id)) {
                return expectation;
            }
        }
        throw new VerificationException("Unknown expectation id '" + id + "' for " + this);
    }
View Full Code Here

    protected class ExpectationHandler implements InvocationHandler {
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (args == null) args = new Object[0];
           
            for (Iterator i = expectations.iterator(); i.hasNext();) {
                Expectation expectation = (Expectation) i.next();
                if (expectation.matches(method.getName(), args)) {
                    return expectation.invoke(proxy, method, args);
                }
            }
           
            // if we get here we didn't match on any expectations          
            verifyNoExpectationsMatchMethodName(method, args);
View Full Code Here

      return message.toString();
    }

    private boolean anyExpectationsMatchMethodName(String methodName) {
            for (Iterator i = expectations.iterator(); i.hasNext();) {
               Expectation expectation = (Expectation) i.next();
               if(expectation.matches(methodName)) return true;
            }
            return false;
        }
View Full Code Here

TOP

Related Classes of org.jbehave.core.mock.Expectation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.