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