You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/07/15 20:19:12 UTC

svn commit: r422275 [1/2] - in /tapestry/tapestry4/trunk/tapestry-portlet: ./ src/test/org/apache/tapestry/portlet/

Author: jkuhnert
Date: Sat Jul 15 11:19:11 2006
New Revision: 422275

URL: http://svn.apache.org/viewvc?rev=422275&view=rev
Log:
Converted unit tests to new base tests/ testng

Modified:
    tapestry/tapestry4/trunk/tapestry-portlet/pom.xml
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/BasePortletWebTestCase.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/PortletWebSessionTest.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletApplicationSpecificationInitializer.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletRenderer.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebActivator.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebContext.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebRequest.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebResponse.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestRenderService.java
    tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestRenderWebResponse.java

Modified: tapestry/tapestry4/trunk/tapestry-portlet/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/pom.xml?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/pom.xml Sat Jul 15 11:19:11 2006
@@ -118,12 +118,6 @@
             <artifactId>easymockclassextension</artifactId>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>3.8.1</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.9</version>

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/BasePortletWebTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/BasePortletWebTestCase.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/BasePortletWebTestCase.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/BasePortletWebTestCase.java Sat Jul 15 11:19:11 2006
@@ -14,18 +14,20 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.testng.AssertJUnit.assertEquals;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 
-import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.BaseComponentTestCase;
 
 /**
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public abstract class BasePortletWebTestCase extends HiveMindTestCase
+public abstract class BasePortletWebTestCase extends BaseComponentTestCase
 {
     protected Enumeration newEnumeration()
     {

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/PortletWebSessionTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/PortletWebSessionTest.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/PortletWebSessionTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/PortletWebSessionTest.java Sat Jul 15 11:19:11 2006
@@ -14,11 +14,16 @@
 
 package org.apache.tapestry.portlet;
 
-import java.util.List;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
 
-import javax.portlet.PortletSession;
+import java.util.List;
 
 import org.apache.tapestry.web.WebSession;
+import org.testng.annotations.Test;
+
+import javax.portlet.PortletSession;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletWebSession}.
@@ -26,6 +31,7 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
+@Test
 public class PortletWebSessionTest extends BasePortletWebTestCase
 {
 
@@ -33,23 +39,22 @@
     {
         PortletSession session = newSession();
 
-        session.getAttributeNames();
-        setReturnValue(session, newEnumeration());
+        expect(session.getAttributeNames()).andReturn(newEnumeration());
 
-        replayControls();
+        replay();
 
         WebSession ws = new PortletWebSession(session);
-
+        
         List l = ws.getAttributeNames();
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     private PortletSession newSession()
     {
-        return (PortletSession) newMock(PortletSession.class);
+        return newMock(PortletSession.class);
     }
 
     public void testGetAttribute()
@@ -58,16 +63,15 @@
 
         PortletSession session = newSession();
 
-        session.getAttribute("attr");
-        setReturnValue(session, attribute);
-
-        replayControls();
+        expect(session.getAttribute("attr")).andReturn(attribute);
+        
+        replay();
 
         WebSession ws = new PortletWebSession(session);
 
         assertSame(attribute, ws.getAttribute("attr"));
 
-        verifyControls();
+        verify();
     }
 
     public void testSetAttribute()
@@ -78,29 +82,28 @@
 
         session.setAttribute("name", attribute);
 
-        replayControls();
+        replay();
 
         WebSession ws = new PortletWebSession(session);
 
         ws.setAttribute("name", attribute);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetId()
     {
         PortletSession session = newSession();
 
-        session.getId();
-        setReturnValue(session, "abc");
-
-        replayControls();
+        expect(session.getId()).andReturn("abc");
+        
+        replay();
 
         WebSession ws = new PortletWebSession(session);
 
         assertEquals("abc", ws.getId());
 
-        verifyControls();
+        verify();
     }
 
     public void testInvalidate()
@@ -109,12 +112,12 @@
 
         session.invalidate();
 
-        replayControls();
+        replay();
 
         WebSession ws = new PortletWebSession(session);
 
         ws.invalidate();
 
-        verifyControls();
+        verify();
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java Sat Jul 15 11:19:11 2006
@@ -14,7 +14,14 @@
 
 package org.apache.tapestry.portlet;
 
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+
+import org.apache.hivemind.Registry;
+import org.apache.tapestry.BaseComponentTestCase;
+import org.testng.annotations.Test;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -23,16 +30,14 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
-import org.apache.hivemind.Registry;
-import org.apache.hivemind.test.HiveMindTestCase;
-
 /**
  * Tests for {@link org.apache.tapestry.portlet.ApplicationPortlet}.
  * 
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestApplicationPortlet extends HiveMindTestCase
+@Test
+public class TestApplicationPortlet extends BaseComponentTestCase
 {
     public static class ApplicationPortletFixture extends ApplicationPortlet
     {
@@ -51,66 +56,67 @@
 
     private PortletApplicationInitializer newInitializer()
     {
-        return (PortletApplicationInitializer) newMock(PortletApplicationInitializer.class);
+        return newMock(PortletApplicationInitializer.class);
     }
 
     private ActionRequestServicer newActionRequestServicer()
     {
-        return (ActionRequestServicer) newMock(ActionRequestServicer.class);
+        return newMock(ActionRequestServicer.class);
     }
 
     private RenderRequestServicer newRenderRequestServicer()
     {
-        return (RenderRequestServicer) newMock(RenderRequestServicer.class);
+        return newMock(RenderRequestServicer.class);
     }
 
     private Registry newRegistry(PortletApplicationInitializer initializer,
             ActionRequestServicer actionRequestServicer, RenderRequestServicer renderRequestServicer)
     {
-        Registry registry = (Registry) newMock(Registry.class);
-
+        Registry registry = newMock(Registry.class);
+        checkOrder(registry, false);
+        
         expect(registry.getService(
                 "tapestry.portlet.PortletApplicationInitializer",
                 PortletApplicationInitializer.class)).andReturn(initializer);
-
+        
         expect(registry.getService("tapestry.portlet.ActionRequestServicer", ActionRequestServicer.class))
         .andReturn(actionRequestServicer);
-
+        
         expect(registry.getService("tapestry.portlet.RenderRequestServicer", RenderRequestServicer.class))
         .andReturn(renderRequestServicer);
-
+        
         return registry;
     }
 
     private PortletConfig newConfig()
     {
-        return (PortletConfig) newMock(PortletConfig.class);
+        return newMock(PortletConfig.class);
     }
 
     private ActionRequest newActionRequest()
     {
-        return (ActionRequest) newMock(ActionRequest.class);
+        return newMock(ActionRequest.class);
     }
 
     private ActionResponse newActionResponse()
     {
-        return (ActionResponse) newMock(ActionResponse.class);
+        return newMock(ActionResponse.class);
     }
 
     private RenderRequest newRenderRequest()
     {
-        return (RenderRequest) newMock(RenderRequest.class);
+        return newMock(RenderRequest.class);
     }
 
     private RenderResponse newRenderResponse()
     {
-        return (RenderResponse) newMock(RenderResponse.class);
+        return newMock(RenderResponse.class);
     }
 
     public void testParseOptionalDescriptors() throws Exception
     {
-        PortletConfig config = (PortletConfig)newMock(PortletConfig.class);
-        PortletContext context = (PortletContext)newMock(PortletContext.class);
+        PortletConfig config = newMock(PortletConfig.class);
+        PortletContext context = newMock(PortletContext.class);
 
         checkOrder(config, false);
         checkOrder(context, false);
@@ -132,18 +138,20 @@
 
         expect(context.getResource("/WEB-INF/myportlet.application")).andReturn(null);
 
-        replayControls();
+        replay();
 
         ApplicationPortlet ap = new ApplicationPortlet();
 
         ap.init(config);
-
+        
         assertNotNull(ap._registry);
         assertNotNull(ap._actionRequestServicer);
         assertNotNull(ap._renderRequestServicer);
 
         assertEquals("parsed", ap._registry.expandSymbols("${module-portlet}", null));
         assertEquals("parsed", ap._registry.expandSymbols("${module-plain}", null));
+        
+        verify();
     }
 
     public void testInitAndDestroy() throws Exception
@@ -157,21 +165,21 @@
 
         initializer.initialize(config);
 
-        replayControls();
+        replay();
 
         ApplicationPortletFixture portlet = new ApplicationPortletFixture(registry);
 
         portlet.init(config);
 
-        verifyControls();
+        verify();
 
         registry.shutdown();
 
-        replayControls();
+        replay();
 
         portlet.destroy();
 
-        verifyControls();
+        verify();
     }
 
     public void testProcessAction() throws Exception
@@ -179,20 +187,20 @@
         PortletApplicationInitializer initializer = newInitializer();
         ActionRequestServicer actionRequestServicer = newActionRequestServicer();
         RenderRequestServicer renderRequestServicer = newRenderRequestServicer();
-
+        
         Registry registry = newRegistry(initializer, actionRequestServicer, renderRequestServicer);
-
+        
         PortletConfig config = newConfig();
-
+        
         initializer.initialize(config);
 
-        replayControls();
+        replay();
 
         ApplicationPortletFixture portlet = new ApplicationPortletFixture(registry);
 
         portlet.init(config);
 
-        verifyControls();
+        verify();
 
         ActionRequest request = newActionRequest();
         ActionResponse response = newActionResponse();
@@ -203,11 +211,11 @@
 
         registry.cleanupThread();
 
-        replayControls();
+        replay();
 
         portlet.processAction(request, response);
 
-        verifyControls();
+        verify();
     }
 
     public void testProcessRender() throws Exception
@@ -222,13 +230,13 @@
 
         initializer.initialize(config);
 
-        replayControls();
+        replay();
 
         ApplicationPortletFixture portlet = new ApplicationPortletFixture(registry);
 
         portlet.init(config);
 
-        verifyControls();
+        verify();
 
         RenderRequest request = newRenderRequest();
         RenderResponse response = newRenderResponse();
@@ -239,10 +247,10 @@
 
         registry.cleanupThread();
 
-        replayControls();
+        replay();
 
         portlet.render(request, response);
 
-        verifyControls();
+        verify();
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java Sat Jul 15 11:19:11 2006
@@ -14,19 +14,24 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.WindowState;
-
-import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.IPage;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.PageNotFoundException;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.WindowState;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.MatchingPortletPageResolver}.
@@ -34,27 +39,18 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestMatchingPortletPageResolver extends HiveMindTestCase
+@Test
+public class TestMatchingPortletPageResolver extends BaseComponentTestCase
 {
-    private IRequestCycle newCycle()
-    {
-        return (IRequestCycle) newMock(IRequestCycle.class);
-    }
-
-    private IPage newPage()
-    {
-        return (IPage) newMock(IPage.class);
-    }
-
+    
     private IRequestCycle newCycle(String pageName)
     {
         IPage page = newPage();
-
-        MockControl control = newControl(IRequestCycle.class);
-        IRequestCycle cycle = (IRequestCycle) control.getMock();
-
-        cycle.getPage(pageName);
-        control.setReturnValue(page);
+        
+        IRequestCycle cycle = newCycle();
+        checkOrder(cycle, false);
+        
+        expect(cycle.getPage(pageName)).andReturn(page);
 
         return cycle;
     }
@@ -74,15 +70,14 @@
     public void testNoMatchOnContentType()
     {
         IRequestCycle cycle = newCycle();
-
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
-
-        trainContentType(requestc, request, "text/xml");
+        
+        PortletRequest request = newMock(PortletRequest.class);
+        
+        trainContentType(request, "text/xml");
 
         List l = Collections.singletonList(newContribution("text/html", null, "wierd", "Wierd"));
 
-        replayControls();
+        replay();
 
         MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
         resolver.setContributions(l);
@@ -91,21 +86,20 @@
 
         assertNull(resolver.getPageNameForRequest(cycle));
 
-        verifyControls();
+        verify();
     }
 
     public void testNoMatchOnPortletMode()
     {
         IRequestCycle cycle = newCycle();
+        
+        PortletRequest request = newMock(PortletRequest.class);
 
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
-
-        trainPortletMode(requestc, request, "edit");
-
+        trainPortletMode(request, "edit");
+        
         List l = Collections.singletonList(newContribution(null, "view", null, "Wierd"));
 
-        replayControls();
+        replay();
 
         MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
         resolver.setContributions(l);
@@ -114,21 +108,20 @@
 
         assertNull(resolver.getPageNameForRequest(cycle));
 
-        verifyControls();
+        verify();
     }
 
     public void testNoMatchOnWindowState()
     {
         IRequestCycle cycle = newCycle();
 
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
+        PortletRequest request = newMock(PortletRequest.class);
 
-        trainWindowState(requestc, request, "huge");
+        trainWindowState(request, "huge");
 
         List l = Collections.singletonList(newContribution(null, null, "tiny", "Wierd"));
 
-        replayControls();
+        replay();
 
         MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
         resolver.setContributions(l);
@@ -137,24 +130,23 @@
 
         assertNull(resolver.getPageNameForRequest(cycle));
 
-        verifyControls();
+        verify();
     }
 
     public void testSortingCounts()
     {
         IRequestCycle cycle = newCycle("EditHuge");
 
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
-
+        PortletRequest request = newMock(PortletRequest.class);
+        
         List l = new ArrayList();
         l.add(newContribution(null, "edit", null, "EditNormal"));
         l.add(newContribution(null, "edit", "huge", "EditHuge"));
+        
+        trainPortletMode(request, "edit");
+        trainWindowState(request, "huge");
 
-        trainPortletMode(requestc, request, "edit");
-        trainWindowState(requestc, request, "huge");
-
-        replayControls();
+        replay();
 
         MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
         resolver.setContributions(l);
@@ -163,35 +155,30 @@
 
         assertEquals("EditHuge", resolver.getPageNameForRequest(cycle));
 
-        verifyControls();
+        verify();
     }
 
     public void testPageMissing()
     {
         IPage page = newPage();
+        IRequestCycle cycle = newCycle();
 
-        MockControl cyclec = newControl(IRequestCycle.class);
-        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
-
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
+        PortletRequest request = newMock(PortletRequest.class);
 
         List l = new ArrayList();
         l.add(newContribution(null, "edit", null, "EditNormal"));
         l.add(newContribution(null, "edit", "huge", "EditHuge"));
 
-        trainPortletMode(requestc, request, "edit");
-        trainWindowState(requestc, request, "huge");
-
-        cycle.getPage("EditHuge");
-        cyclec.setThrowable(new PageNotFoundException("missing!"));
-
-        trainPortletMode(requestc, request, "edit");
-
-        cycle.getPage("EditNormal");
-        cyclec.setReturnValue(page);
+        trainPortletMode(request, "edit");
+        trainWindowState(request, "huge");
 
-        replayControls();
+        expect(cycle.getPage("EditHuge")).andThrow(new PageNotFoundException("missing!"));
+        
+        trainPortletMode(request, "edit");
+
+        expect(cycle.getPage("EditNormal")).andReturn(page);
+        
+        replay();
 
         MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
         resolver.setContributions(l);
@@ -200,28 +187,25 @@
 
         assertEquals("EditNormal", resolver.getPageNameForRequest(cycle));
 
-        verifyControls();
+        verify();
     }
 
-    private void trainContentType(MockControl control, PortletRequest request, String contentType)
+    private void trainContentType(PortletRequest request, String contentType)
     {
-        request.getResponseContentType();
-        control.setReturnValue(contentType);
+        expect(request.getResponseContentType()).andReturn(contentType);
     }
 
-    private void trainPortletMode(MockControl control, PortletRequest request, String modeName)
+    private void trainPortletMode(PortletRequest request, String modeName)
     {
         PortletMode mode = new PortletMode(modeName);
 
-        request.getPortletMode();
-        control.setReturnValue(mode);
+        expect(request.getPortletMode()).andReturn(mode);
     }
 
-    private void trainWindowState(MockControl control, PortletRequest request, String stateName)
+    private void trainWindowState(PortletRequest request, String stateName)
     {
         WindowState state = new WindowState(stateName);
 
-        request.getWindowState();
-        control.setReturnValue(state);
+        expect(request.getWindowState()).andReturn(state);
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletApplicationSpecificationInitializer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletApplicationSpecificationInitializer.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletApplicationSpecificationInitializer.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletApplicationSpecificationInitializer.java Sat Jul 15 11:19:11 2006
@@ -14,19 +14,22 @@
 
 package org.apache.tapestry.portlet;
 
-import java.net.URL;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
 
-import javax.portlet.PortletConfig;
+import java.net.URL;
 
 import org.apache.hivemind.Resource;
-import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.parse.ISpecificationParser;
 import org.apache.tapestry.services.ApplicationGlobals;
 import org.apache.tapestry.services.impl.ApplicationGlobalsImpl;
 import org.apache.tapestry.spec.IApplicationSpecification;
 import org.apache.tapestry.web.WebContext;
 import org.apache.tapestry.web.WebContextResource;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
+
+import javax.portlet.PortletConfig;
 
 /**
  * Tests for {@link PortletApplicationSpecificationInitializer}.
@@ -34,46 +37,42 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletApplicationSpecificationInitializer extends HiveMindTestCase
+@Test
+public class TestPortletApplicationSpecificationInitializer extends BaseComponentTestCase
 {
     private PortletConfig newConfig(String name)
     {
-        MockControl control = newControl(PortletConfig.class);
-        PortletConfig config = (PortletConfig) control.getMock();
-
-        config.getPortletName();
-        control.setReturnValue(name);
-
+        PortletConfig config = newMock(PortletConfig.class);
+        
+        expect(config.getPortletName()).andReturn(name);
+        
         return config;
     }
 
     private IApplicationSpecification newSpecification()
     {
-        return (IApplicationSpecification) newMock(IApplicationSpecification.class);
+        return newMock(IApplicationSpecification.class);
     }
 
     private ISpecificationParser newParser(Resource input, IApplicationSpecification specification)
     {
-        MockControl control = newControl(ISpecificationParser.class);
-        ISpecificationParser parser = (ISpecificationParser) control.getMock();
-
-        parser.parseApplicationSpecification(input);
-        control.setReturnValue(specification);
+        ISpecificationParser parser = newMock(ISpecificationParser.class);
 
+        expect(parser.parseApplicationSpecification(input)).andReturn(specification);
+        
         return parser;
     }
 
     private ApplicationGlobals newGlobals()
     {
-        return (ApplicationGlobals) newMock(ApplicationGlobals.class);
+        return newMock(ApplicationGlobals.class);
     }
 
     public void testFoundInSubdir() throws Exception
     {
         PortletConfig config = newConfig("myportlet");
-
-        MockControl contextc = newControl(WebContext.class);
-        WebContext context = (WebContext) contextc.getMock();
+        
+        WebContext context = newMock(WebContext.class);
 
         IApplicationSpecification specification = newSpecification();
 
@@ -81,9 +80,8 @@
 
         URL fakeURL = getClass().getResource("hivemodule.xml");
 
-        context.getResource("/WEB-INF/myportlet/myportlet.application");
-        contextc.setReturnValue(fakeURL);
-
+        expect(context.getResource("/WEB-INF/myportlet/myportlet.application")).andReturn(fakeURL);
+        
         Resource expectedResource = new WebContextResource(context,
                 "/WEB-INF/myportlet/myportlet.application");
 
@@ -93,7 +91,7 @@
 
         globals.storeSpecification(specification);
 
-        replayControls();
+        replay();
 
         PortletApplicationSpecificationInitializer init = new PortletApplicationSpecificationInitializer();
         init.setContext(context);
@@ -102,15 +100,14 @@
 
         init.initialize(config);
 
-        verifyControls();
+        verify();
     }
 
     public void testFoundInRootDir() throws Exception
     {
         PortletConfig config = newConfig("myportlet");
 
-        MockControl contextc = newControl(WebContext.class);
-        WebContext context = (WebContext) contextc.getMock();
+        WebContext context = newMock(WebContext.class);
 
         IApplicationSpecification specification = newSpecification();
 
@@ -118,11 +115,9 @@
 
         URL fakeURL = getClass().getResource("hivemodule.xml");
 
-        context.getResource("/WEB-INF/myportlet/myportlet.application");
-        contextc.setReturnValue(null);
+        expect(context.getResource("/WEB-INF/myportlet/myportlet.application")).andReturn(null);
 
-        context.getResource("/WEB-INF/myportlet.application");
-        contextc.setReturnValue(fakeURL);
+        expect(context.getResource("/WEB-INF/myportlet.application")).andReturn(fakeURL);
 
         Resource expectedResource = new WebContextResource(context,
                 "/WEB-INF/myportlet.application");
@@ -133,7 +128,7 @@
 
         globals.storeSpecification(specification);
 
-        replayControls();
+        replay();
 
         PortletApplicationSpecificationInitializer init = new PortletApplicationSpecificationInitializer();
         init.setContext(context);
@@ -142,23 +137,20 @@
 
         init.initialize(config);
 
-        verifyControls();
+        verify();
     }
 
     public void testNotFound() throws Exception
     {
         PortletConfig config = newConfig("myportlet");
 
-        MockControl contextc = newControl(WebContext.class);
-        WebContext context = (WebContext) contextc.getMock();
-
-        context.getResource("/WEB-INF/myportlet/myportlet.application");
-        contextc.setReturnValue(null);
-
-        context.getResource("/WEB-INF/myportlet.application");
-        contextc.setReturnValue(null);
+        WebContext context = newMock(WebContext.class);
 
-        replayControls();
+        expect(context.getResource("/WEB-INF/myportlet/myportlet.application")).andReturn(null);
+        
+        expect(context.getResource("/WEB-INF/myportlet.application")).andReturn(null);
+        
+        replay();
 
         ApplicationGlobals globals = new ApplicationGlobalsImpl();
 
@@ -168,7 +160,7 @@
 
         init.initialize(config);
 
-        verifyControls();
+        verify();
 
         IApplicationSpecification spec = globals.getSpecification();
 
@@ -176,4 +168,4 @@
         assertEquals(new WebContextResource(context, "/WEB-INF/myportlet.application"), spec
                 .getSpecificationLocation());
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java Sat Jul 15 11:19:11 2006
@@ -14,15 +14,20 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
+
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.ILink;
 import org.apache.tapestry.services.LinkFactory;
 import org.apache.tapestry.services.ResponseRenderer;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletHomeService}.
@@ -30,42 +35,35 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletHomeService extends HiveMindTestCase
+@Test
+public class TestPortletHomeService extends BaseComponentTestCase
 {
     private ResponseRenderer newResponseRenderer()
     {
-        return (ResponseRenderer) newMock(ResponseRenderer.class);
-    }
-
-    private IRequestCycle newCycle()
-    {
-        return (IRequestCycle) newMock(IRequestCycle.class);
+        return newMock(ResponseRenderer.class);
     }
 
     private PortletRequestGlobals newRequestGlobals(boolean isRender)
     {
-        MockControl control = newControl(PortletRequestGlobals.class);
-        PortletRequestGlobals globals = (PortletRequestGlobals) control.getMock();
-
-        globals.isRenderRequest();
-        control.setReturnValue(isRender);
-
+        PortletRequestGlobals globals = newMock(PortletRequestGlobals.class);
+        checkOrder(globals, false);
+        
+        expect(globals.isRenderRequest()).andReturn(isRender);
+        
         return globals;
     }
 
     private PortletRenderer newPortletRenderer()
     {
-        return (PortletRenderer) newMock(PortletRenderer.class);
+        return newMock(PortletRenderer.class);
     }
 
     private PortletPageResolver newResolver(IRequestCycle cycle, String pageName)
     {
-        MockControl control = newControl(PortletPageResolver.class);
-        PortletPageResolver resolver = (PortletPageResolver) control.getMock();
-
-        resolver.getPageNameForRequest(cycle);
-        control.setReturnValue(pageName);
+        PortletPageResolver resolver = newMock(PortletPageResolver.class);
 
+        expect(resolver.getPageNameForRequest(cycle)).andReturn(pageName);
+        
         return resolver;
     }
 
@@ -78,7 +76,7 @@
 
         renderer.renderPage(cycle, "ZePage");
 
-        replayControls();
+        replay();
 
         PortletHomeService phs = new PortletHomeService();
         phs.setPageResolver(resolver);
@@ -87,20 +85,22 @@
 
         phs.service(cycle);
 
-        verifyControls();
+        verify();
     }
 
     public void testIsActionRequest() throws Exception
     {
         IRequestCycle cycle = newCycle();
         PortletRequestGlobals globals = newRequestGlobals(false);
+        
         ResponseRenderer renderer = newResponseRenderer();
+        
         PortletPageResolver resolver = newResolver(cycle, "ZePage");
-
+        
         cycle.activate("ZePage");
         renderer.renderResponse(cycle);
 
-        replayControls();
+        replay();
 
         PortletHomeService phs = new PortletHomeService();
         phs.setResponseRenderer(renderer);
@@ -109,27 +109,26 @@
 
         phs.service(cycle);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetLink()
     {
         Map parameters = new HashMap();
-
-        LinkFactory factory = (LinkFactory) newMock(LinkFactory.class);
-        ILink link = (ILink) newMock(ILink.class);
+        
+        LinkFactory factory = newMock(LinkFactory.class);
+        ILink link = newMock(ILink.class);
 
         PortletHomeService phs = new PortletHomeService();
         phs.setLinkFactory(factory);
+        
+        expect(factory.constructLink(phs, false, parameters, true)).andReturn(link);
 
-        factory.constructLink(phs, false, parameters, true);
-        setReturnValue(factory, link);
-
-        replayControls();
+        replay();
 
         assertSame(link, phs.getLink(false, null));
 
-        verifyControls();
+        verify();
     }
 
     public void testGetLinkWithParameter()
@@ -144,4 +143,4 @@
             assertEquals("The home service does not require a parameter object.", ex.getMessage());
         }
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java Sat Jul 15 11:19:11 2006
@@ -14,8 +14,17 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
+
 import java.util.Map;
 
+import org.apache.tapestry.BaseComponentTestCase;
+import org.apache.tapestry.engine.ILink;
+import org.apache.tapestry.util.QueryParameterMap;
+import org.testng.annotations.Test;
+
 import javax.portlet.PortletMode;
 import javax.portlet.PortletModeException;
 import javax.portlet.PortletSecurityException;
@@ -23,18 +32,14 @@
 import javax.portlet.WindowState;
 import javax.portlet.WindowStateException;
 
-import org.apache.hivemind.test.HiveMindTestCase;
-import org.apache.tapestry.engine.ILink;
-import org.apache.tapestry.util.QueryParameterMap;
-import org.easymock.MockControl;
-
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletLink}.
  * 
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletLink extends HiveMindTestCase
+@Test
+public class TestPortletLink extends BaseComponentTestCase
 {
     private static class PortletURLFixture implements PortletURL
     {
@@ -78,21 +83,17 @@
 
     private PortletURL newPortletURL()
     {
-        return (PortletURL) newMock(PortletURL.class);
-    }
-
-    private QueryParameterMap newParameters()
-    {
-        return (QueryParameterMap) newMock(QueryParameterMap.class);
+        return newMock(PortletURL.class);
     }
 
     public void testGetAbsoluteURL()
     {
         PortletURL url = newPortletURL();
-        QueryParameterMap parameters = newParameters();
-
-        replayControls();
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
+        
         ILink link = new PortletLink(url, parameters);
 
         try
@@ -115,90 +116,86 @@
             // Accept.
         }
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetParameterNames()
     {
         PortletURL url = newPortletURL();
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
-        MockControl control = newControl(QueryParameterMap.class);
-        QueryParameterMap parameters = (QueryParameterMap) control.getMock();
+        String[] names = { "Fred", "Barney" };
 
-        String[] names =
-        { "Fred", "Barney" };
-
-        parameters.getParameterNames();
-        control.setReturnValue(names);
-
-        replayControls();
+        expect(parameters.getParameterNames()).andReturn(names);
+        
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
-
+        
         assertSame(names, link.getParameterNames());
-
-        verifyControls();
+        
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
-
+    
     public void testGetParameterValues()
     {
         PortletURL url = newPortletURL();
+        
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
-        MockControl control = newControl(QueryParameterMap.class);
-        QueryParameterMap parameters = (QueryParameterMap) control.getMock();
-
-        String[] values =
-        { "Fred", "Barney" };
-
-        parameters.getParameterValues("bedrock");
-        control.setReturnValue(values);
+        String[] values = { "Fred", "Barney" };
 
-        replayControls();
+        expect(parameters.getParameterValues("bedrock")).andReturn(values);
+        
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
-
+        
         assertSame(values, link.getParameterValues("bedrock"));
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetURL()
     {
         PortletURL url = newPortletURL();
 
-        MockControl control = newControl(QueryParameterMap.class);
-        QueryParameterMap parameters = (QueryParameterMap) control.getMock();
-
-        parameters.getParameterNames();
-        control.setReturnValue(new String[0]);
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
-        replayControls();
+        expect(parameters.getParameterNames()).andReturn(new String[0]);
+        
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
 
         assertEquals(url.toString(), link.getURL());
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetURLLongForm()
     {
         PortletURL url = newPortletURL();
 
-        QueryParameterMap parameters = (QueryParameterMap) newMock(QueryParameterMap.class);
-
-        parameters.getParameterNames();
-        setReturnValue(parameters, new String[]
-        { "page" });
-
-        parameters.getParameterValues("page");
-        String[] values = new String[]
-        { "View" };
-        setReturnValue(parameters, values);
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
+        expect(parameters.getParameterNames()).andReturn(new String[] {"page"});
+        
+        String[] values = new String[] { "View" };
+        
+        expect(parameters.getParameterValues("page")).andReturn(values);
+        
         url.setParameter("page", values);
-
-        replayControls();
+        
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
 
@@ -209,66 +206,68 @@
                 "anchor",
                 true));
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetURLUnencoding()
     {
         PortletURL url = new PortletURLFixture("this=foo&amp;that=bar");
 
-        QueryParameterMap parameters = (QueryParameterMap) newMock(QueryParameterMap.class);
-
-        parameters.getParameterNames();
-        setReturnValue(parameters, new String[0]);
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
-        replayControls();
+        expect(parameters.getParameterNames()).andReturn(new String[0]);
+        
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
 
         assertEquals("this=foo&that=bar", link.getURL());
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetURLIncludeParameters()
     {
         PortletURL url = newPortletURL();
-
-        MockControl control = newControl(QueryParameterMap.class);
-        QueryParameterMap parameters = (QueryParameterMap) control.getMock();
-
-        String[] values =
-        { "Fred", "Barney" };
-
-        parameters.getParameterNames();
-        control.setReturnValue(new String[]
-        { "bedrock" });
-        parameters.getParameterValues("bedrock");
-        control.setReturnValue(values);
-
+        
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
+        
+        String[] values = { "Fred", "Barney" };
+        
+        expect(parameters.getParameterNames()).andReturn(new String[]{"bedrock"});
+        
+        expect(parameters.getParameterValues("bedrock")).andReturn(values);
+        
         url.setParameter("bedrock", values);
 
-        replayControls();
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
 
         assertEquals(url.toString(), link.getURL());
 
-        verifyControls();
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
 
     public void testGetURLWithAnchor()
     {
         PortletURL url = newPortletURL();
 
-        QueryParameterMap parameters = newParameters();
+        QueryParameterMap parameters = org.easymock.classextension.EasyMock.createMock(QueryParameterMap.class);
 
-        replayControls();
+        replay();
+        org.easymock.classextension.EasyMock.replay(parameters);
 
         ILink link = new PortletLink(url, parameters);
 
         assertEquals("EasyMock for interface javax.portlet.PortletURL#anchor", link.getURL("anchor", false));
-
-        verifyControls();
+        
+        verify();
+        org.easymock.classextension.EasyMock.verify(parameters);
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletRenderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletRenderer.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletRenderer.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletRenderer.java Sat Jul 15 11:19:11 2006
@@ -14,25 +14,27 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.checkOrder;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.matches;
+
 import java.io.CharArrayWriter;
 import java.io.PrintWriter;
 
-import org.apache.hivemind.test.AggregateArgumentsMatcher;
-import org.apache.hivemind.test.ArgumentMatcher;
-import org.apache.hivemind.test.HiveMindTestCase;
-import org.apache.hivemind.test.RegexpMatcher;
-import org.apache.hivemind.test.TypeMatcher;
+import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IPage;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.NestedMarkupWriter;
+import org.apache.tapestry.PageRenderSupport;
 import org.apache.tapestry.asset.AssetFactory;
 import org.apache.tapestry.markup.MarkupWriterSource;
-import org.apache.tapestry.services.impl.DefaultResponseBuilder;
+import org.apache.tapestry.services.ResponseBuilder;
 import org.apache.tapestry.util.ContentType;
-import org.apache.tapestry.util.PageRenderSupportImpl;
 import org.apache.tapestry.web.WebResponse;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletRendererImpl}.
@@ -40,13 +42,10 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletRenderer extends HiveMindTestCase
+@Test
+public class TestPortletRenderer extends BaseComponentTestCase
 {
-    private NestedMarkupWriter newNestedWriter()
-    {
-        return (NestedMarkupWriter) newMock(NestedMarkupWriter.class);
-    }
-
+    
     private PrintWriter newPrintWriter()
     {
         return new PrintWriter(new CharArrayWriter());
@@ -54,46 +53,39 @@
 
     private AssetFactory newAssetFactory()
     {
-        return (AssetFactory) newMock(AssetFactory.class);
+        return newMock(AssetFactory.class);
     }
 
     private WebResponse newWebResponse(ContentType contentType, PrintWriter writer)
             throws Exception
     {
-        MockControl control = newControl(WebResponse.class);
-        WebResponse response = (WebResponse) control.getMock();
-
-        response.getPrintWriter(contentType);
-        control.setReturnValue(writer);
-
-        response.getNamespace();
-        control.setReturnValue("NAMESPACE");
+        WebResponse response = newMock(WebResponse.class);
+        checkOrder(response, false);
+        
+        expect(response.getPrintWriter(contentType)).andReturn(writer);
 
+        expect(response.getNamespace()).andReturn("NAMESPACE");
+        
         return response;
     }
 
     private MarkupWriterSource newSource(PrintWriter printWriter, ContentType contentType,
             IMarkupWriter writer)
     {
-        MockControl control = newControl(MarkupWriterSource.class);
-        MarkupWriterSource source = (MarkupWriterSource) control.getMock();
-
-        source.newMarkupWriter(printWriter, contentType);
-        control.setReturnValue(writer);
-
+        MarkupWriterSource source = newMock(MarkupWriterSource.class);
+        
+        expect(source.newMarkupWriter(printWriter, contentType)).andReturn(writer);
+        
         return source;
     }
 
     private IPage newPage(ContentType contentType)
     {
-        MockControl control = newControl(IPage.class);
-        IPage page = (IPage) control.getMock();
-
-        page.getResponseContentType();
-        control.setReturnValue(contentType);
+        IPage page = newMock(IPage.class);
 
-        page.getPageName();
-        control.setReturnValue("ZePage");
+        expect(page.getResponseContentType()).andReturn(contentType);
+        
+        expect(page.getPageName()).andReturn("ZePage");
 
         return page;
     }
@@ -104,27 +96,24 @@
     }
     
     private IRequestCycle newCycle(String pageName, IPage page, IMarkupWriter writer)
-    {
-        MockControl control = newControl(IRequestCycle.class);
-        IRequestCycle cycle = (IRequestCycle) control.getMock();
-
+    {   
+        IRequestCycle cycle = newCycle();
+        
         cycle.activate(pageName);
 
-        cycle.getPage();
-        control.setReturnValue(page);
-
-        cycle.getAttribute("org.apache.tapestry.PageRenderSupport");
-        control.setReturnValue(null);
-
+        expect(cycle.getPage()).andReturn(page);
+        
+        expect(cycle.getAttribute("org.apache.tapestry.PageRenderSupport")).andReturn(null);
+        
         // We can check that an instance of PageRenderSupport is passed in, but
         // we can't (easily) check thta it's configured the way we want.
-        cycle.setAttribute("org.apache.tapestry.PageRenderSupport", new PageRenderSupportImpl(
-                newAssetFactory(), "", null, new DefaultResponseBuilder(writer)));
-        control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
-        { null, new TypeMatcher() }));
         
-        cycle.renderPage(null);
-        control.setMatcher(MockControl.ALWAYS_MATCHER);
+        cycle.setAttribute(eq("org.apache.tapestry.PageRenderSupport"), 
+                isA(PageRenderSupport.class));
+                //new PageRenderSupportImpl(newAssetFactory(), "", 
+                  //      null, new DefaultResponseBuilder(writer))
+        
+        cycle.renderPage(isA(ResponseBuilder.class));
         
         return cycle;
     }
@@ -133,28 +122,27 @@
     {
         ContentType ct = new ContentType("text/html");
         PrintWriter pw = newPrintWriter();
+        
         WebResponse response = newWebResponse(ct, pw);
+        
         IMarkupWriter nested = newNestedWriter();
-
-        MockControl control = newControl(IMarkupWriter.class);
-        IMarkupWriter writer = (IMarkupWriter) control.getMock();
-
-        writer.getNestedWriter();
-        control.setReturnValue(nested);
-
+        
+        IMarkupWriter writer = newWriter();
+        
+        expect(writer.getNestedWriter()).andReturn((NestedMarkupWriter)nested);
+        
         MarkupWriterSource source = newSource(pw, ct, writer);
         IPage page = newPage(ct);
         AssetFactory assetFactory = newAssetFactory();
-
+        
         IRequestCycle cycle = newCycle("ZePage", page);
         
         writer.comment("BEGIN Tapestry Portlet appId NAMESPACE");
         writer.comment("Page: ZePage");
-
-        writer.comment("Generated:.*");
-        control.setMatcher(new RegexpMatcher());
-
-        writer.comment("Framework version:.*");
+        
+        writer.comment(matches("Generated:.*"));
+        
+        writer.comment(matches("Framework version:.*"));
 
         nested.close();
 
@@ -162,18 +150,18 @@
 
         writer.close();
 
-        replayControls();
-
+        replay();
+        
         PortletRendererImpl r = new PortletRendererImpl();
         r.setMarkupWriterSource(source);
         r.setResponse(response);
         r.setAssetFactory(assetFactory);
         r.setApplicationId("appId");
-
+        
         r.renderPage(cycle, "ZePage");
-
-        verifyControls();
+        
+        verify();
     }
 
     // TODO: Tests that prove the RenderPageSupport is working properly.
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java Sat Jul 15 11:19:11 2006
@@ -14,16 +14,18 @@
 
 package org.apache.tapestry.portlet;
 
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.WindowState;
+import static org.easymock.EasyMock.expect;
 
-import org.apache.hivemind.test.HiveMindTestCase;
+import org.apache.tapestry.BaseComponentTestCase;
 import org.apache.tapestry.IPage;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.services.ServiceConstants;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.WindowState;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletResponseRenderer}.
@@ -31,49 +33,34 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletResponseRenderer extends HiveMindTestCase
+@Test
+public class TestPortletResponseRenderer extends BaseComponentTestCase
 {
     private ActionResponse newResponse()
     {
-        return (ActionResponse) newMock(ActionResponse.class);
-    }
-
-    private IPage newPage(String name)
-    {
-        MockControl control = newControl(IPage.class);
-        IPage page = (IPage) control.getMock();
-
-        page.getPageName();
-        control.setReturnValue(name);
-
-        return page;
+        return newMock(ActionResponse.class);
     }
 
     private IRequestCycle newCycle(IPage page)
     {
-        MockControl control = newControl(IRequestCycle.class);
-        IRequestCycle cycle = (IRequestCycle) control.getMock();
-
-        cycle.getPage();
-        control.setReturnValue(page);
-
+        IRequestCycle cycle = newCycle();
+        
+        expect(cycle.getPage()).andReturn(page);
+        
         return cycle;
     }
-
+    
     public void testSuccess() throws Exception
     {
         IPage page = newPage("Frodo");
         IRequestCycle cycle = newCycle(page);
+        
+        PortletRequest request = newMock(PortletRequest.class);
+        
+        expect(request.getPortletMode()).andReturn(PortletMode.VIEW);
 
-        MockControl requestc = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) requestc.getMock();
-
-        request.getPortletMode();
-        requestc.setReturnValue(PortletMode.VIEW);
-
-        request.getWindowState();
-        requestc.setReturnValue(WindowState.NORMAL);
-
+        expect(request.getWindowState()).andReturn(WindowState.NORMAL);
+        
         ActionResponse response = newResponse();
 
         response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE);
@@ -81,7 +68,7 @@
         response.setRenderParameter(PortletConstants.PORTLET_MODE, "view");
         response.setRenderParameter(PortletConstants.WINDOW_STATE, "normal");
 
-        replayControls();
+        replay();
 
         PortletResponseRenderer renderer = new PortletResponseRenderer();
         renderer.setResponse(response);
@@ -89,6 +76,6 @@
 
         renderer.renderResponse(cycle);
 
-        verifyControls();
+        verify();
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java Sat Jul 15 11:19:11 2006
@@ -14,23 +14,23 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.*;
+import static org.testng.AssertJUnit.assertSame;
+
 import java.io.IOException;
 
+import org.apache.tapestry.BaseComponentTestCase;
+import org.apache.tapestry.services.WebRequestServicer;
+import org.apache.tapestry.web.WebRequest;
+import org.apache.tapestry.web.WebResponse;
+import org.testng.annotations.Test;
+
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletException;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
-import org.apache.hivemind.test.AggregateArgumentsMatcher;
-import org.apache.hivemind.test.ArgumentMatcher;
-import org.apache.hivemind.test.HiveMindTestCase;
-import org.apache.hivemind.test.TypeMatcher;
-import org.apache.tapestry.services.WebRequestServicer;
-import org.apache.tapestry.web.WebRequest;
-import org.apache.tapestry.web.WebResponse;
-import org.easymock.MockControl;
-
 /**
  * Tests for {@link ActionRequestServicerToWebRequestServicerBridge}&nbsp;and
  * {@link org.apache.tapestry.portlet.RenderRequestServicerToWebRequestServicerBridge}.
@@ -38,7 +38,8 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
-public class TestPortletServicerBridges extends HiveMindTestCase
+@Test
+public class TestPortletServicerBridges extends BaseComponentTestCase
 {
     private class WebRequestServicerFixture implements WebRequestServicer
     {
@@ -56,23 +57,21 @@
 
     public void testActionBridgeSuccess() throws Exception
     {
-        ActionRequest request = (ActionRequest) newMock(ActionRequest.class);
+        ActionRequest request = newMock(ActionRequest.class);
+        ActionResponse response = newMock(ActionResponse.class);
 
-        MockControl responsec = newControl(ActionResponse.class);
-        ActionResponse response = (ActionResponse) responsec.getMock();
-
-        PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
+        PortletRequestGlobals prg = newMock(PortletRequestGlobals.class);
         WebRequestServicerFixture wrs = new WebRequestServicerFixture();
 
         prg.store(request, response);
-
+        
         request.removeAttribute("FOO");
-        response.encodeURL("FOO");
-        responsec.setReturnValue(null);
+        expect(response.encodeURL("FOO")).andReturn(null);
 
-        replayControls();
+        replay();
 
-        ActionRequestServicerToWebRequestServicerBridge bridge = new ActionRequestServicerToWebRequestServicerBridge();
+        ActionRequestServicerToWebRequestServicerBridge bridge = 
+            new ActionRequestServicerToWebRequestServicerBridge();
         bridge.setPortletRequestGlobals(prg);
         bridge.setWebRequestServicer(wrs);
 
@@ -84,27 +83,26 @@
         wrs._request.setAttribute("FOO", null);
         wrs._response.encodeURL("FOO");
 
-        verifyControls();
+        verify();
     }
 
     public void testRenderBridgeSuccess() throws Exception
     {
-        RenderRequest request = (RenderRequest) newMock(RenderRequest.class);
+        RenderRequest request = newMock(RenderRequest.class);
+        RenderResponse response = newMock(RenderResponse.class);
 
-        MockControl responsec = newControl(RenderResponse.class);
-        RenderResponse response = (RenderResponse) responsec.getMock();
-
-        PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
+        PortletRequestGlobals prg = newMock(PortletRequestGlobals.class);
         WebRequestServicerFixture wrs = new WebRequestServicerFixture();
-
+        
         prg.store(request, response);
 
         request.removeAttribute("FOO");
         response.reset();
 
-        replayControls();
+        replay();
 
-        RenderRequestServicerToWebRequestServicerBridge bridge = new RenderRequestServicerToWebRequestServicerBridge();
+        RenderRequestServicerToWebRequestServicerBridge bridge = 
+            new RenderRequestServicerToWebRequestServicerBridge();
         bridge.setPortletRequestGlobals(prg);
         bridge.setWebRequestServicer(wrs);
 
@@ -119,27 +117,24 @@
 
         wrs._response.reset();
 
-        verifyControls();
+        verify();
     }
 
     public void testActionBridgeFailure() throws Exception
     {
-        ActionRequest request = (ActionRequest) newMock(ActionRequest.class);
-        ActionResponse response = (ActionResponse) newMock(ActionResponse.class);
-        PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
-
-        MockControl control = newControl(WebRequestServicer.class);
-        WebRequestServicer servicer = (WebRequestServicer) control.getMock();
-
+        ActionRequest request = newMock(ActionRequest.class);
+        ActionResponse response = newMock(ActionResponse.class);
+        PortletRequestGlobals prg = newMock(PortletRequestGlobals.class);
+        
+        WebRequestServicer servicer = newMock(WebRequestServicer.class);
+        
         Throwable t = new RuntimeException("Failure.");
 
         prg.store(request, response);
-        servicer.service(new PortletWebRequest(request), new PortletWebResponse(response));
-        control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
-        { new TypeMatcher(), new TypeMatcher() }));
-        control.setThrowable(t);
-
-        replayControls();
+        servicer.service(isA(PortletWebRequest.class), isA(PortletWebResponse.class));
+        expectLastCall().andThrow(t);
+        
+        replay();
 
         ActionRequestServicerToWebRequestServicerBridge bridge = new ActionRequestServicerToWebRequestServicerBridge();
         bridge.setPortletRequestGlobals(prg);
@@ -161,32 +156,30 @@
             assertSame(t, ex.getCause());
         }
 
-        verifyControls();
+        verify();
     }
 
     public void testRenderBridgeFailure() throws Exception
     {
-        RenderRequest request = (RenderRequest) newMock(RenderRequest.class);
-        RenderResponse response = (RenderResponse) newMock(RenderResponse.class);
-        PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
-
-        MockControl control = newControl(WebRequestServicer.class);
-        WebRequestServicer servicer = (WebRequestServicer) control.getMock();
-
+        RenderRequest request = newMock(RenderRequest.class);
+        RenderResponse response = newMock(RenderResponse.class);
+        PortletRequestGlobals prg = newMock(PortletRequestGlobals.class);
+        
+        WebRequestServicer servicer = newMock(WebRequestServicer.class);
+        
         Throwable t = new RuntimeException("Failure.");
 
         prg.store(request, response);
-        servicer.service(new PortletWebRequest(request), new RenderWebResponse(response));
-        control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
-        { new TypeMatcher(), new TypeMatcher() }));
-        control.setThrowable(t);
-
-        replayControls();
-
+        
+        servicer.service(isA(PortletWebRequest.class), isA(RenderWebResponse.class));
+        expectLastCall().andThrow(t);
+        
+        replay();
+        
         RenderRequestServicerToWebRequestServicerBridge bridge = new RenderRequestServicerToWebRequestServicerBridge();
         bridge.setPortletRequestGlobals(prg);
         bridge.setWebRequestServicer(servicer);
-
+        
         try
         {
 
@@ -203,6 +196,6 @@
             assertSame(t, ex.getCause());
         }
 
-        verifyControls();
+        verify();
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebActivator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebActivator.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebActivator.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebActivator.java Sat Jul 15 11:19:11 2006
@@ -14,11 +14,15 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
+
 import java.util.List;
 
-import javax.portlet.PortletConfig;
+import org.testng.annotations.Test;
 
-import org.easymock.MockControl;
+import javax.portlet.PortletConfig;
 
 /**
  * Tests for {@link org.apache.tapestry.portlet.PortletWebActivator}.
@@ -26,34 +30,31 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
+@Test
 public class TestPortletWebActivator extends BasePortletWebTestCase
 {
     public void testGetActivatorName()
     {
-        MockControl control = newControl(PortletConfig.class);
-        PortletConfig config = (PortletConfig) control.getMock();
-
-        config.getPortletName();
-        control.setReturnValue("portlet");
-
-        replayControls();
+        PortletConfig config = newMock(PortletConfig.class);
 
+        expect(config.getPortletName()).andReturn("portlet");
+        
+        replay();
+        
         PortletWebActivator pwa = new PortletWebActivator(config);
-
+        
         assertEquals("portlet", pwa.getActivatorName());
 
-        verifyControls();
+        verify();
     }
 
     public void testGetInitParameterNames()
     {
-        MockControl control = newControl(PortletConfig.class);
-        PortletConfig config = (PortletConfig) control.getMock();
-
-        config.getInitParameterNames();
-        control.setReturnValue(newEnumeration());
+        PortletConfig config = newMock(PortletConfig.class);
 
-        replayControls();
+        expect(config.getInitParameterNames()).andReturn(newEnumeration());
+        
+        replay();
 
         PortletWebActivator pwa = new PortletWebActivator(config);
 
@@ -61,25 +62,23 @@
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetInitParameterValue()
     {
         String value = "William Orbit";
+        
+        PortletConfig config = newMock(PortletConfig.class);
 
-        MockControl control = newControl(PortletConfig.class);
-        PortletConfig config = (PortletConfig) control.getMock();
-
-        config.getInitParameter("artist");
-        control.setReturnValue(value);
-
-        replayControls();
+        expect(config.getInitParameter("artist")).andReturn(value);
+        
+        replay();
 
         PortletWebActivator pwa = new PortletWebActivator(config);
 
         assertSame(value, pwa.getInitParameterValue("artist"));
 
-        verifyControls();
+        verify();
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebContext.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebContext.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebContext.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebContext.java Sat Jul 15 11:19:11 2006
@@ -14,30 +14,33 @@
 
 package org.apache.tapestry.portlet;
 
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertSame;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.List;
 
-import javax.portlet.PortletContext;
-
 import org.apache.tapestry.web.WebContext;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
+
+import javax.portlet.PortletContext;
 
 /**
  * @author Howard M. Lewis Ship
  */
+@Test
 public class TestPortletWebContext extends BasePortletWebTestCase
 {
 
     public void testGetInitParameterNames()
     {
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
+        PortletContext context = newMock(PortletContext.class);
 
-        context.getInitParameterNames();
-        control.setReturnValue(newEnumeration());
+        expect(context.getInitParameterNames()).andReturn(newEnumeration());
 
-        replayControls();
+        replay();
 
         WebContext wc = new PortletWebContext(context);
 
@@ -45,139 +48,123 @@
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetInitParameterValue()
     {
         String value = "William Orbit";
+        
+        PortletContext context = newMock(PortletContext.class);
+        
+        expect(context.getInitParameter("artist")).andReturn(value);
 
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
-
-        context.getInitParameter("artist");
-        control.setReturnValue(value);
-
-        replayControls();
+        replay();
 
         WebContext wc = new PortletWebContext(context);
 
         assertSame(value, wc.getInitParameterValue("artist"));
 
-        verifyControls();
+        verify();
     }
 
     public void testGetAttributeNames()
     {
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
-
-        context.getAttributeNames();
-        control.setReturnValue(newEnumeration());
+        PortletContext context = newMock(PortletContext.class);
 
-        replayControls();
+        expect(context.getAttributeNames()).andReturn(newEnumeration());
+        
+        replay();
 
         WebContext wc = new PortletWebContext(context);
-
+        
         List l = wc.getAttributeNames();
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetAttribute()
     {
         Object attribute = new Object();
 
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
+        PortletContext context = newMock(PortletContext.class);
 
-        context.getAttribute("attr");
-        control.setReturnValue(attribute);
+        expect(context.getAttribute("attr")).andReturn(attribute);
 
-        replayControls();
+        replay();
 
         WebContext wc = new PortletWebContext(context);
 
         assertSame(attribute, wc.getAttribute("attr"));
 
-        verifyControls();
+        verify();
     }
 
     public void testSetAttribute()
     {
         Object attribute = new Object();
 
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
-
+        PortletContext context = newMock(PortletContext.class);
+        
         context.setAttribute("name", attribute);
 
-        replayControls();
+        replay();
 
         WebContext wc = new PortletWebContext(context);
 
         wc.setAttribute("name", attribute);
 
-        verifyControls();
+        verify();
     }
 
     public void testSetAttributeToNull()
     {
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
+        PortletContext context = newMock(PortletContext.class);
 
         context.removeAttribute("tonull");
 
-        replayControls();
+        replay();
 
         WebContext wc = new PortletWebContext(context);
 
         wc.setAttribute("tonull", null);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetResource() throws Exception
     {
-        URL url = new URL("http://jakarta.apache.org/tapestry");
+        URL url = new URL("http://tapestry.apache.org/");
 
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
-
-        context.getResource("/tapestry");
-        control.setReturnValue(url);
-
-        replayControls();
+        PortletContext context = newMock(PortletContext.class);
+        
+        expect(context.getResource("/tapestry")).andReturn(url);
+        
+        replay();
 
         WebContext wc = new PortletWebContext(context);
-
+        
         assertSame(url, wc.getResource("/tapestry"));
-
-        verifyControls();
+        
+        verify();
     }
 
     public void testGetResourceFailure() throws Exception
     {
         Throwable t = new MalformedURLException("Like this ever happens.");
 
-        MockControl control = newControl(PortletContext.class);
-        PortletContext context = (PortletContext) control.getMock();
-
-        context.getResource("/tapestry");
-        control.setThrowable(t);
-
-        replayControls();
-
-        interceptLogging(PortletWebContext.class.getName());
+        PortletContext context = newMock(PortletContext.class);
 
+        expect(context.getResource("/tapestry")).andThrow(t);
+        
+        replay();
+        
         WebContext wc = new PortletWebContext(context);
 
         assertNull(wc.getResource("/tapestry"));
-
-        verifyControls();
-
-        assertLoggedMessage("Error getting portlet context resource '/tapestry': Like this ever happens.");
+        
+        verify();
     }
-}
\ No newline at end of file
+}

Modified: tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebRequest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebRequest.java?rev=422275&r1=422274&r2=422275&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebRequest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-portlet/src/test/org/apache/tapestry/portlet/TestPortletWebRequest.java Sat Jul 15 11:19:11 2006
@@ -14,14 +14,19 @@
 
 package org.apache.tapestry.portlet;
 
-import java.util.List;
+import static org.easymock.EasyMock.expect;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertSame;
 
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
+import java.util.List;
 
 import org.apache.tapestry.web.WebRequest;
 import org.apache.tapestry.web.WebSession;
-import org.easymock.MockControl;
+import org.testng.annotations.Test;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
 
 /**
  * Tests for {@link org.apache.tapestry.web.PortletWebRequest}.
@@ -29,22 +34,21 @@
  * @author Howard M. Lewis Ship
  * @since 4.0
  */
+@Test
 public class TestPortletWebRequest extends BasePortletWebTestCase
 {
-    private PortletRequest newRequest()
+    private PortletRequest newPortletRequest()
     {
-        return (PortletRequest) newMock(PortletRequest.class);
+        return newMock(PortletRequest.class);
     }
 
     public void testGetParameterNames()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
-
-        request.getParameterNames();
-        control.setReturnValue(newEnumeration());
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        expect(request.getParameterNames()).andReturn(newEnumeration());
+        
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
@@ -52,73 +56,65 @@
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetParameterValue()
     {
         String value = "William Orbit";
+        
+        PortletRequest request = newPortletRequest();
 
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
-
-        request.getParameter("artist");
-        control.setReturnValue(value);
-
-        replayControls();
+        expect(request.getParameter("artist")).andReturn(value);
+        
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertSame(value, wr.getParameterValue("artist"));
 
-        verifyControls();
+        verify();
     }
 
     public void testGetParameterValues()
     {
-        String[] values =
-        { "William Orbit", "Steely Dan" };
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        String[] values = { "William Orbit", "Steely Dan" };
+        
+        PortletRequest request = newPortletRequest();
 
-        request.getParameterValues("artist");
-        control.setReturnValue(values);
-
-        replayControls();
+        expect(request.getParameterValues("artist")).andReturn(values);
+        
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
-
+        
         assertSame(values, wr.getParameterValues("artist"));
 
-        verifyControls();
+        verify();
     }
 
     public void testGetContextPath()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
-        request.getContextPath();
-        control.setReturnValue("/foo");
+        expect(request.getContextPath()).andReturn("/foo");
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertEquals("/foo", wr.getContextPath());
 
-        verifyControls();
+        verify();
     }
 
     public void testGetAttributeNames()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
-        request.getAttributeNames();
-        control.setReturnValue(newEnumeration());
+        expect(request.getAttributeNames()).andReturn(newEnumeration());
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
@@ -126,171 +122,158 @@
 
         checkList(l);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetAttribute()
     {
         Object attribute = new Object();
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
-        request.getAttribute("attr");
-        control.setReturnValue(attribute);
+        expect(request.getAttribute("attr")).andReturn(attribute);
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertSame(attribute, wr.getAttribute("attr"));
 
-        verifyControls();
+        verify();
     }
 
     public void testSetAttribute()
     {
         Object attribute = new Object();
 
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
         request.setAttribute("name", attribute);
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         wr.setAttribute("name", attribute);
 
-        verifyControls();
+        verify();
     }
 
     public void testSetAttributeToNull()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
         request.removeAttribute("tonull");
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         wr.setAttribute("tonull", null);
 
-        verifyControls();
+        verify();
     }
 
     public void testGetSession()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
-        PortletSession session = (PortletSession) newMock(PortletSession.class);
+        PortletSession session = newMock(PortletSession.class);
 
-        request.getPortletSession(false);
-        control.setReturnValue(null);
+        expect(request.getPortletSession(false)).andReturn(null);
 
         // Get it, doesn't exist, wreate false
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertNull(wr.getSession(false));
 
-        verifyControls();
-
-        request.getPortletSession(true);
-        control.setReturnValue(session);
+        verify();
 
+        expect(request.getPortletSession(true)).andReturn(session);
+        
         // #2: Get it, wreate is true, it is wreated.
 
-        replayControls();
+        replay();
 
         WebSession cs = wr.getSession(true);
 
-        verifyControls();
+        verify();
 
         // #3: Cached in local variable, make sure same
         // think returned.
 
-        replayControls();
+        replay();
 
         assertSame(cs, wr.getSession(false));
 
-        verifyControls();
+        verify();
     }
 
     public void testGetScheme()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
-
-        request.getScheme();
-        control.setReturnValue("http");
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        expect(request.getScheme()).andReturn("http");
+        
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertEquals("http", wr.getScheme());
 
-        verifyControls();
+        verify();
     }
 
     public void testGetServerName()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
-
-        request.getServerName();
-        control.setReturnValue("www.myhost.com");
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        expect(request.getServerName()).andReturn("www.myhost.com");
+        
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertEquals("www.myhost.com", wr.getServerName());
 
-        verifyControls();
+        verify();
     }
 
     public void testGetServerPort()
     {
-        MockControl control = newControl(PortletRequest.class);
-        PortletRequest request = (PortletRequest) control.getMock();
+        PortletRequest request = newPortletRequest();
 
-        request.getServerPort();
-        control.setReturnValue(80);
+        expect(request.getServerPort()).andReturn(80);
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertEquals(80, wr.getServerPort());
 
-        verifyControls();
+        verify();
     }
 
     public void testGetRequestURIUnsupported()
     {
-        PortletRequest request = newRequest();
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertEquals("<PortletRequest>", wr.getRequestURI());
 
-        verifyControls();
+        verify();
     }
 
     public void testForwardUnsupported()
     {
-        PortletRequest request = newRequest();
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
@@ -304,19 +287,19 @@
             // Expected.
         }
 
-        verifyControls();
+        verify();
     }
 
     public void testGetPathInfo()
     {
-        PortletRequest request = newRequest();
+        PortletRequest request = newPortletRequest();
 
-        replayControls();
+        replay();
 
         WebRequest wr = new PortletWebRequest(request);
 
         assertNull(wr.getPathInfo());
 
-        verifyControls();
+        verify();
     }
-}
\ No newline at end of file
+}