hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r290299 - in /jakarta/hivemind/trunk: ./ framework/src/java/org/apache/hivemind/test/ framework/src/test/hivemind/test/rules/ framework/src/test/hivemind/test/services/ framework/src/test/org/apache/hivemind/util/ jmx/src/test/org/apache/hi...
Date Mon, 19 Sep 2005 22:47:31 GMT
Author: hlship
Date: Mon Sep 19 15:47:22 2005
New Revision: 290299

URL: http://svn.apache.org/viewcvs?rev=290299&view=rev
Log:
Add several more convienience methods, related to mock objects, to HiveMindTestCase

Modified:
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
    jakarta/hivemind/trunk/framework/src/test/hivemind/test/rules/TestInstanceTranslator.java
    jakarta/hivemind/trunk/framework/src/test/hivemind/test/services/TestBuilderFactory.java
    jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/util/TestContextResource.java
    jakarta/hivemind/trunk/jmx/src/test/org/apache/hivemind/management/TestMBeanRegistry.java
    jakarta/hivemind/trunk/library/src/test/hivemind/test/lib/TestSpringLookupFactory.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=290299&r1=290298&r2=290299&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
Mon Sep 19 15:47:22 2005
@@ -468,6 +468,12 @@
      * The class to mock may be either an interface or a class. The EasyMock class extension
      * (easymockclassextension-1.1.jar) and CGLIB (cglib-full-2.01.jar) must be present in
the
      * latter case (new since 1.1).
+     * <p>
+     * This method is not deprecated, but is rarely used; typically {@link #newMock(Class)}
is used
+     * to create the control and the mock, and {@link #setReturnValue(Object, Object)} and
+     * {@link #setThrowable(Object, Throwable)} are used to while training it.
+     * {@link #getControl(Object)} is used for the rare cases where the MockControl itself
is
+     * needed.
      */
     protected MockControl newControl(Class mockClass)
     {
@@ -506,6 +512,96 @@
 
         throw new IllegalArgumentException(mock
                 + " is not a mock object controlled by any registered MockControl instance.");
+    }
+
+    /**
+     * Invoked when training a mock object to set the Throwable for the most recently invoked
+     * method.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param t
+     *            the exception the object should throw when it replays
+     * @since 1.1
+     */
+    protected void setThrowable(Object mock, Throwable t)
+    {
+        getControl(mock).setThrowable(t);
+    }
+
+    /**
+     * Invoked when training a mock object to set the return value for the most recently
invoked
+     * method. Overrides of this method exist to support a number of primitive types.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param returnValue
+     *            the value to return from the most recently invoked methods
+     * @since 1.1
+     */
+    protected void setReturnValue(Object mock, Object returnValue)
+    {
+        getControl(mock).setReturnValue(returnValue);
+    }
+
+    /**
+     * Invoked when training a mock object to set the return value for the most recently
invoked
+     * method. Overrides of this method exist to support a number of primitive types.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param returnValue
+     *            the value to return from the most recently invoked methods
+     * @since 1.1
+     */
+    protected void setReturnValue(Object mock, long returnValue)
+    {
+        getControl(mock).setReturnValue(returnValue);
+    }
+
+    /**
+     * Invoked when training a mock object to set the return value for the most recently
invoked
+     * method. Overrides of this method exist to support a number of primitive types.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param returnValue
+     *            the value to return from the most recently invoked methods
+     * @since 1.1
+     */
+    protected void setReturnValue(Object mock, float returnValue)
+    {
+        getControl(mock).setReturnValue(returnValue);
+    }
+
+    /**
+     * Invoked when training a mock object to set the return value for the most recently
invoked
+     * method. Overrides of this method exist to support a number of primitive types.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param returnValue
+     *            the value to return from the most recently invoked methods
+     * @since 1.1
+     */
+    protected void setReturnValue(Object mock, double returnValue)
+    {
+        getControl(mock).setReturnValue(returnValue);
+    }
+
+    /**
+     * Invoked when training a mock object to set the return value for the most recently
invoked
+     * method. Overrides of this method exist to support a number of primitive types.
+     * 
+     * @param mock
+     *            the mock object being trained
+     * @param returnValue
+     *            the value to return from the most recently invoked methods
+     * @since 1.1
+     */
+    protected void setReturnValue(Object mock, boolean returnValue)
+    {
+        getControl(mock).setReturnValue(returnValue);
     }
 
     /**

Modified: jakarta/hivemind/trunk/framework/src/test/hivemind/test/rules/TestInstanceTranslator.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/hivemind/test/rules/TestInstanceTranslator.java?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/test/hivemind/test/rules/TestInstanceTranslator.java
(original)
+++ jakarta/hivemind/trunk/framework/src/test/hivemind/test/rules/TestInstanceTranslator.java
Mon Sep 19 15:47:22 2005
@@ -27,7 +27,6 @@
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.schema.rules.ClassTranslator;
 import org.apache.hivemind.schema.rules.InstanceTranslator;
-import org.easymock.MockControl;
 
 /**
  * Fill in some gaps in {@link org.apache.hivemind.schema.rules.InstanceTranslator} and
@@ -45,6 +44,11 @@
         assertNull(t.translate(null, null, null, null));
     }
 
+    protected Module newModule()
+    {
+        return (Module) newMock(Module.class);
+    }
+
     public void testBadClass() throws Exception
     {
         InstanceTranslator t = new InstanceTranslator();
@@ -52,12 +56,11 @@
         Location l = new LocationImpl(getResource("TestInstanceTranslator.class"), 50);
         e.setLocation(l);
 
-        MockControl c = newControl(Module.class);
-        Module m = (Module) c.getMock();
+        Module m = newModule();
 
         m.resolveType("bad.class.Name");
         ApplicationRuntimeException cause = new ApplicationRuntimeException("failure");
-        c.setThrowable(cause);
+        setThrowable(m, cause);
 
         replayControls();
 
@@ -77,11 +80,10 @@
     {
         InstanceTranslator t = new InstanceTranslator();
 
-        MockControl c = newControl(Module.class);
-        Module m = (Module) c.getMock();
+        Module m = newModule();
 
         m.resolveType("Bean");
-        c.setReturnValue(IntHolder.class);
+        setReturnValue(m, IntHolder.class);
 
         replayControls();
 

Modified: jakarta/hivemind/trunk/framework/src/test/hivemind/test/services/TestBuilderFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/hivemind/test/services/TestBuilderFactory.java?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/test/hivemind/test/services/TestBuilderFactory.java
(original)
+++ jakarta/hivemind/trunk/framework/src/test/hivemind/test/services/TestBuilderFactory.java
Mon Sep 19 15:47:22 2005
@@ -176,79 +176,86 @@
         assertNotNull(h.getClassResolver());
     }
 
-    public void testAutowire()
+    protected ServiceImplementationFactoryParameters newParameters()
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
+        return (ServiceImplementationFactoryParameters) newMock(ServiceImplementationFactoryParameters.class);
+    }
 
-        MockControl c = newControl(Module.class);
-        Module module = (Module) c.getMock();
+    protected Module newModule()
+    {
+        return (Module) newMock(Module.class);
+    }
 
-        ErrorHandler eh = (ErrorHandler) newMock(ErrorHandler.class);
+    protected ErrorHandler newErrorHandler()
+    {
+        return (ErrorHandler) newMock(ErrorHandler.class);
+    }
 
-        MockControl logc = newControl(Log.class);
-        Log log = (Log) logc.getMock();
+    protected Log newLog()
+    {
+        return (Log) newMock(Log.class);
+    }
 
-        MockControl messagesControl = newControl(Messages.class);
-        Messages messages = (Messages) messagesControl.getMock();
+    protected Messages newMessages()
+    {
+        return (Messages) newMock(Messages.class);
+    }
 
-        ErrorLog errorLog = (ErrorLog) newMock(ErrorLog.class);
+    protected ErrorLog newErrorLog()
+    {
+        return (ErrorLog) newMock(ErrorLog.class);
+    }
+
+    public void testAutowire()
+    {
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        ErrorHandler eh = newErrorHandler();
+        Log log = newLog();
+        Messages messages = newMessages();
+        ErrorLog errorLog = newErrorLog();
 
         // Normally I try and get all the invocations into chronological
         // order ... but with this refactoring, that's painful; these
         // are in an order that appeases junit.
 
-        fp.getLog();
-        fpc.setReturnValue(log);
+        trainGetLog(fp, log);
 
-        fp.getServiceId();
-        fpc.setReturnValue("foo.bar.Baz");
+        trainGetServiceId(fp, "foo.bar.Baz");
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+        trainGetInvokingModule(fp, module);
 
-        module.resolveType("hivemind.test.services.AutowireTarget");
-        c.setReturnValue(AutowireTarget.class);
+        trainResolveType(module, "hivemind.test.services.AutowireTarget", AutowireTarget.class);
 
-        fp.getLog();
-        fpc.setReturnValue(log);
+        trainGetLog(fp, log);
 
-        debug(fpc, fp, logc, log, "Autowired property log to " + log);
+        trainDebug(fp, log, "Autowired property log to " + log);
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+        trainGetInvokingModule(fp, module);
 
-        module.getClassResolver();
-        c.setReturnValue(getClassResolver());
+        trainGetClassResolver(module, getClassResolver());
 
-        debug(fpc, fp, logc, log, "Autowired property classResolver to " + getClassResolver());
+        trainDebug(fp, log, "Autowired property classResolver to " + getClassResolver());
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+        trainGetInvokingModule(fp, module);
 
-        module.getMessages();
-        c.setReturnValue(messages);
+        trainGetMessages(module, messages);
 
-        debug(fpc, fp, logc, log, "Autowired property messages to " + messages);
+        trainDebug(fp, log, "Autowired property messages to " + messages);
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+        trainGetInvokingModule(fp, module);
 
-        module.getErrorHandler();
-        c.setReturnValue(eh);
+        trainGetErrorHandler(module, eh);
 
-        debug(fpc, fp, logc, log, "Autowired property errorHandler to " + eh);
+        trainDebug(fp, log, "Autowired property errorHandler to " + eh);
 
-        fp.getServiceId();
-        fpc.setReturnValue("foo.bar.Baz");
+        trainGetServiceId(fp);
 
-        debug(fpc, fp, logc, log, "Autowired property serviceId to foo.bar.Baz");
+        trainDebug(fp, log, "Autowired property serviceId to foo.bar.Baz");
 
-        fp.getErrorLog();
-        fpc.setReturnValue(errorLog);
+        trainGetErrorLog(fp, errorLog);
 
-        debug(fpc, fp, logc, log, "Autowired property errorLog to " + errorLog);
+        trainDebug(fp, log, "Autowired property errorLog to " + errorLog);
 
         replayControls();
 
@@ -274,43 +281,87 @@
         verifyControls();
     }
 
-    private void debug(MockControl fpc, ServiceImplementationFactoryParameters fp,
-            MockControl logc, Log log, String string)
+    private void trainGetErrorLog(ServiceImplementationFactoryParameters fp, ErrorLog errorLog)
     {
-        fp.getLog();
-        fpc.setReturnValue(log);
+        fp.getErrorLog();
+        setReturnValue(fp, errorLog);
+    }
 
-        log.isDebugEnabled();
-        logc.setReturnValue(true);
+    private void trainGetServiceId(ServiceImplementationFactoryParameters fp)
+    {
+        fp.getServiceId();
+        setReturnValue(fp, "foo.bar.Baz");
+    }
 
-        log.debug(string);
+    private void trainGetErrorHandler(Module module, ErrorHandler eh)
+    {
+        module.getErrorHandler();
+        setReturnValue(module, eh);
     }
 
-    /**
-     * Test that BuilderFactory will invoke the "initializeService" method by default.
-     */
-    public void testAutowireInitializer()
+    private void trainGetMessages(Module module, Messages messages)
     {
-        MockControl c = newControl(Module.class);
-        Module module = (Module) c.getMock();
+        module.getMessages();
+        setReturnValue(module, messages);
+    }
 
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
+    private void trainGetClassResolver(Module module, ClassResolver resolver)
+    {
+        module.getClassResolver();
+        setReturnValue(module, resolver);
+    }
 
-        Log log = (Log) newMock(Log.class);
+    private void trainResolveType(Module module, String typeName, Class type)
+    {
+        module.resolveType(typeName);
+        setReturnValue(module, type);
+    }
 
-        fp.getLog();
-        fpc.setReturnValue(log);
+    private void trainGetInvokingModule(ServiceImplementationFactoryParameters fp, Module
module)
+    {
+        fp.getInvokingModule();
+        setReturnValue(fp, module);
+    }
 
+    protected void trainGetServiceId(ServiceImplementationFactoryParameters fp, String serviceId)
+    {
         fp.getServiceId();
-        fpc.setReturnValue("foo");
+        setReturnValue(fp, serviceId);
+    }
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+    protected void trainGetLog(ServiceImplementationFactoryParameters fp, Log log)
+    {
+        fp.getLog();
+        setReturnValue(fp, log);
+    }
+
+    private void trainDebug(ServiceImplementationFactoryParameters fp, Log log, String string)
+    {
+        fp.getLog();
+        setReturnValue(fp, log);
+
+        log.isDebugEnabled();
+        setReturnValue(log, true);
 
-        module.resolveType("hivemind.test.services.InitializeFixture");
-        c.setReturnValue(InitializeFixture.class);
+        log.debug(string);
+    }
+
+    /**
+     * Test that BuilderFactory will invoke the "initializeService" method by default.
+     */
+    public void testAutowireInitializer()
+    {
+        Module module = newModule();
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Log log = newLog();
+
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo");
+        trainGetInvokingModule(fp, module);
+        trainResolveType(
+                module,
+                "hivemind.test.services.InitializeFixture",
+                InitializeFixture.class);
 
         replayControls();
 
@@ -332,26 +383,17 @@
      */
     public void testInitializer()
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
-
-        MockControl c = newControl(Module.class);
-        Module module = (Module) c.getMock();
-
-        Log log = (Log) newMock(Log.class);
-
-        fp.getLog();
-        fpc.setReturnValue(log);
-
-        fp.getServiceId();
-        fpc.setReturnValue("foo");
-
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
-
-        module.resolveType("hivemind.test.services.InitializeFixture");
-        c.setReturnValue(InitializeFixture.class);
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        Log log = newLog();
+
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo");
+        trainGetInvokingModule(fp, module);
+        trainResolveType(
+                module,
+                "hivemind.test.services.InitializeFixture",
+                InitializeFixture.class);
 
         replayControls();
 
@@ -369,39 +411,24 @@
 
     public void testAutowireServices()
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
-
-        MockControl mc = newControl(Module.class);
-        Module module = (Module) mc.getMock();
-
-        MockControl lc = newControl(Log.class);
-        Log log = (Log) lc.getMock();
-
-        fp.getLog();
-        fpc.setReturnValue(log);
-
-        fp.getServiceId();
-        fpc.setReturnValue("foo");
-
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
-
-        module.resolveType("hivemind.test.services.ServiceAutowireTarget");
-        mc.setReturnValue(ServiceAutowireTarget.class);
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        Log log = newLog();
+
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo");
+        trainGetInvokingModule(fp, module);
+        trainResolveType(
+                module,
+                "hivemind.test.services.ServiceAutowireTarget",
+                ServiceAutowireTarget.class);
 
         StringHolder h = new StringHolderImpl();
 
-        module.containsService(String.class);
-        mc.setReturnValue(false);
-        module.containsService(StringHolder.class);
-        mc.setReturnValue(true);
-        module.getService(StringHolder.class);
-        mc.setReturnValue(h);
-
-        log.isDebugEnabled();
-        lc.setReturnValue(false);
+        trainContainsService(module, String.class, false);
+        trainContainsService(module, StringHolder.class, true);
+        trainGetService(module, StringHolder.class, h);
+        trainIsDebugEnabled(log);
 
         replayControls();
 
@@ -417,33 +444,40 @@
         verifyControls();
     }
 
-    public void testAutowireServicesFailure()
+    private void trainIsDebugEnabled(Log log)
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
-
-        MockControl mc = newControl(Module.class);
-        Module module = (Module) mc.getMock();
-
-        Log log = (Log) newMock(Log.class);
-
-        fp.getLog();
-        fpc.setReturnValue(log);
+        log.isDebugEnabled();
+        setReturnValue(log, false);
+    }
 
-        fp.getServiceId();
-        fpc.setReturnValue("foo.bar");
+    private void trainGetService(Module module, Class serviceInterface, Object service)
+    {
+        module.getService(serviceInterface);
+        setReturnValue(module, service);
+    }
 
-        fp.getInvokingModule();
-        fpc.setReturnValue(module);
+    private void trainContainsService(Module module, Class serviceInterface, boolean containsService)
+    {
+        module.containsService(serviceInterface);
+        setReturnValue(module, containsService);
+    }
 
-        module.resolveType("hivemind.test.services.ServiceAutowireTarget");
-        mc.setReturnValue(ServiceAutowireTarget.class);
+    public void testAutowireServicesFailure()
+    {
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        Log log = newLog();
+
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo.bar");
+        trainGetInvokingModule(fp, module);
+        trainResolveType(
+                module,
+                "hivemind.test.services.ServiceAutowireTarget",
+                ServiceAutowireTarget.class);
 
-        module.containsService(String.class);
-        mc.setReturnValue(false);
-        module.containsService(StringHolder.class);
-        mc.setReturnValue(false);
+        trainContainsService(module, String.class, false);
+        trainContainsService(module, StringHolder.class, false);
 
         replayControls();
 
@@ -461,41 +495,29 @@
 
     public void testAutowireConstructor() throws Exception
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
-
-        MockControl mc = newControl(Module.class);
-        Module module = (Module) mc.getMock();
-
-        MockControl lc = newControl(Log.class);
-        Log log = (Log) lc.getMock();
-
-        fp.getLog();
-        fpc.setReturnValue(log);
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        Log log = newLog();
 
-        fp.getServiceId();
-        fpc.setReturnValue("foo");
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo");
 
         fp.getInvokingModule();
-        fpc.setReturnValue(module, MockControl.ONE_OR_MORE);
+        getControl(fp).setReturnValue(module, MockControl.ONE_OR_MORE);
 
-        module.resolveType("hivemind.test.services.ConstructorAutowireTarget");
-        mc.setReturnValue(ConstructorAutowireTarget.class);
+        trainResolveType(
+                module,
+                "hivemind.test.services.ConstructorAutowireTarget",
+                ConstructorAutowireTarget.class);
 
-        module.containsService(Comparable.class);
-        mc.setReturnValue(false);
-
-        module.containsService(StringHolder.class);
-        mc.setReturnValue(true);
+        trainContainsService(module, Comparable.class, false);
+        trainContainsService(module, StringHolder.class, true);
 
         StringHolder h = new StringHolderImpl();
 
-        module.getService(StringHolder.class);
-        mc.setReturnValue(h);
+        trainGetService(module, StringHolder.class, h);
 
-        module.getClassResolver();
-        mc.setReturnValue(getClassResolver());
+        trainGetClassResolver(module, getClassResolver());
 
         replayControls();
 
@@ -515,33 +537,24 @@
 
     public void testAutowireConstructorFailure() throws Exception
     {
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
+        ServiceImplementationFactoryParameters fp = newParameters();
+        Module module = newModule();
+        Log log = newLog();
 
-        MockControl mc = newControl(Module.class);
-        Module module = (Module) mc.getMock();
-
-        MockControl lc = newControl(Log.class);
-        Log log = (Log) lc.getMock();
-
-        fp.getLog();
-        fpc.setReturnValue(log);
-
-        fp.getServiceId();
-        fpc.setReturnValue("foo");
+        trainGetLog(fp, log);
+        trainGetServiceId(fp, "foo");
 
         fp.getInvokingModule();
-        fpc.setReturnValue(module, MockControl.ONE_OR_MORE);
-
-        module.resolveType("hivemind.test.services.ConstructorAutowireTarget");
-        mc.setReturnValue(ConstructorAutowireTarget.class);
-
-        module.containsService(Comparable.class);
-        mc.setReturnValue(false);
+        getControl(fp).setReturnValue(module, MockControl.ONE_OR_MORE);
 
-        module.containsService(StringHolder.class);
-        mc.setReturnValue(false, 2);
+        trainResolveType(
+                module,
+                "hivemind.test.services.ConstructorAutowireTarget",
+                ConstructorAutowireTarget.class);
+
+        trainContainsService(module, Comparable.class, false);
+        trainContainsService(module, StringHolder.class, false);
+        trainContainsService(module, StringHolder.class, false);
 
         replayControls();
 

Modified: jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/util/TestContextResource.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/util/TestContextResource.java?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/util/TestContextResource.java
(original)
+++ jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/util/TestContextResource.java
Mon Sep 19 15:47:22 2005
@@ -21,7 +21,6 @@
 
 import org.apache.hivemind.Resource;
 import org.apache.hivemind.test.HiveMindTestCase;
-import org.easymock.MockControl;
 
 /**
  * Tests for {@link org.apache.hivemind.util.ContextResource}.
@@ -57,11 +56,10 @@
 
     public void testLocalizationExists() throws Exception
     {
-        MockControl control = newControl(ServletContext.class);
-        ServletContext context = (ServletContext) control.getMock();
+        ServletContext context = newContext();
 
         context.getResource("/foo/bar/baz_en.html");
-        control.setReturnValue(new URL("http://foo.com"));
+        setReturnValue(context, new URL("http://foo.com"));
 
         replayControls();
 
@@ -77,14 +75,13 @@
 
     public void testLocalizationSame() throws Exception
     {
-        MockControl control = newControl(ServletContext.class);
-        ServletContext context = (ServletContext) control.getMock();
+        ServletContext context = newContext();
 
         context.getResource("/foo/bar/baz_en.html");
-        control.setReturnValue(null);
+        setReturnValue(context, null);
 
         context.getResource("/foo/bar/baz.html");
-        control.setReturnValue(new URL("http://foo.com"));
+        setReturnValue(context, new URL("http://foo.com"));
 
         replayControls();
 
@@ -99,14 +96,13 @@
 
     public void testLocalizationMissing() throws Exception
     {
-        MockControl control = newControl(ServletContext.class);
-        ServletContext context = (ServletContext) control.getMock();
+        ServletContext context = newContext();
 
         context.getResource("/foo/bar/baz_en.html");
-        control.setReturnValue(null);
+        setReturnValue(context, null);
 
         context.getResource("/foo/bar/baz.html");
-        control.setReturnValue(null);
+        setReturnValue(context, null);
 
         replayControls();
 

Modified: jakarta/hivemind/trunk/jmx/src/test/org/apache/hivemind/management/TestMBeanRegistry.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/jmx/src/test/org/apache/hivemind/management/TestMBeanRegistry.java?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/jmx/src/test/org/apache/hivemind/management/TestMBeanRegistry.java
(original)
+++ jakarta/hivemind/trunk/jmx/src/test/org/apache/hivemind/management/TestMBeanRegistry.java
Mon Sep 19 15:47:22 2005
@@ -28,10 +28,7 @@
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.events.RegistryShutdownListener;
-import org.apache.hivemind.impl.DefaultClassResolver;
 import org.apache.hivemind.impl.DefaultErrorHandler;
-import org.apache.hivemind.impl.ModuleImpl;
-import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.management.impl.MBeanRegistrationContribution;
 import org.apache.hivemind.management.impl.MBeanRegistryImpl;
@@ -52,8 +49,6 @@
 {
     private ErrorHandler errorHandler;
 
-    private MockControl logControl;
-
     private Log log;
 
     private MockControl serverControl;
@@ -65,7 +60,6 @@
     public void setUp()
     {
         errorHandler = new DefaultErrorHandler();
-        logControl = (MockControl) newControl(Log.class);
         log = LogFactory.getLog(MBeanRegistry.class);
         serverControl = newControl(MBeanServer.class);
         server = (MBeanServer) serverControl.getMock();
@@ -221,16 +215,6 @@
         mbeanRegistry.registerMBean(calculatorMBean, Calculator.class, objectName);
 
         verifyControls();
-    }
-
-    private Module newModule()
-    {
-        ModuleImpl result = new ModuleImpl();
-
-        result.setClassResolver(new DefaultClassResolver());
-        result.setPackageName("");
-
-        return result;
     }
 
 }

Modified: jakarta/hivemind/trunk/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
(original)
+++ jakarta/hivemind/trunk/library/src/test/hivemind/test/lib/TestSpringLookupFactory.java
Mon Sep 19 15:47:22 2005
@@ -22,7 +22,6 @@
 import org.apache.hivemind.lib.impl.SpringBeanParameter;
 import org.apache.hivemind.lib.impl.SpringLookupFactory;
 import org.apache.hivemind.test.HiveMindTestCase;
-import org.easymock.MockControl;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.xml.XmlBeanFactory;
 import org.springframework.core.io.ClassPathResource;
@@ -51,12 +50,9 @@
     {
         SpringLookupFactory lf = new SpringLookupFactory();
 
-        MockControl control = newControl(BeanFactory.class);
-        BeanFactory beanFactory = (BeanFactory) control.getMock();
+        BeanFactory beanFactory = (BeanFactory) newMock(BeanFactory.class);
 
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
+        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
newMock(ServiceImplementationFactoryParameters.class);
 
         lf.setDefaultBeanFactory(beanFactory);
 
@@ -65,13 +61,13 @@
         Object fred = new Object();
 
         beanFactory.getBean("fred", List.class);
-        control.setReturnValue(fred);
+        setReturnValue(beanFactory, fred);
 
         fp.getFirstParameter();
-        fpc.setReturnValue(param);
+        setReturnValue(fp, param);
 
         fp.getServiceInterface();
-        fpc.setReturnValue(List.class);
+        setReturnValue(fp, List.class);
 
         replayControls();
 
@@ -85,26 +81,22 @@
     public void testBeanSpecificFactory()
     {
         SpringLookupFactory lf = new SpringLookupFactory();
+        BeanFactory beanFactory = (BeanFactory) newMock(BeanFactory.class);
 
-        MockControl control = newControl(BeanFactory.class);
-        BeanFactory beanFactory = (BeanFactory) control.getMock();
-
-        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
-        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
-                .getMock();
+        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
newMock(ServiceImplementationFactoryParameters.class);
 
         SpringBeanParameter param = buildParameter("fred", beanFactory);
 
         Object fred = new Object();
 
         beanFactory.getBean("fred", List.class);
-        control.setReturnValue(fred);
+        setReturnValue(beanFactory, fred);
 
         fp.getFirstParameter();
-        fpc.setReturnValue(param);
+        setReturnValue(fp, param);
 
         fp.getServiceInterface();
-        fpc.setReturnValue(List.class);
+        setReturnValue(fp, List.class);
 
         replayControls();
 

Modified: jakarta/hivemind/trunk/status.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/status.xml?rev=290299&r1=290298&r2=290299&view=diff
==============================================================================
--- jakarta/hivemind/trunk/status.xml (original)
+++ jakarta/hivemind/trunk/status.xml Mon Sep 19 15:47:22 2005
@@ -31,7 +31,7 @@
   </todo>
   <changes>
     <release version="1.1-beta-4" date="unreleased">
-      
+      <action type="add" dev="HLS">Add several more convienience methods, related to
mock objects, to HiveMindTestCase</action>      
     </release>
     <release version="1.1-beta-3" date="Aug 22 2005">
       <action type="update" dev="HLS">Change dist targets to use SSH passphrase for
authentication.</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