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 [26/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/views/jsp/BeanTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/BeanTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/BeanTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/BeanTagTest.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;
@@ -34,7 +37,7 @@
tag.component.addParameter("result", "success");
assertEquals("success", stack.findValue("result"));
- // TestAction from bean tag, Action from execution and DefaultTextProvider
+ // TestAction from bean tag, Action from execution and DefaultTextProvider
assertEquals(3, stack.size());
tag.doEndTag();
assertEquals(2, stack.size());
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseIfTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseIfTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseIfTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseIfTagTest.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;
@@ -30,85 +33,85 @@
import com.opensymphony.xwork2.util.ValueStackFactory;
/**
- *
+ *
*/
public class ElseIfTagTest extends TestCase {
- protected MockPageContext pageContext;
- protected MockJspWriter jspWriter;
- protected ValueStack stack;
-
-
- public void testIfIsFalseElseIfIsTrue() throws Exception {
- stack.getContext().put(If.ANSWER, Boolean.FALSE);
-
- ElseIfTag tag = new ElseIfTag();
- tag.setPageContext(pageContext);
- tag.setTest("true");
-
- int result = tag.doStartTag();
- tag.doEndTag();
-
- assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
- }
-
- public void testIfIsFalseElseIfIsFalse() throws Exception {
- stack.getContext().put(If.ANSWER, Boolean.FALSE);
-
- ElseIfTag tag = new ElseIfTag();
- tag.setPageContext(pageContext);
- tag.setTest("false");
-
- int result = tag.doStartTag();
- tag.doEndTag();
-
- assertEquals(result, TagSupport.SKIP_BODY);
- }
-
- public void testIfIsTrueElseIfIsTrue() throws Exception {
- stack.getContext().put(If.ANSWER, Boolean.TRUE);
-
- ElseIfTag tag = new ElseIfTag();
- tag.setPageContext(pageContext);
- tag.setTest("true");
-
- int result = tag.doStartTag();
- tag.doEndTag();
-
- assertEquals(result, TagSupport.SKIP_BODY);
- }
-
- public void testIfIsTrueElseIfIsFalse() throws Exception {
- stack.getContext().put(If.ANSWER, Boolean.TRUE);
-
- ElseIfTag tag = new ElseIfTag();
- tag.setPageContext(pageContext);
- tag.setTest("false");
-
- int result = tag.doStartTag();
- tag.doEndTag();
-
- assertEquals(result, TagSupport.SKIP_BODY);
- }
-
-
- protected void setUp() throws Exception {
- stack = ValueStackFactory.getFactory().createValueStack();
-
- jspWriter = new MockJspWriter();
-
- StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
-
- StrutsMockServletContext servletContext = new StrutsMockServletContext();
- servletContext.setServletInfo("not-weblogic");
-
- pageContext = new MockPageContext();
- pageContext.setJspWriter(jspWriter);
- pageContext.setRequest(request);
- pageContext.setServletContext(servletContext);
-
- request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
- }
-
-
+ protected MockPageContext pageContext;
+ protected MockJspWriter jspWriter;
+ protected ValueStack stack;
+
+
+ public void testIfIsFalseElseIfIsTrue() throws Exception {
+ stack.getContext().put(If.ANSWER, Boolean.FALSE);
+
+ ElseIfTag tag = new ElseIfTag();
+ tag.setPageContext(pageContext);
+ tag.setTest("true");
+
+ int result = tag.doStartTag();
+ tag.doEndTag();
+
+ assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
+ }
+
+ public void testIfIsFalseElseIfIsFalse() throws Exception {
+ stack.getContext().put(If.ANSWER, Boolean.FALSE);
+
+ ElseIfTag tag = new ElseIfTag();
+ tag.setPageContext(pageContext);
+ tag.setTest("false");
+
+ int result = tag.doStartTag();
+ tag.doEndTag();
+
+ assertEquals(result, TagSupport.SKIP_BODY);
+ }
+
+ public void testIfIsTrueElseIfIsTrue() throws Exception {
+ stack.getContext().put(If.ANSWER, Boolean.TRUE);
+
+ ElseIfTag tag = new ElseIfTag();
+ tag.setPageContext(pageContext);
+ tag.setTest("true");
+
+ int result = tag.doStartTag();
+ tag.doEndTag();
+
+ assertEquals(result, TagSupport.SKIP_BODY);
+ }
+
+ public void testIfIsTrueElseIfIsFalse() throws Exception {
+ stack.getContext().put(If.ANSWER, Boolean.TRUE);
+
+ ElseIfTag tag = new ElseIfTag();
+ tag.setPageContext(pageContext);
+ tag.setTest("false");
+
+ int result = tag.doStartTag();
+ tag.doEndTag();
+
+ assertEquals(result, TagSupport.SKIP_BODY);
+ }
+
+
+ protected void setUp() throws Exception {
+ stack = ValueStackFactory.getFactory().createValueStack();
+
+ jspWriter = new MockJspWriter();
+
+ StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
+
+ StrutsMockServletContext servletContext = new StrutsMockServletContext();
+ servletContext.setServletInfo("not-weblogic");
+
+ pageContext = new MockPageContext();
+ pageContext.setJspWriter(jspWriter);
+ pageContext.setRequest(request);
+ pageContext.setServletContext(servletContext);
+
+ request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
+ }
+
+
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ElseTagTest.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;
@@ -40,12 +43,12 @@
public void testTestFalse() {
- stack.getContext().put(If.ANSWER, new Boolean(false));
+ stack.getContext().put(If.ANSWER, new Boolean(false));
int result = 0;
try {
- elseTag.setPageContext(pageContext);
+ elseTag.setPageContext(pageContext);
result = elseTag.doStartTag();
elseTag.doEndTag();
} catch (JspException e) {
@@ -71,7 +74,7 @@
}
public void testTestTrue() {
- stack.getContext().put(If.ANSWER, new Boolean(true));
+ stack.getContext().put(If.ANSWER, new Boolean(true));
elseTag.setPageContext(pageContext);
int result = 0;
@@ -93,14 +96,14 @@
// create the mock http servlet request
StrutsMockHttpServletRequest request = new StrutsMockHttpServletRequest();
-
+
// NOTE: in Struts Tag library, TagUtil gets stack from request, which will be set
// when request going through the FilterDispatcher --> DispatcherUtil etc. route
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);
StrutsMockServletContext servletContext = new StrutsMockServletContext();
servletContext.setServletInfo("not-weblogic");
-
+
// create the mock page context
pageContext = new StrutsMockPageContext();
pageContext.setRequest(request);
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IfTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IfTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IfTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IfTagTest.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;
@@ -152,169 +155,169 @@
fail();
}
}
-
-
+
+
public void testIfElse1() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("true");
-
- ElseTag elseTag = new ElseTag();
- elseTag.setPageContext(pageContext);
-
- int r1 = ifTag.doStartTag();
- ifTag.doEndTag();
- int r2 = elseTag.doStartTag();
- elseTag.doEndTag();
-
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
- assertEquals(TagSupport.SKIP_BODY, r2);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("true");
+
+ ElseTag elseTag = new ElseTag();
+ elseTag.setPageContext(pageContext);
+
+ int r1 = ifTag.doStartTag();
+ ifTag.doEndTag();
+ int r2 = elseTag.doStartTag();
+ elseTag.doEndTag();
+
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
+ assertEquals(TagSupport.SKIP_BODY, r2);
}
-
+
public void testIfElse2() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("false");
-
- ElseTag elseTag = new ElseTag();
- elseTag.setPageContext(pageContext);
-
- int r1 = ifTag.doStartTag();
- ifTag.doEndTag();
- int r2 = elseTag.doStartTag();
- elseTag.doEndTag();
-
- assertEquals(TagSupport.SKIP_BODY, r1);
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("false");
+
+ ElseTag elseTag = new ElseTag();
+ elseTag.setPageContext(pageContext);
+
+ int r1 = ifTag.doStartTag();
+ ifTag.doEndTag();
+ int r2 = elseTag.doStartTag();
+ elseTag.doEndTag();
+
+ assertEquals(TagSupport.SKIP_BODY, r1);
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
}
-
+
public void testIfElseIf() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("false");
-
- ElseIfTag elseIfTag1 = new ElseIfTag();
- elseIfTag1.setPageContext(pageContext);
- elseIfTag1.setTest("false");
-
- ElseIfTag elseIfTag2 = new ElseIfTag();
- elseIfTag2.setPageContext(pageContext);
- elseIfTag2.setTest("true");
-
- ElseIfTag elseIfTag3 = new ElseIfTag();
- elseIfTag3.setPageContext(pageContext);
- elseIfTag3.setTest("true");
-
- int r1 = ifTag.doStartTag();
- ifTag.doEndTag();
- int r2 = elseIfTag1.doStartTag();
- elseIfTag1.doEndTag();
- int r3 = elseIfTag2.doStartTag();
- elseIfTag2.doEndTag();
- int r4 = elseIfTag3.doStartTag();
- elseIfTag3.doEndTag();
-
- assertEquals(TagSupport.SKIP_BODY, r1);
- assertEquals(TagSupport.SKIP_BODY, r2);
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r3);
- assertEquals(TagSupport.SKIP_BODY, r4);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("false");
+
+ ElseIfTag elseIfTag1 = new ElseIfTag();
+ elseIfTag1.setPageContext(pageContext);
+ elseIfTag1.setTest("false");
+
+ ElseIfTag elseIfTag2 = new ElseIfTag();
+ elseIfTag2.setPageContext(pageContext);
+ elseIfTag2.setTest("true");
+
+ ElseIfTag elseIfTag3 = new ElseIfTag();
+ elseIfTag3.setPageContext(pageContext);
+ elseIfTag3.setTest("true");
+
+ int r1 = ifTag.doStartTag();
+ ifTag.doEndTag();
+ int r2 = elseIfTag1.doStartTag();
+ elseIfTag1.doEndTag();
+ int r3 = elseIfTag2.doStartTag();
+ elseIfTag2.doEndTag();
+ int r4 = elseIfTag3.doStartTag();
+ elseIfTag3.doEndTag();
+
+ assertEquals(TagSupport.SKIP_BODY, r1);
+ assertEquals(TagSupport.SKIP_BODY, r2);
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r3);
+ assertEquals(TagSupport.SKIP_BODY, r4);
}
-
+
public void testIfElseIfElse() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("false");
-
- ElseIfTag elseIfTag1 = new ElseIfTag();
- elseIfTag1.setPageContext(pageContext);
- elseIfTag1.setTest("false");
-
- ElseIfTag elseIfTag2 = new ElseIfTag();
- elseIfTag2.setPageContext(pageContext);
- elseIfTag2.setTest("false");
-
- ElseIfTag elseIfTag3 = new ElseIfTag();
- elseIfTag3.setPageContext(pageContext);
- elseIfTag3.setTest("false");
-
- ElseTag elseTag = new ElseTag();
- elseTag.setPageContext(pageContext);
-
- int r1 = ifTag.doStartTag();
- ifTag.doEndTag();
- int r2 = elseIfTag1.doStartTag();
- elseIfTag1.doEndTag();
- int r3 = elseIfTag2.doStartTag();
- elseIfTag2.doEndTag();
- int r4 = elseIfTag3.doStartTag();
- elseIfTag3.doEndTag();
- int r5 = elseTag.doStartTag();
- elseTag.doEndTag();
-
- assertEquals(TagSupport.SKIP_BODY, r1);
- assertEquals(TagSupport.SKIP_BODY, r2);
- assertEquals(TagSupport.SKIP_BODY, r3);
- assertEquals(TagSupport.SKIP_BODY, r4);
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r5);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("false");
+
+ ElseIfTag elseIfTag1 = new ElseIfTag();
+ elseIfTag1.setPageContext(pageContext);
+ elseIfTag1.setTest("false");
+
+ ElseIfTag elseIfTag2 = new ElseIfTag();
+ elseIfTag2.setPageContext(pageContext);
+ elseIfTag2.setTest("false");
+
+ ElseIfTag elseIfTag3 = new ElseIfTag();
+ elseIfTag3.setPageContext(pageContext);
+ elseIfTag3.setTest("false");
+
+ ElseTag elseTag = new ElseTag();
+ elseTag.setPageContext(pageContext);
+
+ int r1 = ifTag.doStartTag();
+ ifTag.doEndTag();
+ int r2 = elseIfTag1.doStartTag();
+ elseIfTag1.doEndTag();
+ int r3 = elseIfTag2.doStartTag();
+ elseIfTag2.doEndTag();
+ int r4 = elseIfTag3.doStartTag();
+ elseIfTag3.doEndTag();
+ int r5 = elseTag.doStartTag();
+ elseTag.doEndTag();
+
+ assertEquals(TagSupport.SKIP_BODY, r1);
+ assertEquals(TagSupport.SKIP_BODY, r2);
+ assertEquals(TagSupport.SKIP_BODY, r3);
+ assertEquals(TagSupport.SKIP_BODY, r4);
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r5);
}
-
-
+
+
public void testNestedIfElse1() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("true");
-
- IfTag nestedIfTag = new IfTag();
- nestedIfTag.setPageContext(pageContext);
- nestedIfTag.setTest("true");
-
- ElseTag elseTag = new ElseTag();
- elseTag.setPageContext(pageContext);
-
- int r1 = ifTag.doStartTag();
- int r2 = nestedIfTag.doStartTag();
- int r3 = nestedIfTag.doEndTag();
- int r4 = ifTag.doEndTag();
- int r5 = elseTag.doStartTag();
- int r6 = elseTag.doEndTag();
-
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
- assertEquals(TagSupport.EVAL_PAGE, r3);
- assertEquals(TagSupport.EVAL_PAGE, r4);
- assertEquals(TagSupport.SKIP_BODY, r5);
- assertEquals(TagSupport.EVAL_PAGE, r6);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("true");
+
+ IfTag nestedIfTag = new IfTag();
+ nestedIfTag.setPageContext(pageContext);
+ nestedIfTag.setTest("true");
+
+ ElseTag elseTag = new ElseTag();
+ elseTag.setPageContext(pageContext);
+
+ int r1 = ifTag.doStartTag();
+ int r2 = nestedIfTag.doStartTag();
+ int r3 = nestedIfTag.doEndTag();
+ int r4 = ifTag.doEndTag();
+ int r5 = elseTag.doStartTag();
+ int r6 = elseTag.doEndTag();
+
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r2);
+ assertEquals(TagSupport.EVAL_PAGE, r3);
+ assertEquals(TagSupport.EVAL_PAGE, r4);
+ assertEquals(TagSupport.SKIP_BODY, r5);
+ assertEquals(TagSupport.EVAL_PAGE, r6);
}
-
+
public void testNestedIfElse2() throws Exception {
- IfTag ifTag = new IfTag();
- ifTag.setPageContext(pageContext);
- ifTag.setTest("true");
-
- IfTag nestedIfTag = new IfTag();
- nestedIfTag.setPageContext(pageContext);
- nestedIfTag.setTest("false");
-
- ElseTag elseTag = new ElseTag();
- elseTag.setPageContext(pageContext);
-
- int r1 = ifTag.doStartTag();
- int r2 = nestedIfTag.doStartTag();
- int r3 = nestedIfTag.doEndTag();
- int r4 = ifTag.doEndTag();
- int r5 = elseTag.doStartTag();
- int r6 = elseTag.doEndTag();
-
- assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
- assertEquals(TagSupport.SKIP_BODY, r2);
- assertEquals(TagSupport.EVAL_PAGE, r3);
- assertEquals(TagSupport.EVAL_PAGE, r4);
- assertEquals(TagSupport.SKIP_BODY, r5);
- assertEquals(TagSupport.EVAL_PAGE, r6);
+ IfTag ifTag = new IfTag();
+ ifTag.setPageContext(pageContext);
+ ifTag.setTest("true");
+
+ IfTag nestedIfTag = new IfTag();
+ nestedIfTag.setPageContext(pageContext);
+ nestedIfTag.setTest("false");
+
+ ElseTag elseTag = new ElseTag();
+ elseTag.setPageContext(pageContext);
+
+ int r1 = ifTag.doStartTag();
+ int r2 = nestedIfTag.doStartTag();
+ int r3 = nestedIfTag.doEndTag();
+ int r4 = ifTag.doEndTag();
+ int r5 = elseTag.doStartTag();
+ int r6 = elseTag.doEndTag();
+
+ assertEquals(TagSupport.EVAL_BODY_INCLUDE, r1);
+ assertEquals(TagSupport.SKIP_BODY, r2);
+ assertEquals(TagSupport.EVAL_PAGE, r3);
+ assertEquals(TagSupport.EVAL_PAGE, r4);
+ assertEquals(TagSupport.SKIP_BODY, r5);
+ assertEquals(TagSupport.EVAL_PAGE, r6);
}
-
-
-
+
+
+
protected void setUp() throws Exception {
// create the needed objects
@@ -330,7 +333,7 @@
pageContext = new MockPageContext();
pageContext.setRequest(request);
pageContext.setJspWriter(new MockJspWriter());
-
+
// associate the tag with the mock page request
tag.setPageContext(pageContext);
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.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/IteratorGeneratorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorGeneratorTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorGeneratorTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorGeneratorTagTest.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;
@@ -27,181 +30,181 @@
/**
* Test case for IteratorGeneratorTag.
- *
+ *
*/
public class IteratorGeneratorTagTest extends AbstractTagTest {
- public void testGeneratorBasic() throws Exception {
- IteratorGeneratorTag tag = new IteratorGeneratorTag();
-
- tag.setPageContext(pageContext);
- tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
- tag.doStartTag();
- Object topOfStack = stack.findValue("top");
-
-
- assertTrue(topOfStack instanceof Iterator);
- // 1
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "aaa");
- // 2
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "bbb");
- // 3
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "ccc");
- // 4
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "ddd");
- // 5
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(),"eee");
-
- assertFalse(((Iterator)topOfStack).hasNext());
-
- tag.doEndTag();
- Object afterTopOfStack = stack.findValue("top");
-
-
- assertNotSame(afterTopOfStack, topOfStack);
- }
-
- public void testGeneratorWithSeparator() throws Exception {
- IteratorGeneratorTag tag = new IteratorGeneratorTag();
-
- tag.setPageContext(pageContext);
- tag.setVal("%{'aaa|bbb|ccc|ddd|eee'}");
- tag.setSeparator("|");
- tag.doStartTag();
- Object topOfStack = stack.findValue("top");
- tag.doEndTag();
- Object afterTopOfStack = stack.findValue("top");
-
- assertTrue(topOfStack instanceof Iterator);
- // 1
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "aaa");
- // 2
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "bbb");
- // 3
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "ccc");
- // 4
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "ddd");
- // 5
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "eee");
-
- assertFalse(((Iterator)topOfStack).hasNext());
- assertNotSame(afterTopOfStack, topOfStack);
- }
-
- public void testGeneratorWithConverter() throws Exception {
- IteratorGeneratorTag tag = new IteratorGeneratorTag();
-
- tag.setPageContext(pageContext);
- tag.setVal("%{'aaa, bbb, ccc, ddd, eee'}");
- tag.setConverter("myConverter");
- tag.doStartTag();
- Object topOfStack = stack.findValue("top");
- tag.doEndTag();
- Object afterTopOfStack = stack.findValue("top");
-
- assertTrue(topOfStack instanceof Iterator);
- // 1.
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "myConverter-aaa");
- // 2
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "myConverter-bbb");
- // 3
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "myConverter-ccc");
- // 4.
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "myConverter-ddd");
- // 5.
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "myConverter-eee");
-
- assertFalse(((Iterator)topOfStack).hasNext());
- assertNotSame(afterTopOfStack, topOfStack);
- }
-
- public void testGeneratorWithId() throws Exception {
- IteratorGeneratorTag tag = new IteratorGeneratorTag();
- tag.setPageContext(pageContext);
- tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
- tag.setId("myPageContextAttId");
- tag.doStartTag();
- tag.doEndTag();
-
- Object pageContextIterator = pageContext.getAttribute("myPageContextAttId");
-
- assertTrue(pageContextIterator instanceof Iterator);
- // 1
- assertTrue(((Iterator)pageContextIterator).hasNext());
- assertEquals(((Iterator)pageContextIterator).next(), "aaa");
- // 2.
- assertTrue(((Iterator)pageContextIterator).hasNext());
- assertEquals(((Iterator)pageContextIterator).next(), "bbb");
- // 3.
- assertTrue(((Iterator)pageContextIterator).hasNext());
- assertEquals(((Iterator)pageContextIterator).next(), "ccc");
- // 4
- assertTrue(((Iterator)pageContextIterator).hasNext());
- assertEquals(((Iterator)pageContextIterator).next(), "ddd");
- // 5
- assertTrue(((Iterator)pageContextIterator).hasNext());
- assertEquals(((Iterator)pageContextIterator).next(), "eee");
-
- assertFalse(((Iterator)pageContextIterator).hasNext());
- }
-
- public void testGeneratorWithCount() throws Exception {
- IteratorGeneratorTag tag = new IteratorGeneratorTag();
-
- tag.setPageContext(pageContext);
- tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
- tag.setCount("myCount");
- tag.doStartTag();
- Object topOfStack = stack.findValue("top");
- tag.doEndTag();
- Object afterTopOfStack = stack.findValue("top");
-
-
- assertTrue(topOfStack instanceof Iterator);
- // 1
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "aaa");
- // 2
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "bbb");
- // 3.
- assertTrue(((Iterator)topOfStack).hasNext());
- assertEquals(((Iterator)topOfStack).next(), "ccc");
-
- assertFalse(((Iterator)topOfStack).hasNext());
- assertNotSame(topOfStack, afterTopOfStack);
- }
-
-
- public Action getAction() {
- return new ActionSupport() {
- public Converter getMyConverter() {
- return new Converter() {
- public Object convert(String value) throws Exception {
- return "myConverter-"+value;
- }
- };
- }
-
- public int getMyCount() {
- return 3;
- }
- };
- }
+ public void testGeneratorBasic() throws Exception {
+ IteratorGeneratorTag tag = new IteratorGeneratorTag();
+
+ tag.setPageContext(pageContext);
+ tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
+ tag.doStartTag();
+ Object topOfStack = stack.findValue("top");
+
+
+ assertTrue(topOfStack instanceof Iterator);
+ // 1
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "aaa");
+ // 2
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "bbb");
+ // 3
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "ccc");
+ // 4
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "ddd");
+ // 5
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(),"eee");
+
+ assertFalse(((Iterator)topOfStack).hasNext());
+
+ tag.doEndTag();
+ Object afterTopOfStack = stack.findValue("top");
+
+
+ assertNotSame(afterTopOfStack, topOfStack);
+ }
+
+ public void testGeneratorWithSeparator() throws Exception {
+ IteratorGeneratorTag tag = new IteratorGeneratorTag();
+
+ tag.setPageContext(pageContext);
+ tag.setVal("%{'aaa|bbb|ccc|ddd|eee'}");
+ tag.setSeparator("|");
+ tag.doStartTag();
+ Object topOfStack = stack.findValue("top");
+ tag.doEndTag();
+ Object afterTopOfStack = stack.findValue("top");
+
+ assertTrue(topOfStack instanceof Iterator);
+ // 1
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "aaa");
+ // 2
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "bbb");
+ // 3
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "ccc");
+ // 4
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "ddd");
+ // 5
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "eee");
+
+ assertFalse(((Iterator)topOfStack).hasNext());
+ assertNotSame(afterTopOfStack, topOfStack);
+ }
+
+ public void testGeneratorWithConverter() throws Exception {
+ IteratorGeneratorTag tag = new IteratorGeneratorTag();
+
+ tag.setPageContext(pageContext);
+ tag.setVal("%{'aaa, bbb, ccc, ddd, eee'}");
+ tag.setConverter("myConverter");
+ tag.doStartTag();
+ Object topOfStack = stack.findValue("top");
+ tag.doEndTag();
+ Object afterTopOfStack = stack.findValue("top");
+
+ assertTrue(topOfStack instanceof Iterator);
+ // 1.
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "myConverter-aaa");
+ // 2
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "myConverter-bbb");
+ // 3
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "myConverter-ccc");
+ // 4.
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "myConverter-ddd");
+ // 5.
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "myConverter-eee");
+
+ assertFalse(((Iterator)topOfStack).hasNext());
+ assertNotSame(afterTopOfStack, topOfStack);
+ }
+
+ public void testGeneratorWithId() throws Exception {
+ IteratorGeneratorTag tag = new IteratorGeneratorTag();
+ tag.setPageContext(pageContext);
+ tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
+ tag.setId("myPageContextAttId");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ Object pageContextIterator = pageContext.getAttribute("myPageContextAttId");
+
+ assertTrue(pageContextIterator instanceof Iterator);
+ // 1
+ assertTrue(((Iterator)pageContextIterator).hasNext());
+ assertEquals(((Iterator)pageContextIterator).next(), "aaa");
+ // 2.
+ assertTrue(((Iterator)pageContextIterator).hasNext());
+ assertEquals(((Iterator)pageContextIterator).next(), "bbb");
+ // 3.
+ assertTrue(((Iterator)pageContextIterator).hasNext());
+ assertEquals(((Iterator)pageContextIterator).next(), "ccc");
+ // 4
+ assertTrue(((Iterator)pageContextIterator).hasNext());
+ assertEquals(((Iterator)pageContextIterator).next(), "ddd");
+ // 5
+ assertTrue(((Iterator)pageContextIterator).hasNext());
+ assertEquals(((Iterator)pageContextIterator).next(), "eee");
+
+ assertFalse(((Iterator)pageContextIterator).hasNext());
+ }
+
+ public void testGeneratorWithCount() throws Exception {
+ IteratorGeneratorTag tag = new IteratorGeneratorTag();
+
+ tag.setPageContext(pageContext);
+ tag.setVal("%{'aaa,bbb,ccc,ddd,eee'}");
+ tag.setCount("myCount");
+ tag.doStartTag();
+ Object topOfStack = stack.findValue("top");
+ tag.doEndTag();
+ Object afterTopOfStack = stack.findValue("top");
+
+
+ assertTrue(topOfStack instanceof Iterator);
+ // 1
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "aaa");
+ // 2
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "bbb");
+ // 3.
+ assertTrue(((Iterator)topOfStack).hasNext());
+ assertEquals(((Iterator)topOfStack).next(), "ccc");
+
+ assertFalse(((Iterator)topOfStack).hasNext());
+ assertNotSame(topOfStack, afterTopOfStack);
+ }
+
+
+ public Action getAction() {
+ return new ActionSupport() {
+ public Converter getMyConverter() {
+ return new Converter() {
+ public Object convert(String value) throws Exception {
+ return "myConverter-"+value;
+ }
+ };
+ }
+
+ public int getMyCount() {
+ return 3;
+ }
+ };
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IteratorTagTest.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,74 +34,74 @@
/**
- * Test Case for Iterator Tag
- *
+ * Test Case for Iterator Tag
+ *
*/
public class IteratorTagTest extends AbstractUITagTest {
IteratorTag tag;
-
+
public void testIteratingWithIdSpecified() throws Exception {
- List list = new ArrayList();
- list.add("one");
- list.add("two");
- list.add("three");
- list.add("four");
- list.add("five");
-
- Foo foo = new Foo();
- foo.setList(list);
-
- stack.push(foo);
-
- tag.setValue("list");
- tag.setId("myId");
-
- // one
- int result = tag.doStartTag();
- assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
- assertEquals(stack.peek(), "one");
- assertEquals(stack.getContext().get("myId"), "one");
-
-
- tag.doInitBody();
-
- // two
- result = tag.doAfterBody();
- assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
- assertEquals(stack.peek(), "two");
- assertEquals(stack.getContext().get("myId"), "two");
-
-
- // three
- result = tag.doAfterBody();
- assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
- assertEquals(stack.peek(), "three");
- assertEquals(stack.getContext().get("myId"), "three");
-
-
- // four
- result = tag.doAfterBody();
- assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
- assertEquals(stack.peek(), "four");
- assertEquals(stack.getContext().get("myId"), "four");
-
-
- // five
- result = tag.doAfterBody();
- assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
- assertEquals(stack.peek(), "five");
- assertEquals(stack.getContext().get("myId"), "five");
-
-
- result = tag.doAfterBody();
- assertEquals(result, TagSupport.SKIP_BODY);
-
- result = tag.doEndTag();
- assertEquals(result, TagSupport.EVAL_PAGE);
+ List list = new ArrayList();
+ list.add("one");
+ list.add("two");
+ list.add("three");
+ list.add("four");
+ list.add("five");
+
+ Foo foo = new Foo();
+ foo.setList(list);
+
+ stack.push(foo);
+
+ tag.setValue("list");
+ tag.setId("myId");
+
+ // one
+ int result = tag.doStartTag();
+ assertEquals(result, TagSupport.EVAL_BODY_INCLUDE);
+ assertEquals(stack.peek(), "one");
+ assertEquals(stack.getContext().get("myId"), "one");
+
+
+ tag.doInitBody();
+
+ // two
+ result = tag.doAfterBody();
+ assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+ assertEquals(stack.peek(), "two");
+ assertEquals(stack.getContext().get("myId"), "two");
+
+
+ // three
+ result = tag.doAfterBody();
+ assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+ assertEquals(stack.peek(), "three");
+ assertEquals(stack.getContext().get("myId"), "three");
+
+
+ // four
+ result = tag.doAfterBody();
+ assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+ assertEquals(stack.peek(), "four");
+ assertEquals(stack.getContext().get("myId"), "four");
+
+
+ // five
+ result = tag.doAfterBody();
+ assertEquals(result, TagSupport.EVAL_BODY_AGAIN);
+ assertEquals(stack.peek(), "five");
+ assertEquals(stack.getContext().get("myId"), "five");
+
+
+ result = tag.doAfterBody();
+ assertEquals(result, TagSupport.SKIP_BODY);
+
+ result = tag.doEndTag();
+ assertEquals(result, TagSupport.EVAL_PAGE);
}
-
+
public void testArrayIterator() {
Foo foo = new Foo();
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/MergeIteratorTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/MergeIteratorTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/MergeIteratorTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/MergeIteratorTagTest.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;
@@ -28,153 +31,153 @@
/**
* Test case for MergeIteratorTag.
- *
+ *
*/
public class MergeIteratorTagTest extends AbstractTagTest {
- public void testMergingIteratorWithArrayAsSource() throws Exception {
- MergeIteratorTag tag = new MergeIteratorTag();
- tag.setPageContext(pageContext);
- tag.setId("myMergedIterator");
-
- 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 mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
-
- assertNotNull(mergedIterator);
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "1");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "a");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "A");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "2");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "b");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "B");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "3");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "c");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "C");
- assertFalse(mergedIterator.hasNext());
- }
-
-
- public void testMergingIteratorsWithListAsSource() throws Exception {
- MergeIteratorTag tag = new MergeIteratorTag();
- tag.setPageContext(pageContext);
- tag.setId("myMergedIterator");
-
- 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 mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
-
- assertNotNull(mergedIterator);
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "1");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "a");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "A");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "2");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "b");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "B");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "3");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "c");
- assertTrue(mergedIterator.hasNext());
- assertEquals(mergedIterator.next(), "C");
- assertFalse(mergedIterator.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();
- 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 testMergingIteratorWithArrayAsSource() throws Exception {
+ MergeIteratorTag tag = new MergeIteratorTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myMergedIterator");
+
+ 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 mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
+
+ assertNotNull(mergedIterator);
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "1");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "a");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "A");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "2");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "b");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "B");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "3");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "c");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "C");
+ assertFalse(mergedIterator.hasNext());
+ }
+
+
+ public void testMergingIteratorsWithListAsSource() throws Exception {
+ MergeIteratorTag tag = new MergeIteratorTag();
+ tag.setPageContext(pageContext);
+ tag.setId("myMergedIterator");
+
+ 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 mergedIterator = (Iterator) stack.findValue("#myMergedIterator"); // if not iterator, let CCE surface
+
+ assertNotNull(mergedIterator);
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "1");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "a");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "A");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "2");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "b");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "B");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "3");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "c");
+ assertTrue(mergedIterator.hasNext());
+ assertEquals(mergedIterator.next(), "C");
+ assertFalse(mergedIterator.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();
+ 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"};
+ }
+ };
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.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;
@@ -53,87 +56,87 @@
*/
public class PortletUrlTagTest extends MockObjectTestCase {
- URLTag tag = new URLTag();
+ URLTag tag = new URLTag();
+
+ Mock mockHttpReq = null;
- Mock mockHttpReq = null;
+ Mock mockHttpRes = null;
- Mock mockHttpRes = null;
+ Mock mockPortletReq = null;
- Mock mockPortletReq = null;
+ Mock mockPortletRes = null;
- Mock mockPortletRes = null;
+ Mock mockPageCtx = null;
- Mock mockPageCtx = null;
+ Mock mockPortletUrl = null;
- Mock mockPortletUrl = null;
-
- MockJspWriter mockJspWriter = null;
+ MockJspWriter mockJspWriter = null;
- ValueStack stack = null;
+ ValueStack stack = null;
+
+ public static void main(String[] args) {
+ TestRunner.run(PortletUrlTagTest.class);
+ }
- public static void main(String[] args) {
- TestRunner.run(PortletUrlTagTest.class);
- }
+ public void setUp() throws Exception {
+ super.setUp();
- public void setUp() throws Exception {
- super.setUp();
-
- Settings.reset();
+ Settings.reset();
Dispatcher.setInstance(new Dispatcher(null));
-
+
mockPortletApiAvailable();
-
- stack = ValueStackFactory.getFactory().createValueStack();
-
- mockHttpReq = mock(HttpServletRequest.class);
- mockHttpRes = mock(HttpServletResponse.class);
- mockPortletReq = mock(RenderRequest.class);
- mockPortletRes = mock(RenderResponse.class);
- mockPageCtx = mock(PageContext.class);
- mockPortletUrl = mock(PortletURL.class);
- mockJspWriter = new MockJspWriter();
-
- mockPageCtx.stubs().method("getRequest").will(
- returnValue((HttpServletRequest) mockHttpReq.proxy()));
- mockPageCtx.stubs().method("getResponse").will(
- returnValue((HttpServletResponse) mockHttpRes.proxy()));
- mockPageCtx.stubs().method("getOut").will(returnValue(mockJspWriter));
-
- mockHttpReq.stubs().method("getScheme").will(returnValue("http"));
- mockHttpReq.stubs().method("getAttribute").with(
- eq("struts.valueStack")).will(returnValue(stack));
- mockHttpReq.stubs().method("getAttribute").with(
- eq("javax.portlet.response")).will(
- returnValue((PortletResponse) mockPortletRes.proxy()));
- mockHttpReq.stubs().method("getAttribute").with(
- eq("javax.portlet.request")).will(
- returnValue((PortletRequest) mockPortletReq.proxy()));
-
- mockPortletReq.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
- mockPortletReq.stubs().method("getWindowState").will(returnValue(WindowState.NORMAL));
- mockPortletReq.stubs().method("getContextPath").will(returnValue("/contextPath"));
-
- tag.setPageContext((PageContext) mockPageCtx.proxy());
-
- Map modeMap = new HashMap();
- modeMap.put(PortletMode.VIEW, "/view");
- modeMap.put(PortletMode.HELP, "/help");
- modeMap.put(PortletMode.EDIT, "/edit");
- Map sessionMap = new HashMap();
- Map contextMap = new HashMap();
- contextMap.put(ActionContext.SESSION, sessionMap);
- contextMap.put(PortletActionConstants.REQUEST, mockPortletReq.proxy());
- contextMap.put(PortletActionConstants.RESPONSE, mockPortletRes.proxy());
- contextMap.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
- contextMap.put(PortletActionConstants.MODE_NAMESPACE_MAP, modeMap);
- ActionContext ctx = new ActionContext(contextMap);
- ctx.setValueStack(stack);
- ActionContext.setContext(ctx);
+ stack = ValueStackFactory.getFactory().createValueStack();
+
+
+ mockHttpReq = mock(HttpServletRequest.class);
+ mockHttpRes = mock(HttpServletResponse.class);
+ mockPortletReq = mock(RenderRequest.class);
+ mockPortletRes = mock(RenderResponse.class);
+ mockPageCtx = mock(PageContext.class);
+ mockPortletUrl = mock(PortletURL.class);
+ mockJspWriter = new MockJspWriter();
+
+ mockPageCtx.stubs().method("getRequest").will(
+ returnValue((HttpServletRequest) mockHttpReq.proxy()));
+ mockPageCtx.stubs().method("getResponse").will(
+ returnValue((HttpServletResponse) mockHttpRes.proxy()));
+ mockPageCtx.stubs().method("getOut").will(returnValue(mockJspWriter));
+
+ mockHttpReq.stubs().method("getScheme").will(returnValue("http"));
+ mockHttpReq.stubs().method("getAttribute").with(
+ eq("struts.valueStack")).will(returnValue(stack));
+ mockHttpReq.stubs().method("getAttribute").with(
+ eq("javax.portlet.response")).will(
+ returnValue((PortletResponse) mockPortletRes.proxy()));
+ mockHttpReq.stubs().method("getAttribute").with(
+ eq("javax.portlet.request")).will(
+ returnValue((PortletRequest) mockPortletReq.proxy()));
+
+ mockPortletReq.stubs().method("getPortletMode").will(returnValue(PortletMode.VIEW));
+ mockPortletReq.stubs().method("getWindowState").will(returnValue(WindowState.NORMAL));
+ mockPortletReq.stubs().method("getContextPath").will(returnValue("/contextPath"));
+
+ tag.setPageContext((PageContext) mockPageCtx.proxy());
+
+ Map modeMap = new HashMap();
+ modeMap.put(PortletMode.VIEW, "/view");
+ modeMap.put(PortletMode.HELP, "/help");
+ modeMap.put(PortletMode.EDIT, "/edit");
+ Map sessionMap = new HashMap();
+ Map contextMap = new HashMap();
+ contextMap.put(ActionContext.SESSION, sessionMap);
+ contextMap.put(PortletActionConstants.REQUEST, mockPortletReq.proxy());
+ contextMap.put(PortletActionConstants.RESPONSE, mockPortletRes.proxy());
+ contextMap.put(PortletActionConstants.PHASE, PortletActionConstants.RENDER_PHASE);
+ contextMap.put(PortletActionConstants.MODE_NAMESPACE_MAP, modeMap);
+ ActionContext ctx = new ActionContext(contextMap);
+ ctx.setValueStack(stack);
+ ActionContext.setContext(ctx);
}
- /**
- *
+ /**
+ *
*/
private void mockPortletApiAvailable() {
try {
@@ -142,219 +145,219 @@
field.set(null, Boolean.TRUE);
}
catch(Exception e) {
-
+
}
-
+
}
public void testEnsureParamsAreStringArrays() {
- Map params = new HashMap();
- params.put("param1", "Test1");
- params.put("param2", new String[] { "Test2" });
-
- Map result = PortletUrlHelper.ensureParamsAreStringArrays(params);
- assertEquals(2, result.size());
- assertTrue(result.get("param1") instanceof String[]);
- }
-
- public void testSetWindowState() throws Exception {
-
- PortletMode mode = PortletMode.VIEW;
-
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
-
- mockPortletRes.expects(once()).method("createRenderURL").will(
- returnValue((PortletURL) mockPortletUrl.proxy()));
-
- Map paramMap = new HashMap();
- paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
- paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
- mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
- mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.MAXIMIZED));
- mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
-
- tag.setAction("testAction");
- tag.setWindowState("maximized");
- tag.doStartTag();
- tag.doEndTag();
-
- }
-
- public void testSetPortletMode() throws Exception {
-
- PortletMode mode = PortletMode.HELP;
-
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
-
- mockPortletRes.expects(once()).method("createRenderURL").will(
- returnValue((PortletURL) mockPortletUrl.proxy()));
-
- Map paramMap = new HashMap();
- paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/help/testAction"});
- paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
- mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
- mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.HELP));
- mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
-
- tag.setAction("testAction");
- tag.setPortletMode("help");
- tag.doStartTag();
- tag.doEndTag();
- }
-
- public void testUrlWithQueryParams() throws Exception {
-
- PortletMode mode = PortletMode.VIEW;
-
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
-
- mockPortletRes.expects(once()).method("createRenderURL").will(
- returnValue((PortletURL) mockPortletUrl.proxy()));
-
- Map paramMap = new HashMap();
- paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
- paramMap.put("testParam1", new String[]{"testValue1"});
- paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
- mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
- mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
- mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
-
- tag.setAction("testAction?testParam1=testValue1");
- tag.doStartTag();
- tag.doEndTag();
- }
-
- public void testActionUrl() throws Exception {
-
- PortletMode mode = PortletMode.VIEW;
-
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
-
- mockPortletRes.expects(once()).method("createActionURL").will(
- returnValue((PortletURL) mockPortletUrl.proxy()));
-
- Map paramMap = new HashMap();
- paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
- paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
-
- mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
- mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
- mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
-
- tag.setAction("testAction");
- tag.setPortletUrlType("action");
- tag.doStartTag();
- tag.doEndTag();
- }
-
- public void testResourceUrl() throws Exception {
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
- mockPortletRes.expects(once()).method("encodeURL").will(returnValue("/contextPath/image.gif"));
- mockJspWriter.setExpectedData("/contextPath/image.gif");
- tag.setValue("image.gif");
- tag.doStartTag();
- tag.doEndTag();
- mockJspWriter.verify();
- }
-
- public void testResourceUrlWithNestedParam() throws Exception {
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
- mockPortletRes.expects(once()).method("encodeURL").with(eq("/contextPath/image.gif?testParam1=testValue1")).will(returnValue("/contextPath/image.gif?testParam1=testValue1"));
- mockJspWriter.setExpectedData("/contextPath/image.gif?testParam1=testValue1");
-
- ParamTag paramTag = new ParamTag();
- paramTag.setPageContext((PageContext)mockPageCtx.proxy());
- paramTag.setParent(tag);
- paramTag.setName("testParam1");
- paramTag.setValue("'testValue1'");
- tag.setValue("image.gif");
- tag.doStartTag();
- paramTag.doStartTag();
- paramTag.doEndTag();
- tag.doEndTag();
- mockJspWriter.verify();
- }
-
- public void testResourceUrlWithTwoNestedParam() throws Exception {
- mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
- mockPortletRes.expects(once()).method("encodeURL").with(eq("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2")).will(returnValue("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2"));
- mockJspWriter.setExpectedData("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2");
-
- ParamTag paramTag = new ParamTag();
- paramTag.setPageContext((PageContext)mockPageCtx.proxy());
- paramTag.setParent(tag);
- paramTag.setName("testParam1");
- paramTag.setValue("'testValue1'");
- ParamTag paramTag2 = new ParamTag();
- paramTag2.setPageContext((PageContext)mockPageCtx.proxy());
- paramTag2.setParent(tag);
- paramTag2.setName("testParam2");
- paramTag2.setValue("'testValue2'");
- tag.setValue("image.gif");
- tag.doStartTag();
- paramTag.doStartTag();
- paramTag.doEndTag();
- paramTag2.doStartTag();
- paramTag2.doEndTag();
- tag.doEndTag();
- mockJspWriter.verify();
- }
-
- private static class ParamMapConstraint implements Constraint {
-
- private Map myExpectedMap = null;
- private Map myActualMap = null;
-
- public ParamMapConstraint(Map expectedMap) {
- if(expectedMap == null) {
- throw new IllegalArgumentException("Use an isNull constraint instead!");
- }
- myExpectedMap = expectedMap;
- }
-
- /* (non-Javadoc)
- * @see org.jmock.core.Constraint#eval(java.lang.Object)
- */
- public boolean eval(Object val) {
- myActualMap = (Map)val;
- boolean result = false;
- if(val != null) {
- if(myExpectedMap.size() == myActualMap.size()) {
- Iterator keys = myExpectedMap.keySet().iterator();
- boolean allSame = true;
- while(keys.hasNext()) {
- Object key = keys.next();
- if(!myActualMap.containsKey(key)) {
- allSame = false;
- break;
- }
- else {
- String[] expected = (String[])myExpectedMap.get(key);
- String[] actual = (String[])myActualMap.get(key);
- if(!Arrays.equals(expected, actual)) {
- allSame = false;
- break;
- }
- }
- }
- result = allSame;
- }
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.jmock.core.SelfDescribing#describeTo(java.lang.StringBuffer)
- */
- public StringBuffer describeTo(StringBuffer sb) {
- return sb.append(myExpectedMap);
- }
-
-
+ Map params = new HashMap();
+ params.put("param1", "Test1");
+ params.put("param2", new String[] { "Test2" });
+
+ Map result = PortletUrlHelper.ensureParamsAreStringArrays(params);
+ assertEquals(2, result.size());
+ assertTrue(result.get("param1") instanceof String[]);
+ }
+
+ public void testSetWindowState() throws Exception {
+
+ PortletMode mode = PortletMode.VIEW;
+
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+
+ mockPortletRes.expects(once()).method("createRenderURL").will(
+ returnValue((PortletURL) mockPortletUrl.proxy()));
+
+ Map paramMap = new HashMap();
+ paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
+ paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
+
+ mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
+ mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.MAXIMIZED));
+ mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
+
+ tag.setAction("testAction");
+ tag.setWindowState("maximized");
+ tag.doStartTag();
+ tag.doEndTag();
+
+ }
+
+ public void testSetPortletMode() throws Exception {
+
+ PortletMode mode = PortletMode.HELP;
+
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+
+ mockPortletRes.expects(once()).method("createRenderURL").will(
+ returnValue((PortletURL) mockPortletUrl.proxy()));
+
+ Map paramMap = new HashMap();
+ paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/help/testAction"});
+ paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
+
+ mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
+ mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.HELP));
+ mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
+
+ tag.setAction("testAction");
+ tag.setPortletMode("help");
+ tag.doStartTag();
+ tag.doEndTag();
+ }
+
+ public void testUrlWithQueryParams() throws Exception {
+
+ PortletMode mode = PortletMode.VIEW;
+
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
- }
+ mockPortletRes.expects(once()).method("createRenderURL").will(
+ returnValue((PortletURL) mockPortletUrl.proxy()));
+
+ Map paramMap = new HashMap();
+ paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
+ paramMap.put("testParam1", new String[]{"testValue1"});
+ paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
+
+ mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
+ mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
+ mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
+
+ tag.setAction("testAction?testParam1=testValue1");
+ tag.doStartTag();
+ tag.doEndTag();
+ }
+
+ public void testActionUrl() throws Exception {
+
+ PortletMode mode = PortletMode.VIEW;
+
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+
+ mockPortletRes.expects(once()).method("createActionURL").will(
+ returnValue((PortletURL) mockPortletUrl.proxy()));
+
+ Map paramMap = new HashMap();
+ paramMap.put(PortletActionConstants.ACTION_PARAM, new String[]{"/view/testAction"});
+ paramMap.put(PortletActionConstants.MODE_PARAM, new String[]{mode.toString()});
+
+ mockPortletUrl.expects(once()).method("setParameters").with(new ParamMapConstraint(paramMap));
+ mockPortletUrl.expects(once()).method("setPortletMode").with(eq(PortletMode.VIEW));
+ mockPortletUrl.expects(once()).method("setWindowState").with(eq(WindowState.NORMAL));
+
+ tag.setAction("testAction");
+ tag.setPortletUrlType("action");
+ tag.doStartTag();
+ tag.doEndTag();
+ }
+
+ public void testResourceUrl() throws Exception {
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+ mockPortletRes.expects(once()).method("encodeURL").will(returnValue("/contextPath/image.gif"));
+ mockJspWriter.setExpectedData("/contextPath/image.gif");
+ tag.setValue("image.gif");
+ tag.doStartTag();
+ tag.doEndTag();
+ mockJspWriter.verify();
+ }
+
+ public void testResourceUrlWithNestedParam() throws Exception {
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+ mockPortletRes.expects(once()).method("encodeURL").with(eq("/contextPath/image.gif?testParam1=testValue1")).will(returnValue("/contextPath/image.gif?testParam1=testValue1"));
+ mockJspWriter.setExpectedData("/contextPath/image.gif?testParam1=testValue1");
+
+ ParamTag paramTag = new ParamTag();
+ paramTag.setPageContext((PageContext)mockPageCtx.proxy());
+ paramTag.setParent(tag);
+ paramTag.setName("testParam1");
+ paramTag.setValue("'testValue1'");
+ tag.setValue("image.gif");
+ tag.doStartTag();
+ paramTag.doStartTag();
+ paramTag.doEndTag();
+ tag.doEndTag();
+ mockJspWriter.verify();
+ }
+
+ public void testResourceUrlWithTwoNestedParam() throws Exception {
+ mockHttpReq.stubs().method("getQueryString").will(returnValue(""));
+ mockPortletRes.expects(once()).method("encodeURL").with(eq("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2")).will(returnValue("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2"));
+ mockJspWriter.setExpectedData("/contextPath/image.gif?testParam1=testValue1&testParam2=testValue2");
+
+ ParamTag paramTag = new ParamTag();
+ paramTag.setPageContext((PageContext)mockPageCtx.proxy());
+ paramTag.setParent(tag);
+ paramTag.setName("testParam1");
+ paramTag.setValue("'testValue1'");
+ ParamTag paramTag2 = new ParamTag();
+ paramTag2.setPageContext((PageContext)mockPageCtx.proxy());
+ paramTag2.setParent(tag);
+ paramTag2.setName("testParam2");
+ paramTag2.setValue("'testValue2'");
+ tag.setValue("image.gif");
+ tag.doStartTag();
+ paramTag.doStartTag();
+ paramTag.doEndTag();
+ paramTag2.doStartTag();
+ paramTag2.doEndTag();
+ tag.doEndTag();
+ mockJspWriter.verify();
+ }
+
+ private static class ParamMapConstraint implements Constraint {
+
+ private Map myExpectedMap = null;
+ private Map myActualMap = null;
+
+ public ParamMapConstraint(Map expectedMap) {
+ if(expectedMap == null) {
+ throw new IllegalArgumentException("Use an isNull constraint instead!");
+ }
+ myExpectedMap = expectedMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jmock.core.Constraint#eval(java.lang.Object)
+ */
+ public boolean eval(Object val) {
+ myActualMap = (Map)val;
+ boolean result = false;
+ if(val != null) {
+ if(myExpectedMap.size() == myActualMap.size()) {
+ Iterator keys = myExpectedMap.keySet().iterator();
+ boolean allSame = true;
+ while(keys.hasNext()) {
+ Object key = keys.next();
+ if(!myActualMap.containsKey(key)) {
+ allSame = false;
+ break;
+ }
+ else {
+ String[] expected = (String[])myExpectedMap.get(key);
+ String[] actual = (String[])myActualMap.get(key);
+ if(!Arrays.equals(expected, actual)) {
+ allSame = false;
+ break;
+ }
+ }
+ }
+ result = allSame;
+ }
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jmock.core.SelfDescribing#describeTo(java.lang.StringBuffer)
+ */
+ public StringBuffer describeTo(StringBuffer sb) {
+ return sb.append(myExpectedMap);
+ }
+
+
+
+ }
}
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.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;
@@ -33,7 +36,7 @@
/**
* PropertyTag test case.
- *
+ *
*/
public class PropertyTagTest extends StrutsTestCase {
Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PushTagTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PushTagTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PushTagTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PushTagTest.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;