You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 19:13:25 UTC
svn commit: r376783 [2/2] -
/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELErrorsTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELErrorsTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELErrorsTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELErrorsTag.java Fri Feb 10 10:13:22 2006
@@ -1,52 +1,48 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.strutsel.taglib.utils.JspTagTestCase;
-
-public class TestELErrorsTag
- extends JspTagTestCase {
- protected static final String FOOTER_VALUE = "zzz";
- protected static final String HEADER_VALUE = "aaa";
- protected static final String PREFIX_VALUE = "[[[";
- protected static final String PROPERTY_KEY = "property";
- protected static final String REQUIRED_TEXT_VALUE_KEY =
- "RequiredTextValue";
- protected static final String SUFFIX_VALUE = "]]]";
- protected static final String XXX_VALUE = "xxx";
- protected static final String YYY_VALUE = "yyy";
- protected ELErrorsTag elErrorsTag = null;
- private static Log log =
- LogFactory.getLog(TestELErrorsTag.class);
+public class TestELErrorsTag extends JspTagTestCase {
+ protected static final String FOOTER_VALUE = "zzz";
+ protected static final String HEADER_VALUE = "aaa";
+ protected static final String PREFIX_VALUE = "[[[";
+ protected static final String PROPERTY_KEY = "property";
+ protected static final String REQUIRED_TEXT_VALUE_KEY = "RequiredTextValue";
+ protected static final String SUFFIX_VALUE = "]]]";
+ protected static final String XXX_VALUE = "xxx";
+ protected static final String YYY_VALUE = "yyy";
+ private static Log log = LogFactory.getLog(TestELErrorsTag.class);
+ protected ELErrorsTag elErrorsTag = null;
public TestELErrorsTag(String theName) {
super(theName);
}
public static void main(String[] args) {
- junit.awtui.TestRunner.main(
- new String[] { TestELErrorsTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELErrorsTag.class
+ .getName() });
}
public static Test suite() {
@@ -58,422 +54,353 @@
elErrorsTag.setPageContext(pageContext);
}
- public void testDummy()
- {
+ public void testDummy() {
}
-// /**
-// * Tests simple global error with all tag attributes set to default, and no
-// * header, footer, prefix or suffix.
-// */
-// public void testPlain()
-// throws ServletException, JspException {
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(ActionErrors.GLOBAL_ERROR, error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = XXX_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// System.out.println("pageContext[" + pageContext + "]");
-// System.out.println("name[" + elErrorsTag.getName() + "]");
-// System.out.println("request[" + pageContext.getRequest() + "]");
-// System.out.println("session[" + pageContext.getSession() + "]");
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// /**
-// * Tests multiple errors put in errors list, with two different property
-// * names, but referring to the same error, but still using the default
-// * value of "property", which will cause both errors to be retrieved.
-// */
-// public void testMultiProperties()
-// throws ServletException, JspException {
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(PROPERTY_KEY + "1", error);
-// errors.add(PROPERTY_KEY + "2", error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = XXX_VALUE + " " + XXX_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endMultiProperties(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// /**
-// * Tests putting in two errors in errors list, with two different property
-// * names, and referring to two different error keys, and the "property"
-// * attribute set to only one of them.
-// */
-// public void testOnlyWantOneProperty()
-// throws ServletException, JspException {
-// elErrorsTag.setPropertyExpr(PROPERTY_KEY + "2");
-
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error1.misc", XXX_VALUE);
-// messageResources.addMessage("error2.misc", YYY_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// errors.add(PROPERTY_KEY + "1", new ActionError("error1.misc"));
-// errors.add(PROPERTY_KEY + "2", new ActionError("error2.misc"));
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = YYY_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endOnlyWantOneProperty(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// /**
-// * Tests one error on a specific property, with "property" attribute set to
-// * default.
-// */
-// public void testProperty()
-// throws ServletException, JspException {
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(PROPERTY_KEY, error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = XXX_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endProperty(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// /**
-// * Just like "testPropertySpecified", but the "property" value is an EL
-// * expression, evaluating to the same value as in the other test.
-// */
-// public void testPropertySpecifiedEL()
-// throws ServletException, JspException {
-// String varName = "targetVar";
-// pageContext.setAttribute(varName, PROPERTY_KEY);
-// elErrorsTag.setPropertyExpr("${" + varName + "}");
-// testPropertySpecified();
-// }
-
-// public void endPropertySpecifiedEL(com.meterware.httpunit.WebResponse testResponse) {
-// endPropertySpecified(testResponse);
-// }
-
-// /**
-// * Tests one error in errors list, set to a property, and the "property"
-// * attribute set to that property key.
-// */
-// public void testPropertySpecified()
-// throws ServletException, JspException {
-// elErrorsTag.setPropertyExpr(PROPERTY_KEY);
-
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(PROPERTY_KEY, error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = XXX_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endPropertySpecified(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// /**
-// * Tests one error in the errors list, set to a property, and the
-// * "property" attribute set to a different property key.
-// */
-// public void testPropertySpecifiedWrong()
-// throws ServletException, JspException {
-// elErrorsTag.setPropertyExpr(PROPERTY_KEY + "x");
-
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(PROPERTY_KEY, error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = "";
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endPropertySpecifiedWrong(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// public void tearDown() {
-// elErrorsTag = null;
-// }
-
-// /**
-// * Tests a single error in errors list, with the "header" and "footer"
-// * resource set to non-empty strings.
-// */
-// public void testHeaderFooter()
-// throws ServletException, JspException {
-// HashMapMessageResources messageResources = new HashMapMessageResources(
-// null, null, true);
-// messageResources.addMessage("error.misc", XXX_VALUE);
-// messageResources.addMessage("errors.header", HEADER_VALUE);
-// messageResources.addMessage("errors.footer", FOOTER_VALUE);
-// String bundle = elErrorsTag.getBundle();
-// if (bundle == null)
-// bundle = Action.MESSAGES_KEY;
-// pageContext.setAttribute(bundle, messageResources,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionErrors errors = new ActionErrors();
-// ActionError error = new ActionError("error.misc");
-// errors.add(ActionErrors.GLOBAL_ERROR, error);
-// pageContext.setAttribute(elErrorsTag.getName(), errors,
-// PageContext.REQUEST_SCOPE);
-
-// HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
-// String requiredText = HEADER_VALUE + " " + XXX_VALUE +
-// " " + FOOTER_VALUE;
-// response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
-
-// int startTagReturn = elErrorsTag.doStartTag();
-// int afterBodyReturn = elErrorsTag.doAfterBody();
-// int endTagReturn = elErrorsTag.doEndTag();
-// }
-
-// public void endHeaderFooter(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-
-// String nodeText = DOMHelper.getNodeText(document, "/html/body");
-// log.debug("nodeText[" + nodeText + "]");
-
-// String requiredTextValue = (String)testResponse.getHeaderField(
-// REQUIRED_TEXT_VALUE_KEY);
-
-// if (!nodeText.equals(requiredTextValue)) {
-// fail("The <errors> tag instance should have resulted " +
-// "in the text " + "\"" + requiredTextValue +
-// "\", but instead had the value \"" + nodeText + "\".");
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
+ // /**
+ // * Tests simple global error with all tag attributes set to default, and no
+ // * header, footer, prefix or suffix.
+ // */
+ // public void testPlain()
+ // throws ServletException, JspException {
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(ActionErrors.GLOBAL_ERROR, error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = XXX_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // System.out.println("pageContext[" + pageContext + "]");
+ // System.out.println("name[" + elErrorsTag.getName() + "]");
+ // System.out.println("request[" + pageContext.getRequest() + "]");
+ // System.out.println("session[" + pageContext.getSession() + "]");
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // /**
+ // * Tests multiple errors put in errors list, with two different property
+ // * names, but referring to the same error, but still using the default
+ // * value of "property", which will cause both errors to be retrieved.
+ // */
+ // public void testMultiProperties()
+ // throws ServletException, JspException {
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(PROPERTY_KEY + "1", error);
+ // errors.add(PROPERTY_KEY + "2", error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = XXX_VALUE + " " + XXX_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endMultiProperties(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // /**
+ // * Tests putting in two errors in errors list, with two different property
+ // * names, and referring to two different error keys, and the "property"
+ // * attribute set to only one of them.
+ // */
+ // public void testOnlyWantOneProperty()
+ // throws ServletException, JspException {
+ // elErrorsTag.setPropertyExpr(PROPERTY_KEY + "2");
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error1.misc", XXX_VALUE);
+ // messageResources.addMessage("error2.misc", YYY_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // errors.add(PROPERTY_KEY + "1", new ActionError("error1.misc"));
+ // errors.add(PROPERTY_KEY + "2", new ActionError("error2.misc"));
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = YYY_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endOnlyWantOneProperty(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // /**
+ // * Tests one error on a specific property, with "property" attribute set to
+ // * default.
+ // */
+ // public void testProperty()
+ // throws ServletException, JspException {
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(PROPERTY_KEY, error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = XXX_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endProperty(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // /**
+ // * Just like "testPropertySpecified", but the "property" value is an EL
+ // * expression, evaluating to the same value as in the other test.
+ // */
+ // public void testPropertySpecifiedEL()
+ // throws ServletException, JspException {
+ // String varName = "targetVar";
+ // pageContext.setAttribute(varName, PROPERTY_KEY);
+ // elErrorsTag.setPropertyExpr("${" + varName + "}");
+ // testPropertySpecified();
+ // }
+ // public void endPropertySpecifiedEL(com.meterware.httpunit.WebResponse testResponse) {
+ // endPropertySpecified(testResponse);
+ // }
+ // /**
+ // * Tests one error in errors list, set to a property, and the "property"
+ // * attribute set to that property key.
+ // */
+ // public void testPropertySpecified()
+ // throws ServletException, JspException {
+ // elErrorsTag.setPropertyExpr(PROPERTY_KEY);
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(PROPERTY_KEY, error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = XXX_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endPropertySpecified(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // /**
+ // * Tests one error in the errors list, set to a property, and the
+ // * "property" attribute set to a different property key.
+ // */
+ // public void testPropertySpecifiedWrong()
+ // throws ServletException, JspException {
+ // elErrorsTag.setPropertyExpr(PROPERTY_KEY + "x");
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(PROPERTY_KEY, error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = "";
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endPropertySpecifiedWrong(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // public void tearDown() {
+ // elErrorsTag = null;
+ // }
+ // /**
+ // * Tests a single error in errors list, with the "header" and "footer"
+ // * resource set to non-empty strings.
+ // */
+ // public void testHeaderFooter()
+ // throws ServletException, JspException {
+ // HashMapMessageResources messageResources = new HashMapMessageResources(
+ // null, null, true);
+ // messageResources.addMessage("error.misc", XXX_VALUE);
+ // messageResources.addMessage("errors.header", HEADER_VALUE);
+ // messageResources.addMessage("errors.footer", FOOTER_VALUE);
+ // String bundle = elErrorsTag.getBundle();
+ // if (bundle == null)
+ // bundle = Action.MESSAGES_KEY;
+ // pageContext.setAttribute(bundle, messageResources,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionErrors errors = new ActionErrors();
+ // ActionError error = new ActionError("error.misc");
+ // errors.add(ActionErrors.GLOBAL_ERROR, error);
+ // pageContext.setAttribute(elErrorsTag.getName(), errors,
+ // PageContext.REQUEST_SCOPE);
+ // HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ // String requiredText = HEADER_VALUE + " " + XXX_VALUE +
+ // " " + FOOTER_VALUE;
+ // response.addHeader(REQUIRED_TEXT_VALUE_KEY, requiredText);
+ // int startTagReturn = elErrorsTag.doStartTag();
+ // int afterBodyReturn = elErrorsTag.doAfterBody();
+ // int endTagReturn = elErrorsTag.doEndTag();
+ // }
+ // public void endHeaderFooter(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // String nodeText = DOMHelper.getNodeText(document, "/html/body");
+ // log.debug("nodeText[" + nodeText + "]");
+ // String requiredTextValue = (String)testResponse.getHeaderField(
+ // REQUIRED_TEXT_VALUE_KEY);
+ // if (!nodeText.equals(requiredTextValue)) {
+ // fail("The <errors> tag instance should have resulted " +
+ // "in the text " + "\"" + requiredTextValue +
+ // "\", but instead had the value \"" + nodeText + "\".");
+ // }
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
}
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFileTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFileTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFileTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFileTag.java Fri Feb 10 10:13:22 2006
@@ -1,28 +1,22 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
-import java.util.HashMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspException;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -31,29 +25,28 @@
import org.apache.strutsel.taglib.utils.TestFormBean;
import org.apache.strutsel.taglib.utils.TestHelper;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
-public class TestELFileTag
- extends JspTagTestCase {
+import java.util.HashMap;
- protected static final String PROPERTY_ATTR_VALUE =
- "stringProperty";
- protected static final String REQUIRED_DISABLED_VALUE_KEY =
- "RequiredDisabledValue";
- protected static final String REQUIRED_TYPE_VALUE_KEY =
- "RequiredTypeValue";
- protected static final String REQUIRED_VALUE_VALUE_KEY =
- "RequiredValueValue";
- protected static final String REQUIRED_NAME_VALUE_KEY =
- "RequiredNameValue";
- protected ELFileTag elFileTag = null;
+public class TestELFileTag extends JspTagTestCase {
+ protected static final String PROPERTY_ATTR_VALUE = "stringProperty";
+ protected static final String REQUIRED_DISABLED_VALUE_KEY =
+ "RequiredDisabledValue";
+ protected static final String REQUIRED_TYPE_VALUE_KEY = "RequiredTypeValue";
+ protected static final String REQUIRED_VALUE_VALUE_KEY =
+ "RequiredValueValue";
+ protected static final String REQUIRED_NAME_VALUE_KEY = "RequiredNameValue";
+ protected ELFileTag elFileTag = null;
public TestELFileTag(String theName) {
super(theName);
}
public static void main(String[] args) {
- junit.awtui.TestRunner.main(
- new String[] { TestELFileTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELFileTag.class.getName() });
}
public static Test suite() {
@@ -73,25 +66,30 @@
/**
* Tests a plain "file" tag, with all default attribute values.
*/
- public void testPlain()
- throws ServletException, JspException {
- HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ public void testPlain() throws ServletException, JspException {
+ HttpServletResponse response =
+ (HttpServletResponse) pageContext.getResponse();
TestFormBean formBean = new TestFormBean();
+
pageContext.setAttribute("testFormBean", formBean);
elFileTag.setNameExpr("testFormBean");
String requiredNameValue = PROPERTY_ATTR_VALUE;
+
response.addHeader(REQUIRED_NAME_VALUE_KEY, requiredNameValue);
+
String requiredTypeValue = "file";
+
response.addHeader(REQUIRED_TYPE_VALUE_KEY, requiredTypeValue);
String requiredValueValue = "";
+
response.addHeader(REQUIRED_VALUE_VALUE_KEY, requiredValueValue);
- int startTagReturn = elFileTag.doStartTag();
+ int startTagReturn = elFileTag.doStartTag();
int afterBodyReturn = elFileTag.doAfterBody();
- int endTagReturn = elFileTag.doEndTag();
+ int endTagReturn = elFileTag.doEndTag();
}
public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
@@ -99,21 +97,21 @@
TestHelper.printResponse(testResponse);
org.w3c.dom.Document document = testResponse.getDOM();
+
DOMHelper.printNode(document.getDocumentElement());
HashMap attrMap = new HashMap();
- DOMHelper.recordFoundAttributes(testResponse.getDOM(),
- "/html/body/input", attrMap);
- DOMHelper.verifyAttributesPresent(attrMap,
- new String[] {
- "name", "type", "value" },
- false);
- checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
- "file", "name");
- checkAttrValue(attrMap, testResponse, REQUIRED_TYPE_VALUE_KEY,
- "file", "type");
- checkAttrValue(attrMap, testResponse, REQUIRED_VALUE_VALUE_KEY,
- "file", "value");
+
+ DOMHelper.recordFoundAttributes(testResponse.getDOM(),
+ "/html/body/input", attrMap);
+ DOMHelper.verifyAttributesPresent(attrMap,
+ new String[] { "name", "type", "value" }, false);
+ checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
+ "file", "name");
+ checkAttrValue(attrMap, testResponse, REQUIRED_TYPE_VALUE_KEY,
+ "file", "type");
+ checkAttrValue(attrMap, testResponse, REQUIRED_VALUE_VALUE_KEY,
+ "file", "value");
} catch (Exception ex) {
ex.printStackTrace();
fail();
@@ -124,20 +122,21 @@
* Tests the "disabled" attribute.
*/
public void testDisabled()
- throws ServletException, JspException {
-
+ throws ServletException, JspException {
TestFormBean formBean = new TestFormBean();
+
pageContext.setAttribute("testFormBean", formBean);
elFileTag.setNameExpr("testFormBean");
elFileTag.setDisabledExpr("true");
String requiredDisabledValue = "disabled";
+
response.addHeader(REQUIRED_DISABLED_VALUE_KEY, requiredDisabledValue);
- int startTagReturn = elFileTag.doStartTag();
+ int startTagReturn = elFileTag.doStartTag();
int afterBodyReturn = elFileTag.doAfterBody();
- int endTagReturn = elFileTag.doEndTag();
+ int endTagReturn = elFileTag.doEndTag();
}
public void endDisabled(com.meterware.httpunit.WebResponse testResponse) {
@@ -145,16 +144,17 @@
TestHelper.printResponse(testResponse);
org.w3c.dom.Document document = testResponse.getDOM();
+
DOMHelper.printNode(document.getDocumentElement());
HashMap attrMap = new HashMap();
- DOMHelper.recordFoundAttributes(testResponse.getDOM(),
- "/html/body/input", attrMap);
- DOMHelper.verifyAttributesPresent(attrMap,
- new String[] { "disabled" },
- true);
- checkAttrValue(attrMap, testResponse, REQUIRED_DISABLED_VALUE_KEY,
- "file", "disabled");
+
+ DOMHelper.recordFoundAttributes(testResponse.getDOM(),
+ "/html/body/input", attrMap);
+ DOMHelper.verifyAttributesPresent(attrMap,
+ new String[] { "disabled" }, true);
+ checkAttrValue(attrMap, testResponse, REQUIRED_DISABLED_VALUE_KEY,
+ "file", "disabled");
} catch (Exception ex) {
ex.printStackTrace();
fail();
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFormTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFormTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFormTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFormTag.java Fri Feb 10 10:13:22 2006
@@ -1,54 +1,47 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.strutsel.taglib.utils.JspTagTestCase;
-public class TestELFormTag extends JspTagTestCase
-{
-
- protected static final String ACTION_NAME = "stuff";
- protected static final String FORM_BEAN_CLASS =
+public class TestELFormTag extends JspTagTestCase {
+ protected static final String ACTION_NAME = "stuff";
+ protected static final String FORM_BEAN_CLASS =
"org.apache.strutsel.taglib.utils.TestFormBean";
-
- protected static final String REQUIRED_NAME_VALUE_KEY =
- "RequiredNameValue";
- protected static final String REQUIRED_METHOD_VALUE_KEY =
- "RequiredMethodValue";
- protected static final String REQUIRED_ACTION_VALUE_KEY =
- "RequiredActionValue";
-
- protected ELFormTag elFormTag = null;
-
- private static Log log = LogFactory.getLog(TestELFormTag.class);
+ protected static final String REQUIRED_NAME_VALUE_KEY = "RequiredNameValue";
+ protected static final String REQUIRED_METHOD_VALUE_KEY =
+ "RequiredMethodValue";
+ protected static final String REQUIRED_ACTION_VALUE_KEY =
+ "RequiredActionValue";
+ private static Log log = LogFactory.getLog(TestELFormTag.class);
+ protected ELFormTag elFormTag = null;
public TestELFormTag(String theName) {
super(theName);
}
public static void main(String[] args) {
- junit.awtui.TestRunner.main(
- new String[] { TestELFormTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELFormTag.class.getName() });
}
public static Test suite() {
@@ -62,236 +55,200 @@
/**
* Converts an action name into the path associated with it. The basic
- * contents of this function was copied from
- * "FormTag.getActionMappingName()".
+ * contents of this function was copied from "FormTag.getActionMappingName()".
*/
- protected String convertActionNameToPath(String actionName)
- {
+ protected String convertActionNameToPath(String actionName) {
String value = actionName;
int questionLoc = actionName.indexOf("?");
- if (questionLoc >= 0)
+
+ if (questionLoc >= 0) {
value = value.substring(0, questionLoc);
+ }
int slashLoc = value.lastIndexOf("/");
- int periodLoc = value.lastIndexOf(".");
+ int periodLoc = value.lastIndexOf(".");
- if ((periodLoc >= 0) && (periodLoc > slashLoc))
+ if ((periodLoc >= 0) && (periodLoc > slashLoc)) {
value = value.substring(0, periodLoc);
+ }
- if (!value.startsWith("/"))
+ if (!value.startsWith("/")) {
value = "/" + value;
+ }
return (value);
}
-// /**
-// * Return the form action converted into a server-relative URL.
-// * <p>
-// * This is copied from FormTag, with the small change of passing the action
-// * name as a parameter, and calling
-// * <code>convertActionNameToPath(actionName)</code> instead of the
-// * original's <code>getActionMappingName()</code>.
-// */
-// protected String getActionMappingURL(String actionName) {
-
-// HttpServletRequest request =
-// (HttpServletRequest) pageContext.getRequest();
-// StringBuffer value = new StringBuffer(request.getContextPath());
-// ApplicationConfig config = (ApplicationConfig)
-// pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
-// if (config != null) {
-// value.append(config.getPrefix());
-// }
-
-// // Use our servlet mapping, if one is specified
-// String servletMapping = (String)
-// pageContext.getAttribute(Action.SERVLET_KEY,
-// PageContext.APPLICATION_SCOPE);
-// if (servletMapping != null) {
-// String queryString = null;
-// int question = actionName.indexOf("?");
-// if (question >= 0) {
-// queryString = actionName.substring(question);
-// }
-// String actionMapping = convertActionNameToPath(actionName);
-// if (servletMapping.startsWith("*.")) {
-// value.append(actionMapping);
-// value.append(servletMapping.substring(1));
-// } else if (servletMapping.endsWith("/*")) {
-// value.append(servletMapping.substring
-// (0, servletMapping.length() - 2));
-// value.append(actionMapping);
-// } else if (servletMapping.equals("/")) {
-// value.append(actionMapping);
-// }
-// if (queryString != null) {
-// value.append(queryString);
-// }
-// }
-
-// // Otherwise, assume extension mapping is in use and extension is
-// // already included in the action property
-// else {
-// if (!actionName.startsWith("/")) {
-// value.append("/");
-// }
-// value.append(actionName);
-// }
-
-// // Return the completed value
-// return (value.toString());
-// }
-
-// protected void setupServletEnvironment()
-// throws ServletException
-// {
-// ActionServlet actionServlet = new ActionServlet();
-// actionServlet.init(pageContext.getServletConfig());
-// actionServlet.init();
-
-// ApplicationConfig appConfig = new ApplicationConfig("");
-
-// pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
-// PageContext.APPLICATION_SCOPE);
-// }
-
- public void testDummy()
- {
- }
-
-// public void testPlain()
-// throws ServletException, JspException
-// {
-// ActionServlet actionServlet = new ActionServlet();
-// actionServlet.init(pageContext.getServletConfig());
-// actionServlet.init();
-
-// // ApplicationConfig appConfig = new ApplicationConfig("");
-
-// // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
-// // PageContext.APPLICATION_SCOPE);
-
-// ActionMapping mapping = new ActionMapping();
-// mapping.setName(ACTION_NAME);
-// mapping.setPath(convertActionNameToPath(mapping.getName()));
-
-// ActionFormBean formBean =
-// new ActionFormBean(mapping.getName(), FORM_BEAN_CLASS);
-
-// appConfig.addActionConfig(mapping);
-// appConfig.addFormBeanConfig(formBean);
-
-// HttpServletResponse response =
-// (HttpServletResponse)pageContext.getResponse();
-
-// String encodedURL =
-// response.encodeURL(RequestUtils.
-// getActionMappingURL(mapping.getName(),
-// pageContext));
-
-// response.addHeader(REQUIRED_NAME_VALUE_KEY, ACTION_NAME);
-// response.addHeader(REQUIRED_METHOD_VALUE_KEY, "post");
-// response.addHeader(REQUIRED_ACTION_VALUE_KEY, encodedURL);
-
-// elFormTag.setActionExpr(ACTION_NAME);
-
-// int startTagReturn = elFormTag.doStartTag();
-// int endTagReturn = elFormTag.doEndTag();
-// }
-
-// public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// Element docElement = testResponse.getDOM().getDocumentElement();
-// DOMHelper.printNode(docElement);
-
-// HashMap attrMap = new HashMap();
-
-// DOMHelper.recordFoundAttributes(testResponse.getDOM(),
-// "/html/body/form", attrMap);
-// DOMHelper.verifyAttributesPresent(attrMap,
-// new String[] { "name", "method",
-// "action" },
-// false);
-// checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
-// "form", "name");
-// checkAttrValue(attrMap, testResponse, REQUIRED_METHOD_VALUE_KEY,
-// "form", "method");
-// checkAttrValue(attrMap, testResponse, REQUIRED_ACTION_VALUE_KEY,
-// "form", "action");
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
-
-// public void testMethod()
-// throws ServletException, JspException
-// {
-// ActionServlet actionServlet = new ActionServlet();
-// actionServlet.init(pageContext.getServletConfig());
-// actionServlet.init();
-
-// ApplicationConfig appConfig = new ApplicationConfig("");
-
-// pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionMapping mapping = new ActionMapping();
-// mapping.setName(ACTION_NAME);
-// mapping.setPath(convertActionNameToPath(mapping.getName()));
-
-// ActionFormBean formBean =
-// new ActionFormBean(mapping.getName(), FORM_BEAN_CLASS);
-
-// appConfig.addActionConfig(mapping);
-// appConfig.addFormBeanConfig(formBean);
-
-// HttpServletResponse response =
-// (HttpServletResponse)pageContext.getResponse();
-
-// String encodedURL =
-// response.encodeURL(RequestUtils.
-// getActionMappingURL(mapping.getName(),
-// pageContext));
-
-// response.addHeader(REQUIRED_NAME_VALUE_KEY, ACTION_NAME);
-// response.addHeader(REQUIRED_METHOD_VALUE_KEY, "GET");
-// response.addHeader(REQUIRED_ACTION_VALUE_KEY, encodedURL);
-
-// elFormTag.setActionExpr(ACTION_NAME);
-// elFormTag.setMethodExpr("GET");
-
-// int startTagReturn = elFormTag.doStartTag();
-// int endTagReturn = elFormTag.doEndTag();
-// }
-
-// public void endMethod(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// Element docElement = testResponse.getDOM().getDocumentElement();
-// DOMHelper.printNode(docElement);
-
-// HashMap attrMap = new HashMap();
-
-// DOMHelper.recordFoundAttributes(testResponse.getDOM(),
-// "/html/body/form", attrMap);
-// DOMHelper.verifyAttributesPresent(attrMap,
-// new String[] { "name", "method",
-// "action" },
-// false);
-// checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
-// "form", "name");
-// checkAttrValue(attrMap, testResponse, REQUIRED_METHOD_VALUE_KEY,
-// "form", "method");
-// checkAttrValue(attrMap, testResponse, REQUIRED_ACTION_VALUE_KEY,
-// "form", "action");
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
+ // /**
+ // * Return the form action converted into a server-relative URL.
+ // * <p>
+ // * This is copied from FormTag, with the small change of passing the action
+ // * name as a parameter, and calling
+ // * <code>convertActionNameToPath(actionName)</code> instead of the
+ // * original's <code>getActionMappingName()</code>.
+ // */
+ // protected String getActionMappingURL(String actionName) {
+ // HttpServletRequest request =
+ // (HttpServletRequest) pageContext.getRequest();
+ // StringBuffer value = new StringBuffer(request.getContextPath());
+ // ApplicationConfig config = (ApplicationConfig)
+ // pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
+ // if (config != null) {
+ // value.append(config.getPrefix());
+ // }
+ // // Use our servlet mapping, if one is specified
+ // String servletMapping = (String)
+ // pageContext.getAttribute(Action.SERVLET_KEY,
+ // PageContext.APPLICATION_SCOPE);
+ // if (servletMapping != null) {
+ // String queryString = null;
+ // int question = actionName.indexOf("?");
+ // if (question >= 0) {
+ // queryString = actionName.substring(question);
+ // }
+ // String actionMapping = convertActionNameToPath(actionName);
+ // if (servletMapping.startsWith("*.")) {
+ // value.append(actionMapping);
+ // value.append(servletMapping.substring(1));
+ // } else if (servletMapping.endsWith("/*")) {
+ // value.append(servletMapping.substring
+ // (0, servletMapping.length() - 2));
+ // value.append(actionMapping);
+ // } else if (servletMapping.equals("/")) {
+ // value.append(actionMapping);
+ // }
+ // if (queryString != null) {
+ // value.append(queryString);
+ // }
+ // }
+ // // Otherwise, assume extension mapping is in use and extension is
+ // // already included in the action property
+ // else {
+ // if (!actionName.startsWith("/")) {
+ // value.append("/");
+ // }
+ // value.append(actionName);
+ // }
+ // // Return the completed value
+ // return (value.toString());
+ // }
+ // protected void setupServletEnvironment()
+ // throws ServletException
+ // {
+ // ActionServlet actionServlet = new ActionServlet();
+ // actionServlet.init(pageContext.getServletConfig());
+ // actionServlet.init();
+ // ApplicationConfig appConfig = new ApplicationConfig("");
+ // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
+ // PageContext.APPLICATION_SCOPE);
+ // }
+ public void testDummy() {
+ }
+
+ // public void testPlain()
+ // throws ServletException, JspException
+ // {
+ // ActionServlet actionServlet = new ActionServlet();
+ // actionServlet.init(pageContext.getServletConfig());
+ // actionServlet.init();
+ // // ApplicationConfig appConfig = new ApplicationConfig("");
+ // // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
+ // // PageContext.APPLICATION_SCOPE);
+ // ActionMapping mapping = new ActionMapping();
+ // mapping.setName(ACTION_NAME);
+ // mapping.setPath(convertActionNameToPath(mapping.getName()));
+ // ActionFormBean formBean =
+ // new ActionFormBean(mapping.getName(), FORM_BEAN_CLASS);
+ // appConfig.addActionConfig(mapping);
+ // appConfig.addFormBeanConfig(formBean);
+ // HttpServletResponse response =
+ // (HttpServletResponse)pageContext.getResponse();
+ // String encodedURL =
+ // response.encodeURL(RequestUtils.
+ // getActionMappingURL(mapping.getName(),
+ // pageContext));
+ // response.addHeader(REQUIRED_NAME_VALUE_KEY, ACTION_NAME);
+ // response.addHeader(REQUIRED_METHOD_VALUE_KEY, "post");
+ // response.addHeader(REQUIRED_ACTION_VALUE_KEY, encodedURL);
+ // elFormTag.setActionExpr(ACTION_NAME);
+ // int startTagReturn = elFormTag.doStartTag();
+ // int endTagReturn = elFormTag.doEndTag();
+ // }
+ // public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // Element docElement = testResponse.getDOM().getDocumentElement();
+ // DOMHelper.printNode(docElement);
+ // HashMap attrMap = new HashMap();
+ // DOMHelper.recordFoundAttributes(testResponse.getDOM(),
+ // "/html/body/form", attrMap);
+ // DOMHelper.verifyAttributesPresent(attrMap,
+ // new String[] { "name", "method",
+ // "action" },
+ // false);
+ // checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
+ // "form", "name");
+ // checkAttrValue(attrMap, testResponse, REQUIRED_METHOD_VALUE_KEY,
+ // "form", "method");
+ // checkAttrValue(attrMap, testResponse, REQUIRED_ACTION_VALUE_KEY,
+ // "form", "action");
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
+ // public void testMethod()
+ // throws ServletException, JspException
+ // {
+ // ActionServlet actionServlet = new ActionServlet();
+ // actionServlet.init(pageContext.getServletConfig());
+ // actionServlet.init();
+ // ApplicationConfig appConfig = new ApplicationConfig("");
+ // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionMapping mapping = new ActionMapping();
+ // mapping.setName(ACTION_NAME);
+ // mapping.setPath(convertActionNameToPath(mapping.getName()));
+ // ActionFormBean formBean =
+ // new ActionFormBean(mapping.getName(), FORM_BEAN_CLASS);
+ // appConfig.addActionConfig(mapping);
+ // appConfig.addFormBeanConfig(formBean);
+ // HttpServletResponse response =
+ // (HttpServletResponse)pageContext.getResponse();
+ // String encodedURL =
+ // response.encodeURL(RequestUtils.
+ // getActionMappingURL(mapping.getName(),
+ // pageContext));
+ // response.addHeader(REQUIRED_NAME_VALUE_KEY, ACTION_NAME);
+ // response.addHeader(REQUIRED_METHOD_VALUE_KEY, "GET");
+ // response.addHeader(REQUIRED_ACTION_VALUE_KEY, encodedURL);
+ // elFormTag.setActionExpr(ACTION_NAME);
+ // elFormTag.setMethodExpr("GET");
+ // int startTagReturn = elFormTag.doStartTag();
+ // int endTagReturn = elFormTag.doEndTag();
+ // }
+ // public void endMethod(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // Element docElement = testResponse.getDOM().getDocumentElement();
+ // DOMHelper.printNode(docElement);
+ // HashMap attrMap = new HashMap();
+ // DOMHelper.recordFoundAttributes(testResponse.getDOM(),
+ // "/html/body/form", attrMap);
+ // DOMHelper.verifyAttributesPresent(attrMap,
+ // new String[] { "name", "method",
+ // "action" },
+ // false);
+ // checkAttrValue(attrMap, testResponse, REQUIRED_NAME_VALUE_KEY,
+ // "form", "name");
+ // checkAttrValue(attrMap, testResponse, REQUIRED_METHOD_VALUE_KEY,
+ // "form", "method");
+ // checkAttrValue(attrMap, testResponse, REQUIRED_ACTION_VALUE_KEY,
+ // "form", "action");
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
}
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFrameTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFrameTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFrameTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELFrameTag.java Fri Feb 10 10:13:22 2006
@@ -1,46 +1,42 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspException;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.strutsel.taglib.utils.JspTagTestCase;
-
-public class TestELFrameTag
- extends JspTagTestCase {
+import org.apache.strutsel.taglib.utils.JspTagTestCase;
- private static final String FORWARD_VALUE = "stuff";
- private static final String PATH_VALUE = "/stuff";
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
- protected ELFrameTag elFrameTag = null;
+public class TestELFrameTag extends JspTagTestCase {
+ private static final String FORWARD_VALUE = "stuff";
+ private static final String PATH_VALUE = "/stuff";
+ protected ELFrameTag elFrameTag = null;
public TestELFrameTag(String theName) {
super(theName);
}
public static void main(String[] args) {
- junit.awtui.TestRunner.
- main(new String[] { TestELFrameTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELFrameTag.class.getName() });
}
public static Test suite() {
@@ -60,65 +56,56 @@
* Tests all attributes unset, which is illegal. At least one of
* "forward", "href", or "page" needs to be set.
*/
- public void testPlain()
- throws ServletException, JspException {
- HttpServletResponse response =
- (HttpServletResponse)pageContext.getResponse();
+ public void testPlain() throws ServletException, JspException {
+ HttpServletResponse response =
+ (HttpServletResponse) pageContext.getResponse();
- boolean gotCorrectException = false;
+ boolean gotCorrectException = false;
try {
- int startTagReturn = elFrameTag.doStartTag();
+ int startTagReturn = elFrameTag.doStartTag();
} catch (JspException ex) {
// This is supposed to happen.
- gotCorrectException = true;
+ gotCorrectException = true;
} catch (Exception ex) {
fail();
}
- if (!gotCorrectException)
+ if (!gotCorrectException) {
fail();
+ }
}
-// /**
-// * Tests setting "forward" attribute to a Forward with a null Path.
-// */
-// public void testForward()
-// throws ServletException, JspException {
-
-// ActionServlet actionServlet = new ActionServlet();
-// actionServlet.init(pageContext.getServletConfig());
-// actionServlet.init();
-
-// ApplicationConfig appConfig = new ApplicationConfig("");
-
-// pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
-// PageContext.APPLICATION_SCOPE);
-
-// ActionForward actionForward = new ActionForward();
-// actionForward.setName(FORWARD_VALUE);
-// actionForward.setPath(PATH_VALUE);
-// appConfig.addForwardConfig(actionForward);
-
-// elFrameTag.setForwardExpr(FORWARD_VALUE);
-
-// HttpServletResponse response =
-// (HttpServletResponse)pageContext.getResponse();
-
-// int startTagReturn = elFrameTag.doStartTag();
-// int afterBodyReturn = elFrameTag.doAfterBody();
-// int endTagReturn = elFrameTag.doEndTag();
-// }
-
-// public void endForward(com.meterware.httpunit.WebResponse testResponse) {
-// try {
-// TestHelper.printResponse(testResponse);
-
-// org.w3c.dom.Document document = testResponse.getDOM();
-// DOMHelper.printNode(document.getDocumentElement());
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// fail();
-// }
-// }
+ // /**
+ // * Tests setting "forward" attribute to a Forward with a null Path.
+ // */
+ // public void testForward()
+ // throws ServletException, JspException {
+ // ActionServlet actionServlet = new ActionServlet();
+ // actionServlet.init(pageContext.getServletConfig());
+ // actionServlet.init();
+ // ApplicationConfig appConfig = new ApplicationConfig("");
+ // pageContext.setAttribute(Action.APPLICATION_KEY, appConfig,
+ // PageContext.APPLICATION_SCOPE);
+ // ActionForward actionForward = new ActionForward();
+ // actionForward.setName(FORWARD_VALUE);
+ // actionForward.setPath(PATH_VALUE);
+ // appConfig.addForwardConfig(actionForward);
+ // elFrameTag.setForwardExpr(FORWARD_VALUE);
+ // HttpServletResponse response =
+ // (HttpServletResponse)pageContext.getResponse();
+ // int startTagReturn = elFrameTag.doStartTag();
+ // int afterBodyReturn = elFrameTag.doAfterBody();
+ // int endTagReturn = elFrameTag.doEndTag();
+ // }
+ // public void endForward(com.meterware.httpunit.WebResponse testResponse) {
+ // try {
+ // TestHelper.printResponse(testResponse);
+ // org.w3c.dom.Document document = testResponse.getDOM();
+ // DOMHelper.printNode(document.getDocumentElement());
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // fail();
+ // }
+ // }
}
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHiddenTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHiddenTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHiddenTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHiddenTag.java Fri Feb 10 10:13:22 2006
@@ -1,45 +1,45 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
-import java.util.HashMap;
-import javax.servlet.ServletException;
-import javax.servlet.jsp.JspException;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.apache.struts.util.LabelValueBean;
+import org.apache.strutsel.taglib.utils.DOMHelper;
import org.apache.strutsel.taglib.utils.JspTagTestCase;
import org.apache.strutsel.taglib.utils.TestHelper;
-import org.apache.strutsel.taglib.utils.DOMHelper;
-public class TestELHiddenTag
- extends JspTagTestCase {
+import javax.servlet.ServletException;
+import javax.servlet.jsp.JspException;
+
+import java.util.HashMap;
- protected ELHiddenTag elHiddenTag = null;
+public class TestELHiddenTag extends JspTagTestCase {
+ protected ELHiddenTag elHiddenTag = null;
public TestELHiddenTag(String theName) {
super(theName);
}
-
+
public static void main(String[] args) {
- junit.awtui.TestRunner.
- main(new String[] { TestELHiddenTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELHiddenTag.class
+ .getName() });
}
public static Test suite() {
@@ -47,7 +47,7 @@
}
public void setUp() {
- elHiddenTag = new ELHiddenTag();
+ elHiddenTag = new ELHiddenTag();
elHiddenTag.setPageContext(pageContext);
}
@@ -55,18 +55,17 @@
elHiddenTag = null;
}
- public void testPlain()
- throws ServletException, JspException {
+ public void testPlain() throws ServletException, JspException {
+ LabelValueBean bean = new LabelValueBean("junk", "stuff");
- LabelValueBean bean = new LabelValueBean("junk", "stuff");
pageContext.setAttribute("testFormBean", bean);
elHiddenTag.setNameExpr("testFormBean");
elHiddenTag.setPropertyExpr("value");
- int startTagReturn = elHiddenTag.doStartTag();
+ int startTagReturn = elHiddenTag.doStartTag();
int afterBodyReturn = elHiddenTag.doAfterBody();
- int endTagReturn = elHiddenTag.doEndTag();
+ int endTagReturn = elHiddenTag.doEndTag();
}
public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
@@ -74,16 +73,15 @@
TestHelper.printResponse(testResponse);
org.w3c.dom.Document document = testResponse.getDOM();
+
DOMHelper.printNode(document.getDocumentElement());
HashMap attrMap = new HashMap();
- DOMHelper.recordFoundAttributes(testResponse.getDOM(),
- "/html/body/input", attrMap);
- DOMHelper.
- verifyAttributesPresent(attrMap,
- new String[] { "type", "name",
- "value" },
- false);
+
+ DOMHelper.recordFoundAttributes(testResponse.getDOM(),
+ "/html/body/input", attrMap);
+ DOMHelper.verifyAttributesPresent(attrMap,
+ new String[] { "type", "name", "value" }, false);
} catch (Exception ex) {
ex.printStackTrace();
fail();
Modified: struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHtmlTag.java
URL: http://svn.apache.org/viewcvs/struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHtmlTag.java?rev=376783&r1=376782&r2=376783&view=diff
==============================================================================
--- struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHtmlTag.java (original)
+++ struts/el/trunk/src/test/org/apache/strutsel/taglib/html/TestELHtmlTag.java Fri Feb 10 10:13:22 2006
@@ -1,44 +1,43 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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
- *
+ *
* 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.strutsel.taglib.html;
-import java.util.HashMap;
-import javax.servlet.ServletException;
-import javax.servlet.jsp.JspException;
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.apache.strutsel.taglib.utils.DOMHelper;
import org.apache.strutsel.taglib.utils.JspTagTestCase;
import org.apache.strutsel.taglib.utils.TestHelper;
-public class TestELHtmlTag
- extends JspTagTestCase {
+import javax.servlet.ServletException;
+import javax.servlet.jsp.JspException;
+
+import java.util.HashMap;
- protected ELHtmlTag elHtmlTag = null;
+public class TestELHtmlTag extends JspTagTestCase {
+ protected ELHtmlTag elHtmlTag = null;
public TestELHtmlTag(String theName) {
super(theName);
}
-
+
public static void main(String[] args) {
- junit.awtui.TestRunner.
- main(new String[] { TestELHtmlTag.class.getName() });
+ junit.awtui.TestRunner.main(new String[] { TestELHtmlTag.class.getName() });
}
public static Test suite() {
@@ -46,7 +45,7 @@
}
public void setUp() {
- elHtmlTag = new ELHtmlTag();
+ elHtmlTag = new ELHtmlTag();
elHtmlTag.setPageContext(pageContext);
}
@@ -54,16 +53,15 @@
elHtmlTag = null;
}
- public void testPlain()
- throws ServletException, JspException {
+ public void testPlain() throws ServletException, JspException {
+ Boolean bool = new Boolean(true);
- Boolean bool = new Boolean(true);
pageContext.setAttribute("localeFlag", bool);
elHtmlTag.setXhtmlExpr("true");
- int startTagReturn = elHtmlTag.doStartTag();
+ int startTagReturn = elHtmlTag.doStartTag();
int afterBodyReturn = elHtmlTag.doAfterBody();
- int endTagReturn = elHtmlTag.doEndTag();
+ int endTagReturn = elHtmlTag.doEndTag();
}
public void endPlain(com.meterware.httpunit.WebResponse testResponse) {
@@ -71,16 +69,15 @@
TestHelper.printResponse(testResponse);
org.w3c.dom.Document document = testResponse.getDOM();
+
DOMHelper.printNode(document.getDocumentElement());
HashMap attrMap = new HashMap();
- DOMHelper.recordFoundAttributes(testResponse.getDOM(),
- "/html", attrMap);
- DOMHelper.
- verifyAttributesPresent(attrMap,
- new String[] { "lang", "xml:lang",
- "xmlns" },
- false);
+
+ DOMHelper.recordFoundAttributes(testResponse.getDOM(), "/html",
+ attrMap);
+ DOMHelper.verifyAttributesPresent(attrMap,
+ new String[] { "lang", "xml:lang", "xmlns" }, false);
} catch (Exception ex) {
ex.printStackTrace();
fail();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org