|
Struts example source code file (AnotherActionComponentTest.java)
The Struts AnotherActionComponentTest.java source codepackage org.apache.struts2.components; import org.apache.struts2.views.jsp.AbstractTagTest; import org.apache.struts2.TestConfigurationProvider; import org.apache.struts2.StrutsException; /** * Describe your class here * * @author $Author$ * <p/> * $Id$ */ public class AnotherActionComponentTest extends AbstractTagTest { public void testRethrowException() throws Exception { request.setupGetServletPath(TestConfigurationProvider.TEST_NAMESPACE + "/" + "foo.action" ); ActionComponent ac = new ActionComponent(stack, request, response) ; container.inject(ac); ac.setNamespace(TestConfigurationProvider.TEST_NAMESPACE); ac.setName(TestConfigurationProvider.TEST_ACTION_NAME + "!executeThrowsException"); ac.setRethrowException(true); boolean exceptionCaught = false; try { ac.executeAction(); } catch (Exception e) { if (e instanceof StrutsException) exceptionCaught = true; } assertTrue(exceptionCaught); } public void testDoesNotThrowException() throws Exception { request.setupGetServletPath(TestConfigurationProvider.TEST_NAMESPACE + "/" + "foo.action" ); ActionComponent ac = new ActionComponent(stack, request, response) ; container.inject(ac); ac.setNamespace(TestConfigurationProvider.TEST_NAMESPACE); ac.setName(TestConfigurationProvider.TEST_ACTION_NAME+ "!executeThrowsException"); ac.setRethrowException(false); boolean exceptionCaught = false; try { ac.executeAction(); } catch (Exception e) { if (e instanceof StrutsException) exceptionCaught = true; } assertTrue(! exceptionCaught); } } Other Struts examples (source code examples)Here is a short list of links related to this Struts AnotherActionComponentTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.