Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
 Wed Apr 18 18:13:57 2012
@@ -88,11 +88,11 @@ public class PortletUrlHelper {
     public String buildUrl(String action, String namespace, String method, 
Map<String, Object> params,
             String scheme, String type, String portletMode, String windowState,
             boolean includeContext, boolean encodeResult) {
-       StringBuffer resultingAction = new StringBuffer();
+       StringBuilder resultingAction = new StringBuilder();
         PortletRequest request = PortletActionContext.getRequest();
         LOG.debug("Creating url. Action = " + action + ", Namespace = "
                 + namespace + ", Type = " + type);
-        namespace = prependNamespace(namespace, portletMode, 
!URLTYPE_NAME_RESOURCE.equalsIgnoreCase(type));
+        namespace = prependNamespace(namespace, portletMode, false);
         if (StringUtils.isEmpty(portletMode)) {
             portletMode = 
PortletActionContext.getRequest().getPortletMode().toString();
         }
@@ -137,7 +137,7 @@ public class PortletUrlHelper {
 
         String result = url.toString();
         // TEMP BUG-WORKAROUND FOR DOUBLE ESCAPING OF AMPERSAND
-        if(result.indexOf("&amp;") >= 0) {
+        if(result.contains("&amp;")) {
             result = result.replace("&amp;", "&");
         }
         return result;
@@ -179,14 +179,14 @@ public class PortletUrlHelper {
      * @return prepended namespace.
      */
     private String prependNamespace(String namespace, String portletMode, 
boolean prependModeNamespace) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         String modeNamespace;
         if (prependModeNamespace) {
             PortletMode mode = 
PortletActionContext.getRequest().getPortletMode();
             if(StringUtils.isNotEmpty(portletMode)) {
                 mode = new PortletMode(portletMode);
             }
-            modeNamespace = 
(String)PortletActionContext.getModeNamespaceMap().get(mode);
+            modeNamespace = 
PortletActionContext.getModeNamespaceMap().get(mode);
         } else {
             modeNamespace = null;
         }

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java
 Wed Apr 18 18:13:57 2012
@@ -20,37 +20,34 @@
  */
 package org.apache.struts2.views.freemarker;
 
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.dispatcher.StrutsResultSupport;
-import org.apache.struts2.portlet.PortletActionConstants;
-import org.apache.struts2.portlet.context.PortletActionContext;
-import org.apache.struts2.views.util.ResourceUtil;
-
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.ValueStack;
-
 import freemarker.template.Configuration;
 import freemarker.template.ObjectWrapper;
 import freemarker.template.Template;
 import freemarker.template.TemplateException;
 import freemarker.template.TemplateModel;
 import freemarker.template.TemplateModelException;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.StrutsResultSupport;
+import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.PortletPhase;
+import org.apache.struts2.portlet.context.PortletActionContext;
+import org.apache.struts2.views.util.ResourceUtil;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
 
 /**
  */
-public class PortletFreemarkerResult extends StrutsResultSupport implements 
PortletActionConstants {
+public class PortletFreemarkerResult extends StrutsResultSupport {
 
     private static final long serialVersionUID = -5570612389289887543L;
 
@@ -104,39 +101,26 @@ public class PortletFreemarkerResult ext
      */
     public void doExecute(String location, ActionInvocation invocation)
             throws IOException, TemplateException, PortletException {
-        if (PortletActionContext.isAction()) {
+        PortletPhase phase = PortletActionContext.getPhase();
+        if (phase.isAction()) {
             executeActionResult(location, invocation);
-        } else if (PortletActionContext.isRender()) {
+        } else if (phase.isRender()) {
             executeRenderResult(location, invocation);
         }
     }
 
-    /**
-     * @param location
-     * @param invocation
-     */
-    private void executeActionResult(String location,
-                                     ActionInvocation invocation) {
+    private void executeActionResult(String location, ActionInvocation 
invocation) {
         ActionResponse res = PortletActionContext.getActionResponse();
         // View is rendered outside an action...uh oh...
-        
invocation.getInvocationContext().getSession().put(RENDER_DIRECT_LOCATION, 
location);
-        res.setRenderParameter(PortletActionConstants.ACTION_PARAM, 
"freemarkerDirect");
+        
invocation.getInvocationContext().getSession().put(PortletConstants.RENDER_DIRECT_LOCATION,
 location);
+        res.setRenderParameter(PortletConstants.ACTION_PARAM, 
"freemarkerDirect");
         res.setRenderParameter("location", location);
-        res.setRenderParameter(PortletActionConstants.MODE_PARAM, 
PortletActionContext
-                .getRequest().getPortletMode().toString());
+        res.setRenderParameter(PortletConstants.MODE_PARAM, 
PortletActionContext.getRequest().getPortletMode().toString());
 
     }
 
-    /**
-     * @param location
-     * @param invocation
-     * @throws TemplateException
-     * @throws IOException
-     * @throws TemplateModelException
-     */
-    private void executeRenderResult(String location,
-                                     ActionInvocation invocation) throws 
TemplateException, IOException,
-            TemplateModelException, PortletException {
+    private void executeRenderResult(String location, ActionInvocation 
invocation)
+            throws TemplateException, IOException, PortletException {
         this.location = location;
         this.invocation = invocation;
         this.configuration = getConfiguration();
@@ -173,8 +157,7 @@ public class PortletFreemarkerResult ext
      * from the ConfigurationManager instance. </b>
      */
     protected Configuration getConfiguration() throws TemplateException {
-        return freemarkerManager.getConfiguration(
-                ServletActionContext.getServletContext());
+        return 
freemarkerManager.getConfiguration(ServletActionContext.getServletContext());
     }
 
     /**
@@ -218,11 +201,8 @@ public class PortletFreemarkerResult ext
                 .getServletContext();
         HttpServletRequest request = ServletActionContext.getRequest();
         HttpServletResponse response = ServletActionContext.getResponse();
-        ValueStack stack = ServletActionContext.getContext()
-                .getValueStack();
-        return freemarkerManager.buildTemplateModel(stack,
-                invocation.getAction(), servletContext, request, response,
-                wrapper);
+        ValueStack stack = ServletActionContext.getContext().getValueStack();
+        return freemarkerManager.buildTemplateModel(stack, 
invocation.getAction(), servletContext, request, response, wrapper);
     }
 
     /**
@@ -239,8 +219,7 @@ public class PortletFreemarkerResult ext
      * the default implementation of postTemplateProcess applies the 
contentType
      * parameter
      */
-    protected void postTemplateProcess(Template template, TemplateModel data)
-            throws IOException {
+    protected void postTemplateProcess(Template template, TemplateModel data) 
throws IOException {
     }
 
     /**
@@ -253,8 +232,7 @@ public class PortletFreemarkerResult ext
      * @return true to process the template, false to suppress template
      *         processing.
      */
-    protected boolean preTemplateProcess(Template template, TemplateModel 
model)
-            throws IOException {
+    protected boolean preTemplateProcess(Template template, TemplateModel 
model) throws IOException {
         Object attrContentType = template.getCustomAttribute("content_type");
 
         if (attrContentType != null) {

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/components/PortletUrlRendererTest.java
 Wed Apr 18 18:13:57 2012
@@ -11,6 +11,8 @@ import org.springframework.mock.web.port
 import org.springframework.mock.web.portlet.MockPortletRequest;
 
 import javax.portlet.PortletContext;
+import javax.portlet.PortletMode;
+
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Collections;
@@ -46,5 +48,14 @@ public class PortletUrlRendererTest exte
         // then
         assertTrue("/portlettest".equals(component.getNamespace()));
     }
+    
+    public void testIsPortelModeChanged() {
+       PortletUrlRenderer renderer = new PortletUrlRenderer();
+       PortletMode mode = new PortletMode("test");
+       UrlProvider provider = new ComponentUrlProvider(null, null);
+       provider.setPortletMode("test2");
+       
+       assertTrue(renderer.isPortletModeChange(provider, mode));
+    }
 
 }

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/context/PortletActionContextTest.java
 Wed Apr 18 18:13:57 2012
@@ -20,23 +20,36 @@
  */
 package org.apache.struts2.portlet.context;
 
-import static org.apache.struts2.portlet.PortletConstants.*;
-import static org.apache.struts2.portlet.context.PortletActionContext.*;
-
-import java.util.HashMap;
-import java.util.Map;
+import com.opensymphony.xwork2.ActionContext;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.portlet.PortletPhase;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import org.jmock.Mock;
-import org.jmock.MockObjectTestCase;
-
-import com.opensymphony.xwork2.ActionContext;
+import static 
org.apache.struts2.portlet.PortletConstants.DEFAULT_ACTION_FOR_MODE;
+import static org.apache.struts2.portlet.PortletConstants.PHASE;
+import static org.apache.struts2.portlet.PortletConstants.PORTLET_CONFIG;
+import static org.apache.struts2.portlet.PortletConstants.PORTLET_NAMESPACE;
+import static org.apache.struts2.portlet.PortletConstants.REQUEST;
+import static org.apache.struts2.portlet.PortletConstants.RESPONSE;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getActionRequest;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getActionResponse;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getDefaultActionForMode;
+import static org.apache.struts2.portlet.context.PortletActionContext.getPhase;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getPortletConfig;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getPortletNamespace;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getRenderRequest;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getRenderResponse;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getRequest;
+import static 
org.apache.struts2.portlet.context.PortletActionContext.getResponse;
 
 /**
  */
@@ -77,33 +90,39 @@ public class PortletActionContextTest ex
     }
 
     public void testGetPhase() {
-        context.put(PHASE, RENDER_PHASE);
+        context.put(PHASE, PortletPhase.RENDER_PHASE);
 
-        assertEquals(RENDER_PHASE, getPhase());
+        assertEquals(PortletPhase.RENDER_PHASE, getPhase());
     }
 
     public void testIsRender() {
-        context.put(PHASE, RENDER_PHASE);
+        context.put(PHASE, PortletPhase.RENDER_PHASE);
 
-        assertTrue(isRender());
-        assertFalse(isAction());
-        assertFalse(isEvent());
+        PortletPhase phase = getPhase();
+
+        assertTrue(phase.isRender());
+        assertFalse(phase.isAction());
+        assertFalse(phase.isEvent());
     }
 
     public void testIsAction() {
-        context.put(PHASE, ACTION_PHASE);
+        context.put(PHASE, PortletPhase.ACTION_PHASE);
+
+        PortletPhase phase = getPhase();
 
-        assertTrue(isAction());
-        assertFalse(isRender());
-        assertFalse(isEvent());
+        assertTrue(phase.isAction());
+        assertFalse(phase.isRender());
+        assertFalse(phase.isEvent());
     }
     
     public void testIsEvent() {
-       context.put(PHASE, EVENT_PHASE);
-       
-       assertTrue(isEvent());
-       assertFalse(isAction());
-       assertFalse(isRender());
+       context.put(PHASE, PortletPhase.EVENT_PHASE);
+
+        PortletPhase phase = getPhase();
+
+       assertTrue(phase.isEvent());
+       assertFalse(phase.isAction());
+       assertFalse(phase.isRender());
     }
 
     public void testGetPortletConfig() {
@@ -114,7 +133,7 @@ public class PortletActionContextTest ex
     public void testGetRenderRequestAndResponse() {
         context.put(REQUEST, renderRequest);
         context.put(RESPONSE, renderResponse);
-        context.put(PHASE, RENDER_PHASE);
+        context.put(PHASE, PortletPhase.RENDER_PHASE);
         assertSame(renderRequest, getRenderRequest());
         assertSame(renderResponse, getRenderResponse());
         assertSame(renderRequest, getRequest());
@@ -124,7 +143,7 @@ public class PortletActionContextTest ex
     public void testGetRenderRequestAndResponseInEventPhase() {
         context.put(REQUEST, renderRequest);
         context.put(RESPONSE, renderResponse);
-        context.put(PHASE, ACTION_PHASE);
+        context.put(PHASE, PortletPhase.ACTION_PHASE);
         try {
             getRenderRequest();
             fail("Should throw IllegalStateException!");
@@ -144,7 +163,7 @@ public class PortletActionContextTest ex
     public void testGetActionRequestAndResponse() {
         context.put(REQUEST, actionRequest);
         context.put(RESPONSE, actionResponse);
-        context.put(PHASE, ACTION_PHASE);
+        context.put(PHASE, PortletPhase.ACTION_PHASE);
         assertSame(actionRequest, getActionRequest());
         assertSame(actionResponse, getActionResponse());
         assertSame(actionRequest, getRequest());
@@ -154,7 +173,7 @@ public class PortletActionContextTest ex
     public void testGetActionRequestAndResponseInRenderPhase() {
         context.put(REQUEST, actionRequest);
         context.put(RESPONSE, actionResponse);
-        context.put(PHASE, RENDER_PHASE);
+        context.put(PHASE, PortletPhase.RENDER_PHASE);
         try {
             getActionRequest();
             fail("Should throw IllegalStateException!");

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
 Wed Apr 18 18:13:57 2012
@@ -20,20 +20,17 @@
  */
 package org.apache.struts2.portlet.interceptor;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.portlet.PortletRequest;
-
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
 import junit.framework.TestCase;
-
-import org.apache.struts2.portlet.PortletActionConstants;
+import org.apache.struts2.portlet.PortletConstants;
 import org.easymock.EasyMock;
 
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
+import javax.portlet.PortletRequest;
+import java.util.HashMap;
+import java.util.Map;
 
-public class PortletAwareInterceptorTest extends TestCase implements 
PortletActionConstants {
+public class PortletAwareInterceptorTest extends TestCase {
 
        private PortletAwareInterceptor interceptor;
        
@@ -49,7 +46,7 @@ public class PortletAwareInterceptorTest
        public void testPortletRequestIsSet() throws Exception {
                PortletRequest request = 
EasyMock.createMock(PortletRequest.class);
                Map<String, Object> ctx = new HashMap<String, Object>();
-               ctx.put(REQUEST, request);
+               ctx.put(PortletConstants.REQUEST, request);
                PortletRequestAware action = 
EasyMock.createMock(PortletRequestAware.class);
                action.setPortletRequest(request);
                

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
 Wed Apr 18 18:13:57 2012
@@ -20,23 +20,26 @@
  */
 package org.apache.struts2.portlet.interceptor;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.portlet.ActionResponse;
-import javax.portlet.RenderRequest;
-
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
 import org.apache.struts2.StrutsTestCase;
 import org.apache.struts2.dispatcher.DefaultActionSupport;
+import org.apache.struts2.portlet.PortletPhase;
 import org.apache.struts2.portlet.dispatcher.DirectRenderFromEventAction;
 import org.easymock.EasyMock;
 
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
+import javax.portlet.ActionResponse;
+import javax.portlet.RenderRequest;
+import java.util.HashMap;
+import java.util.Map;
 
-import static org.apache.struts2.portlet.PortletConstants.*;
+import static org.apache.struts2.portlet.PortletConstants.EVENT_ACTION;
+import static org.apache.struts2.portlet.PortletConstants.PHASE;
+import static org.apache.struts2.portlet.PortletConstants.REQUEST;
+import static org.apache.struts2.portlet.PortletConstants.RESPONSE;
+import static 
org.apache.struts2.portlet.PortletConstants.STACK_FROM_EVENT_PHASE;
 
 public class PortletStateInterceptorTest extends StrutsTestCase {
 
@@ -52,7 +55,7 @@ public class PortletStateInterceptorTest
                ActionInvocation invocation = 
EasyMock.createNiceMock(ActionInvocation.class);
                
                Map<String, Object> ctxMap = new HashMap<String, Object>();
-               ctxMap.put(PHASE, ACTION_PHASE);
+               ctxMap.put(PHASE, PortletPhase.ACTION_PHASE);
                ctxMap.put(RESPONSE, actionResponse);
                Map<String, Object> session = new HashMap<String, Object>();
                
@@ -92,7 +95,7 @@ public class PortletStateInterceptorTest
                
                session.put(STACK_FROM_EVENT_PHASE, eventPhaseStack);
                
-               ctxMap.put(PHASE, RENDER_PHASE);
+               ctxMap.put(PHASE, PortletPhase.RENDER_PHASE);
                ctxMap.put(REQUEST, renderRequest);
                
                ActionContext ctx = new ActionContext(ctxMap);
@@ -133,7 +136,7 @@ public class PortletStateInterceptorTest
                
                session.put(STACK_FROM_EVENT_PHASE, eventPhaseStack);
                
-               ctxMap.put(PHASE, RENDER_PHASE);
+               ctxMap.put(PHASE, PortletPhase.RENDER_PHASE);
                ctxMap.put(REQUEST, renderRequest);
                
                ActionContext ctx = new ActionContext(ctxMap);

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
 Wed Apr 18 18:13:57 2012
@@ -20,11 +20,16 @@
  */
 package org.apache.struts2.portlet.result;
 
-import static org.apache.struts2.portlet.PortletConstants.*;
-import static com.opensymphony.xwork2.ActionContext.*;
-
-import java.util.HashMap;
-import java.util.Map;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionProxy;
+import junit.textui.TestRunner;
+import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.PortletPhase;
+import org.jmock.Mock;
+import org.jmock.cglib.MockObjectTestCase;
+import org.jmock.core.Constraint;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -33,16 +38,17 @@ import javax.portlet.PortletMode;
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import java.util.HashMap;
+import java.util.Map;
 
-import junit.textui.TestRunner;
-
-import org.apache.struts2.StrutsStatics;
-import org.jmock.Mock;
-import org.jmock.cglib.MockObjectTestCase;
-import org.jmock.core.Constraint;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
+import static com.opensymphony.xwork2.ActionContext.PARAMETERS;
+import static com.opensymphony.xwork2.ActionContext.SESSION;
+import static org.apache.struts2.portlet.PortletConstants.ACTION_PARAM;
+import static org.apache.struts2.portlet.PortletConstants.MODE_PARAM;
+import static org.apache.struts2.portlet.PortletConstants.PHASE;
+import static 
org.apache.struts2.portlet.PortletConstants.RENDER_DIRECT_LOCATION;
+import static org.apache.struts2.portlet.PortletConstants.REQUEST;
+import static org.apache.struts2.portlet.PortletConstants.RESPONSE;
 
 /**
  * PortletResultTest. Insert description.
@@ -51,13 +57,16 @@ import com.opensymphony.xwork2.ActionInv
 public class PortletResultTest extends MockObjectTestCase implements 
StrutsStatics {
 
     Mock mockInvocation = null;
-    Mock mockConfig = null;
     Mock mockCtx = null;
+    Mock mockProxy = null;
+       ActionProxy proxy = null;
+       ActionInvocation invocation = null;
 
     public void setUp() throws Exception {
         super.setUp();
         mockInvocation = mock(ActionInvocation.class);
         mockCtx = mock(PortletContext.class);
+        mockProxy = mock(ActionProxy.class);
 
         Map<String, String[]> paramMap = new HashMap<String, String[]>();
         Map<String, Object> sessionMap = new HashMap<String, Object>();
@@ -68,8 +77,11 @@ public class PortletResultTest extends M
         context.put(STRUTS_PORTLET_CONTEXT, mockCtx.proxy());
 
         ActionContext.setContext(new ActionContext(context));
-
+        mockProxy.stubs().method("getNamespace").will(returnValue("/test"));
+        proxy = (ActionProxy) mockProxy.proxy();
         
mockInvocation.stubs().method("getInvocationContext").will(returnValue(ActionContext.getContext()));
+        mockInvocation.stubs().method("getProxy").will(returnValue(proxy));
+        invocation = (ActionInvocation) mockInvocation.proxy();
 
     }
 
@@ -96,7 +108,7 @@ public class PortletResultTest extends M
         ctxMap.put(RESPONSE, res);
         ctxMap.put(REQUEST, req);
         ctxMap.put(SERVLET_CONTEXT, ctx);
-        ctxMap.put(PHASE, RENDER_PHASE);
+        ctxMap.put(PHASE, PortletPhase.RENDER_PHASE);
 
         PortletResult result = new PortletResult();
         try {
@@ -118,17 +130,20 @@ public class PortletResultTest extends M
         mockResponse.expects(once()).method("setRenderParameter").with(params);
         params = new Constraint[]{eq(MODE_PARAM), 
eq(PortletMode.VIEW.toString())};
         mockResponse.expects(once()).method("setRenderParameter").with(params);
+        params = new 
Constraint[]{eq(PortletConstants.RENDER_DIRECT_NAMESPACE), eq("/test")};
+        mockResponse.expects(once()).method("setRenderParameter").with(params);
+        
         
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
         ActionContext ctx = ActionContext.getContext();
 
         ctx.put(REQUEST, mockRequest.proxy());
         ctx.put(RESPONSE, mockResponse.proxy());
-        ctx.put(PHASE, ACTION_PHASE);
+        ctx.put(PHASE, PortletPhase.ACTION_PHASE);
 
         PortletResult result = new PortletResult();
         try {
-            result.doExecute("testView.action", 
(ActionInvocation)mockInvocation.proxy());
+            result.doExecute("testView.action", invocation);
         }
         catch(Exception e) {
             e.printStackTrace();
@@ -145,6 +160,9 @@ public class PortletResultTest extends M
         mockResponse.expects(once()).method("setRenderParameter").with(params);
         params = new Constraint[]{eq(MODE_PARAM), 
eq(PortletMode.VIEW.toString())};
         mockResponse.expects(once()).method("setRenderParameter").with(params);
+        params = new 
Constraint[]{eq(PortletConstants.RENDER_DIRECT_NAMESPACE), eq("/test")};
+        mockResponse.expects(once()).method("setRenderParameter").with(params);
+
         
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
  
@@ -154,7 +172,7 @@ public class PortletResultTest extends M
         
         ctx.put(REQUEST, mockRequest.proxy());
         ctx.put(RESPONSE, mockResponse.proxy());
-        ctx.put(PHASE, ACTION_PHASE);
+        ctx.put(PHASE, PortletPhase.ACTION_PHASE);
         ctx.put(ActionContext.SESSION, session);
 
         PortletResult result = new PortletResult();
@@ -180,6 +198,9 @@ public class PortletResultTest extends M
         mockResponse.expects(once()).method("setRenderParameter").with(params);
         params = new Constraint[]{eq(MODE_PARAM), 
eq(PortletMode.VIEW.toString())};
         mockResponse.expects(once()).method("setRenderParameter").with(params);
+        params = new 
Constraint[]{eq(PortletConstants.RENDER_DIRECT_NAMESPACE), eq("/test")};
+        mockResponse.expects(once()).method("setRenderParameter").with(params);
+        
         
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
 
@@ -187,7 +208,7 @@ public class PortletResultTest extends M
 
         ctx.put(REQUEST, mockRequest.proxy());
         ctx.put(RESPONSE, mockResponse.proxy());
-        ctx.put(PHASE, ACTION_PHASE);
+        ctx.put(PHASE, PortletPhase.ACTION_PHASE);
 
         PortletResult result = new PortletResult();
         try {
@@ -220,7 +241,7 @@ public class PortletResultTest extends M
         ctxMap.put(RESPONSE, res);
         ctxMap.put(REQUEST, req);
         ctxMap.put(SERVLET_CONTEXT, ctx);
-        ctxMap.put(PHASE, RENDER_PHASE);
+        ctxMap.put(PHASE, PortletPhase.RENDER_PHASE);
 
         
mockResponse.expects(atLeastOnce()).method("setTitle").with(eq("testTitle"));
         
mockResponse.expects(atLeastOnce()).method("setContentType").with(eq("testContentType"));

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java
 Wed Apr 18 18:13:57 2012
@@ -20,12 +20,10 @@
  */
 package org.apache.struts2.portlet.util;
 
-import static org.apache.struts2.portlet.PortletConstants.*;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
+import com.opensymphony.xwork2.ActionContext;
+import junit.framework.TestCase;
+import org.apache.struts2.portlet.PortletPhase;
+import org.easymock.EasyMock;
 
 import javax.portlet.PortletMode;
 import javax.portlet.PortletModeException;
@@ -35,12 +33,17 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import javax.portlet.WindowStateException;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
 
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import com.opensymphony.xwork2.ActionContext;
+import static org.apache.struts2.portlet.PortletConstants.ACTION_PARAM;
+import static org.apache.struts2.portlet.PortletConstants.MODE_NAMESPACE_MAP;
+import static org.apache.struts2.portlet.PortletConstants.MODE_PARAM;
+import static org.apache.struts2.portlet.PortletConstants.PHASE;
+import static org.apache.struts2.portlet.PortletConstants.REQUEST;
+import static org.apache.struts2.portlet.PortletConstants.RESPONSE;
 
 /**
  */
@@ -70,7 +73,7 @@ public class PortletUrlHelperTest extend
         Map<String, Object> context = new HashMap<String, Object>();
         context.put(REQUEST, renderRequest);
         context.put(RESPONSE, renderResponse);
-        context.put(PHASE, RENDER_PHASE);
+        context.put(PHASE, PortletPhase.RENDER_PHASE);
         context.put(MODE_NAMESPACE_MAP, modeNamespaceMap);
 
         ActionContext.setContext(new ActionContext(context));
@@ -84,7 +87,7 @@ public class PortletUrlHelperTest extend
         EasyMock.replay(renderResponse);
 
         (new PortletUrlHelper()).buildUrl("testAction", null, null,
-                new HashMap(), null, null, null);
+                new HashMap<String, Object>(), null, null, null);
         assertEquals(PortletMode.VIEW, url.getPortletMode());
         assertEquals(WindowState.NORMAL, url.getWindowState());
         assertEquals("testAction", url.getParameterMap().get(ACTION_PARAM)[0]);
@@ -98,7 +101,7 @@ public class PortletUrlHelperTest extend
         EasyMock.replay(renderResponse);
 
         (new PortletUrlHelper()).buildUrl("testAction", null, null,
-                new HashMap(), null, "edit", null);
+                new HashMap<String, Object>(), null, "edit", null);
         
         assertEquals(PortletMode.EDIT, url.getPortletMode());
         assertEquals(WindowState.NORMAL, url.getWindowState());
@@ -113,7 +116,7 @@ public class PortletUrlHelperTest extend
         EasyMock.replay(renderResponse);
         
         (new PortletUrlHelper()).buildUrl("testAction", null, null,
-                new HashMap(), null, null, "maximized");
+                new HashMap<String, Object>(), null, null, "maximized");
         
         assertEquals(PortletMode.VIEW, url.getPortletMode());
         assertEquals(WindowState.MAXIMIZED, url.getWindowState());
@@ -128,7 +131,7 @@ public class PortletUrlHelperTest extend
         EasyMock.replay(renderRequest);
         
         (new PortletUrlHelper()).buildUrl("testAction", null, null,
-                new HashMap(), "action", null, null);
+                new HashMap<String, Object>(), "action", null, null);
         
         assertEquals(PortletMode.VIEW, url.getPortletMode());
         assertEquals(WindowState.NORMAL, url.getWindowState());

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java?rev=1327601&r1=1327600&r2=1327601&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
 Wed Apr 18 18:13:57 2012
@@ -28,7 +28,9 @@ import com.opensymphony.xwork2.util.Valu
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import junit.textui.TestRunner;
 import org.apache.struts2.dispatcher.Dispatcher;
-import org.apache.struts2.portlet.PortletActionConstants;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.PortletPhase;
 import org.apache.struts2.portlet.util.PortletUrlHelper;
 import org.jmock.Mock;
 import org.jmock.cglib.MockObjectTestCase;
@@ -36,8 +38,6 @@ import org.jmock.core.Constraint;
 
 import javax.portlet.PortletContext;
 import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
 import javax.portlet.PortletURL;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
@@ -77,6 +77,10 @@ public class PortletUrlTagTest extends M
     Mock mockCtx = null;
 
     ValueStack stack = null;
+    
+    Mock mockActionProxy = null;
+
+       Mock mockActionInvocation = null;
 
     public static void main(String[] args) {
         TestRunner.run(PortletUrlTagTest.class);
@@ -92,10 +96,11 @@ public class PortletUrlTagTest extends M
 
         stack = 
du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
         stack.getContext().put(ActionContext.CONTAINER, du.getContainer());
-        ActionContext.setContext(new ActionContext(stack.getContext()));
+        ActionContext context = new ActionContext(stack.getContext());
+        ActionContext.setContext(context);
         
-
-
+       mockActionInvocation  = mock(ActionInvocation.class);
+        mockActionProxy = mock(ActionProxy.class);
         mockHttpReq = mock(HttpServletRequest.class);
         mockHttpRes = mock(HttpServletResponse.class);
         mockPortletReq = mock(RenderRequest.class);
@@ -104,11 +109,14 @@ public class PortletUrlTagTest extends M
         mockPortletUrl = mock(PortletURL.class);
         mockJspWriter = new MockJspWriter();
         mockCtx = mock(PortletContext.class);
-
+        
+        
mockActionProxy.stubs().method("getNamespace").will(returnValue("/view"));
+        mockActionInvocation.stubs().method("getProxy").will(returnValue(
+                mockActionProxy.proxy()));
         mockPageCtx.stubs().method("getRequest").will(
-                returnValue((HttpServletRequest) mockHttpReq.proxy()));
+                returnValue(mockHttpReq.proxy()));
         mockPageCtx.stubs().method("getResponse").will(
-                returnValue((HttpServletResponse) mockHttpRes.proxy()));
+                returnValue(mockHttpRes.proxy()));
         mockPageCtx.stubs().method("getOut").will(returnValue(mockJspWriter));
 
         mockHttpReq.stubs().method("getScheme").will(returnValue("http"));
@@ -116,10 +124,10 @@ public class PortletUrlTagTest extends M
                 eq("struts.valueStack")).will(returnValue(stack));
         mockHttpReq.stubs().method("getAttribute").with(
                 eq("javax.portlet.response")).will(
-                returnValue((PortletResponse) mockPortletRes.proxy()));
+                returnValue(mockPortletRes.proxy()));
         mockHttpReq.stubs().method("getAttribute").with(
                 eq("javax.portlet.request")).will(
-                returnValue((PortletRequest) mockPortletReq.proxy()));
+                returnValue(mockPortletReq.proxy()));
         mockHttpReq.stubs().method("getAttribute").with(
                 eq("javax.servlet.include.servlet_path")).will(
                 returnValue("/servletPath"));
@@ -136,17 +144,26 @@ public class PortletUrlTagTest extends M
         modeMap.put(PortletMode.VIEW, "/view");
         modeMap.put(PortletMode.HELP, "/help");
         modeMap.put(PortletMode.EDIT, "/edit");
+        Map<PortletMode,ActionMapping> actionMap = new 
HashMap<PortletMode,ActionMapping>();
+        actionMap.put(PortletMode.VIEW, new ActionMapping("defaultView", 
"/view", "execute", new HashMap<String,Object>()));
+        actionMap.put(PortletMode.HELP, new ActionMapping("defaultHelp", 
"/help", "execute", new HashMap<String,Object>()));
+        actionMap.put(PortletMode.EDIT, new ActionMapping("defaultEdit", 
"/edit", "execute", new HashMap<String,Object>()));
         Map sessionMap = new HashMap();
         Map contextMap = new HashMap();
         contextMap.put(ActionContext.SESSION, sessionMap);
-        contextMap.put(PortletActionConstants.REQUEST, mockPortletReq.proxy());
-        contextMap.put(PortletActionConstants.RESPONSE, 
mockPortletRes.proxy());
-        contextMap.put(PortletActionConstants.PHASE, 
PortletActionConstants.RENDER_PHASE);
-        contextMap.put(PortletActionConstants.MODE_NAMESPACE_MAP, modeMap);
+        contextMap.put(PortletConstants.REQUEST, mockPortletReq.proxy());
+        contextMap.put(PortletConstants.RESPONSE, mockPortletRes.proxy());
+        contextMap.put(PortletConstants.PHASE, PortletPhase.RENDER_PHASE);
+        contextMap.put(PortletConstants.MODE_NAMESPACE_MAP, modeMap);
+        contextMap.put(PortletConstants.DEFAULT_ACTION_MAP, actionMap);
         contextMap.put(STRUTS_PORTLET_CONTEXT, mockCtx.proxy());
+        
         ActionContext ctx = new ActionContext(contextMap);
         ctx.setValueStack(stack);
+        ActionInvocation ai = (ActionInvocation)mockActionInvocation.proxy();
+       stack.getContext().put(ActionContext.ACTION_INVOCATION, ai);
         ActionContext.setContext(ctx);
+        
     }
 
     public void testEnsureParamsAreStringArrays() {
@@ -166,12 +183,12 @@ public class PortletUrlTagTest extends M
         mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
 
         mockPortletRes.expects(once()).method("createRenderURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
 
         Map paramMap = new HashMap();
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
 
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.MAXIMIZED));
@@ -191,22 +208,46 @@ public class PortletUrlTagTest extends M
         mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
 
         mockPortletRes.expects(once()).method("createRenderURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
 
         Map paramMap = new HashMap();
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/help/testAction"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/help/testAction"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
 
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.HELP));
         
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
 
+        tag.setNamespace("/help");
         tag.setAction("testAction");
         tag.setPortletMode("help");
         tag.doStartTag();
         tag.doEndTag();
     }
+    
+    public void 
testWhenPortletModeDiffersFromCurrentAndNoParametersAreSetRenderTheDefaults()
+                throws Exception {
+        PortletMode mode = PortletMode.HELP;
+
+        mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+
+        mockPortletRes.expects(once()).method("createRenderURL").will(
+                returnValue(mockPortletUrl.proxy()));
+        
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
+
+        Map paramMap = new HashMap();
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/help/defaultHelp"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
+
+        mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
+        
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.HELP));
+        
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
+
+        tag.setPortletMode("help");
+        tag.doStartTag();
+        tag.doEndTag();
+    }
 
     public void testUrlWithQueryParams() throws Exception {
 
@@ -215,13 +256,13 @@ public class PortletUrlTagTest extends M
         mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
 
         mockPortletRes.expects(once()).method("createRenderURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
 
         Map paramMap = new HashMap();
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
         paramMap.put("testParam1", new String[]{"testValue1"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
 
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
@@ -239,17 +280,18 @@ public class PortletUrlTagTest extends M
         mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
 
         mockPortletRes.expects(once()).method("createActionURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
 
         Map paramMap = new HashMap();
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/view/testAction"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
 
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
         
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
 
+        tag.setNamespace("/view");
         tag.setAction("testAction");
         tag.setPortletUrlType("action");
         tag.doStartTag();
@@ -316,12 +358,12 @@ public class PortletUrlTagTest extends M
        PortletMode mode = PortletMode.VIEW;
        mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
         mockPortletRes.expects(once()).method("createRenderURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
        tag.setAction("testAction");
        Map paramMap = new HashMap();
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/view/testAction!input"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+        paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/view/testAction!input"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
         
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
@@ -334,22 +376,16 @@ public class PortletUrlTagTest extends M
        PortletMode mode = PortletMode.VIEW;
        mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
         mockPortletRes.expects(once()).method("createRenderURL").will(
-                returnValue((PortletURL) mockPortletUrl.proxy()));
+                returnValue(mockPortletUrl.proxy()));
         
mockCtx.expects(atLeastOnce()).method("getMajorVersion").will(returnValue(1));
        Map paramMap = new HashMap();
        
-       Mock mockActionProxy = mock(ActionProxy.class);
+       
        
mockActionProxy.stubs().method("getActionName").will(returnValue("currentExecutingAction"));
-       mockActionProxy.stubs().method("getNamespace").will(returnValue(""));
-       final ActionProxy proxy = (ActionProxy)mockActionProxy.proxy();
        
-       Mock mockActionInvocation = mock(ActionInvocation.class);
-       
mockActionInvocation.stubs().method("getProxy").will(returnValue(proxy));
-       ActionInvocation ai = (ActionInvocation)mockActionInvocation.proxy();
-
-       stack.getContext().put(ActionContext.ACTION_INVOCATION, ai);
-        paramMap.put(PortletActionConstants.ACTION_PARAM, new 
String[]{"/view/currentExecutingAction"});
-        paramMap.put(PortletActionConstants.MODE_PARAM, new 
String[]{mode.toString()});
+       
+       paramMap.put(PortletConstants.ACTION_PARAM, new 
String[]{"/view/currentExecutingAction"});
+        paramMap.put(PortletConstants.MODE_PARAM, new 
String[]{mode.toString()});
         mockPortletUrl.expects(once()).method("setParameters").with(new 
ParamMapConstraint(paramMap));
         
mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
         
mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
@@ -404,11 +440,20 @@ public class PortletUrlTagTest extends M
          * @see 
org.jmock.core.SelfDescribing#describeTo(java.lang.StringBuffer)
          */
         public StringBuffer describeTo(StringBuffer sb) {
-               Iterator<String> it = myExpectedMap.keySet().iterator();
+               sb.append("\n Expected: ");
+               describeTo(myExpectedMap, sb);
+               sb.append("\n Actual: ");
+               describeTo(myActualMap, sb);
+               
+            return sb;
+        }
+        
+        private StringBuffer describeTo(Map map,StringBuffer sb) {
+               Iterator<String> it = map.keySet().iterator();
                while(it.hasNext()) {
                        String key = it.next();
                        sb.append(key).append("=");
-                       String[] value = (String[])myExpectedMap.get(key);
+                       String[] value = (String[])map.get(key);
                        sb.append(value[0]);
                        if(it.hasNext()) {
                                sb.append(", ");


Reply via email to