Author: martinc Date: Thu Jan 13 21:24:57 2005 New Revision: 125144 URL: http://svn.apache.org/viewcvs?view=rev&rev=125144 Log: Remove tests for methods that were moved to the taglib subproject. These tests are now in TestTagUtils.java in that subproject. Modified: struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java
Modified: struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java Url: http://svn.apache.org/viewcvs/struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java?view=diff&rev=125144&p1=struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java&r1=125143&p2=struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java&r2=125144 ============================================================================== --- struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java (original) +++ struts/core/trunk/src/test/org/apache/struts/util/TestRequestUtils.java Thu Jan 13 21:24:57 2005 @@ -24,8 +24,6 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.jsp.JspException; - import junit.framework.Test; import junit.framework.TestSuite; @@ -39,7 +37,6 @@ import org.apache.struts.mock.MockFormBean; import org.apache.struts.mock.MockPrincipal; import org.apache.struts.mock.TestMockBase; -import org.apache.struts.taglib.html.Constants; /** @@ -161,775 +158,6 @@ } - // ---------------------------------------------------- computeParameters() - - - // No parameters and no transaction token - public void testComputeParameters0a() { - - Map map = null; - try { - map = RequestUtils.computeParameters(page, - null, null, null, null, - null, null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNull("Map is null", map); - - } - - - // No parameters but add transaction token - public void testComputeParameters0b() { - - session.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token"); - Map map = null; - try { - map = RequestUtils.computeParameters - (page, null, null, null, null, - null, null, null, true); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("One parameter in the returned map", - 1, map.size()); - assertTrue("Transaction token parameter present", - map.containsKey(Constants.TOKEN_KEY)); - assertEquals("Transaction token parameter value", - "token", - (String) map.get(Constants.TOKEN_KEY)); - - } - - - // Single parameter -- name - public void testComputeParameters1a() { - - session.setAttribute("attr", "bar"); - Map map = null; - try { - map = RequestUtils.computeParameters - (page, "foo", "attr", null, null, - null, null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("One parameter in the returned map", - 1, map.size()); - assertTrue("Parameter present", - map.containsKey("foo")); - assertEquals("Parameter value", - "bar", - (String) map.get("foo")); - - } - - - // Single parameter -- scope + name - public void testComputeParameters1b() { - - request.setAttribute("attr", "bar"); - Map map = null; - try { - map = RequestUtils.computeParameters - (page, "foo", "attr", null, "request", - null, null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("One parameter in the returned map", - 1, map.size()); - assertTrue("Parameter present", - map.containsKey("foo")); - assertEquals("Parameter value", - "bar", - (String) map.get("foo")); - - } - - - // Single parameter -- scope + name + property - public void testComputeParameters1c() { - - request.setAttribute("attr", new MockFormBean("bar")); - - Map map = null; - try { - map = RequestUtils.computeParameters - (page, "foo", "attr", "stringProperty", "request", - null, null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("One parameter in the returned map", - 1, map.size()); - assertTrue("Parameter present", - map.containsKey("foo")); - assertEquals("Parameter value", - "bar", - (String) map.get("foo")); - - } - - - // Provided map -- name - public void testComputeParameters2a() { - - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - session.setAttribute("attr", map); - - try { - map = RequestUtils.computeParameters - (page, null, null, null, null, - "attr", null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("Two parameter in the returned map", - 2, map.size()); - assertTrue("Parameter foo1 present", - map.containsKey("foo1")); - assertEquals("Parameter foo1 value", - "bar1", - (String) map.get("foo1")); - assertTrue("Parameter foo2 present", - map.containsKey("foo2")); - assertEquals("Parameter foo2 value", - "bar2", - (String) map.get("foo2")); - - } - - - // Provided map -- scope + name - public void testComputeParameters2b() { - - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - request.setAttribute("attr", map); - - try { - map = RequestUtils.computeParameters - (page, null, null, null, null, - "attr", null, "request", false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("Two parameter in the returned map", - 2, map.size()); - assertTrue("Parameter foo1 present", - map.containsKey("foo1")); - assertEquals("Parameter foo1 value", - "bar1", - (String) map.get("foo1")); - assertTrue("Parameter foo2 present", - map.containsKey("foo2")); - assertEquals("Parameter foo2 value", - "bar2", - (String) map.get("foo2")); - - } - - - // Provided map -- scope + name + property - public void testComputeParameters2c() { - - request.setAttribute("attr", new MockFormBean()); - - Map map = null; - try { - map = RequestUtils.computeParameters - (page, null, null, null, null, - "attr", "mapProperty", "request", false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("Two parameter in the returned map", - 2, map.size()); - assertTrue("Parameter foo1 present", - map.containsKey("foo1")); - assertEquals("Parameter foo1 value", - "bar1", - (String) map.get("foo1")); - assertTrue("Parameter foo2 present", - map.containsKey("foo2")); - assertEquals("Parameter foo2 value", - "bar2", - (String) map.get("foo2")); - - } - - - // Provided map -- name with one key and two values - public void testComputeParameters2d() { - - Map map = new HashMap(); - map.put("foo", new String[] { "bar1", "bar2" }); - session.setAttribute("attr", map); - - try { - map = RequestUtils.computeParameters - (page, null, null, null, null, - "attr", null, null, false); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("One parameter in the returned map", - 1, map.size()); - assertTrue("Parameter foo present", - map.containsKey("foo")); - assertTrue("Parameter foo value type", - map.get("foo") instanceof String[]); - String values[] = (String[]) map.get("foo"); - assertEquals("Values count", - 2, values.length); - - } - - - // Kitchen sink combination of parameters with a merge - public void testComputeParameters3a() { - - request.setAttribute("attr", new MockFormBean("bar3")); - session.setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token"); - - Map map = null; - try { - map = RequestUtils.computeParameters - (page, "foo1", "attr", "stringProperty", "request", - "attr", "mapProperty", "request", true); - } catch (JspException e) { - fail("JspException: " + e); - } - assertNotNull("Map is not null", map); - assertEquals("Three parameter in the returned map", - 3, map.size()); - - assertTrue("Parameter foo1 present", - map.containsKey("foo1")); - assertTrue("Parameter foo1 value type", - map.get("foo1") instanceof String[]); - String values[] = (String[]) map.get("foo1"); - assertEquals("Values count", - 2, values.length); - - assertTrue("Parameter foo2 present", - map.containsKey("foo2")); - assertEquals("Parameter foo2 value", - "bar2", - (String) map.get("foo2")); - - assertTrue("Transaction token parameter present", - map.containsKey(Constants.TOKEN_KEY)); - assertEquals("Transaction token parameter value", - "token", - (String) map.get(Constants.TOKEN_KEY)); - } - - - // ----------------------------------------------------------- computeURL() - - - // Default module -- Forward only - public void testComputeURL1a() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "foo", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/bar.jsp", - url); - - } - - - // Default module -- Href only - public void testComputeURL1b() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - "http://foo.com/bar", null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "http://foo.com/bar", - url); - - } - - - // Default module -- Page only - public void testComputeURL1c() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/bar", - url); - - } - - - // Default module -- Forward with pattern - public void testComputeURL1d() { - - moduleConfig.getControllerConfig().setForwardPattern - ("$C/WEB-INF/pages$M$P"); - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "foo", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/WEB-INF/pages/bar.jsp", - url); - - } - - - // Default module -- Page with pattern - public void testComputeURL1e() { - - moduleConfig.getControllerConfig().setPagePattern - ("$C/WEB-INF/pages$M$P"); - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/WEB-INF/pages/bar", - url); - - } - - - // Default module -- Forward with relative path (non-context-relative) - public void testComputeURL1f() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "relative1", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - // "/myapp/relative.jsp", - "relative.jsp", - url); - } - - - // Default module -- Forward with relative path (context-relative) - public void testComputeURL1g() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "relative2", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - // "/myapp/relative.jsp", - "relative.jsp", - url); - } - - - // Default module -- Forward with external path - public void testComputeURL1h() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "external", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "http://jakarta.apache.org/", - url); - } - - - // Second module -- Forward only - public void testComputeURL2a() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "foo", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/2/baz.jsp", - url); - - } - - - // Second module -- Href only - public void testComputeURL2b() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - "http://foo.com/bar", null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "http://foo.com/bar", - url); - - } - - - // Second module -- Page only - public void testComputeURL2c() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/2/bar", - url); - - } - - - // Default module -- Forward with pattern - public void testComputeURL2d() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - moduleConfig2.getControllerConfig().setForwardPattern - ("$C/WEB-INF/pages$M$P"); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "foo", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/WEB-INF/pages/2/baz.jsp", - url); - - } - - - // Second module -- Page with pattern - public void testComputeURL2e() { - - moduleConfig2.getControllerConfig().setPagePattern - ("$C/WEB-INF/pages$M$P"); - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/WEB-INF/pages/2/bar", - url); - - } - - - // Second module -- Forward with relative path (non-context-relative) - public void testComputeURL2f() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "relative1", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - // "/myapp/2/relative.jsp", - "relative.jsp", - url); - } - - - // Second module -- Forward with relative path (context-relative) - public void testComputeURL2g() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "relative2", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - // "/myapp/relative.jsp", - "relative.jsp", - url); - } - - - // Second module -- Forward with external path - public void testComputeURL2h() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, "external", - null, null, - null, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "http://jakarta.apache.org/", - url); - } - - - // Add parameters only -- forward URL - public void testComputeURL3a() { - - request.setPathElements("/myapp", "/action.do", null, null); - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - map, null, false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertTrue("url value", - url.equals("/myapp/bar?foo1=bar1&foo2=bar2") || - url.equals("/myapp/bar?foo2=bar2&foo1=bar1")); - - } - - - // Add anchor only -- forward URL - public void testComputeURL3b() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, "anchor", false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/bar#anchor", - url); - - } - - - // Add parameters + anchor -- forward URL - public void testComputeURL3c() { - - request.setPathElements("/myapp", "/action.do", null, null); - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - map, "anchor", false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertTrue("url value", - url.equals("/myapp/bar?foo1=bar1&foo2=bar2#anchor") || - url.equals("/myapp/bar?foo2=bar2&foo1=bar1#anchor")); - - } - - - // Add parameters only -- redirect URL - public void testComputeURL3d() { - - request.setPathElements("/myapp", "/action.do", null, null); - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - map, null, true); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertTrue("url value", - url.equals("/myapp/bar?foo1=bar1&foo2=bar2") || - url.equals("/myapp/bar?foo2=bar2&foo1=bar1")); - - } - - - // Add anchor only -- redirect URL - public void testComputeURL3e() { - - request.setPathElements("/myapp", "/action.do", null, null); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - null, "anchor", true); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertEquals("url value", - "/myapp/bar#anchor", - url); - - } - - - // Add parameters + anchor -- redirect URL - public void testComputeURL3f() { - - request.setPathElements("/myapp", "/action.do", null, null); - Map map = new HashMap(); - map.put("foo1", "bar1"); - map.put("foo2", "bar2"); - String url = null; - try { - url = RequestUtils.computeURL - (page, null, - null, "/bar", - map, "anchor", false); - } catch (MalformedURLException e) { - fail("MalformedURLException: " + e); - } - assertNotNull("url present", url); - assertTrue("url value", - url.equals("/myapp/bar?foo1=bar1&foo2=bar2#anchor") || - url.equals("/myapp/bar?foo2=bar2&foo1=bar1#anchor")); - - } - - // ----------------------------------------------------- createActionForm() @@ -1422,66 +650,6 @@ result); } - - - // -------------------------------------------------------------- pageURL() - - - // Default module (default pagePattern) - public void testPageURL1() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig); - request.setPathElements("/myapp", "/action.do", null, null); - String page = null; - String result = null; - - // Straight substitution - page = "/mypages/index.jsp"; - result = RequestUtils.pageURL(request, page); - assertNotNull("straight sub found", result); - assertEquals("straight sub value", - "/mypages/index.jsp", result); - - - } - - - // Second module (default pagePattern) - public void testPageURL2() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig2); - request.setPathElements("/myapp", "/2/action.do", null, null); - String page = null; - String result = null; - - // Straight substitution - page = "/mypages/index.jsp"; - result = RequestUtils.pageURL(request, page); - assertNotNull("straight sub found", result); - assertEquals("straight sub value", - "/2/mypages/index.jsp", result); - - - } - - - // Third module (custom pagePattern) - public void testPageURL3() { - - request.setAttribute(Globals.MODULE_KEY, moduleConfig3); - request.setPathElements("/myapp", "/3/action.do", null, null); - String page = null; - String result = null; - - // Straight substitution - page = "/mypages/index.jsp"; - result = RequestUtils.pageURL(request, page); - assertNotNull("straight sub found", result); - assertEquals("straight sub value", - "/paging/3/mypages/index.jsp", result); - - - } // ----------------------------------------------------------- requestURL() --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]