1*06a9728cSXin Li /* 2*06a9728cSXin Li * Copyright 2001-2009 OFFIS, Tammo Freese 3*06a9728cSXin Li * 4*06a9728cSXin Li * Licensed under the Apache License, Version 2.0 (the "License"); 5*06a9728cSXin Li * you may not use this file except in compliance with the License. 6*06a9728cSXin Li * You may obtain a copy of the License at 7*06a9728cSXin Li * 8*06a9728cSXin Li * http://www.apache.org/licenses/LICENSE-2.0 9*06a9728cSXin Li * 10*06a9728cSXin Li * Unless required by applicable law or agreed to in writing, software 11*06a9728cSXin Li * distributed under the License is distributed on an "AS IS" BASIS, 12*06a9728cSXin Li * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*06a9728cSXin Li * See the License for the specific language governing permissions and 14*06a9728cSXin Li * limitations under the License. 15*06a9728cSXin Li */ 16*06a9728cSXin Li package org.easymock; 17*06a9728cSXin Li 18*06a9728cSXin Li /** 19*06a9728cSXin Li * Controls all the mock objects created by it. 20*06a9728cSXin Li * For details, see the EasyMock documentation. 21*06a9728cSXin Li */ 22*06a9728cSXin Li public interface IMocksControl { 23*06a9728cSXin Li /** 24*06a9728cSXin Li * Creates a mock object that implements the given interface. 25*06a9728cSXin Li * @param <T> the interface that the mock object should implement. 26*06a9728cSXin Li * @param toMock the class of the interface that the mock object should implement. 27*06a9728cSXin Li * @return the mock object. 28*06a9728cSXin Li */ createMock(Class<T> toMock)29*06a9728cSXin Li <T> T createMock(Class<T> toMock); 30*06a9728cSXin Li 31*06a9728cSXin Li /** 32*06a9728cSXin Li * Creates a mock object that implements the given interface. 33*06a9728cSXin Li * @param name the name of the mock object . 34*06a9728cSXin Li * @param toMock the class of the interface that the mock object should implement. 35*06a9728cSXin Li * @param <T> the interface that the mock object should implement. 36*06a9728cSXin Li * @return the mock object. 37*06a9728cSXin Li * @throws IllegalArgumentException if the name is not a valid Java identifier. 38*06a9728cSXin Li */ createMock(String name, Class<T> toMock)39*06a9728cSXin Li <T> T createMock(String name, Class<T> toMock); 40*06a9728cSXin Li 41*06a9728cSXin Li /** 42*06a9728cSXin Li * Removes all expectations for the mock objects of this control. 43*06a9728cSXin Li */ reset()44*06a9728cSXin Li void reset(); 45*06a9728cSXin Li 46*06a9728cSXin Li /** 47*06a9728cSXin Li * Removes all expectations for the mock objects of this control and turn 48*06a9728cSXin Li * them to nice mocks. 49*06a9728cSXin Li */ resetToNice()50*06a9728cSXin Li void resetToNice(); 51*06a9728cSXin Li 52*06a9728cSXin Li /** 53*06a9728cSXin Li * Removes all expectations for the mock objects of this control and turn 54*06a9728cSXin Li * them to default mocks. 55*06a9728cSXin Li */ resetToDefault()56*06a9728cSXin Li void resetToDefault(); 57*06a9728cSXin Li 58*06a9728cSXin Li /** 59*06a9728cSXin Li * Removes all expectations for the mock objects of this control and turn 60*06a9728cSXin Li * them to strict mocks. 61*06a9728cSXin Li */ resetToStrict()62*06a9728cSXin Li void resetToStrict(); 63*06a9728cSXin Li 64*06a9728cSXin Li /** 65*06a9728cSXin Li * Switches the control from record mode to replay mode. 66*06a9728cSXin Li */ replay()67*06a9728cSXin Li void replay(); 68*06a9728cSXin Li 69*06a9728cSXin Li /** 70*06a9728cSXin Li * Verifies that all expectations were met. 71*06a9728cSXin Li */ verify()72*06a9728cSXin Li void verify(); 73*06a9728cSXin Li 74*06a9728cSXin Li /** 75*06a9728cSXin Li * Switches order checking on and off. 76*06a9728cSXin Li * @param state <code>true</code> switches order checking on, <code>false</code> switches it off. 77*06a9728cSXin Li */ checkOrder(boolean state)78*06a9728cSXin Li void checkOrder(boolean state); 79*06a9728cSXin Li 80*06a9728cSXin Li /** 81*06a9728cSXin Li * Makes the mock thread safe. 82*06a9728cSXin Li * 83*06a9728cSXin Li * @param threadSafe If the mock should be thread safe or not 84*06a9728cSXin Li */ makeThreadSafe(boolean threadSafe)85*06a9728cSXin Li void makeThreadSafe(boolean threadSafe); 86*06a9728cSXin Li 87*06a9728cSXin Li /** 88*06a9728cSXin Li * Check that the mock is called from only one thread 89*06a9728cSXin Li * 90*06a9728cSXin Li * @param shouldBeUsedInOneThread 91*06a9728cSXin Li * If it should be used in one thread only or not 92*06a9728cSXin Li */ checkIsUsedInOneThread(boolean shouldBeUsedInOneThread)93*06a9728cSXin Li void checkIsUsedInOneThread(boolean shouldBeUsedInOneThread); 94*06a9728cSXin Li } 95