hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r233319 - in /jakarta/hivemind/trunk: framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java status.xml
Date Thu, 18 Aug 2005 13:51:58 GMT
Author: hlship
Date: Thu Aug 18 06:51:51 2005
New Revision: 233319

URL: http://svn.apache.org/viewcvs?rev=233319&view=rev
Log:
Add getControl() method to HiveMindTestCase, to locate a managed MockControl from a mock object
instance.

Modified:
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
    jakarta/hivemind/trunk/status.xml

Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java?rev=233319&r1=233318&r2=233319&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
(original)
+++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
Thu Aug 18 06:51:51 2005
@@ -55,7 +55,7 @@
  */
 public abstract class HiveMindTestCase extends TestCase
 {
-    ///CLOVER:OFF
+    // /CLOVER:OFF
 
     /**
      * An instance of {@link DefaultClassResolver} that can be used by tests.
@@ -482,6 +482,33 @@
     }
 
     /**
+     * Accesses the control for a previously created mock object. Iterates over the list
of managed
+     * controls until one is found whose mock object identity equals the mock object provided.
+     * 
+     * @param Mock
+     *            object whose control is needed
+     * @return the corresponding MockControl if found
+     * @throws IllegalArgumentException
+     *             if not found
+     * @since 1.1
+     */
+
+    protected MockControl getControl(Object mock)
+    {
+        Iterator i = _controls.iterator();
+        while (i.hasNext())
+        {
+            MockControl control = (MockControl) i.next();
+
+            if (control.getMock() == mock)
+                return control;
+        }
+
+        throw new IllegalArgumentException(mock
+                + " is not a mock object controlled by any registered MockControl instance.");
+    }
+
+    /**
      * Adds the control to the list of managed controls used by {@link #replayControls()}
and
      * {@link #verifyControls()}.
      */
@@ -557,9 +584,9 @@
     private int _line = 1;
 
     /**
-     * Returns a new {@link Location} instance. The resource is the test class, and the line
-     * number increments by one from one for each invocation (thus each call will get a unique
-     * instance not equal to any previously obtained instance).
+     * Returns a new {@link Location} instance. The resource is the test class, and the line
number
+     * increments by one from one for each invocation (thus each call will get a unique instance
not
+     * equal to any previously obtained instance).
      * 
      * @since 1.1
      */

Modified: jakarta/hivemind/trunk/status.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/status.xml?rev=233319&r1=233318&r2=233319&view=diff
==============================================================================
--- jakarta/hivemind/trunk/status.xml (original)
+++ jakarta/hivemind/trunk/status.xml Thu Aug 18 06:51:51 2005
@@ -36,6 +36,7 @@
       <action type="fix" dev="JC" fixes-bug="HIVEMIND-148" due-to="Ben Fortuna">Registry.getServiceIds()
doesn't support concrete class service points.</action>
       <action type="fix" dev="JC" fixes-bug="HIVEMIND-135" due-to="Richard Hensley">Upgrade
Build to use a hivebuild.properties from the users home directory.</action>
       <action type="update" dev="HLS">Reorganize the examples so that they can be tracked
by Clover. Fix the format of times in the JUnit Test Report.</action>
+      <action type="add" dev="HLS">Add getControl() method to HiveMindTestCase, to
locate a managed MockControl from a mock object instance.</action>
     </release>
     <release version="1.1-beta-2" date="Jun 28 2005">
       <action type="fix" dev="JC" fixes-bug="HIVEMIND-122" due-to="Michael Frericks">IBM
JDK 1.4.1 and java.net.URL.openStream causes NPE"</action>



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message