Repository: struts-site Updated Branches: refs/heads/asf-site 6775f9c62 -> 64baebde5
Updates production by Jenkins Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/64baebde Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/64baebde Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/64baebde Branch: refs/heads/asf-site Commit: 64baebde56594db4273c0892eb2385f196f8ecdb Parents: 6775f9c Author: jenkins <bui...@apache.org> Authored: Wed Aug 23 11:48:36 2017 +0000 Committer: jenkins <bui...@apache.org> Committed: Wed Aug 23 11:48:36 2017 +0000 ---------------------------------------------------------------------- content/plugins/junit/index.html | 63 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/64baebde/content/plugins/junit/index.html ---------------------------------------------------------------------- diff --git a/content/plugins/junit/index.html b/content/plugins/junit/index.html index 2e350c0..3e9d003 100644 --- a/content/plugins/junit/index.html +++ b/content/plugins/junit/index.html @@ -144,8 +144,9 @@ an action:</p> <ul> <li>Mapping: -```xml - <struts> +```xml</li> +</ul> +<struts> <constant name="struts.objectFactory" value="spring" /> <package name="test" namespace="/test" extends="struts-default"> <action name="testAction" class="org.apache.struts2.TestAction"> @@ -153,40 +154,38 @@ an action:</p> </action> </package> </struts> - <p>```</p> - </li> - <li> - <p>Action: -```java<br /> +<div class="highlighter-rouge"><pre class="highlight"><code>- Action: +```java public class TestAction extends ActionSupport { - private String name;</p> + private String name; + + public String getName() { + return name; + } - <div class="highlighter-rouge"><pre class="highlight"><code>public String getName() { - return name; + public void setName(String name) { + this.name = name; + } } - -public void setName(String name) { - this.name = name; -} } ``` </code></pre> - </div> - </li> - <li> - <p>JUnit: +</div> +<ul> + <li>JUnit: ```java -package org.apache.struts2;</p> +package org.apache.struts2;</li> +</ul> - <p>import org.apache.struts2.dispatcher.mapper.ActionMapping;</p> +<p>import org.apache.struts2.dispatcher.mapper.ActionMapping;</p> - <p>import java.util.HashMap; +<p>import java.util.HashMap; import java.io.UnsupportedEncodingException;</p> - <p>import com.opensymphony.xwork2.ActionProxy; +<p>import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.Action;</p> - <p>import javax.servlet.ServletException;</p> +<p>import javax.servlet.ServletException;</p> - <p>public class StrutsTestCaseTest extends StrutsTestCase { +<p>public class StrutsTestCaseTest extends StrutsTestCase { public void testGetActionMapping() { ActionMapping mapping = getActionMapping(â/test/testAction.actionâ); assertNotNull(mapping); @@ -194,26 +193,26 @@ import com.opensymphony.xwork2.Action;</p> assertEquals(âtestActionâ, mapping.getName()); }</p> - <div class="highlighter-rouge"><pre class="highlight"><code>public void testGetActionProxy() throws Exception { +<div class="highlighter-rouge"><pre class="highlight"><code>public void testGetActionProxy() throws Exception { //set parameters before calling getActionProxy request.setParameter("name", "FD"); - + ActionProxy proxy = getActionProxy("/test/testAction.action"); assertNotNull(proxy); - + TestAction action = (TestAction) proxy.getAction(); assertNotNull(action); - + String result = proxy.execute(); assertEquals(Action.SUCCESS, result); assertEquals("FD", action.getName()); } - + public void testExecuteAction() throws ServletException, UnsupportedEncodingException { String output = executeAction("/test/testAction.action"); assertEquals("Hello", output); } - + public void testGetValueFromStack() throws ServletException, UnsupportedEncodingException { request.setParameter("name", "FD"); executeAction("/test/testAction.action"); @@ -221,9 +220,7 @@ public void testGetValueFromStack() throws ServletException, UnsupportedEncoding assertEquals("FD", name); } } ``` </code></pre> - </div> - </li> -</ul> +</div> <h2 id="the-template">The template</h2>