You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/06 16:02:22 UTC
svn commit: r471756 [25/31] - in /struts/struts2/trunk: apps/blank/
apps/blank/src/main/java/example/ apps/blank/src/test/java/example/
apps/mailreader/src/main/java/mailreader2/
apps/portlet/src/main/java/org/apache/struts2/portlet/example/ apps/portl...
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/result/PortletResultTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.portlet.result;
@@ -41,50 +44,50 @@
/**
* PortletResultTest. Insert description.
- *
+ *
*/
public class PortletResultTest extends MockObjectTestCase {
-
+
Mock mockInvocation = null;
Mock mockConfig = null;
Mock mockCtx = null;
-
+
public void setUp() throws Exception {
super.setUp();
mockInvocation = mock(ActionInvocation.class);
mockConfig = mock(PortletConfig.class);
mockCtx = mock(PortletContext.class);
-
+
mockConfig.stubs().method(ANYTHING);
mockConfig.stubs().method("getPortletContext").will(returnValue(mockCtx.proxy()));
-
+
Map paramMap = new HashMap();
Map sessionMap = new HashMap();
-
+
Map context = new HashMap();
context.put(ActionContext.SESSION, sessionMap);
context.put(ActionContext.PARAMETERS, paramMap);
context.put(PortletActionConstants.PORTLET_CONFIG, mockConfig.proxy());
-
+
ActionContext.setContext(new ActionContext(context));
-
+
mockInvocation.stubs().method("getInvocationContext").will(returnValue(ActionContext.getContext()));
-
+
}
-
+
public void testDoExecute_render() {
Mock mockRequest = mock(RenderRequest.class);
Mock mockResponse = mock(RenderResponse.class);
Mock mockRd = mock(PortletRequestDispatcher.class);
Mock mockPrep = mock(PortletRequestDispatcher.class);
-
+
RenderRequest req = (RenderRequest)mockRequest.proxy();
RenderResponse res = (RenderResponse)mockResponse.proxy();
PortletRequestDispatcher rd = (PortletRequestDispatcher)mockRd.proxy();
PortletConfig cfg = (PortletConfig)mockConfig.proxy();
PortletContext ctx = (PortletContext)mockCtx.proxy();
ActionInvocation inv = (ActionInvocation)mockInvocation.proxy();
-
+
Constraint[] params = new Constraint[]{same(req), same(res)};
mockRd.expects(once()).method("include").with(params);
mockPrep.expects(once()).method("include").with(params);
@@ -92,15 +95,15 @@
mockCtx.expects(once()).method("getNamedDispatcher").with(eq("preparator")).will(returnValue(mockPrep.proxy()));
mockResponse.expects(once()).method("setContentType").with(eq("text/html"));
mockConfig.expects(once()).method("getPortletContext").will(returnValue(ctx));
-
+
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
-
+
ActionContext ctxMap = ActionContext.getContext();
ctxMap.put(PortletActionConstants.RESPONSE, res);
ctxMap.put(PortletActionConstants.REQUEST, req);
ctxMap.put(PortletActionConstants.PORTLET_CONFIG, cfg);
ctxMap.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
-
+
PortletResult result = new PortletResult();
try {
result.doExecute("/WEB-INF/pages/testPage.jsp", inv);
@@ -109,25 +112,25 @@
e.printStackTrace();
fail("Error occured!");
}
-
+
}
-
+
public void testDoExecute_event_locationIsAction() {
-
+
Mock mockRequest = mock(ActionRequest.class);
Mock mockResponse = mock(ActionResponse.class);
-
+
Constraint[] params = new Constraint[]{eq(PortletActionConstants.ACTION_PARAM), eq("testView")};
mockResponse.expects(once()).method("setRenderParameter").with(params);
params = new Constraint[]{eq(PortletActionConstants.MODE_PARAM), eq(PortletMode.VIEW.toString())};
mockResponse.expects(once()).method("setRenderParameter").with(params);
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
ActionContext ctx = ActionContext.getContext();
-
+
ctx.put(PortletActionConstants.REQUEST, mockRequest.proxy());
ctx.put(PortletActionConstants.RESPONSE, mockResponse.proxy());
ctx.put(PortletActionConstants.PHASE, PortletActionConstants.EVENT_PHASE);
-
+
PortletResult result = new PortletResult();
try {
result.doExecute("testView.action", (ActionInvocation)mockInvocation.proxy());
@@ -136,13 +139,13 @@
e.printStackTrace();
fail("Error occured!");
}
-
+
}
-
+
public void testDoExecute_event_locationIsJsp() {
Mock mockRequest = mock(ActionRequest.class);
Mock mockResponse = mock(ActionResponse.class);
-
+
Constraint[] params = new Constraint[]{eq(PortletActionConstants.ACTION_PARAM), eq("renderDirect")};
mockResponse.expects(once()).method("setRenderParameter").with(params);
params = new Constraint[]{eq("location"), eq("/WEB-INF/pages/testJsp.jsp")};
@@ -150,13 +153,13 @@
params = new Constraint[]{eq(PortletActionConstants.MODE_PARAM), eq(PortletMode.VIEW.toString())};
mockResponse.expects(once()).method("setRenderParameter").with(params);
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
-
+
ActionContext ctx = ActionContext.getContext();
-
+
ctx.put(PortletActionConstants.REQUEST, mockRequest.proxy());
ctx.put(PortletActionConstants.RESPONSE, mockResponse.proxy());
ctx.put(PortletActionConstants.PHASE, PortletActionConstants.EVENT_PHASE);
-
+
PortletResult result = new PortletResult();
try {
result.doExecute("/WEB-INF/pages/testJsp.jsp", (ActionInvocation)mockInvocation.proxy());
@@ -166,11 +169,11 @@
fail("Error occured!");
}
}
-
+
public void testDoExecute_event_locationHasQueryParams() {
Mock mockRequest = mock(ActionRequest.class);
Mock mockResponse = mock(ActionResponse.class);
-
+
Constraint[] params = new Constraint[]{eq(PortletActionConstants.ACTION_PARAM), eq("testView")};
mockResponse.expects(once()).method("setRenderParameter").with(params);
params = new Constraint[]{eq("testParam1"), eq("testValue1")};
@@ -180,13 +183,13 @@
params = new Constraint[]{eq(PortletActionConstants.MODE_PARAM), eq(PortletMode.VIEW.toString())};
mockResponse.expects(once()).method("setRenderParameter").with(params);
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
-
+
ActionContext ctx = ActionContext.getContext();
-
+
ctx.put(PortletActionConstants.REQUEST, mockRequest.proxy());
ctx.put(PortletActionConstants.RESPONSE, mockResponse.proxy());
ctx.put(PortletActionConstants.PHASE, PortletActionConstants.EVENT_PHASE);
-
+
PortletResult result = new PortletResult();
try {
result.doExecute("testView.action?testParam1=testValue1&testParam2=testValue2", (ActionInvocation)mockInvocation.proxy());
@@ -196,50 +199,50 @@
fail("Error occured!");
}
}
-
+
public void testTitleAndContentType() throws Exception {
Mock mockRequest = mock(RenderRequest.class);
Mock mockResponse = mock(RenderResponse.class);
Mock mockRd = mock(PortletRequestDispatcher.class);
Mock mockPrep = mock(PortletRequestDispatcher.class);
-
+
RenderRequest req = (RenderRequest)mockRequest.proxy();
RenderResponse res = (RenderResponse)mockResponse.proxy();
PortletRequestDispatcher rd = (PortletRequestDispatcher)mockRd.proxy();
PortletConfig cfg = (PortletConfig)mockConfig.proxy();
PortletContext ctx = (PortletContext)mockCtx.proxy();
-
+
Constraint[] params = new Constraint[]{same(req), same(res)};
mockRd.expects(once()).method("include").with(params);
mockPrep.expects(once()).method("include").with(params);
mockCtx.expects(once()).method("getRequestDispatcher").with(eq("/WEB-INF/pages/testPage.jsp")).will(returnValue(rd));
mockCtx.expects(once()).method("getNamedDispatcher").with(eq("preparator")).will(returnValue(mockPrep.proxy()));
mockConfig.expects(once()).method("getPortletContext").will(returnValue(ctx));
-
+
mockRequest.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
-
+
ActionContext ctxMap = ActionContext.getContext();
ctxMap.put(PortletActionConstants.RESPONSE, res);
ctxMap.put(PortletActionConstants.REQUEST, req);
ctxMap.put(PortletActionConstants.PORTLET_CONFIG, cfg);
ctxMap.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
-
+
mockResponse.expects(atLeastOnce()).method("setTitle").with(eq("testTitle"));
mockResponse.expects(atLeastOnce()).method("setContentType").with(eq("testContentType"));
-
+
PortletResult result = new PortletResult();
result.setTitle("testTitle");
result.setContentType("testContentType");
result.doExecute("/WEB-INF/pages/testPage.jsp", (ActionInvocation)mockInvocation.proxy());
}
-
+
public void tearDown() throws Exception {
super.tearDown();
ActionContext.setContext(null);
}
-
+
public static void main(String[] args) {
TestRunner.run(PortletResultTest.class);
}
-
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/PortletUrlHelperTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.portlet.util;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/StrutsUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/StrutsUtilTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/StrutsUtilTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/util/StrutsUtilTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.portlet.util;
@@ -37,204 +40,204 @@
/**
* Test case for StrutsUtil.
- *
+ *
*/
public class StrutsUtilTest extends StrutsTestCase {
-
- protected ValueStack stack = null;
- protected InternalMockHttpServletRequest request = null;
- protected MockHttpServletResponse response = null;
- protected StrutsUtil strutsUtil = null;
-
- public void testBeanMethod() throws Exception {
- Object o = strutsUtil.bean("org.apache.struts2.TestAction");
- assertNotNull(o);
- assertTrue(o instanceof TestAction);
- }
-
- public void testIsTrueMethod() throws Exception {
- stack.push(new Object() {
- public String getMyString() {
- return "myString";
- }
- public boolean getMyBoolean(boolean bool) {
- return bool;
- }
- });
- assertTrue(strutsUtil.isTrue("myString == 'myString'"));
- assertFalse(strutsUtil.isTrue("myString == 'myOtherString'"));
- assertTrue(strutsUtil.isTrue("getMyBoolean(true)"));
- assertFalse(strutsUtil.isTrue("getMyBoolean(false)"));
- }
-
- public void testFindStringMethod() throws Exception {
- stack.push(new Object() {
- public String getMyString() {
- return "myString";
- }
- public boolean getMyBoolean(boolean bool) {
- return bool;
- }
- });
-
- assertEquals(strutsUtil.findString("myString"), "myString");
- assertNull(strutsUtil.findString("myOtherString"));
- assertEquals(strutsUtil.findString("getMyBoolean(true)"), "true");
- }
-
- public void testIncludeMethod() throws Exception {
- strutsUtil.include("/some/includedJspFile.jsp");
-
- // with include, this must have been created and should not be null
- assertNotNull(request.getDispatcher());
- // this must be true, indicating we actaully ask container to do an include
- assertTrue(request.getDispatcher().included);
- }
-
-
- public void testUrlEncodeMethod() throws Exception {
- assertEquals(
- strutsUtil.urlEncode("http://www.opensymphony.com/action2/index.jsp?param1=value1"),
- "http%3A%2F%2Fwww.opensymphony.com%2Faction2%2Findex.jsp%3Fparam1%3Dvalue1");
- }
-
- public void testBuildUrlMethod() throws Exception {
- request.setContextPath("/myContextPath");
- assertEquals(strutsUtil.buildUrl("/someUrl?param1=value1"), "/myContextPath/someUrl?param1=value1");
- }
-
-
- public void testFindValueMethod() throws Exception {
- stack.push(new Object() {
- public String getMyString() {
- return "myString";
- }
- public boolean getMyBoolean(boolean bool) {
- return bool;
- }
- });
- Object obj1 = strutsUtil.findValue("myString", "java.lang.String");
- Object obj2 = strutsUtil.findValue("getMyBoolean(true)", "java.lang.Boolean");
-
- assertNotNull(obj1);
- assertNotNull(obj2);
- assertTrue(obj1 instanceof String);
- assertTrue(obj2 instanceof Boolean);
- assertEquals(obj1, "myString");
- assertEquals(obj2, Boolean.TRUE);
- }
-
-
-
- public void testGetTextMethod() throws Exception {
- // this should be in xwork-messages.properties (included by default
- // by LocalizedTextUtil
- assertNotNull(strutsUtil.getText("xwork.error.action.execution"));
- assertEquals(strutsUtil.getText("xwork.error.action.execution"), "Error during Action invocation");
- }
-
-
- public void testGetContextMethod() throws Exception {
- request.setContextPath("/myContext");
- assertEquals(strutsUtil.getContext(), "/myContext");
- }
-
-
- public void testMakeSelectListMethod() throws Exception {
- String[] selectedList = new String[] { "Car", "Airplane", "Bus" };
- List list = new ArrayList();
- list.add("Lorry");
- list.add("Car");
- list.add("Helicopter");
-
- stack.getContext().put("mySelectedList", selectedList);
- stack.getContext().put("myList", list);
-
- List listMade = strutsUtil.makeSelectList("#mySelectedList", "#myList", null, null);
-
- assertEquals(listMade.size(), 3);
- assertEquals(((ListEntry)listMade.get(0)).getKey(), "Lorry");
- assertEquals(((ListEntry)listMade.get(0)).getValue(), "Lorry");
- assertEquals(((ListEntry)listMade.get(0)).getIsSelected(), false);
- assertEquals(((ListEntry)listMade.get(1)).getKey(), "Car");
- assertEquals(((ListEntry)listMade.get(1)).getValue(), "Car");
- assertEquals(((ListEntry)listMade.get(1)).getIsSelected(), true);
- assertEquals(((ListEntry)listMade.get(2)).getKey(), "Helicopter");
- assertEquals(((ListEntry)listMade.get(2)).getValue(), "Helicopter");
- assertEquals(((ListEntry)listMade.get(2)).getIsSelected(), false);
- }
-
-
- public void testHtmlEncode() throws Exception {
- assertEquals(
- strutsUtil.htmlEncode("<html><head><title>some title</title><body>some content</body></html>"),
- "<html><head><title>some title</title><body>some content</body></html>");
- }
-
-
- public void testToInt() throws Exception {
- assertEquals(strutsUtil.toInt(11l), 11);
- }
-
-
- public void testToLong() throws Exception {
- assertEquals(strutsUtil.toLong(11), 11l);
- }
-
-
- public void testToString() throws Exception {
- assertEquals(strutsUtil.toString(1), "1");
- assertEquals(strutsUtil.toString(11l), "11");
- }
-
-
- // === Junit Hook
-
- protected void setUp() throws Exception {
- super.setUp();
- stack = ValueStackFactory.getFactory().createValueStack();
- request = new InternalMockHttpServletRequest();
- response = new MockHttpServletResponse();
- strutsUtil = new StrutsUtil(stack, request, response);
- }
-
- protected void tearDown() throws Exception {
- stack = null;
- request = null;
- response = null;
- strutsUtil = null;
- super.tearDown();
- }
-
-
-
- // === internal class to assist in testing
-
- class InternalMockHttpServletRequest extends MockHttpServletRequest {
- InternalMockRequestDispatcher dispatcher = null;
- public RequestDispatcher getRequestDispatcher(String path) {
- dispatcher = new InternalMockRequestDispatcher(path);
- return dispatcher;
- }
-
- public InternalMockRequestDispatcher getDispatcher() {
- return dispatcher;
- }
- }
-
- class InternalMockRequestDispatcher extends MockRequestDispatcher {
- private String url;
- boolean included = false;
- public InternalMockRequestDispatcher(String url) {
- super(url);
- this.url = url;
- }
- public void include(ServletRequest servletRequest, ServletResponse servletResponse) {
- if (servletResponse instanceof MockHttpServletResponse) {
- ((MockHttpServletResponse) servletResponse).setIncludedUrl(this.url);
- }
- included = true;
- }
- }
-
+
+ protected ValueStack stack = null;
+ protected InternalMockHttpServletRequest request = null;
+ protected MockHttpServletResponse response = null;
+ protected StrutsUtil strutsUtil = null;
+
+ public void testBeanMethod() throws Exception {
+ Object o = strutsUtil.bean("org.apache.struts2.TestAction");
+ assertNotNull(o);
+ assertTrue(o instanceof TestAction);
+ }
+
+ public void testIsTrueMethod() throws Exception {
+ stack.push(new Object() {
+ public String getMyString() {
+ return "myString";
+ }
+ public boolean getMyBoolean(boolean bool) {
+ return bool;
+ }
+ });
+ assertTrue(strutsUtil.isTrue("myString == 'myString'"));
+ assertFalse(strutsUtil.isTrue("myString == 'myOtherString'"));
+ assertTrue(strutsUtil.isTrue("getMyBoolean(true)"));
+ assertFalse(strutsUtil.isTrue("getMyBoolean(false)"));
+ }
+
+ public void testFindStringMethod() throws Exception {
+ stack.push(new Object() {
+ public String getMyString() {
+ return "myString";
+ }
+ public boolean getMyBoolean(boolean bool) {
+ return bool;
+ }
+ });
+
+ assertEquals(strutsUtil.findString("myString"), "myString");
+ assertNull(strutsUtil.findString("myOtherString"));
+ assertEquals(strutsUtil.findString("getMyBoolean(true)"), "true");
+ }
+
+ public void testIncludeMethod() throws Exception {
+ strutsUtil.include("/some/includedJspFile.jsp");
+
+ // with include, this must have been created and should not be null
+ assertNotNull(request.getDispatcher());
+ // this must be true, indicating we actaully ask container to do an include
+ assertTrue(request.getDispatcher().included);
+ }
+
+
+ public void testUrlEncodeMethod() throws Exception {
+ assertEquals(
+ strutsUtil.urlEncode("http://www.opensymphony.com/action2/index.jsp?param1=value1"),
+ "http%3A%2F%2Fwww.opensymphony.com%2Faction2%2Findex.jsp%3Fparam1%3Dvalue1");
+ }
+
+ public void testBuildUrlMethod() throws Exception {
+ request.setContextPath("/myContextPath");
+ assertEquals(strutsUtil.buildUrl("/someUrl?param1=value1"), "/myContextPath/someUrl?param1=value1");
+ }
+
+
+ public void testFindValueMethod() throws Exception {
+ stack.push(new Object() {
+ public String getMyString() {
+ return "myString";
+ }
+ public boolean getMyBoolean(boolean bool) {
+ return bool;
+ }
+ });
+ Object obj1 = strutsUtil.findValue("myString", "java.lang.String");
+ Object obj2 = strutsUtil.findValue("getMyBoolean(true)", "java.lang.Boolean");
+
+ assertNotNull(obj1);
+ assertNotNull(obj2);
+ assertTrue(obj1 instanceof String);
+ assertTrue(obj2 instanceof Boolean);
+ assertEquals(obj1, "myString");
+ assertEquals(obj2, Boolean.TRUE);
+ }
+
+
+
+ public void testGetTextMethod() throws Exception {
+ // this should be in xwork-messages.properties (included by default
+ // by LocalizedTextUtil
+ assertNotNull(strutsUtil.getText("xwork.error.action.execution"));
+ assertEquals(strutsUtil.getText("xwork.error.action.execution"), "Error during Action invocation");
+ }
+
+
+ public void testGetContextMethod() throws Exception {
+ request.setContextPath("/myContext");
+ assertEquals(strutsUtil.getContext(), "/myContext");
+ }
+
+
+ public void testMakeSelectListMethod() throws Exception {
+ String[] selectedList = new String[] { "Car", "Airplane", "Bus" };
+ List list = new ArrayList();
+ list.add("Lorry");
+ list.add("Car");
+ list.add("Helicopter");
+
+ stack.getContext().put("mySelectedList", selectedList);
+ stack.getContext().put("myList", list);
+
+ List listMade = strutsUtil.makeSelectList("#mySelectedList", "#myList", null, null);
+
+ assertEquals(listMade.size(), 3);
+ assertEquals(((ListEntry)listMade.get(0)).getKey(), "Lorry");
+ assertEquals(((ListEntry)listMade.get(0)).getValue(), "Lorry");
+ assertEquals(((ListEntry)listMade.get(0)).getIsSelected(), false);
+ assertEquals(((ListEntry)listMade.get(1)).getKey(), "Car");
+ assertEquals(((ListEntry)listMade.get(1)).getValue(), "Car");
+ assertEquals(((ListEntry)listMade.get(1)).getIsSelected(), true);
+ assertEquals(((ListEntry)listMade.get(2)).getKey(), "Helicopter");
+ assertEquals(((ListEntry)listMade.get(2)).getValue(), "Helicopter");
+ assertEquals(((ListEntry)listMade.get(2)).getIsSelected(), false);
+ }
+
+
+ public void testHtmlEncode() throws Exception {
+ assertEquals(
+ strutsUtil.htmlEncode("<html><head><title>some title</title><body>some content</body></html>"),
+ "<html><head><title>some title</title><body>some content</body></html>");
+ }
+
+
+ public void testToInt() throws Exception {
+ assertEquals(strutsUtil.toInt(11l), 11);
+ }
+
+
+ public void testToLong() throws Exception {
+ assertEquals(strutsUtil.toLong(11), 11l);
+ }
+
+
+ public void testToString() throws Exception {
+ assertEquals(strutsUtil.toString(1), "1");
+ assertEquals(strutsUtil.toString(11l), "11");
+ }
+
+
+ // === Junit Hook
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ stack = ValueStackFactory.getFactory().createValueStack();
+ request = new InternalMockHttpServletRequest();
+ response = new MockHttpServletResponse();
+ strutsUtil = new StrutsUtil(stack, request, response);
+ }
+
+ protected void tearDown() throws Exception {
+ stack = null;
+ request = null;
+ response = null;
+ strutsUtil = null;
+ super.tearDown();
+ }
+
+
+
+ // === internal class to assist in testing
+
+ class InternalMockHttpServletRequest extends MockHttpServletRequest {
+ InternalMockRequestDispatcher dispatcher = null;
+ public RequestDispatcher getRequestDispatcher(String path) {
+ dispatcher = new InternalMockRequestDispatcher(path);
+ return dispatcher;
+ }
+
+ public InternalMockRequestDispatcher getDispatcher() {
+ return dispatcher;
+ }
+ }
+
+ class InternalMockRequestDispatcher extends MockRequestDispatcher {
+ private String url;
+ boolean included = false;
+ public InternalMockRequestDispatcher(String url) {
+ super(url);
+ this.url = url;
+ }
+ public void include(ServletRequest servletRequest, ServletResponse servletResponse) {
+ if (servletResponse instanceof MockHttpServletResponse) {
+ ((MockHttpServletResponse) servletResponse).setIncludedUrl(this.url);
+ }
+ included = true;
+ }
+ }
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.spring;
@@ -39,7 +42,7 @@
StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory();
ServletContext msc = (ServletContext) new MockServletContext();
fac.init(msc);
-
+
assertEquals(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, fac.getAutowireStrategy());
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/ContainUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/ContainUtilTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/ContainUtilTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/ContainUtilTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
- * $Id: ContainUtil.java 418521 2006-07-01 23:36:50Z mrdon $
+ * $Id: $
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
@@ -25,94 +28,94 @@
import junit.framework.TestCase;
/**
- *
+ *
* @version $Date$ $Id$
*/
public class ContainUtilTest extends TestCase {
- public void testNull() throws Exception {
- assertFalse(ContainUtil.contains(null, null));
- assertFalse(ContainUtil.contains(new Object(), null));
- assertFalse(ContainUtil.contains(null, new Object()));
- }
-
- public void testSimpleList() throws Exception {
- List<String> l = new ArrayList<String>();
- l.add("one");
- l.add("two");
-
- assertFalse(ContainUtil.contains(l, "three"));
- assertTrue(ContainUtil.contains(l, "one"));
- assertTrue(ContainUtil.contains(l, "two"));
- }
-
- public void testSimpleSet() throws Exception {
- Set<String> s = new LinkedHashSet<String>();
- s.add("one");
- s.add("two");
-
- assertFalse(ContainUtil.contains(s, "thre"));
- assertTrue(ContainUtil.contains(s, "one"));
- assertTrue(ContainUtil.contains(s, "two"));
- }
-
- public void testComplexList() throws Exception {
- List<MyObject> l = new ArrayList<MyObject>();
- l.add(new MyObject("tm_jee", 20));
- l.add(new MyObject("jenny", 22));
-
- assertFalse(ContainUtil.contains(l, new MyObject("paul", 50)));
- assertFalse(ContainUtil.contains(l, new MyObject("tm_jee", 44)));
- assertTrue(ContainUtil.contains(l, new MyObject("tm_jee", 20)));
- assertTrue(ContainUtil.contains(l, new MyObject("jenny", 22)));
- }
-
- public void testComplexMap() throws Exception {
- Set<MyObject> s = new LinkedHashSet<MyObject>();
- s.add(new MyObject("tm_jee", 20));
- s.add(new MyObject("jenny", 22));
-
- assertFalse(ContainUtil.contains(s, new MyObject("paul", 50)));
- assertFalse(ContainUtil.contains(s, new MyObject("tm_jee", 44)));
- assertTrue(ContainUtil.contains(s, new MyObject("tm_jee", 20)));
- assertTrue(ContainUtil.contains(s, new MyObject("jenny", 22)));
- }
-
- public void testObject() throws Exception {
- assertFalse(ContainUtil.contains("aaa", "bbb"));
- assertFalse(ContainUtil.contains(new MyObject("tm_jee", 22), new MyObject("tmjee", 22)));
- assertTrue(ContainUtil.contains("apple", "apple"));
- assertTrue(ContainUtil.contains(new MyObject("tm_jee", 22), new MyObject("tm_jee", 22)));
- }
-
-
- public static class MyObject {
- private String name;
- private Integer age;
-
- public MyObject(String name, Integer age) {
- this.name = name;
- this.age = age;
- }
-
- @Override
- public int hashCode() {
- return this.name.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) { return false; }
- if (! (obj instanceof MyObject)) { return false; }
- MyObject tmp = (MyObject) obj;
- if (
- tmp.name.equals(this.name) &&
- tmp.age.equals(this.age)
- ) {
- return true;
- }
- return false;
-
- }
- }
+ public void testNull() throws Exception {
+ assertFalse(ContainUtil.contains(null, null));
+ assertFalse(ContainUtil.contains(new Object(), null));
+ assertFalse(ContainUtil.contains(null, new Object()));
+ }
+
+ public void testSimpleList() throws Exception {
+ List<String> l = new ArrayList<String>();
+ l.add("one");
+ l.add("two");
+
+ assertFalse(ContainUtil.contains(l, "three"));
+ assertTrue(ContainUtil.contains(l, "one"));
+ assertTrue(ContainUtil.contains(l, "two"));
+ }
+
+ public void testSimpleSet() throws Exception {
+ Set<String> s = new LinkedHashSet<String>();
+ s.add("one");
+ s.add("two");
+
+ assertFalse(ContainUtil.contains(s, "thre"));
+ assertTrue(ContainUtil.contains(s, "one"));
+ assertTrue(ContainUtil.contains(s, "two"));
+ }
+
+ public void testComplexList() throws Exception {
+ List<MyObject> l = new ArrayList<MyObject>();
+ l.add(new MyObject("tm_jee", 20));
+ l.add(new MyObject("jenny", 22));
+
+ assertFalse(ContainUtil.contains(l, new MyObject("paul", 50)));
+ assertFalse(ContainUtil.contains(l, new MyObject("tm_jee", 44)));
+ assertTrue(ContainUtil.contains(l, new MyObject("tm_jee", 20)));
+ assertTrue(ContainUtil.contains(l, new MyObject("jenny", 22)));
+ }
+
+ public void testComplexMap() throws Exception {
+ Set<MyObject> s = new LinkedHashSet<MyObject>();
+ s.add(new MyObject("tm_jee", 20));
+ s.add(new MyObject("jenny", 22));
+
+ assertFalse(ContainUtil.contains(s, new MyObject("paul", 50)));
+ assertFalse(ContainUtil.contains(s, new MyObject("tm_jee", 44)));
+ assertTrue(ContainUtil.contains(s, new MyObject("tm_jee", 20)));
+ assertTrue(ContainUtil.contains(s, new MyObject("jenny", 22)));
+ }
+
+ public void testObject() throws Exception {
+ assertFalse(ContainUtil.contains("aaa", "bbb"));
+ assertFalse(ContainUtil.contains(new MyObject("tm_jee", 22), new MyObject("tmjee", 22)));
+ assertTrue(ContainUtil.contains("apple", "apple"));
+ assertTrue(ContainUtil.contains(new MyObject("tm_jee", 22), new MyObject("tm_jee", 22)));
+ }
+
+
+ public static class MyObject {
+ private String name;
+ private Integer age;
+
+ public MyObject(String name, Integer age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) { return false; }
+ if (! (obj instanceof MyObject)) { return false; }
+ MyObject tmp = (MyObject) obj;
+ if (
+ tmp.name.equals(this.name) &&
+ tmp.age.equals(this.age)
+ ) {
+ return true;
+ }
+ return false;
+
+ }
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/CounterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/CounterTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/CounterTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/CounterTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/InvocationSessionStoreTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/InvocationSessionStoreTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/InvocationSessionStoreTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/InvocationSessionStoreTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/PrefixTrieTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/PrefixTrieTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/PrefixTrieTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/PrefixTrieTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
@@ -32,7 +35,7 @@
assertSame(foo, trie.get("foo:bar"));
assertSame(a, trie.get("a:bar"));
assertNull(trie.get("tee:bar"));
- assertNull(trie.get("foobar"));
+ assertNull(trie.get("foobar"));
}
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/StrutsTypeConverterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/StrutsTypeConverterTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/StrutsTypeConverterTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/StrutsTypeConverterTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
@@ -26,82 +29,82 @@
/**
* Test case for Struts Type Converter.
- *
+ *
*/
public class StrutsTypeConverterTest extends TestCase {
- /**
- * Typically form Struts -> html
- *
- * @throws Exception
- */
- public void testConvertToString() throws Exception {
- InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
- strutsTypeConverter.convertValue(new HashMap(), "", String.class);
- assertTrue(strutsTypeConverter.isConvertToString);
- assertEquals(strutsTypeConverter.objToBeConverted, "");
- }
-
- /**
- * Typically form html -> Struts
- *
- * @throws Exception
- */
- public void testConvertFromString() throws Exception {
- InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
- strutsTypeConverter.convertValue(new HashMap(), "12/12/1997", Date.class);
- assertTrue(strutsTypeConverter.isConvertFromString);
- assertTrue(strutsTypeConverter.objToBeConverted instanceof String[]);
- assertEquals(((String[])strutsTypeConverter.objToBeConverted).length, 1);
- }
-
- /**
- * Typically from html -> Struts (in array due to the nature of html, param
- * being able to have many values).
- *
- * @throws Exception
- */
- public void testConvertFromStringInArrayForm() throws Exception {
- InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
- strutsTypeConverter.convertValue(new HashMap(), new String[] { "12/12/1997", "1/1/1977" }, Date.class);
- assertTrue(strutsTypeConverter.isConvertFromString);
- assertTrue(strutsTypeConverter.objToBeConverted instanceof String[]);
- assertEquals(((String[])strutsTypeConverter.objToBeConverted).length, 2);
- }
-
-
- public void testFallbackConversion() throws Exception {
- InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
- strutsTypeConverter.convertValue(new HashMap(), new Object(), Date.class);
- assertTrue(strutsTypeConverter.fallbackConversion);
- }
-
- // === internal class for testing
- class InternalStrutsTypeConverter extends StrutsTypeConverter {
-
- boolean isConvertFromString = false;
- boolean isConvertToString = false;
- boolean fallbackConversion = false;
-
- Object objToBeConverted;
-
- public Object convertFromString(Map context, String[] values, Class toClass) {
- isConvertFromString = true;
- objToBeConverted = values;
- return null;
- }
-
- public String convertToString(Map context, Object o) {
- isConvertToString = true;
- objToBeConverted = o;
- return null;
- }
-
- protected Object performFallbackConversion(Map context, Object o, Class toClass) {
- fallbackConversion = true;
- return null;
- }
-
- }
-
+ /**
+ * Typically form Struts -> html
+ *
+ * @throws Exception
+ */
+ public void testConvertToString() throws Exception {
+ InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
+ strutsTypeConverter.convertValue(new HashMap(), "", String.class);
+ assertTrue(strutsTypeConverter.isConvertToString);
+ assertEquals(strutsTypeConverter.objToBeConverted, "");
+ }
+
+ /**
+ * Typically form html -> Struts
+ *
+ * @throws Exception
+ */
+ public void testConvertFromString() throws Exception {
+ InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
+ strutsTypeConverter.convertValue(new HashMap(), "12/12/1997", Date.class);
+ assertTrue(strutsTypeConverter.isConvertFromString);
+ assertTrue(strutsTypeConverter.objToBeConverted instanceof String[]);
+ assertEquals(((String[])strutsTypeConverter.objToBeConverted).length, 1);
+ }
+
+ /**
+ * Typically from html -> Struts (in array due to the nature of html, param
+ * being able to have many values).
+ *
+ * @throws Exception
+ */
+ public void testConvertFromStringInArrayForm() throws Exception {
+ InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
+ strutsTypeConverter.convertValue(new HashMap(), new String[] { "12/12/1997", "1/1/1977" }, Date.class);
+ assertTrue(strutsTypeConverter.isConvertFromString);
+ assertTrue(strutsTypeConverter.objToBeConverted instanceof String[]);
+ assertEquals(((String[])strutsTypeConverter.objToBeConverted).length, 2);
+ }
+
+
+ public void testFallbackConversion() throws Exception {
+ InternalStrutsTypeConverter strutsTypeConverter = new InternalStrutsTypeConverter();
+ strutsTypeConverter.convertValue(new HashMap(), new Object(), Date.class);
+ assertTrue(strutsTypeConverter.fallbackConversion);
+ }
+
+ // === internal class for testing
+ class InternalStrutsTypeConverter extends StrutsTypeConverter {
+
+ boolean isConvertFromString = false;
+ boolean isConvertToString = false;
+ boolean fallbackConversion = false;
+
+ Object objToBeConverted;
+
+ public Object convertFromString(Map context, String[] values, Class toClass) {
+ isConvertFromString = true;
+ objToBeConverted = values;
+ return null;
+ }
+
+ public String convertToString(Map context, Object o) {
+ isConvertToString = true;
+ objToBeConverted = o;
+ return null;
+ }
+
+ protected Object performFallbackConversion(Map context, Object o, Class toClass) {
+ fallbackConversion = true;
+ return null;
+ }
+
+ }
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/util/TokenHelperTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.util;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.freemarker;
@@ -23,16 +26,16 @@
import org.apache.struts2.views.jsp.StrutsMockServletContext;
/**
- * Test case for FreemarkerManager
- *
+ * Test case for FreemarkerManager
+ *
*/
public class FreemarkerManagerTest extends StrutsTestCase {
-
- public void testIfStrutsEncodingIsSetProperty() throws Exception {
- Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8");
- StrutsMockServletContext servletContext = new StrutsMockServletContext();
- servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);
- freemarker.template.Configuration conf = FreemarkerManager.getInstance().getConfiguration(servletContext);
- assertEquals(conf.getDefaultEncoding(), "UTF-8");
- }
+
+ public void testIfStrutsEncodingIsSetProperty() throws Exception {
+ Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8");
+ StrutsMockServletContext servletContext = new StrutsMockServletContext();
+ servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);
+ freemarker.template.Configuration conf = FreemarkerManager.getInstance().getConfiguration(servletContext);
+ assertEquals(conf.getDefaultEncoding(), "UTF-8");
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.freemarker;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestAction.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.freemarker;
@@ -27,7 +30,7 @@
*/
public class TestAction extends ActionSupport {
- private static final long serialVersionUID = -762413863731432302L;
+ private static final long serialVersionUID = -762413863731432302L;
public TestAction() {
super();
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestBean.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestBean.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/TestBean.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.freemarker;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.jsp;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractUITagTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.jsp;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.jsp;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AnchorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AnchorTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AnchorTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AnchorTagTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.jsp;
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AppendIteratorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AppendIteratorTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AppendIteratorTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AppendIteratorTagTest.java Mon Nov 6 07:01:43 2006
@@ -1,19 +1,22 @@
/*
* $Id$
*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.struts2.views.jsp;
@@ -31,148 +34,148 @@
*/
public class AppendIteratorTagTest extends AbstractTagTest {
-
- public void testAppendingIteratorUsingArrayAsSource() throws Exception {
- AppendIteratorTag tag = new AppendIteratorTag();
- tag.setPageContext(pageContext);
- tag.setId("myAppendedIterator");
-
- ParamTag iterator1ParamTag = new ParamTag();
- iterator1ParamTag.setPageContext(pageContext);
- iterator1ParamTag.setValue("%{myArr1}");
-
- ParamTag iterator2ParamTag = new ParamTag();
- iterator2ParamTag.setPageContext(pageContext);
- iterator2ParamTag.setValue("%{myArr2}");
-
- ParamTag iterator3ParamTag = new ParamTag();
- iterator3ParamTag.setPageContext(pageContext);
- iterator3ParamTag.setValue("%{myArr3}");
-
-
- tag.doStartTag();
- iterator1ParamTag.doStartTag();
- iterator1ParamTag.doEndTag();
- iterator2ParamTag.doStartTag();
- iterator2ParamTag.doEndTag();
- iterator3ParamTag.doStartTag();
- iterator3ParamTag.doEndTag();
- tag.doEndTag();
-
- Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
-
- assertNotNull(appendedIterator);
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "1");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "2");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "3");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "a");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "b");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "c");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "A");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "B");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "C");
- assertFalse(appendedIterator.hasNext());
- }
-
- public void testAppendingIteratorsUsingListAsSource() throws Exception {
- AppendIteratorTag tag = new AppendIteratorTag();
- tag.setPageContext(pageContext);
- tag.setId("myAppendedIterator");
-
- ParamTag iterator1ParamTag = new ParamTag();
- iterator1ParamTag.setPageContext(pageContext);
- iterator1ParamTag.setValue("%{myList1}");
-
- ParamTag iterator2ParamTag = new ParamTag();
- iterator2ParamTag.setPageContext(pageContext);
- iterator2ParamTag.setValue("%{myList2}");
-
- ParamTag iterator3ParamTag = new ParamTag();
- iterator3ParamTag.setPageContext(pageContext);
- iterator3ParamTag.setValue("%{myList3}");
-
-
- tag.doStartTag();
- iterator1ParamTag.doStartTag();
- iterator1ParamTag.doEndTag();
- iterator2ParamTag.doStartTag();
- iterator2ParamTag.doEndTag();
- iterator3ParamTag.doStartTag();
- iterator3ParamTag.doEndTag();
- tag.doEndTag();
-
- Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
-
- assertNotNull(appendedIterator);
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "1");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "2");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "3");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "a");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "b");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "c");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "A");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "B");
- assertTrue(appendedIterator.hasNext());
- assertEquals(appendedIterator.next(), "C");
- assertFalse(appendedIterator.hasNext());
- }
-
-
-
- public Action getAction() {
- return new ActionSupport() {
- public List getMyList1() {
- List l = new ArrayList();
- l.add("1");
- l.add("2");
- l.add("3");
- return l;
- }
-
- public List getMyList2() {
- List l = new ArrayList();
- l.add("a");
- l.add("b");
- l.add("c");
- return l;
- }
-
- public List getMyList3() {
- List l = new ArrayList(0);
- l.add("A");
- l.add("B");
- l.add("C");
- return l;
- }
-
- public String[] getMyArr1() {
- return new String[] { "1", "2", "3" };
- }
-
- public String[] getMyArr2() {
- return new String[] { "a", "b", "c" };
- }
-
- public String[] getMyArr3() {
- return new String[] { "A", "B", "C" };
- }
- };
- }
+
+ public void testAppendingIteratorUsingArrayAsSource() throws Exception {
+ AppendIteratorTag tag = new AppendIteratorTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myAppendedIterator");
+
+ ParamTag iterator1ParamTag = new ParamTag();
+ iterator1ParamTag.setPageContext(pageContext);
+ iterator1ParamTag.setValue("%{myArr1}");
+
+ ParamTag iterator2ParamTag = new ParamTag();
+ iterator2ParamTag.setPageContext(pageContext);
+ iterator2ParamTag.setValue("%{myArr2}");
+
+ ParamTag iterator3ParamTag = new ParamTag();
+ iterator3ParamTag.setPageContext(pageContext);
+ iterator3ParamTag.setValue("%{myArr3}");
+
+
+ tag.doStartTag();
+ iterator1ParamTag.doStartTag();
+ iterator1ParamTag.doEndTag();
+ iterator2ParamTag.doStartTag();
+ iterator2ParamTag.doEndTag();
+ iterator3ParamTag.doStartTag();
+ iterator3ParamTag.doEndTag();
+ tag.doEndTag();
+
+ Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
+
+ assertNotNull(appendedIterator);
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "1");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "2");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "3");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "a");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "b");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "c");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "A");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "B");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "C");
+ assertFalse(appendedIterator.hasNext());
+ }
+
+ public void testAppendingIteratorsUsingListAsSource() throws Exception {
+ AppendIteratorTag tag = new AppendIteratorTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myAppendedIterator");
+
+ ParamTag iterator1ParamTag = new ParamTag();
+ iterator1ParamTag.setPageContext(pageContext);
+ iterator1ParamTag.setValue("%{myList1}");
+
+ ParamTag iterator2ParamTag = new ParamTag();
+ iterator2ParamTag.setPageContext(pageContext);
+ iterator2ParamTag.setValue("%{myList2}");
+
+ ParamTag iterator3ParamTag = new ParamTag();
+ iterator3ParamTag.setPageContext(pageContext);
+ iterator3ParamTag.setValue("%{myList3}");
+
+
+ tag.doStartTag();
+ iterator1ParamTag.doStartTag();
+ iterator1ParamTag.doEndTag();
+ iterator2ParamTag.doStartTag();
+ iterator2ParamTag.doEndTag();
+ iterator3ParamTag.doStartTag();
+ iterator3ParamTag.doEndTag();
+ tag.doEndTag();
+
+ Iterator appendedIterator = (Iterator) stack.findValue("#myAppendedIterator");
+
+ assertNotNull(appendedIterator);
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "1");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "2");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "3");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "a");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "b");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "c");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "A");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "B");
+ assertTrue(appendedIterator.hasNext());
+ assertEquals(appendedIterator.next(), "C");
+ assertFalse(appendedIterator.hasNext());
+ }
+
+
+
+ public Action getAction() {
+ return new ActionSupport() {
+ public List getMyList1() {
+ List l = new ArrayList();
+ l.add("1");
+ l.add("2");
+ l.add("3");
+ return l;
+ }
+
+ public List getMyList2() {
+ List l = new ArrayList();
+ l.add("a");
+ l.add("b");
+ l.add("c");
+ return l;
+ }
+
+ public List getMyList3() {
+ List l = new ArrayList(0);
+ l.add("A");
+ l.add("B");
+ l.add("C");
+ return l;
+ }
+
+ public String[] getMyArr1() {
+ return new String[] { "1", "2", "3" };
+ }
+
+ public String[] getMyArr2() {
+ return new String[] { "a", "b", "c" };
+ }
+
+ public String[] getMyArr3() {
+ return new String[] { "A", "B", "C" };
+ }
+ };
+ }
}